packages feed

readline-statevar (empty) → 1.0.1.0

raw patch · 4 files changed

+454/−0 lines, 4 filesdep +StateVardep +basedep +readlinesetup-changed

Dependencies added: StateVar, base, readline

Files

+ LICENSE view
@@ -0,0 +1,10 @@+Copyright (c) 2009, Krzysztof Skrzętnicki+All rights reserved.++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.+    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.+    * The names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ System/Console/Readline/StateVar.hs view
@@ -0,0 +1,401 @@+{-# LANGUAGE CPP #-} +module System.Console.Readline.StateVar ( +    readline ,+    addHistory ,+    +    {-+    getLineBuffer,        -- :: IO String+    setLineBuffer,        -- :: String -> IO ()+    -}+    lineBuffer,++    +    -- Functions involving point positions are meaningful only when string+    -- conversion between Haskell and C preserves the length.++    point, end, mark,+    {-+    getPoint,             -- :: IO Int+    setPoint,             -- :: Int -> IO ()+    getEnd,               -- :: IO Int+    setEnd,               -- :: Int -> IO ()+    getMark,              -- :: IO Int+    setMark,              -- :: Int -> IO ()+    -}+    +    done, pendingInput,+    {-+    setDone,              -- :: Bool -> IO ()+    setPendingInput,      -- :: Char -> IO ()+    -}++    eraseEmptyLine,+    {-+    setEraseEmptyLine,    -- :: Bool -> IO ()+    -}+++    prompt,+    {-+    getPrompt,            -- :: IO String+    -}++    alreadyPrompted,+    {-+    setAlreadyPrompted,   -- :: Bool -> IO ()+    -}++    libraryVersion, terminalName, readLineName, inStream, outStream, startupHook,+    {-+    getLibraryVersion,    -- :: IO String+    getTerminalName,      -- :: IO String+    setReadlineName,      -- :: String -> IO ()+    getInStream,          -- :: IO Handle+    getOutStream,         -- :: IO Handle+    setStartupHook,       -- :: Maybe (IO ()) -> IO ()+    -}++    preInputHook,+    {-+    setPreInputHook,      -- :: Maybe (IO ()) -> IO ()+    -}++    eventHook, redisplayFunction,+    {-+    setEventHook,         -- :: Maybe (IO ()) -> IO ()+    setRedisplayFunction, -- :: Maybe (IO ()) -> IO ()+    -}+    +    +    -- | Keymaps+    Keymap,             -- data Keymap+    newBareKeymap ,+    copyKeymap ,+    newKeymap ,+    freeKeymap ,+    -- | Keymap vars+    keymap, keymapByName, keymapName, executingKeymap, bindingKeymap,+    {-+    getKeymap,          -- :: IO Keymap+    setKeymap,          -- :: Keymap -> IO ()+    getKeymapByName,    -- :: String -> IO Keymap+    getKeymapName,      -- :: Keymap -> IO (Maybe String)+    getExecutingKeymap, -- :: IO Keymap+    getBindingKeymap,   -- :: IO Keymap+    -}+    +    -- | Callbacks+    Callback,           -- type Callback = Int -> Char -> IO Int+    addDefun ,+    bindKey ,+    bindKeyInMap ,+    unbindKey ,+    unbindKeyInMap ,+    unbindCommandInMap ,+    Entry(..),          -- data Entry+                        --     = Function Callback+                        --     | Macro    String+                        --     | Keymap   Keymap+    genericBind ,+    parseAndBind ,+    readInitFile ,+    +    --------------------------------------------------------------------+    -- Associating Function Names and Bindings.+    +    namedFunction ,+    functionOfKeyseq ,+    functionDumper ,+    listFunmapNames ,++    funmapNames ,++    +    beginUndoGroup, endUndoGroup ,+    UndoCode(..),   -- data UndoCode+                    --     = UndoDelete+                    --     | UndoInsert+                    --     | UndoBegin+                    --     | UndoEnd+    addUndo ,+    freeUndoList ,+    doUndo ,+    modifying ,+    +    --------------------------------------------------------------------+    -- Redisplay.+    +    redisplay ,+    forcedUpdateDisplay ,+    onNewLine ,++    onNewLineWithPrompt ,++    resetLineState ,+    message ,+    clearMessage ,++    savePrompt ,+    restorePrompt ,++    --------------------------------------------------------------------+    -- Modifying Text.+    +    insertText ,+    deleteText ,+    copyText ,+    killText ,+    +    --------------------------------------------------------------------+    -- Utility functions.+    +    readKey ,+    stuffChar ,+    initialize ,+    resetTerminal ,+    ding ,++    displayMatchList ,+    +    --------------------------------------------------------------------+    -- Alternate Interface.+    +    callbackHandlerInstall ,+    callbackReadChar ,+        +    catchSignals, catchSigwinch, +    +    {-+    setCatchSignals,    -- :: Bool -> IO ()+    getCatchSignals,    -- :: IO Bool+    setCatchSigwinch,   -- :: Bool -> IO ()+    getCatchSigwinch,   -- :: IO Bool+    -}+    cleanupAfterSignal ,+    freeLineState ,+    resetAfterSignal ,+    resizeTerminal ,++    setSignals ,+    clearSignals ,+    +    --------------------------------------------------------------------+    -- Completion functions.+    +    completeInternal ,+    complete ,+    possibleCompletions ,+    insertCompletions ,+    -- readline uses functions that are called multiple times and+    -- return an entry at a time, maintaining their state at which+    -- point they are. This is silly in a functional language so here+    -- we work with functions String -> IO [String].+    completionMatches ,+    filenameCompletionFunction ,+    usernameCompletionFunction ,+    +    completionEntryFunction, attemptedCompletionFunction, filenameQuotingFunction,+{-+    setCompletionEntryFunction,+        -- :: Maybe (String -> IO [String]) -> IO ()+    setAttemptedCompletionFunction,+        -- :: Maybe (String -> Int -> Int -> IO (Maybe (String, [String]))) -> IO ()+    setFilenameQuotingFunction,+        -- :: Maybe (String -> Bool -> Ptr CChar -> IO String) -> IO ()+-}+    quoteFilename ,+    filenameDequotingFunction, charIsQuotedP, completionQueryItems,+{-+    setFilenameDequotingFunction,+        -- :: Maybe (String -> Maybe Char -> IO String) -> IO ()+    setCharIsQuotedP,+        -- :: Maybe (String -> Int -> IO Bool) -> IO ()+    getCompletionQueryItems,          -- :: IO Int+    setCompletionQueryItems,          -- :: Int -> IO ()+-}++    basicWordBreakCharacters,      +    basicQuoteCharacters,          +    completerWordBreakCharacters,  +    completerQuoteCharacters,      +    filenameQuoteCharacters,       +    specialPrefixes,               +    completionAppendCharacter,     +    ignoreCompletionDuplicates,    +    filenameCompletionDesired,     +    filenameQuotingDesired,        +    inhibitCompletion,             +    attemptedCompletionOver,       +    ignoreSomeCompletionsFunction, +    directoryCompletionHook,+    completionWordBreakHook,+    completionDisplayMatchesHook++{-+    getBasicWordBreakCharacters,      -- :: IO String+    setBasicWordBreakCharacters,      -- :: String -> IO ()+    getBasicQuoteCharacters,          -- :: IO String+    setBasicQuoteCharacters,          -- :: String -> IO ()+    getCompleterWordBreakCharacters,  -- :: IO String+    setCompleterWordBreakCharacters,  -- :: String -> IO ()+    getCompleterQuoteCharacters,      -- :: IO String+    setCompleterQuoteCharacters,      -- :: String -> IO ()+    getFilenameQuoteCharacters,       -- :: IO String+    setFilenameQuoteCharacters,       -- :: String -> IO ()+    getSpecialPrefixes,               -- :: IO String+    setSpecialPrefixes,               -- :: String -> IO ()+    getCompletionAppendCharacter,     -- :: IO (Maybe Char)+    setCompletionAppendCharacter,     -- :: Maybe Char -> IO ()+    setIgnoreCompletionDuplicates,    -- :: Bool -> IO ()+    getIgnoreCompletionDuplicates,    -- :: IO Bool+    setFilenameCompletionDesired,     -- :: Bool -> IO ()+    getFilenameCompletionDesired,     -- :: IO Bool+    setFilenameQuotingDesired,        -- :: Bool -> IO ()+    getFilenameQuotingDesired,        -- :: IO Bool+    setInhibitCompletion,             -- :: Bool -> IO ()+    getInhibitCompletion,             -- :: IO Bool+    setAttemptedCompletionOver,       -- :: Bool -> IO ()+    getAttemptedCompletionOver,       -- :: IO Bool+    setIgnoreSomeCompletionsFunction,+        -- :: Maybe ([String] -> IO [String]) -> IO ()+        -- The function may not make the list longer!+    setDirectoryCompletionHook+        -- :: Maybe (String -> IO String) -> IO ()+    setCompletionWordBreakHook+    setCompletionDisplayMatchesHook+-}++    )+where++import System.Console.Readline+import Data.StateVar+import System.IO+import Foreign+import Foreign.C++++lineBuffer = makeStateVar getLineBuffer setLineBuffer+point      = makeStateVar getPoint      setPoint+end        = makeStateVar getEnd        setEnd+mark       = makeStateVar getMark       setMark+keymap     = makeStateVar getKeymap     setKeymap++done            = makeSettableStateVar setDone+pendingInput    = makeSettableStateVar setPendingInput+eraseEmptyLine  = makeSettableStateVar setEraseEmptyLine+alreadyPrompted = makeSettableStateVar setAlreadyPrompted+readLineName    = makeSettableStateVar setReadlineName++startupHook       = makeSettableStateVar setStartupHook+preInputHook      = makeSettableStateVar setPreInputHook+eventHook         = makeSettableStateVar setEventHook+redisplayFunction = makeSettableStateVar setRedisplayFunction+++prompt         = makeGettableStateVar getPrompt+libraryVersion = makeGettableStateVar getLibraryVersion+terminalName   = makeGettableStateVar getTerminalName++inStream        = makeGettableStateVar getInStream+outStream       = makeGettableStateVar getOutStream+keymapByName nm = makeGettableStateVar (getKeymapByName nm)+keymapName km   = makeGettableStateVar (getKeymapName km)++executingKeymap = makeGettableStateVar getExecutingKeymap+bindingKeymap   = makeGettableStateVar getBindingKeymap ++---++catchSignals  = makeStateVar getCatchSignals  setCatchSignals+catchSigwinch = makeStateVar getCatchSigwinch setCatchSigwinch++completionEntryFunction     = makeSettableStateVar setCompletionEntryFunction+attemptedCompletionFunction = makeSettableStateVar setAttemptedCompletionFunction+filenameQuotingFunction     = makeSettableStateVar setFilenameQuotingFunction+filenameDequotingFunction   = makeSettableStateVar setFilenameDequotingFunction+charIsQuotedP               = makeSettableStateVar setCharIsQuotedP++completionQueryItems         = makeStateVar getCompletionQueryItems         setCompletionQueryItems +basicWordBreakCharacters     = makeStateVar getBasicWordBreakCharacters     setBasicWordBreakCharacters +basicQuoteCharacters         = makeStateVar getBasicQuoteCharacters         setBasicQuoteCharacters +completerWordBreakCharacters = makeStateVar getCompleterWordBreakCharacters setCompleterWordBreakCharacters+completerQuoteCharacters     = makeStateVar getCompleterQuoteCharacters     setCompleterQuoteCharacters +filenameQuoteCharacters      = makeStateVar getFilenameQuoteCharacters      setFilenameQuoteCharacters +specialPrefixes              = makeStateVar getSpecialPrefixes              setSpecialPrefixes +completionAppendCharacter    = makeStateVar getCompletionAppendCharacter    setCompletionAppendCharacter +ignoreCompletionDuplicates   = makeStateVar getIgnoreCompletionDuplicates   setIgnoreCompletionDuplicates+filenameCompletionDesired    = makeStateVar getFilenameCompletionDesired    setFilenameCompletionDesired+filenameQuotingDesired       = makeStateVar getFilenameQuotingDesired       setFilenameQuotingDesired +inhibitCompletion            = makeStateVar getInhibitCompletion            setInhibitCompletion +attemptedCompletionOver      = makeStateVar getAttemptedCompletionOver      setAttemptedCompletionOver++ignoreSomeCompletionsFunction = makeSettableStateVar setIgnoreSomeCompletionsFunction+directoryCompletionHook       = makeSettableStateVar setDirectoryCompletionHook+completionWordBreakHook       = makeSettableStateVar setCompletionWordBreakHook+completionDisplayMatchesHook  = makeSettableStateVar setCompletionDisplayMatchesHook++--++alreadyPrompted :: SettableStateVar Bool+attemptedCompletionFunction :: SettableStateVar+                               (Maybe (String -> Int -> Int -> IO (Maybe (String, [String]))))+attemptedCompletionOver :: StateVar Bool+basicQuoteCharacters :: StateVar String+basicWordBreakCharacters :: StateVar String+bindingKeymap :: GettableStateVar Keymap+catchSignals :: StateVar Bool+catchSigwinch :: StateVar Bool+charIsQuotedP :: SettableStateVar+                   (Maybe (String -> Int -> IO Bool))+completerQuoteCharacters :: StateVar String+completerWordBreakCharacters :: StateVar String+completionAppendCharacter :: StateVar (Maybe Char)+completionDisplayMatchesHook :: SettableStateVar+                                  (Maybe ([String] -> IO ()))+completionEntryFunction :: SettableStateVar+                             (Maybe (String -> IO [String]))+completionQueryItems :: StateVar Int+completionWordBreakHook :: SettableStateVar+                             (Maybe (IO (Maybe String)))+directoryCompletionHook :: SettableStateVar+                             (Maybe (String -> IO String))+done :: SettableStateVar Bool+end :: StateVar Int+eraseEmptyLine :: SettableStateVar Bool+eventHook :: SettableStateVar (Maybe (IO ()))+executingKeymap :: GettableStateVar Keymap+filenameCompletionDesired :: StateVar Bool+filenameDequotingFunction :: SettableStateVar+                               (Maybe (String -> Maybe Char -> IO String))+filenameQuoteCharacters :: StateVar String+filenameQuotingDesired :: StateVar Bool+filenameQuotingFunction :: SettableStateVar+                             (Maybe+                                (String+                                 -> Bool+                                 -> Ptr CChar+                                 -> IO String))+ignoreCompletionDuplicates :: StateVar Bool+ignoreSomeCompletionsFunction :: SettableStateVar+                                   (Maybe ([String] -> IO [String]))+inStream :: GettableStateVar Handle+inhibitCompletion :: StateVar Bool+keymap :: StateVar Keymap+keymapByName :: String -> GettableStateVar Keymap+keymapName :: Keymap -> GettableStateVar (Maybe String)+libraryVersion :: GettableStateVar String+lineBuffer :: StateVar String+mark :: StateVar Int+outStream :: GettableStateVar Handle+pendingInput :: SettableStateVar Char+point :: StateVar Int+preInputHook :: SettableStateVar (Maybe (IO ()))+prompt :: GettableStateVar String+readLineName :: SettableStateVar String+redisplayFunction :: SettableStateVar (Maybe (IO ()))+specialPrefixes :: StateVar String+startupHook :: SettableStateVar (Maybe (IO ()))+terminalName :: GettableStateVar String+
+ readline-statevar.cabal view
@@ -0,0 +1,40 @@+name:                readline-statevar+version:             1.0.1.0+synopsis:            Readline with variables (setX/getY) wrapped in state vars+description:         readline package is a good wrapping library around libreadline.+                    .+                     Unfortunately, there is a lot of set/get pairs of functions, which clutter namespace.+                     This kind of API can be nicely expressed as StateVars, as in HOpenGL.+                     .+                     readline-statevar seeks to fill this gap and provide nicer API based on StateVars.+                     .+                     For clarity: this module wraps only System.Console.Readline module.+                     System.Console.SimpleLineEditor is left untouched.++category:            Utils+license:             BSD3+license-file:        LICENSE+author:              Krzysztof Skrzetnicki <krzysztof.skrzetnicki+hackage@gmail.com>+maintainer:          Krzysztof Skrzetnicki <krzysztof.skrzetnicki+hackage@gmail.com>+build-type:          Simple+Cabal-Version: >= 1.6++source-repository    head+    Type:     Git+    Location: http://github.com/Tener/haskell-readline-statevar.git++source-repository    this+    Type:     Git+    Location: http://github.com/Tener/haskell-readline-statevar.git+    Tag: 1.0.1.0++flag debug+      default: False++library+        exposed-modules: System.Console.Readline.StateVar+        build-depends: readline >= 1.0.1 && < 1.1.0,+                       base >= 4.1.0 && < 5,+                       StateVar >= 1.0.0 && < 1.1.0+        if flag(debug)+           cpp-options: -DDEBUG