-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | The Haskell-Scriptable Editor -- -- Yi is a text editor written in Haskell and extensible in Haskell. The -- goal of the Yi project is to provide a flexible, powerful, and correct -- editor for haskell hacking. @package yi @version 0.6.5.0 module Yi.Char.Unicode greek :: [(String, String)] symbols :: [(String, String)] subscripts, superscripts :: [(String, String)] checkAmbs :: [(String, String)] -> [(String, String)] disamb :: [(String, String)] -> [(String, String)] -- | This is a little helper for completion interfaces. module Yi.Keymap.Completion data CompletionTree a CT :: [(a, CompletionTree a)] -> CompletionTree a stepTree :: Eq a => CompletionTree a -> a -> Maybe ([a], CompletionTree a) obvious :: CompletionTree a -> ([a], CompletionTree a) mergeTrees :: Ord a => [CompletionTree a] -> CompletionTree a listToTree :: [a] -> CompletionTree a complete :: Eq a => CompletionTree a -> [a] -> ([a], CompletionTree a) instance Show a => Show (CompletionTree a) module Yi.Monad class Ref ref readRef :: (Ref ref, MonadIO m) => ref a -> m a writeRef :: (Ref ref, MonadIO m) => ref a -> a -> m () modifyRef :: (Ref ref, MonadIO m) => ref a -> (a -> a) -> m () -- | Gets specific component of the state, using a projection function -- supplied. gets :: MonadState s m => (s -> a) -> m a getsA :: MonadState s m => Accessor s p -> (p -> a) -> m a -- | Combination of the Control.Monad.State modify and gets getsAndModify :: MonadState s m => (s -> (s, a)) -> m a maybeM :: Monad m => (x -> m ()) -> Maybe x -> m () modifiesRef :: (Ref ref, MonadReader r m, MonadIO m) => (r -> ref a) -> (a -> a) -> m () modifiesThenReadsRef :: (MonadReader r m, MonadIO m) => (r -> IORef a) -> (a -> a) -> m a readsRef :: (Ref ref, MonadReader r m, MonadIO m) => (r -> ref a) -> m a -- | Rerun the monad until the boolean result is false, collecting list of -- results. repeatUntilM :: Monad m => m (Bool, a) -> m [a] whenM :: Monad m => m Bool -> m () -> m () with :: (MonadReader yi m, MonadIO m) => (yi -> component) -> (component -> IO a) -> m a writesRef :: (MonadReader r m, MonadIO m) => (r -> IORef a) -> a -> m () instance Ref MVar instance Ref IORef module Parser.Incremental type Process token result = Zip token (result :< ()) -- | Parse the same thing as the argument, but will be used only as backup. -- ie, it will be used only if disjuncted with a failing parser. recoverWith :: Parser s a -> Parser s a symbol :: (s -> Bool) -> Parser s s eof :: Parser s () lookNext :: Parser s (Maybe s) testNext :: (Maybe s -> Bool) -> Parser s () -- | Run a process (in case you do not need the incremental interface) run :: Process s a -> [s] -> (a, [String]) -- | Make a parser into a process. mkProcess :: Parser s a -> Process s a profile :: Steps s r -> Profile -- | Push some symbols. pushSyms :: [s] -> Zip s r -> Zip s r -- | Push eof pushEof :: Zip s r -> Zip s r evalL :: Zip s output -> Zip s output evalR :: Zip token (a :< rest) -> (a, [String]) feedZ :: Maybe [s] -> Zip s r -> Zip s r -- | Parser specification data Parser s a Look :: Parser s a -> (s -> Parser s a) -> Parser s a Yuck :: Parser s a -> Parser s a Enter :: String -> Parser s a -> Parser s a countWidth :: Zip s r -> Int fullLog :: Zip s output -> ([String], Tree LogEntry) data LogEntry LLog :: String -> LogEntry LEmpty :: LogEntry LDislike :: LogEntry LShift :: LogEntry LDone :: LogEntry LFail :: LogEntry LSusp :: LogEntry LS :: String -> LogEntry evalL' :: Zip s output -> Zip s output instance Show Profile instance Show LogEntry instance Show (Zip s output) instance Monad (Parser s) instance Alternative (Parser s) instance Applicative (Parser s) instance Functor (Parser s) instance Show (RPolish i o) instance Show (Steps s r) module Yi.Debug -- | Set the file to which debugging output should be written. Though this -- is called initDebug. Debugging output is not created by default -- (i.e., if this function is never called.) The target file can not be -- changed, nor debugging disabled. initDebug :: FilePath -> IO () -- | Outputs the given string before returning the second argument. trace :: String -> a -> a -- | Traces x and returns y. traceM :: Monad m => String -> a -> m a -- | Like traceM, but returns (). traceM_ :: Monad m => String -> m () logPutStrLn :: MonadIO m => String -> m () logError :: MonadIO m => String -> m () logStream :: Show a => String -> Chan a -> IO () error :: String -> a module Yi.Config.Misc data ScrollStyle SnapToCenter :: ScrollStyle SingleLine :: ScrollStyle -- | String manipulation utilities module Yi.String isBlank :: String -> Bool -- | Remove any trailing strings matching irs (input record -- separator) from input string. Like perl's chomp(1). chomp :: String -> String -> String capitalize :: String -> String capitalizeFirst :: String -> String -- | Trim spaces at beginning and end dropSpace :: String -> String fillText :: Int -> String -> [String] onLines :: ([String] -> [String]) -> String -> String -- | A helper function for creating functions suitable for -- modifySelectionB and modifyRegionB. To be used when -- the desired function should map across the lines of a region. mapLines :: (String -> String) -> String -> String -- | Split a String in lines. Unlike lines, this does not remove any -- empty line at the end. lines' :: String -> [String] -- | Inverse of lines'. In contrast to unlines, this does not -- add an empty line at the end. unlines' :: [String] -> String padLeft, padRight :: Int -> String -> String -- | This module defines a Rope representation. module Data.Rope data Rope fromString :: String -> Rope toString :: Rope -> String toReverseString :: Rope -> String null :: Rope -> Bool empty :: Rope take, drop :: Int -> Rope -> Rope -- | Append two strings by merging the two finger trees. append :: Rope -> Rope -> Rope -- | Split the string at the specified position. splitAt :: Int -> Rope -> (Rope, Rope) -- | Split before the specified line. Lines are indexed from 0. splitAtLine :: Int -> Rope -> (Rope, Rope) -- | Get the length of the string. (This information cached, so O(1) -- amortized runtime.) length :: Rope -> Int reverse :: Rope -> Rope -- | Count the number of newlines in the strings. (This information cached, -- so O(1) amortized runtime.) countNewLines :: Rope -> Int readFile :: FilePath -> IO Rope writeFile :: FilePath -> Rope -> IO () -- | Split the rope on a chunk, so that the desired position lies within -- the first chunk of the second rope. splitAtChunkBefore :: Int -> Rope -> (Rope, Rope) instance Eq Chunk instance Show Chunk instance Show Size instance Eq Rope instance Show Rope instance Binary Rope instance Measured Size Chunk instance Monoid Size -- | Support for OO-like prototypes. module Data.Prototype -- | A prototype. Typically the parameter will be a record type. Fields can -- be defined in terms of others fields, with the idea that some of these -- definitons can be overridden. -- -- Example: -- --
-- data O = O {f1, f2, f3 :: Int}
-- deriving Show
-- o1 = Proto $ \self -> O
-- {
-- f1 = 1,
-- f2 = f1 self + 1, -- 'f1 self' refers to the overriden definition of f1.
-- f3 = f1 self + 2
-- }
--
newtype Proto a
Proto :: (a -> a) -> Proto a
fromProto :: Proto a -> a -> a
-- | Get the value of a prototype. This can return bottom in case some
-- fields are recursively defined in terms of each other.
extractValue :: Proto t -> t
-- | Override a prototype. Fields can be defined in terms of their
-- definition in the base prototype.
--
-- Example:
--
--
-- o2 = o1 `override` \super self -> super
-- {
-- f1 = f1 super + 10,
-- f3 = f3 super + 1
-- }
--
override :: Proto a -> (a -> a -> a) -> Proto a
-- | Field access
(.->) :: Proto t -> (t -> a) -> a
module Yi.Prelude
(<>) :: Monoid a => a -> a -> a
-- | Append two lists, i.e.,
--
-- -- [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] -- [x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...] ---- -- If the first list is not finite, the result is the first list. (++) :: [a] -> [a] -> [a] -- | Same as >>=, but with the arguments interchanged. (=<<) :: Monad m => (a -> m b) -> m a -> m b -- | Strict (call-by-value) application, defined in terms of seq. ($!) :: (a -> b) -> a -> b -- | Double-precision floating point numbers. It is desirable that this -- type be at least equal in range and precision to the IEEE -- double-precision type. data Double :: * -- | The Binary class provides put and get, methods -- to encode and decode a Haskell value to a lazy ByteString. It mirrors -- the Read and Show classes for textual representation of Haskell types, -- and is suitable for serialising Haskell values to disk, over the -- network. -- -- For parsing and generating simple external binary formats (e.g. C -- structures), Binary may be used, but in general is not suitable for -- complex protocols. Instead use the Put and Get primitives directly. -- -- Instances of Binary should satisfy the following property: -- --
-- decode . encode == id ---- -- That is, the get and put methods should be the inverse -- of each other. A range of instances are provided for basic Haskell -- types. class Binary t -- | The character type Char is an enumeration whose values -- represent Unicode (or equivalently ISO/IEC 10646) characters (see -- http://www.unicode.org/ for details). This set extends the ISO -- 8859-1 (Latin-1) character set (the first 256 characters), which is -- itself an extension of the ASCII character set (the first 128 -- characters). A character literal in Haskell has type Char. -- -- To convert a Char to or from the corresponding Int value -- defined by Unicode, use toEnum and fromEnum from the -- Enum class respectively (or equivalently ord and -- chr). data Char :: * -- | The Either type represents values with two possibilities: a -- value of type Either a b is either Left -- a or Right b. -- -- The Either type is sometimes used to represent a value which is -- either correct or an error; by convention, the Left constructor -- is used to hold an error value and the Right constructor is -- used to hold a correct value (mnemonic: "right" also means "correct"). data Either a b :: * -> * -> * Left :: a -> Either a b Right :: b -> Either a b type Endom a = a -> a -- | The Eq class defines equality (==) and inequality -- (/=). All the basic datatypes exported by the Prelude -- are instances of Eq, and Eq may be derived for any -- datatype whose constituents are also instances of Eq. -- -- Minimal complete definition: either == or /=. class Eq a (==) :: Eq a => a -> a -> Bool (/=) :: Eq a => a -> a -> Bool -- | Fractional numbers, supporting real division. -- -- Minimal complete definition: fromRational and (recip or -- (/)) class Num a => Fractional a (/) :: Fractional a => a -> a -> a recip :: Fractional a => a -> a fromRational :: Fractional a => Rational -> a -- | The Functor class is used for types that can be mapped over. -- Instances of Functor should satisfy the following laws: -- --
-- fmap id == id -- fmap (f . g) == fmap f . fmap g ---- -- The instances of Functor for lists, Maybe and IO -- satisfy these laws. class Functor (f :: * -> *) fmap :: Functor f => (a -> b) -> f a -> f b -- | A value of type IO a is a computation which, when -- performed, does some I/O before returning a value of type a. -- -- There is really only one way to "perform" an I/O action: bind it to -- Main.main in your program. When your program is run, the I/O -- will be performed. It isn't possible to perform I/O from an arbitrary -- function, unless that function is itself in the IO monad and -- called at some point, directly or indirectly, from Main.main. -- -- IO is a monad, so IO actions can be combined using -- either the do-notation or the >> and >>= -- operations from the Monad class. data IO a :: * -> * -- | The default value. If a function tries to get a copy of the state, but -- the state hasn't yet been created, initial will be called to -- supply *some* value. The value of initial will probably be something -- like Nothing, [], "", or empty - compare the mempty of -- Data.Monoid. class Initializable a initial :: Initializable a => a -- | Arbitrary-precision integers. data Integer :: * -- | Integral numbers, supporting integer division. -- -- Minimal complete definition: quotRem and toInteger class (Real a, Enum a) => Integral a quot :: Integral a => a -> a -> a rem :: Integral a => a -> a -> a div :: Integral a => a -> a -> a mod :: Integral a => a -> a -> a quotRem :: Integral a => a -> a -> (a, a) divMod :: Integral a => a -> a -> (a, a) toInteger :: Integral a => a -> Integer -- | The Bounded class is used to name the upper and lower limits of -- a type. Ord is not a superclass of Bounded since types -- that are not totally ordered may also have upper and lower bounds. -- -- The Bounded class may be derived for any enumeration type; -- minBound is the first constructor listed in the data -- declaration and maxBound is the last. Bounded may also -- be derived for single-constructor datatypes whose constituent types -- are in Bounded. class Bounded a minBound :: Bounded a => a maxBound :: Bounded a => a -- | Class Enum defines operations on sequentially ordered types. -- -- The enumFrom... methods are used in Haskell's translation of -- arithmetic sequences. -- -- Instances of Enum may be derived for any enumeration type -- (types whose constructors have no fields). The nullary constructors -- are assumed to be numbered left-to-right by fromEnum from -- 0 through n-1. See Chapter 10 of the Haskell -- Report for more details. -- -- For any type that is an instance of class Bounded as well as -- Enum, the following should hold: -- --
-- enumFrom x = enumFromTo x maxBound -- enumFromThen x y = enumFromThenTo x y bound -- where -- bound | fromEnum y >= fromEnum x = maxBound -- | otherwise = minBound --class Enum a succ :: Enum a => a -> a pred :: Enum a => a -> a toEnum :: Enum a => Int -> a fromEnum :: Enum a => a -> Int enumFrom :: Enum a => a -> [a] enumFromThen :: Enum a => a -> a -> [a] enumFromTo :: Enum a => a -> a -> [a] enumFromThenTo :: Enum a => a -> a -> a -> [a] -- | The Maybe type encapsulates an optional value. A value of type -- Maybe a either contains a value of type a -- (represented as Just a), or it is empty (represented -- as Nothing). Using Maybe is a good way to deal with -- errors or exceptional cases without resorting to drastic measures such -- as error. -- -- The Maybe type is also a monad. It is a simple kind of error -- monad, where all errors are represented by Nothing. A richer -- error monad can be built using the Either type. data Maybe a :: * -> * Nothing :: Maybe a Just :: a -> Maybe a -- | The Monad class defines the basic operations over a -- monad, a concept from a branch of mathematics known as -- category theory. From the perspective of a Haskell programmer, -- however, it is best to think of a monad as an abstract datatype -- of actions. Haskell's do expressions provide a convenient -- syntax for writing monadic expressions. -- -- Minimal complete definition: >>= and return. -- -- Instances of Monad should satisfy the following laws: -- --
-- return a >>= k == k a -- m >>= return == m -- m >>= (\x -> k x >>= h) == (m >>= k) >>= h ---- -- Instances of both Monad and Functor should additionally -- satisfy the law: -- --
-- fmap f xs == xs >>= return . f ---- -- The instances of Monad for lists, Maybe and IO -- defined in the Prelude satisfy these laws. class Monad (m :: * -> *) (>>=) :: Monad m => m a -> (a -> m b) -> m b (>>) :: Monad m => m a -> m b -> m b return :: Monad m => a -> m a fail :: Monad m => String -> m a -- | Basic numeric class. -- -- Minimal complete definition: all except negate or (-) class Num a (+) :: Num a => a -> a -> a (*) :: Num a => a -> a -> a (-) :: Num a => a -> a -> a negate :: Num a => a -> a abs :: Num a => a -> a signum :: Num a => a -> a fromInteger :: Num a => Integer -> a -- | The Ord class is used for totally ordered datatypes. -- -- Instances of Ord can be derived for any user-defined datatype -- whose constituent types are in Ord. The declared order of the -- constructors in the data declaration determines the ordering in -- derived Ord instances. The Ordering datatype allows a -- single comparison to determine the precise ordering of two objects. -- -- Minimal complete definition: either compare or <=. -- Using compare can be more efficient for complex types. class Eq a => Ord a compare :: Ord a => a -> a -> Ordering (<) :: Ord a => a -> a -> Bool (>=) :: Ord a => a -> a -> Bool (>) :: Ord a => a -> a -> Bool (<=) :: Ord a => a -> a -> Bool max :: Ord a => a -> a -> a min :: Ord a => a -> a -> a -- | Parsing of Strings, producing values. -- -- Minimal complete definition: readsPrec (or, for GHC only, -- readPrec) -- -- Derived instances of Read make the following assumptions, which -- derived instances of Show obey: -- --
-- infixr 5 :^: -- data Tree a = Leaf a | Tree a :^: Tree a ---- -- the derived instance of Read in Haskell 98 is equivalent to -- --
-- instance (Read a) => Read (Tree a) where
--
-- readsPrec d r = readParen (d > app_prec)
-- (\r -> [(Leaf m,t) |
-- ("Leaf",s) <- lex r,
-- (m,t) <- readsPrec (app_prec+1) s]) r
--
-- ++ readParen (d > up_prec)
-- (\r -> [(u:^:v,w) |
-- (u,s) <- readsPrec (up_prec+1) r,
-- (":^:",t) <- lex s,
-- (v,w) <- readsPrec (up_prec+1) t]) r
--
-- where app_prec = 10
-- up_prec = 5
--
--
-- Note that right-associativity of :^: is unused.
--
-- The derived instance in GHC is equivalent to
--
-- -- instance (Read a) => Read (Tree a) where -- -- readPrec = parens $ (prec app_prec $ do -- Ident "Leaf" <- lexP -- m <- step readPrec -- return (Leaf m)) -- -- +++ (prec up_prec $ do -- u <- step readPrec -- Symbol ":^:" <- lexP -- v <- step readPrec -- return (u :^: v)) -- -- where app_prec = 10 -- up_prec = 5 -- -- readListPrec = readListPrecDefault --class Read a readsPrec :: Read a => Int -> ReadS a readList :: Read a => ReadS [a] class (Num a, Ord a) => Real a toRational :: Real a => a -> Rational -- | Extracting components of fractions. -- -- Minimal complete definition: properFraction class (Real a, Fractional a) => RealFrac a properFraction :: (RealFrac a, Integral b) => a -> (b, a) truncate :: (RealFrac a, Integral b) => a -> b round :: (RealFrac a, Integral b) => a -> b ceiling :: (RealFrac a, Integral b) => a -> b floor :: (RealFrac a, Integral b) => a -> b -- | The reader monad transformer, which adds a read-only environment to -- the given monad. -- -- The return function ignores the environment, while -- >>= passes the inherited environment to both -- subcomputations. newtype ReaderT r (m :: * -> *) a :: * -> (* -> *) -> * -> * ReaderT :: (r -> m a) -> ReaderT r a -- | The underlying computation, as a function of the environment. runReaderT :: ReaderT r a -> r -> m a class SemiNum absolute relative | absolute -> relative (+~) :: SemiNum absolute relative => absolute -> relative -> absolute (-~) :: SemiNum absolute relative => absolute -> relative -> absolute (~-) :: SemiNum absolute relative => absolute -> absolute -> relative -- | A String is a list of characters. String constants in Haskell -- are values of type String. type String = [Char] -- | The class Typeable allows a concrete representation of a type -- to be calculated. class Typeable a -- | Return the longest common prefix of a set of lists. -- --
-- P(xs) === all (isPrefixOf (commonPrefix xs)) xs -- length s > length (commonPrefix xs) --> not (all (isPrefixOf s) xs) --commonPrefix :: Eq a => [[a]] -> [a] discard :: Functor f => f a -> f () -- | Write nothing. Use with dummyGet dummyPut :: a -> Put -- | Read nothing, and return initial. Use with dummyPut. dummyGet :: Initializable a => Get a -- | Lift an accessor to a traversable structure. (This can be seen as a -- generalization of fmap) every :: Traversable t => Accessor whole part -> Accessor (t whole) (t part) -- | Finds the first element satisfying the predicate, and returns a zipper -- pointing at it. findPL :: (a -> Bool) -> [a] -> Maybe (PointedList a) -- | general coercion from integral types fromIntegral :: (Integral a, Num b) => a -> b -- | Extract the first component of a pair. fst :: (a, b) -> a fst3 :: (a, b, c) -> a -- | Alternative to groupBy. -- --
-- groupBy' (\a b -> abs (a - b) <= 1) [1,2,3] = [[1,2,3]] ---- -- whereas -- --
-- groupBy (\a b -> abs (a - b) <= 1) [1,2,3] = [[1,2],[3]] ---- -- TODO: Check in ghc 6.12 release if groupBy == groupBy'. groupBy' :: (a -> a -> Bool) -> [a] -> [[a]] list :: b -> (a -> [a] -> b) -> [a] -> b -- | Extract the first element of a list, which must be non-empty. head :: [a] -> a -- | Return all the elements of a list except the last one. The list must -- be non-empty. init :: [a] -> [a] io :: MonadIO m => IO a -> m a -- | Extract the last element of a list, which must be finite and -- non-empty. last :: [a] -> a -- | lookup key assocs looks up a key in an association -- list. lookup :: Eq a => a -> [(a, b)] -> Maybe b -- | As Map.adjust, but the combining function is applied strictly. mapAdjust' :: Ord k => (a -> a) -> k -> Map k a -> Map k a -- | As Map.alter, but the newly inserted element is forced with the map. mapAlter' :: Ord k => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a -- | Generalisation of fromList to arbitrary foldables. mapFromFoldable :: (Foldable t, Ord k) => t (k, a) -> Map k a putA :: MonadState r m => T r a -> a -> m () getA :: MonadState r m => T r a -> m a modA :: MonadState r m => T r a -> (a -> a) -> m () -- | As nub, but with O(n*log(n)) behaviour. nubSet :: Ord a => [a] -> [a] -- | Test whether a list is empty. null :: [a] -> Bool -- | The print function outputs a value of any printable type to the -- standard output device. Printable types are those that are instances -- of class Show; print converts values to strings for -- output using the show operation and adds a newline. -- -- For example, a program to print the first 20 integers and their powers -- of 2 could be written as: -- --
-- main = print ([(n, 2^n) | n <- [0..19]]) --print :: Show a => a -> IO () -- | The same as putStr, but adds a newline character. putStrLn :: String -> IO () -- | replicate n x is a list of length n with -- x the value of every element. It is an instance of the more -- general genericReplicate, in which n may be of any -- integral type. replicate :: Int -> a -> [a] -- | The read function reads input from a string, which must be -- completely consumed by the input process. read :: Read a => String -> a -- | Evaluates its first argument to head normal form, and then returns its -- second argument as the result. seq :: a -> b -> b singleton :: a -> [a] -- | Extract the second component of a pair. snd :: (a, b) -> b snd3 :: (a, b, c) -> b -- | Given a function which moves the focus from index A to index B, return -- a function which swaps the elements at indexes A and B and then moves -- the focus. See Yi.Editor.swapWinWithFirstE for an example. swapFocus :: (PointedList a -> PointedList a) -> (PointedList a -> PointedList a) -- | Extract the elements after the head of a list, which must be -- non-empty. tail :: [a] -> [a] trd3 :: (a, b, c) -> c -- | A special case of error. It is expected that compilers will -- recognize this and insert error messages which are more appropriate to -- the context in which undefined appears. undefined :: a -- | unlines is an inverse operation to lines. It joins -- lines, after appending a terminating newline to each. unlines :: [String] -> String -- | Conditional execution of monadic expressions. For example, -- --
-- when debug (putStr "Debugging\n") ---- -- will output the string Debugging\n if the Boolean value -- debug is True, and otherwise do nothing. when :: Monad m => Bool -> m () -> m () -- | The computation writeFile file str function writes the -- string str, to the file file. writeFile :: FilePath -> String -> IO () instance (Eq k, Hashable k, Binary k, Binary v) => Binary (HashMap k v) instance Initializable (Maybe a) module Yi.Event data Event Event :: Key -> [Modifier] -> Event prettyEvent :: Event -> String data Key KEsc :: Key KFun :: Int -> Key KPrtScr :: Key KPause :: Key KASCII :: Char -> Key KBS :: Key KIns :: Key KHome :: Key KPageUp :: Key KDel :: Key KEnd :: Key KPageDown :: Key KNP5 :: Key KUp :: Key KMenu :: Key KLeft :: Key KDown :: Key KRight :: Key KEnter :: Key KTab :: Key data Modifier MShift :: Modifier MCtrl :: Modifier MMeta :: Modifier MSuper :: Modifier MHyper :: Modifier -- | Map an Event to a Char. This is used in the emacs keymap for Ctrl-Q -- and vim keymap insertSpecialChar eventToChar :: Event -> Char instance Show Modifier instance Eq Modifier instance Ord Modifier instance Eq Key instance Show Key instance Ord Key instance Eq Event instance Show Event instance Ord Event -- | Colors and friends. module Yi.Style -- | Visual text attributes to be applied during layout. data Attributes Attributes :: !Color -> !Color -> !Bool -> !Bool -> !Bool -> !Bool -> Attributes foreground :: Attributes -> !Color background :: Attributes -> !Color -- | The text should be show as active or selected. This can -- be implemented by reverse video on the terminal. reverseAttr :: Attributes -> !Bool bold :: Attributes -> !Bool italic :: Attributes -> !Bool underline :: Attributes -> !Bool emptyAttributes :: Attributes -- | The style is used to transform attributes by modifying one or more of -- the visual text attributes. type Style = Endo Attributes -- | The UI type data UIStyle UIStyle :: Attributes -> Style -> Attributes -> Style -> Style -> Attributes -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> UIStyle -- | ground attributes for the modeline modelineAttributes :: UIStyle -> Attributes -- | transformation of modeline in focus modelineFocusStyle :: UIStyle -> Style -- | ground attributes for the tabbar tabBarAttributes :: UIStyle -> Attributes -- | a tab that currently holds the focus tabInFocusStyle :: UIStyle -> Style -- | a tab that does not have the current focus tabNotFocusedStyle :: UIStyle -> Style -- | ground attributes for the main text views baseAttributes :: UIStyle -> Attributes -- | the selected portion selectedStyle :: UIStyle -> Style -- | empty file marker colours eofStyle :: UIStyle -> Style -- | indicates errors in text errorStyle :: UIStyle -> Style -- | search matchesparen matchesother hints hintStyle :: UIStyle -> Style -- | current search match strongHintStyle :: UIStyle -> Style -- | all comments commentStyle :: UIStyle -> Style -- | additional only for block comments blockCommentStyle :: UIStyle -> Style -- | applied to language keywords keywordStyle :: UIStyle -> Style -- | numbers numberStyle :: UIStyle -> Style -- | preprocessor directive (often in Haskell or C) preprocessorStyle :: UIStyle -> Style -- | constant strings stringStyle :: UIStyle -> Style -- | additional style for long strings longStringStyle :: UIStyle -> Style -- | type name (such as class in an OO language) typeStyle :: UIStyle -> Style -- | data constructor dataConstructorStyle :: UIStyle -> Style -- | style of import names importStyle :: UIStyle -> Style -- | builtin things, e.g. Array in JavaScript builtinStyle :: UIStyle -> Style -- | regular expressions regexStyle :: UIStyle -> Style -- | any standard variable (identifier) variableStyle :: UIStyle -> Style -- | infix operators operatorStyle :: UIStyle -> Style -- | Style of a quotation (e.g. in template haskell) quoteStyle :: UIStyle -> Style -- | stuff that's passed to the shell in a Makefile makeFileAction :: UIStyle -> Style -- | makefile rule headers makeFileRuleHead :: UIStyle -> Style -- | A StyleName determines what style to use, taking into account the set -- of rendering preferences given by a UIStyle. Typically, style -- names will be Style-valued field names of UIStyle. type StyleName = UIStyle -> Style -- | A style that sets the foreground. withFg, withBg :: Color -> Style -- | A style that sets the font to bold withBd, withReverse, withUnderline, withItlc :: Bool -> Style -- | The identity transform. defaultStyle :: StyleName data Color RGB :: {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> {-# UNPACK #-} !Word8 -> Color -- | The system-default color of the engine used. e.g. in Gtk this should -- pick whatever the user has chosen as default color (background or -- forground depending on usage) for the text. Default :: Color -- | Convert a color to its text specification, as to be accepted by -- XParseColor colorToText :: Color -> String black, yellow, brown, green, darkgreen, red, darkred, lightGrey, grey :: Color darkblue, brightwhite, white, cyan, darkcyan, magenta, purple, blue :: Color instance Eq Color instance Ord Color instance Show Color instance Eq Attributes instance Ord Attributes instance Show Attributes module Yi.Style.Library type Theme = Proto UIStyle -- | Abstract theme that provides useful defaults. defaultTheme :: Theme -- | The default Theme defaultLightTheme :: Theme -- | A Theme inspired by the darkblue colorscheme of Vim. darkBlueTheme :: Theme -- | Basic types useful everywhere we play with buffers. module Yi.Buffer.Basic -- | Direction of movement inside a buffer data Direction Backward :: Direction Forward :: Direction reverseDir :: Direction -> Direction -- | reverse if Backward mayReverse :: Direction -> [a] -> [a] -- | direction is in the same style of maybe or -- either functions, It takes one argument per direction -- (backward, then forward) and a direction to select the output. directionElim :: Direction -> a -> a -> a -- | A mark in a buffer newtype Mark Mark :: Int -> Mark markId :: Mark -> Int -- | Reference to a buffer. newtype BufferRef BufferRef :: Int -> BufferRef -- | A point in a buffer newtype Point Point :: Int -> Point fromPoint :: Point -> Int -- | Size of a buffer region newtype Size Size :: Int -> Size fromSize :: Size -> Int fromString :: String -> Rope -- | Window references newtype WindowRef WindowRef :: Int -> WindowRef unWindowRef :: WindowRef -> Int instance Typeable Mark instance Typeable BufferRef instance Typeable Point instance Typeable WindowRef instance Integral Point instance Real Point instance Num Point instance Num BufferRef instance Eq Mark instance Ord Mark instance Show Mark instance Binary Mark instance Eq BufferRef instance Ord BufferRef instance Binary BufferRef instance Eq Point instance Ord Point instance Enum Point instance Bounded Point instance Binary Point instance Ix Point instance Show Size instance Eq Size instance Ord Size instance Num Size instance Enum Size instance Real Size instance Integral Size instance Binary Size instance Eq WindowRef instance Ord WindowRef instance Enum WindowRef instance Show WindowRef instance Binary WindowRef instance Initializable WindowRef instance SemiNum Point Size instance Show Point instance Show BufferRef instance Binary Direction instance Typeable Direction instance Eq Direction instance Ord Direction instance Show Direction instance Bounded Direction instance Enum Direction module Yi.KillRing data Killring krKilled :: Killring -> Bool krContents :: Killring -> [String] -- | Finish an atomic command, for the purpose of killring accumulation. krEndCmd :: Killring -> Killring -- | Put some text in the killring. It's accumulated if the last command -- was a kill too krPut :: Direction -> String -> Killring -> Killring -- | Set the top of the killring. Never accumulate the previous content. krSet :: String -> Killring -> Killring -- | Get the top of the killring. krGet :: Killring -> String krEmpty :: Killring instance Binary Killring instance Show Killring module Yi.Regex data SearchOption -- | Compile for matching that ignores char case IgnoreCase :: SearchOption -- | Compile for newline-insensitive matching NoNewLine :: SearchOption -- | Treat the input not as a regex but as a literal string to search for. QuoteRegex :: SearchOption makeSearchOptsM :: [SearchOption] -> String -> Either String SearchExp data SearchExp SearchExp :: String -> Regex -> Regex -> SearchExp seInput :: SearchExp -> String seCompiled :: SearchExp -> Regex seBackCompiled :: SearchExp -> Regex searchString :: SearchExp -> String searchRegex :: Direction -> SearchExp -> Regex emptySearch :: SearchExp -- | The regular expression that matches nothing. emptyRegex :: Regex -- | Return an escaped (for parseRegex use) version of the string. regexEscapeString :: String -> String instance Eq SearchOption instance Uniplate Pattern module Yi.Dynamic -- | Class of values that can go in a ConfigDynamic or a -- ConfigDynamicValues. These will typically go in a -- Config. As the Config has no mutable state, there is -- no need to serialize these values: if needed, they will be set in the -- user's configuration file. The Initializable constraint ensures -- that, even if the user hasn't customised this config variable, a value -- is stil available. class (Initializable a, Typeable a) => YiConfigVariable a -- | An "extensible record" of YiConfigVariables. Can be constructed -- and accessed with initial and configVariableA. -- -- This type can be thought of as a record containing all -- YiConfigVariables in existence. data ConfigVariables -- | Accessor for any YiConfigVariable. Neither reader nor writer -- can fail: if the user's config file hasn't set a value for a -- YiConfigVariable, then the default value is used. configVariableA :: YiConfigVariable a => Accessor ConfigVariables a -- | Class of values that can go in a Dynamic or a -- DynamicValues. These are typically for storing custom state in -- a FBuffer or an Editor. class (Initializable a, Binary a, Typeable a) => YiVariable a -- | An extensible record, indexed by type. data DynamicValues -- | Accessor for a dynamic component. If the component is not found, the -- value initial is used. dynamicValueA :: YiVariable a => Accessor DynamicValues a instance Typeable Dynamic instance Typeable DynamicValues instance Monoid ConfigVariables instance Monoid DynamicValues instance Initializable DynamicValues instance Binary DynamicValues instance Binary Dynamic instance Initializable ConfigVariables -- | This module defines the Region ADT module Yi.Region -- | The region data type. The region is semi open: it includes the start -- but not the end bound. This allows simpler region-manipulation -- algorithms. Invariant : regionStart r <= regionEnd r data Region -- | The empty region emptyRegion :: Region regionIsEmpty :: Region -> Bool -- | Construct a region from its bounds, emacs style: the right bound is -- excluded mkRegion :: Point -> Point -> Region mkRegion' :: Direction -> Point -> Point -> Region mkSizeRegion :: Point -> Size -> Region regionStart :: Region -> Point regionEnd :: Region -> Point regionSize :: Region -> Size regionDirection :: Region -> Direction -- | True if the given point is inside the given region. inRegion :: Point -> Region -> Bool -- | True if the given point is inside the given region or at the end of -- it. nearRegion :: Point -> Region -> Bool -- | Returns if a region (1st arg) is included in another (2nd arg) includedRegion :: Region -> Region -> Bool fmapRegion :: (Point -> Point) -> Region -> Region -- | Take the intersection of two regions intersectRegion :: Region -> Region -> Region -- | Take the union of two regions (including what is between them) unionRegion :: Region -> Region -> Region regionFirst :: Region -> Point regionLast :: Region -> Point regionsOverlap :: Bool -> Region -> Region -> Bool instance Show Region instance Binary Region instance Typeable Region module Yi.Window -- | A window onto a buffer. data Window Window :: !Bool -> !BufferRef -> ![BufferRef] -> Int -> Region -> !WindowRef -> Int -> Window -- | regular or mini window? isMini :: Window -> !Bool -- | the buffer this window opens to bufkey :: Window -> !BufferRef -- | list of last accessed buffers (former bufKeys). Last accessed one is -- first element bufAccessList :: Window -> ![BufferRef] -- | height of the window (in number of screen lines displayed) height :: Window -> Int -- | view area. note that the top point is also available as a buffer mark. winRegion :: Window -> Region -- | identifier for the window (for UI sync) This is required for accurate -- scrolling. Scrolling depends on the actual number of buffer lines -- displayed. Line wrapping changes that number relative to the height so -- we can't use height for that purpose. wkey :: Window -> !WindowRef -- | The actual number of buffer lines displayed. Taking into account line -- wrapping actualLines :: Window -> Int -- | Get the identification of a window. winkey :: Window -> (Bool, BufferRef) -- | Return a fake window onto a buffer. dummyWindow :: BufferRef -> Window instance Typeable Window instance Eq Window instance Show Window instance Binary Window -- | This module defines a common interface for syntax-awareness. module Yi.Syntax -- | The main type of syntax highlighters. This record type combines all -- the required functions, and is parametrized on the type of the -- internal state. data Highlighter cache syntax SynHL :: cache -> (Scanner Point Char -> Point -> cache -> cache) -> (cache -> WindowRef -> syntax) -> (Map WindowRef Region -> cache -> cache) -> Highlighter cache syntax -- | The start state for the highlighter. hlStartState :: Highlighter cache syntax -> cache hlRun :: Highlighter cache syntax -> Scanner Point Char -> Point -> cache -> cache hlGetTree :: Highlighter cache syntax -> cache -> WindowRef -> syntax -- | focus at a given point, and return the coresponding node. (hint -- the -- root can always be returned, at the cost of performance.) hlFocus :: Highlighter cache syntax -> Map WindowRef Region -> cache -> cache data Cache state result data Scanner st a Scanner :: st -> (st -> Point) -> a -> (st -> [(st, a)]) -> Scanner st a -- | Initial state scanInit :: Scanner st a -> st -- | How far did the scanner look to produce this intermediate state? The -- state can be reused as long as nothing changes before that point. scanLooked :: Scanner st a -> st -> Point scanEmpty :: Scanner st a -> a -- | Running function returns a list of results and intermediate states. -- Note: the state is the state before producing the result in the -- second component. scanRun :: Scanner st a -> st -> [(st, a)] data ExtHL syntax ExtHL :: (Highlighter cache syntax) -> ExtHL syntax noHighlighter :: Highlighter () syntax -- | This takes as input a scanner that returns the full result at -- each element in the list; perhaps in a different form for the purpose -- of incremental-lazy eval. mkHighlighter :: Show state => (Scanner Point Char -> Scanner state result) -> Highlighter (Cache state result) result skipScanner :: Int -> Scanner st a -> Scanner st a emptyFileScan :: Scanner Point Char -- | A point in a buffer newtype Point Point :: Int -> Point fromPoint :: Point -> Int -- | Size of a buffer region newtype Size Size :: Int -> Size fromSize :: Size -> Int type Length = Int type Stroke = Span StyleName data Span a Span :: !Point -> !a -> !Point -> Span a spanBegin :: Span a -> !Point spanContents :: Span a -> !a spanEnd :: Span a -> !Point instance Show a => Show (Span a) instance Functor (Scanner st) instance Functor Span instance Foldable Span instance Traversable Span -- | An implementation of restricted, linear undo, as described in: -- --
-- T. Berlage, "A selective undo mechanism for graphical user interfaces -- based on command objects", ACM Transactions on Computer-Human -- Interaction 1(3), pp. 269-294, 1994. ---- -- Implementation based on a proposal by sjw. -- -- From Berlage: -- --
-- All buffer-mutating commands are stored (in abstract form) in an -- Undo list. The most recent item in this list is the action that -- will be undone next. When it is undone, it is removed from the Undo -- list, and its inverse is added to the Redo list. The last command -- put into the Redo list can be redone, and again prepended to the -- Undo list. New commands are added to the Undo list without -- affecting the Redo list. ---- -- Now, the above assumes that commands can be _redone_ in a state other -- than that in which it was orginally done. This is not the case in our -- text editor: a user may delete, for example, between an undo and a -- redo. Berlage addresses this in S2.3. A Yi example: -- --
-- Delete some characters -- Undo partialy -- Move prior in the file, and delete another _chunk_ -- Redo some things == corruption. ---- -- Berlage describes the stable execution property: -- --
-- A command is always redone in the same state that it was originally -- executed in, and is always undone in the state that was reached -- after the original execution. ---- --
-- The only case where the linear undo model violates the stable -- execution property is when _a new command is submitted while the -- redo list is not empty_. The _restricted linear undo model_ ... -- clears the redo list in this case. ---- -- Also some discussion of this in: The Text Editor Sam, Rob Pike, -- pg 19. module Yi.Buffer.Undo -- | A new empty URList. Notice we must have a saved file point as -- this is when we assume we are opening the file so it is currently the -- same as the one on disk emptyU :: URList -- | Add an action to the undo list. According to the restricted, linear -- undo model, if we add a command whilst the redo list is not empty, we -- will lose our redoable changes. addChangeU :: Change -> URList -> URList -- | Add a saved file point so that we can tell that the buffer has not -- been modified since the previous saved file point. Notice that we must -- be sure to remove the previous saved file points since they are now -- worthless. setSavedFilePointU :: URList -> URList -- | undoIsAtSavedFilePoint. True if the undo list is at a -- SavedFilePoint indicating that the buffer has not been modified since -- we last saved the file. Note: that an empty undo list does NOT mean -- that the buffer is not modified since the last save. Because we may -- have saved the file and then undone actions done before the save. isAtSavedFilePointU :: URList -> Bool -- | This undoes one interaction step. undoU :: Mark -> URList -> BufferImpl syntax -> (BufferImpl syntax, (URList, [Update])) -- | This redoes one iteraction step. redoU :: Mark -> URList -> BufferImpl syntax -> (BufferImpl syntax, (URList, [Update])) -- | A URList consists of an undo and a redo list. data URList data Change InteractivePoint :: Change AtomicChange :: !Update -> Change instance Binary URList instance Show URList instance Binary Change instance Show Change -- | This is a library of interactive processes combinators, usable to -- define extensible keymaps. -- -- (Inspired by the Parsec library, written by Koen Claessen) -- -- The processes are: -- --
-- putA bufferDynamicValueA updatedvalue -- value <- getA bufferDynamicValueA --bufferDynamicValueA :: YiVariable a => Accessor FBuffer a shortIdentString :: [a] -> FBuffer -> [Char] identString :: FBuffer -> [Char] miniIdentString :: FBuffer -> [Char] identA :: Accessor FBuffer BufferId -- | maybe a filename associated with this buffer. Filename is -- canonicalized. type BufferId = Either String FilePath file :: FBuffer -> (Maybe FilePath) lastSyncTimeA :: Accessor FBuffer UTCTime instance Typeable IndentSettings instance Typeable1 BufferM instance Typeable FBuffer instance Typeable AnyMode instance Eq IndentSettings instance Show IndentSettings instance Eq IndentBehaviour instance Show IndentBehaviour instance Monad BufferM instance Functor BufferM instance MonadWriter [Update] BufferM instance MonadState FBuffer BufferM instance MonadReader Window BufferM instance Show FBuffer instance Eq FBuffer instance Applicative BufferM instance Binary (Mode syntax) instance Binary SelectionStyle instance Binary FBuffer instance Binary UTCTime instance Binary Attributes instance Typeable SelectionStyle instance Typeable Attributes instance Binary a_1627628520 => Binary (MarkSet a_1627628520) instance Functor MarkSet instance Foldable MarkSet instance Traversable MarkSet -- | This module defines buffer operation on regions module Yi.Buffer.Region -- | Swap the content of two Regions swapRegionsB :: Region -> Region -> BufferM () -- | Delete an arbitrary part of the buffer deleteRegionB :: Region -> BufferM () -- | Replace a region with a given string. replaceRegionB :: Region -> String -> BufferM () -- | Replace a region with a given rope. replaceRegionB' :: Region -> Rope -> BufferM () -- | As replaceRegionB, but do a minimal edition instead of deleting -- the whole region and inserting it back. replaceRegionClever :: Region -> String -> BufferM () -- | Read an arbitrary part of the buffer readRegionB :: Region -> BufferM String mapRegionB :: Region -> (Char -> Char) -> BufferM () -- | Modifies the given region according to the given string transformation -- function modifyRegionB :: (String -> String) -> Region -> BufferM () -- | As modifyRegionB, but do a minimal edition instead of deleting -- the whole region and inserting it back. modifyRegionClever :: (String -> String) -> Region -> BufferM () winRegionB :: BufferM Region -- | Extend the right bound of a region to include it. inclusiveRegionB :: Region -> BufferM Region -- | See a region as a block/rectangular region, since regions are -- represented by two point, this returns a list of small regions form -- this block region. blockifyRegion :: Region -> BufferM [Region] -- | A normalized API to many buffer operations. module Yi.Buffer.Normal -- | Designate a given unit of text. data TextUnit -- | a single character Character :: TextUnit -- | a line of text (between newlines) Line :: TextUnit -- | a vertical line of text (area of text between two characters at -- the same column number) VLine :: TextUnit -- | the whole document Document :: TextUnit -- | Turns a unit into its negative by inverting the boundaries. For -- example, outsideUnit unitViWord will be the unit of spaces -- between words. For units without boundaries (Character, -- Document, ...), this is the identity function. outsideUnit :: TextUnit -> TextUnit -- | Unit that have its left and right boundaries at the left boundary of -- the argument unit. leftBoundaryUnit :: TextUnit -> TextUnit -- | delimited on the left and right by given characters, boolean argument -- tells if whether those are included. -- -- a word as in use in Emacs (fundamental mode) unitWord :: TextUnit unitViWord :: TextUnit unitViWORD :: TextUnit unitViWordAnyBnd :: TextUnit unitViWORDAnyBnd :: TextUnit unitViWordOnLine :: TextUnit unitViWORDOnLine :: TextUnit unitDelimited :: Char -> Char -> Bool -> TextUnit unitSentence :: TextUnit -- | Paragraph to implement emacs-like forward-paragraph/backward-paragraph unitEmacsParagraph :: TextUnit -- | Paragraph that begins and ends in the paragraph, not the empty lines -- surrounding it. unitParagraph :: TextUnit -- | Separator characters (space, tab, unicode separators). Most of the -- units above attempt to identify words with various punctuation -- and symbols included or excluded. This set of units is a simple -- inverse: it is true for whitespace or separators and -- false for anything that is not (letters, numbers, symbols, -- punctuation, whatever). isAnySep :: Char -> Bool -- | unitSep is true for any kind of whitespace/separator unitSep :: TextUnit -- | unitSepThisLine is true for any kind of whitespace/separator on this -- line only unitSepThisLine :: TextUnit isWordChar :: Char -> Bool -- | Move to the next unit boundary moveB :: TextUnit -> Direction -> BufferM () -- | As moveB, unless the point is at a unit boundary maybeMoveB :: TextUnit -> Direction -> BufferM () transformB :: (String -> String) -> TextUnit -> Direction -> BufferM () transposeB :: TextUnit -> Direction -> BufferM () -- | Region of the whole textunit where the current point is. regionOfB :: TextUnit -> BufferM Region -- | Non empty region of the whole textunit where the current point is. regionOfNonEmptyB :: TextUnit -> BufferM Region -- | Region between the point and the next boundary. The region is empty if -- the point is at the boundary. regionOfPartB :: TextUnit -> Direction -> BufferM Region -- | Non empty region between the point and the next boundary, In fact the -- region can be empty if we are at the end of file. regionOfPartNonEmptyB :: TextUnit -> Direction -> BufferM Region -- | Non empty region at given point and the next boundary, regionOfPartNonEmptyAtB :: TextUnit -> Direction -> Point -> BufferM Region readPrevUnitB :: TextUnit -> BufferM String readUnitB :: TextUnit -> BufferM String -- | Repeat an action until the condition is fulfilled or the cursor stops -- moving. The Action may be performed zero times. untilB :: BufferM Bool -> BufferM a -> BufferM [a] doUntilB_ :: BufferM Bool -> BufferM a -> BufferM () untilB_ :: BufferM Bool -> BufferM a -> BufferM () whileB :: BufferM Bool -> BufferM a -> BufferM [a] -- | Do an action if the current buffer character passes the predicate doIfCharB :: (Char -> Bool) -> BufferM a -> BufferM () atBoundaryB :: TextUnit -> Direction -> BufferM Bool numberOfB :: TextUnit -> TextUnit -> BufferM Int -- | Delete between point and next unit boundary, return the deleted -- region. deleteB :: TextUnit -> Direction -> BufferM () -- | Generic maybe move operation. As genMoveB, but don't move if we are at -- boundary already. genMaybeMoveB :: TextUnit -> (Direction, BoundarySide) -> Direction -> BufferM () -- | Generic move operation Warning: moving To the (OutsideBound, Backward) -- bound of Document is impossible (offset -1!) genMoveB u b d: -- move in direction d until encountering boundary b or unit u. See -- genAtBoundaryB for boundary explanation. genMoveB :: TextUnit -> (Direction, BoundarySide) -> Direction -> BufferM () -- | Boundary side data BoundarySide InsideBound :: BoundarySide OutsideBound :: BoundarySide -- | genAtBoundaryB u d s returns whether the point is at a given -- boundary (d,s) . Boundary (d,s) , taking Word as -- example, means: Word ^^ ^^ 12 34 1: (Backward,OutsideBound) 2: -- (Backward,InsideBound) 3: (Forward,InsideBound) 4: -- (Forward,OutsideBound) -- -- rules: genAtBoundaryB u Backward InsideBound = atBoundaryB u Backward -- genAtBoundaryB u Forward OutsideBound = atBoundaryB u Forward genAtBoundaryB :: TextUnit -> Direction -> BoundarySide -> BufferM Bool genEnclosingUnit :: TextUnit -> TextUnit genUnitBoundary :: TextUnit -> Direction -> BufferM Bool checkPeekB :: Int -> [Char -> Bool] -> Direction -> BufferM Bool data RegionStyle LineWise :: RegionStyle Inclusive :: RegionStyle Exclusive :: RegionStyle Block :: RegionStyle mkRegionOfStyleB :: Point -> Point -> RegionStyle -> BufferM Region unitWiseRegion :: TextUnit -> Region -> BufferM Region -- | Extend the given region to boundaries of the text unit. For instance -- one can extend the selection to complete lines, or paragraphs. extendRegionToBoundaries :: TextUnit -> BoundarySide -> BoundarySide -> Region -> BufferM Region regionStyleA :: Accessor FBuffer RegionStyle instance YiVariable RegionStyle instance Initializable RegionStyle instance Binary RegionStyle instance Typeable TextUnit instance Typeable RegionStyle instance Eq RegionStyle instance Show RegionStyle module Yi.Buffer.HighLevel -- | Move point to start of line moveToSol :: BufferM () -- | Move point to end of line moveToEol :: BufferM () -- | Move cursor to origin topB :: BufferM () -- | Move cursor to end of buffer botB :: BufferM () -- | Move left if on eol, but not on blank line leftOnEol :: BufferM () -- | Move x chars back, or to the sol, whichever is less moveXorSol :: Int -> BufferM () -- | Move x chars forward, or to the eol, whichever is less moveXorEol :: Int -> BufferM () -- | Move to first char of next word forwards nextWordB :: BufferM () -- | Move to first char of next word backwards prevWordB :: BufferM () -- | Move to the next occurence of c nextCInc :: Char -> BufferM () -- | Move to the character before the next occurence of c nextCExc :: Char -> BufferM () -- | Move to the previous occurence of c prevCInc :: Char -> BufferM () -- | Move to the character after the previous occurence of c prevCExc :: Char -> BufferM () -- | Move to first non-space character in this line firstNonSpaceB :: BufferM () -- | Move to the last non-space character in this line lastNonSpaceB :: BufferM () -- | Go to the first non space character in the line; if already there, -- then go to the beginning of the line. moveNonspaceOrSol :: BufferM () -- | Move down next n paragraphs nextNParagraphs :: Int -> BufferM () -- | Move up prev n paragraphs prevNParagraphs :: Int -> BufferM () goUnmatchedB :: Direction -> Char -> Char -> BufferM () -- | Return true if the current point is the start of a line atSol :: BufferM Bool -- | Return true if the current point is the end of a line atEol :: BufferM Bool -- | True if point at start of file atSof :: BufferM Bool -- | True if point at end of file atEof :: BufferM Bool -- | Get the current line and column number getLineAndCol :: BufferM (Int, Int) -- | Read the line the point is on readLnB :: BufferM String readCharB :: BufferM (Maybe Char) -- | Read from point to end of line readRestOfLnB :: BufferM String -- | Read from point to beginning of line readPreviousOfLnB :: BufferM String hasWhiteSpaceBefore :: BufferM Bool -- | Get the previous point, unless at the beginning of the file prevPointB :: BufferM Point -- | Get the next point, unless at the end of the file nextPointB :: BufferM Point readPrevWordB :: BufferM String -- | Delete one character backward bdeleteB :: BufferM () -- | Delete forward whitespace or non-whitespace depending on the character -- under point. killWordB :: BufferM () -- | Delete backward whitespace or non-whitespace depending on the -- character before point. bkillWordB :: BufferM () -- | capitalise the word under the cursor uppercaseWordB :: BufferM () -- | lowerise word under the cursor lowercaseWordB :: BufferM () -- | capitalise the first letter of this word capitaliseWordB :: BufferM () -- | Delete to the end of line, excluding it. deleteToEol :: BufferM () -- | Delete whole line moving to the next line deleteLineForward :: BufferM () -- | Transpose two characters, (the Emacs C-t action) swapB :: BufferM () -- | Delete trailing whitespace from all lines deleteTrailingSpaceB :: BufferM () -- | Marks -- -- Set the current buffer selection mark setSelectionMarkPointB :: Point -> BufferM () -- | Get the current buffer selection mark getSelectionMarkPointB :: BufferM Point -- | Exchange point & mark. exchangePointAndMarkB :: BufferM () getBookmarkB :: String -> BufferM Mark data BufferFileInfo BufferFileInfo :: FilePath -> Int -> Int -> Int -> Point -> String -> Bool -> BufferFileInfo bufInfoFileName :: BufferFileInfo -> FilePath bufInfoSize :: BufferFileInfo -> Int bufInfoLineNo :: BufferFileInfo -> Int bufInfoColNo :: BufferFileInfo -> Int bufInfoCharNo :: BufferFileInfo -> Point bufInfoPercent :: BufferFileInfo -> String bufInfoModified :: BufferFileInfo -> Bool -- | File info, size in chars, line no, col num, char num, percent bufInfoB :: BufferM BufferFileInfo upScreensB :: Int -> BufferM () downScreensB :: Int -> BufferM () -- | Scroll up 1 screen upScreenB :: BufferM () -- | Scroll down 1 screen downScreenB :: BufferM () -- | Scroll by n screens (negative for up) scrollScreensB :: Int -> BufferM () -- | Scroll according to function passed. The function takes the | Window -- height in lines, its result is passed to scrollB | (negative for up) scrollByB :: (Int -> Int) -> Int -> BufferM () -- | Same as scrollB, but also moves the cursor vimScrollB :: Int -> BufferM () -- | Same as scrollByB, but also moves the cursor vimScrollByB :: (Int -> Int) -> Int -> BufferM () -- | Move to middle line in screen scrollToCursorB :: BufferM () -- | Move cursor to the top of the screen scrollCursorToTopB :: BufferM () -- | Move cursor to the bottom of the screen scrollCursorToBottomB :: BufferM () -- | Scroll by n lines. scrollB :: Int -> BufferM () -- | Move the point to inside the viewable region snapInsB :: BufferM () -- | return index of Sol on line n above current line indexOfSolAbove :: Int -> BufferM Point data RelPosition Above :: RelPosition Below :: RelPosition Within :: RelPosition -- | return relative position of the point p relative to the -- region defined by the points rs and re pointScreenRelPosition :: Point -> Point -> Point -> RelPosition -- | Move the visible region to include the point snapScreenB :: Maybe ScrollStyle -> BufferM Bool -- | Move to n lines down from top of screen downFromTosB :: Int -> BufferM () -- | Move to n lines up from the bottom of the screen upFromBosB :: Int -> BufferM () -- | Move to middle line in screen middleB :: BufferM () pointInWindowB :: Point -> BufferM Bool -- | Return the region between point and mark getRawestSelectRegionB :: BufferM Region -- | Return the empty region if the selection is not visible. getRawSelectRegionB :: BufferM Region -- | Get the current region boundaries. Extended to the current selection -- unit. getSelectRegionB :: BufferM Region -- | Select the given region: set the selection mark at the -- regionStart and the current point at the regionEnd. setSelectRegionB :: Region -> BufferM () -- | Extend the selection mark using the given region. extendSelectRegionB :: Region -> BufferM () deleteBlankLinesB :: BufferM () -- | Get a (lazy) stream of lines in the buffer, starting at the -- next line in the given direction. lineStreamB :: Direction -> BufferM [String] getMaybeNextLineB :: Direction -> BufferM (Maybe String) getNextLineB :: Direction -> BufferM String getNextLineWhichB :: Direction -> (String -> Bool) -> BufferM (Maybe String) getNextNonBlankLineB :: Direction -> BufferM String -- | Uses a string modifying function to modify the current selection -- Currently unsets the mark such that we have no selection, arguably we -- could instead work out where the new positions should be and move the -- mark and point accordingly. modifySelectionB :: (String -> String) -> BufferM () modifyExtendedSelectionB :: TextUnit -> (String -> String) -> BufferM () -- | Prefix each line in the selection using the given string. linePrefixSelectionB :: String -> BufferM () -- | Uncomments the selection using the given line comment starting string. -- This only works for the comments which begin at the start of the line. unLineCommentSelectionB :: String -> String -> BufferM () -- | Toggle line comments in the selection by adding or removing a prefix -- to each line. toggleCommentSelectionB :: String -> String -> BufferM () -- | Justifies all the lines of the selection to be the same as the top -- line. NOTE: if the selection begins part way along a line, the other -- lines will be justified only with respect to the part of the -- indentation which is selected. justifySelectionWithTopB :: BufferM () -- | Replace the contents of the buffer with some string replaceBufferContent :: String -> BufferM () -- | Fill the text in the region so it fits nicely 80 columns. fillRegion :: Region -> BufferM () fillParagraph :: BufferM () -- | Sort the lines of the region. sortLines :: BufferM () -- | Helper function: revert the buffer contents to its on-disk version revertB :: Rope -> UTCTime -> BufferM () smallBufferSize :: Int instance Show RelPosition module Yi.Buffer.Indent -- | Return either a t or the number of spaces specified by tabSize in the -- IndentSettings. Note that if you actually want to insert a tab -- character (for example when editing makefiles) then you should use: -- insertB '\t'. tabB :: BufferM String -- | Retrieve the current indentation settings for the buffer. indentSettingsB :: BufferM IndentSettings -- | A specialisation of autoIndentHelperB. This is the most basic -- and the user is encouraged to specialise autoIndentHelperB on -- their own. autoIndentB :: IndentBehaviour -> BufferM () -- | This takes two arguments the first is a function to obtain indentation -- hints from lines above the current one. The second is a function to -- obtain a set of indentation hints from the previous line. Both of -- these are in the BufferM monad although the second seems like -- it is unnecessary. However we must take into account the length of -- tabs which come from the the tab settings and hence we must be in the -- BufferM monad. -- -- To get the straightforward behaviour of the indents of all previous -- lines until one of them has zero indent call this with: -- autoIndentHelperB fetchPreviousIndentsB (fmap (: []) -- indentOfB) However commonly we wish to have something more -- interesting for the second argument, in particular we commonly wish to -- have the last opening bracket of the previous line as well as its -- indent. autoIndentHelperB :: BufferM [Int] -> (String -> BufferM [Int]) -> IndentBehaviour -> BufferM () -- | Cycles through the indentation hints. It does this without requiring -- to set/get any state. We just look at the current indentation of the -- current line and moving to the largest indent that is cycleIndentsB :: IndentBehaviour -> [Int] -> BufferM () -- | A function generally useful as the first argument to -- autoIndentHelperB. This searches the lines above the current -- line for the indentations of each line until we get to a line which -- has no indentation *and* is not empty. Indicating that we have reached -- the outer scope. fetchPreviousIndentsB :: BufferM [Int] -- | An application of autoIndentHelperB which adds more indentation -- hints using the given keywords. The offsets of the first set of -- keywords are used as hints. For the second set of keywords it is not -- the offsets of the keywords themselves but the offset of the first -- non-white characters after the keywords. -- -- In addition to the keyword hints we also do the same as the default -- (autoIndentB) which is to use any non-closed opening brackets -- as hints. autoIndentWithKeywordsB :: [String] -> [String] -> IndentBehaviour -> BufferM () -- | Returns the position of the last opening bracket on the line which is -- not closed on the same line. Note that if we have unmatched -- parentheses such as ( ] then we may not get the correct answer, -- but in that case then arguably we don't really care if we get the -- correct answer (at least if we get it wrong the user may notice their -- error). We return a list here as it's a convenient way of returning no -- hint in the case of there being no non-closed bracket and normally -- such a hint will be part of a list of hints anyway. NOTE: this could -- be easily modified to return the indentations of *all* the non-closed -- opening brackets. But I think this is not what you generally want. -- TODO: we also do not care whether or not the bracket is within a -- string or escaped. If someone feels up to caring about that by all -- means please fix this. lastOpenBracketHint :: String -> BufferM [Int] -- | Returns the offsets of all the given keywords within the given string. -- This is potentially useful as providing indentation hints. keywordHints :: [String] -> String -> BufferM [Int] -- | Returns the offsets of anything that isn't white space after -- a keyword on the given line. This is essentially then the same as -- keywordHints except that for each keyword on the input rather -- than return the offset at the start of the keyword we return the -- offset of the first non-white character after the keyword. keywordAfterHints :: [String] -> String -> BufferM [Int] -- | Returns the indentation of a given string. Note that this depends on -- the current indentation settings. indentOfB :: String -> BufferM Int -- | Returns the length of a given string taking into account the white -- space and the indentation settings. spacingOfB :: String -> BufferM Int -- | Indents the current line to the given indentation level. In addition -- moves the point according to where it was on the line originally. If -- we were somewhere within the indentation (ie at the start of the line -- or on an empty line) then we want to just go to the end of the (new) -- indentation. However if we are currently pointing somewhere within the -- text of the line then we wish to remain pointing to the same -- character. indentToB :: Int -> BufferM () -- | Indent as much as the previous line indentAsPreviousB :: BufferM () -- | Insert a newline at point and indent the new line as the previous one. newlineAndIndentB :: BufferM () -- | Set the padding of the string to newCount, filling in tabs if -- expandTabs is set in the buffers IndentSettings rePadString :: IndentSettings -> Int -> String -> String -- | shifts right (or left if num is negative) num times, filling in tabs -- if expandTabs is set in the buffers IndentSettings indentString :: IndentSettings -> Int -> String -> String -- | Increases the indentation on the region by the given amount of -- shiftWidth shiftIndentOfRegion :: Int -> Region -> BufferM () deleteIndentOfRegion :: Region -> BufferM () -- | Return the number of spaces at the beginning of the line, up to the -- point. indentOfCurrentPosB :: BufferM Int -- | The Buffer module defines monadic editing operations over -- one-dimensional buffers, maintaining a current point. -- -- This module acts as a Facade for the Buffer.* modules. module Yi.Buffer data UIUpdate TextUpdate :: !Update -> UIUpdate StyleUpdate :: !Point -> !Size -> UIUpdate -- | Mutation actions (also used the undo or redo list) -- -- For the undoredo, we use the partial checkpoint/ (Berlage, -- pg16) strategy to store just the components of the state that change. -- -- Note that the update direction is only a hint for moving the cursor -- (mainly for undo purposes); the insertions and deletions are always -- applied Forward. data Update Insert :: !Point -> !Direction -> !Rope -> Update updatePoint :: Update -> !Point updateDirection :: Update -> !Direction insertUpdateString :: Update -> !Rope Delete :: !Point -> !Direction -> !Rope -> Update updatePoint :: Update -> !Point updateDirection :: Update -> !Direction deleteUpdateString :: Update -> !Rope updateIsDelete :: Update -> Bool -- | Utilities shared by various UIs module Yi.UI.Utils indexedAnnotatedStreamB :: Point -> BufferM [(Point, Char)] applyHeights :: Traversable t => [Int] -> t Window -> t Window spliceAnnots :: [(Point, Char)] -> [Span String] -> [(Point, Char)] -- | Turn a sequence of (from,style,to) strokes into a sequence of picture -- points (from,style), taking special care to ensure that the points are -- strictly increasing and introducing padding segments where neccessary. -- Precondition: Strokes are ordered and not overlapping. strokePicture :: [Span (Endo a)] -> [(Point, a -> a)] -- | Paint the given stroke-picture on top of an existing picture paintStrokes :: (a -> a) -> a -> [(Point, a -> a)] -> [(Point, a)] -> [(Point, a)] paintPicture :: a -> [[Span (Endo a)]] -> [(Point, a)] attributesPictureB :: UIStyle -> Maybe SearchExp -> Region -> [[Span StyleName]] -> BufferM [(Point, Attributes)] attributesPictureAndSelB :: UIStyle -> Maybe SearchExp -> Region -> BufferM [(Point, Attributes)] -- | Arrange a list of items in columns over maximum -- maxNumberOfLines lines arrangeItems :: [String] -> Int -> Int -> [String] -- | Arrange a list of items in columns over numberOfLines lines. arrangeItems' :: [String] -> Int -> Int -> (Int, [String]) module Yi.Process -- | A Posix.popen compatibility mapping. Based on PosixCompat, originally -- written by Derek Elkins for lambdabot TODO: this will probably be -- called readProcess in the new process package (2.0) popen :: FilePath -> [String] -> Maybe String -> IO (String, String, ExitCode) -- | Run a command. This looks up a program name in $PATH, but then calls -- it directly with the argument. runProgCommand :: String -> [String] -> IO (String, String, ExitCode) runShellCommand :: String -> IO (String, String, ExitCode) -- | Run a command using the system shell, returning stdout, stderr and -- exit code shellFileName :: IO String createSubprocess :: FilePath -> [String] -> BufferRef -> IO SubprocessInfo readAvailable :: Handle -> IO String data SubprocessInfo SubprocessInfo :: FilePath -> [String] -> ProcessHandle -> Handle -> Handle -> Handle -> BufferRef -> Bool -> SubprocessInfo procCmd :: SubprocessInfo -> FilePath procArgs :: SubprocessInfo -> [String] procHandle :: SubprocessInfo -> ProcessHandle hIn :: SubprocessInfo -> Handle hOut :: SubprocessInfo -> Handle hErr :: SubprocessInfo -> Handle bufRef :: SubprocessInfo -> BufferRef separateStdErr :: SubprocessInfo -> Bool type SubprocessId = Integer -- | This module defines the layout manager interface (see -- LayoutManager). To desgin a new layout manager, just make an -- instance of this class. module Yi.Layout -- | UI-agnostic layout schema. The basic constructs are -- (horizontal/vertical) stacks with fixed ratios between window sizes; -- and (horizontal/vertical) pairs with a slider in between (if -- available). data Layout a SingleWindow :: a -> Layout a Stack :: !Orientation -> [(Layout a, RelativeSize)] -> Layout a -- | Orientation -- -- Orientation orientation :: Layout a -> !Orientation -- | The layout stack, with the given weights TODO: fix strictness for -- stack (it's still lazy) wins :: Layout a -> [(Layout a, RelativeSize)] Pair :: !Orientation -> !DividerPosition -> !DividerRef -> !Layout a -> !Layout a -> Layout a -- | Orientation -- -- Orientation orientation :: Layout a -> !Orientation -- | Initial position of the divider divPos :: Layout a -> !DividerPosition -- | Index of the divider (for updating the divider position) divRef :: Layout a -> !DividerRef -- | Upper of of the pair pairFst :: Layout a -> !Layout a -- | Lower of the pair pairSnd :: Layout a -> !Layout a -- | Orientations for Stack and Pair data Orientation Horizontal :: Orientation Vertical :: Orientation -- | Divider position, in the range (0,1) type DividerPosition = Double -- | Divider reference type DividerRef = Int -- | Relative sizes, for Stack type RelativeSize = Double -- | Accessor for the DividerPosition with given reference dividerPositionA :: DividerRef -> Accessor (Layout a) DividerPosition -- | The type of layout managers. See the layout managers tall, -- hPairNStack and slidyTall for some example -- implementations. class (Typeable m, Eq m) => LayoutManager m where nextVariant = id previousVariant = id pureLayout :: LayoutManager m => m -> Layout a -> [a] -> Layout a describeLayout :: LayoutManager m => m -> String nextVariant :: LayoutManager m => m -> m previousVariant :: LayoutManager m => m -> m -- | Existential wrapper for Layout data AnyLayoutManager AnyLayoutManager :: !m -> AnyLayoutManager -- | True if the internal layout managers have the same type (but are not -- necessarily equal). layoutManagerSameType :: AnyLayoutManager -> AnyLayoutManager -> Bool -- | Windows placed on top of one another, equally spaced wide :: AnyLayoutManager -- | Windows placed side-by-side, equally spaced. tall :: AnyLayoutManager -- | Tall windows, arranged in a balanced binary tree with sliders in -- between them. slidyTall :: AnyLayoutManager -- | Transposed version of slidyTall slidyWide :: AnyLayoutManager -- | n windows on the left; stack of windows on the right. hPairNStack :: Int -> AnyLayoutManager -- | Transposed version of hPairNStack. vPairNStack :: Int -> AnyLayoutManager -- | A general bounding box data Rectangle Rectangle :: !Double -> !Double -> !Double -> !Double -> Rectangle rectX :: Rectangle -> !Double rectY :: Rectangle -> !Double rectWidth :: Rectangle -> !Double rectHeight :: Rectangle -> !Double layoutToRectangles :: Rectangle -> Layout a -> [(a, Rectangle)] -- | Things with orientations which can be flipped class Transposable r transpose :: Transposable r => r -> r -- | Same as lm, but with all Orientations -- transposed. See slidyWide for an example of its use. newtype Transposed lm Transposed :: lm -> Transposed lm -- | A 'Layout a' wrapped in a state monad for tracking DividerRefs. -- This type is not itself a monad, but should rather be thought -- of as a DividerRef-free version of the Layout type. data LayoutM a pair :: Orientation -> DividerPosition -> LayoutM a -> LayoutM a -> LayoutM a singleWindow :: a -> LayoutM a stack :: Orientation -> [(LayoutM a, RelativeSize)] -> LayoutM a -- | Special case of stack with all RelativeSizes equal. evenStack :: Orientation -> [LayoutM a] -> LayoutM a runLayoutM :: LayoutM a -> Layout a instance Typeable1 Layout instance Typeable AnyLayoutManager instance Typeable Tall instance Typeable Wide instance Typeable SlidyTall instance Typeable HPairNStack instance Typeable1 Transposed instance Typeable VPairNStack instance Typeable SlidyWide instance Eq Orientation instance Show Orientation instance Eq a => Eq (Layout a) instance Functor Layout instance Eq Tall instance Eq Wide instance Eq SlidyTall instance Eq HPairNStack instance Eq Rectangle instance Show Rectangle instance Eq lm => Eq (Transposed lm) instance Eq VPairNStack instance Eq SlidyWide instance LayoutManager lm => LayoutManager (Transposed lm) instance Transposable (Layout a) instance Transposable Orientation instance LayoutManager VPairNStack instance LayoutManager HPairNStack instance LayoutManager SlidyWide instance LayoutManager SlidyTall instance LayoutManager Wide instance LayoutManager Tall instance Initializable AnyLayoutManager instance LayoutManager AnyLayoutManager instance Eq AnyLayoutManager instance Initializable a => Initializable (Layout a) instance Show a => Show (Layout a) module Yi.Config data UIConfig UIConfig :: Int -> Maybe String -> Maybe Int -> Maybe ScrollStyle -> Int -> Bool -> Bool -> Bool -> Bool -> CursorStyle -> Char -> Theme -> UIConfig configVtyEscDelay :: UIConfig -> Int -- | Font name, for the UI that support it. configFontName :: UIConfig -> Maybe String -- | Font size, for the UI that support it. configFontSize :: UIConfig -> Maybe Int -- | Style of scroll configScrollStyle :: UIConfig -> Maybe ScrollStyle -- | Amount to move the buffer when using the scroll wheel configScrollWheelAmount :: UIConfig -> Int -- | Should the scrollbar be shown on the left side? configLeftSideScrollBar :: UIConfig -> Bool -- | Hide scrollbar automatically if text fits on one page. configAutoHideScrollBar :: UIConfig -> Bool -- | Hide the tabbar automatically if only one tab is present configAutoHideTabBar :: UIConfig -> Bool -- | Wrap lines at the edge of the window if too long to display. configLineWrap :: UIConfig -> Bool configCursorStyle :: UIConfig -> CursorStyle -- | The char with which to fill empty window space. Usually '~' for -- vi-like editors, ' ' for everything else. configWindowFill :: UIConfig -> Char -- | UI colours configTheme :: UIConfig -> Theme -- | When should we use a "fat" cursor (i.e. 2 pixels wide, rather than 1)? -- Fat cursors have only been implemented for the Pango frontend. data CursorStyle AlwaysFat :: CursorStyle NeverFat :: CursorStyle FatWhenFocused :: CursorStyle FatWhenFocusedAndInserting :: CursorStyle configStyle :: UIConfig -> UIStyle -- | Configuration record. All Yi hooks can be set here. data Config Config :: UIBoot -> UIConfig -> [Action] -> [Action] -> KeymapSet -> P Event Event -> [AnyMode] -> Bool -> RegionStyle -> Bool -> [([Update] -> BufferM ())] -> [AnyLayoutManager] -> ConfigVariables -> Config -- | UI to use. startFrontEnd :: Config -> UIBoot -- | UI-specific configuration. configUI :: Config -> UIConfig -- | Actions to run when the editor is started. startActions :: Config -> [Action] -- | Actions to run after startup (after startActions) or reload. initialActions :: Config -> [Action] -- | Default keymap to use. defaultKm :: Config -> KeymapSet configInputPreprocess :: Config -> P Event Event -- | List modes by order of preference. modeTable :: Config -> [AnyMode] -- | Produce a .yi.dbg file with a lot of debug information. debugMode :: Config -> Bool -- | Set to Exclusive for an emacs-like behaviour. configRegionStyle :: Config -> RegionStyle -- | Set to True for an emacs-like behaviour, where all deleted text -- is accumulated in a killring. configKillringAccumulate :: Config -> Bool bufferUpdateHandler :: Config -> [([Update] -> BufferM ())] -- | List of layout managers for cycleLayoutManagersNext layoutManagers :: Config -> [AnyLayoutManager] -- | Custom configuration, containing the YiConfigVariables. -- Configure with configVariableA. configVars :: Config -> ConfigVariables configFundamentalMode :: Config -> AnyMode configTopLevelKeymap :: Config -> Keymap type UIBoot = Config -> (Event -> IO ()) -> ([Action] -> IO ()) -> Editor -> IO UI configVarsA :: T Config ConfigVariables layoutManagersA :: T Config [AnyLayoutManager] bufferUpdateHandlerA :: T Config [[Update] -> BufferM ()] configKillringAccumulateA :: T Config Bool configRegionStyleA :: T Config RegionStyle debugModeA :: T Config Bool modeTableA :: T Config [AnyMode] configInputPreprocessA :: T Config (P Event Event) defaultKmA :: T Config KeymapSet initialActionsA :: T Config [Action] startActionsA :: T Config [Action] configUIA :: T Config UIConfig startFrontEndA :: T Config UIBoot configThemeA :: T UIConfig Theme configWindowFillA :: T UIConfig Char configCursorStyleA :: T UIConfig CursorStyle configLineWrapA :: T UIConfig Bool configAutoHideTabBarA :: T UIConfig Bool configAutoHideScrollBarA :: T UIConfig Bool configLeftSideScrollBarA :: T UIConfig Bool configScrollWheelAmountA :: T UIConfig Int configScrollStyleA :: T UIConfig (Maybe ScrollStyle) configFontSizeA :: T UIConfig (Maybe Int) configFontNameA :: T UIConfig (Maybe String) configVtyEscDelayA :: T UIConfig Int -- | exports from Yi.Config.Simple which are useful to "core yi" -- rather than just config files. module Yi.Config.Simple.Types -- | The configuration monad. Run it with configMain. newtype ConfigM a ConfigM :: StateT Config IO a -> ConfigM a runConfigM :: ConfigM a -> StateT Config IO a -- | Fields that can be modified with (%=), get and -- modify. type Field a = Accessor Config a -- | Accessor for any YiConfigVariable, to be used by modules -- defining YiConfigVariables. Such modules should provide a -- custom-named field. For instance, take the following hypothetical -- YiConfigVariable: -- --
-- newtype UserName = UserName { unUserName :: String }
-- deriving(Typeable, Binary, Initializable)
-- instance YiConfigVariable UserName
--
-- $(nameDeriveAccessors ''UserName (n -> Just (n ++ "A")))
--
-- userName :: Field String
-- userName = unUserNameA . customVariable
--
--
-- Here, the hypothetical library would provide the field
-- userName to be used in preference to customVariable.
customVariable :: YiConfigVariable a => Field a
instance Monad ConfigM
instance Functor ConfigM
instance Applicative ConfigM
instance MonadState Config ConfigM
instance MonadIO ConfigM
module Yi.Tab
-- | A tab, containing a collection of windows.
data Tab
type TabRef = Int
-- | Accessor for the windows. If the windows (but not the focus) have
-- changed when setting, then a relayout will be triggered to preserve
-- the internal invariant.
tabWindowsA :: Accessor Tab (PointedList Window)
-- | Accessor for the layout manager. When setting, will trigger a relayout
-- if the layout manager has changed.
tabLayoutManagerA :: Accessor Tab AnyLayoutManager
-- | Gets / sets the position of the divider with the given reference. The
-- caller must ensure that the DividerRef is valid, otherwise an error
-- will (might!) occur.
tabDividerPositionA :: DividerRef -> Accessor Tab DividerPosition
-- | For UI sync; fixes #304
tkey :: Tab -> TabRef
-- | Returns a list of all mini windows associated with the given tab
tabMiniWindows :: Tab -> [Window]
tabFocus :: Tab -> Window
-- | Forces all windows in the tab
forceTab :: Tab -> Tab
-- | A specialised version of fmap.
mapWindows :: (Window -> Window) -> Tab -> Tab
-- | Current layout. Invariant: must be the layout generated by
-- tabLayoutManager, up to changing the divPoss.
tabLayout :: Tab -> (Layout WindowRef)
-- | Folds over the windows in the tab
tabFoldl :: (a -> Window -> a) -> a -> Tab -> a
-- | Make a tab from multiple windows
makeTab :: TabRef -> PointedList Window -> Tab
-- | Make a tab from one window
makeTab1 :: TabRef -> Window -> Tab
instance Typeable Tab
instance Show Tab
instance Eq Tab
instance Binary Tab
-- | The top level editor state, and operations on it.
module Yi.Editor
type Status = ([String], StyleName)
type Statuses = DelayList Status
-- | The Editor state
data Editor
Editor :: ![BufferRef] -> !Map BufferRef FBuffer -> !Int -> !PointedList Tab -> !DynamicValues -> !Statuses -> !Int -> !Killring -> !Maybe SearchExp -> !Direction -> ![Event] -> !Map BufferRef (EditorM ()) -> Editor
-- | Stack of all the buffers. Invariant: never empty Invariant: first
-- buffer is the current one.
bufferStack :: Editor -> ![BufferRef]
buffers :: Editor -> !Map BufferRef FBuffer
-- | Supply for buffer, window and tab ids.
refSupply :: Editor -> !Int
-- | current tab contains the visible windows pointed list.
tabs_ :: Editor -> !PointedList Tab
-- | dynamic components
dynamic :: Editor -> !DynamicValues
statusLines :: Editor -> !Statuses
maxStatusHeight :: Editor -> !Int
killring :: Editor -> !Killring
-- | currently highlighted regex (also most recent regex for use in vim
-- bindings)
currentRegex :: Editor -> !Maybe SearchExp
searchDirection :: Editor -> !Direction
-- | Processed events that didn't yield any action yet.
pendingEvents :: Editor -> ![Event]
-- | Actions to be run when the buffer is closed; should be scrapped.
onCloseActions :: Editor -> !Map BufferRef (EditorM ())
newtype EditorM a
EditorM :: RWS Config () Editor a -> EditorM a
fromEditorM :: EditorM a -> RWS Config () Editor a
class (Monad m, MonadState Editor m) => MonadEditor m where withEditor f = do { cfg <- askCfg; getsAndModify (runEditor cfg f) }
askCfg :: MonadEditor m => m Config
withEditor :: MonadEditor m => EditorM a -> m a
liftEditor :: MonadEditor m => EditorM a -> m a
-- | The initial state
emptyEditor :: Editor
runEditor :: Config -> EditorM a -> Editor -> (Editor, a)
onCloseActionsA :: T Editor (Map BufferRef (EditorM ()))
pendingEventsA :: T Editor [Event]
searchDirectionA :: T Editor Direction
currentRegexA :: T Editor (Maybe SearchExp)
killringA :: T Editor Killring
maxStatusHeightA :: T Editor Int
statusLinesA :: T Editor Statuses
dynamicA :: T Editor DynamicValues
tabs_A :: T Editor (PointedList Tab)
refSupplyA :: T Editor Int
buffersA :: T Editor (Map BufferRef FBuffer)
bufferStackA :: T Editor [BufferRef]
windows :: Editor -> PointedList Window
windowsA :: Accessor Editor (PointedList Window)
tabsA :: Accessor Editor (PointedList Tab)
currentTabA :: Accessor Editor Tab
dynA :: YiVariable a => Accessor Editor a
newRef :: EditorM Int
newBufRef :: EditorM BufferRef
-- | Create and fill a new buffer, using contents of string. | Does not
-- focus the window, or make it the current window. | Call newWindowE or
-- switchToBufferE to take care of that.
stringToNewBuffer :: BufferId -> Rope -> EditorM BufferRef
insertBuffer :: FBuffer -> EditorM ()
forceFold1 :: Foldable t => t a -> t a
forceFoldTabs :: Foldable t => t Tab -> t Tab
-- | Delete a buffer (and release resources associated with it).
deleteBuffer :: BufferRef -> EditorM ()
-- | Return the buffers we have, in no particular order
bufferSet :: Editor -> [FBuffer]
-- | Return a prefix that can be removed from all buffer paths while
-- keeping them unique.
commonNamePrefix :: Editor -> [String]
getBufferStack :: EditorM [FBuffer]
findBuffer :: BufferRef -> EditorM (Maybe FBuffer)
-- | Find buffer with this key
findBufferWith :: BufferRef -> Editor -> FBuffer
-- | Find buffer with this name
findBufferWithName :: String -> Editor -> [BufferRef]
-- | Find buffer with given name. Fail if not found.
getBufferWithName :: String -> EditorM BufferRef
-- | Make all buffers visible by splitting the current window list. FIXME:
-- rename to displayAllBuffersE; make sure buffers are not open twice.
openAllBuffersE :: EditorM ()
-- | Rotate the buffer stack by the given amount.
shiftBuffer :: Int -> EditorM ()
-- | Perform action with any given buffer, using the last window that was
-- used for that buffer.
withGivenBuffer0 :: BufferRef -> BufferM a -> EditorM a
-- | Perform action with any given buffer
withGivenBufferAndWindow0 :: Window -> BufferRef -> BufferM a -> EditorM a
-- | Perform action with current window's buffer
withBuffer0 :: BufferM a -> EditorM a
currentWindowA :: Accessor Editor Window
-- | Return the current buffer
currentBuffer :: Editor -> BufferRef
-- | Display a transient message
printMsg :: String -> EditorM ()
printMsgs :: [String] -> EditorM ()
printStatus :: Status -> EditorM ()
-- | Set the background status line
setStatus :: Status -> EditorM ()
-- | Clear the status line
clrStatus :: EditorM ()
statusLine :: Editor -> [String]
statusLineInfo :: Editor -> Status
setTmpStatus :: Int -> Status -> EditorM ()
-- | Put string into yank register
setRegE :: String -> EditorM ()
-- | Return the contents of the yank register
getRegE :: EditorM String
-- | Dynamically-extensible state components.
--
-- These hooks are used by keymaps to store values that result from
-- Actions (i.e. that restult from IO), as opposed to the pure values
-- they generate themselves, and can be stored internally.
--
-- The dynamic field is a type-indexed map.
--
-- Retrieve a value from the extensible state
getDynamic :: YiVariable a => EditorM a
-- | Insert a value into the extensible state, keyed by its type
setDynamic :: YiVariable a => a -> EditorM ()
-- | Attach the next buffer in the buffer stack to the current window.
nextBufW :: EditorM ()
-- | Attach the previous buffer in the stack list to the current window.
prevBufW :: EditorM ()
-- | Like fnewE, create a new buffer filled with the String s,
-- Switch the current window to this buffer. Doesn't associate any file
-- with the buffer (unlike fnewE) and so is good for popup internal
-- buffers (like scratch)
newBufferE :: BufferId -> Rope -> EditorM BufferRef
-- | Creates an in-memory buffer with a unique name.
--
-- A hint for the buffer naming scheme can be specified in the dynamic
-- variable TempBufferNameHint The new buffer always has a buffer ID that
-- did not exist before newTempBufferE. TODO: this probably a lot more
-- complicated than it should be: why not count from zero every time?
newTempBufferE :: EditorM BufferRef
-- | Specifies the hint for the next temp buffer's name.
data TempBufferNameHint
TempBufferNameHint :: String -> Int -> TempBufferNameHint
tmp_name_base :: TempBufferNameHint -> String
tmp_name_index :: TempBufferNameHint -> Int
alternateBufferE :: Int -> EditorM ()
-- | Create a new zero size window on a given buffer
newZeroSizeWindow :: Bool -> BufferRef -> WindowRef -> Window
-- | Create a new window onto the given buffer.
newWindowE :: Bool -> BufferRef -> EditorM Window
-- | Attach the specified buffer to the current window
switchToBufferE :: BufferRef -> EditorM ()
-- | Attach the specified buffer to some other window than the current one
switchToBufferOtherWindowE :: BufferRef -> EditorM ()
-- | Switch to the buffer specified as parameter. If the buffer name is
-- empty, switch to the next buffer.
switchToBufferWithNameE :: String -> EditorM ()
-- | Close a buffer. Note: close the current buffer if the empty string is
-- given
closeBufferE :: String -> EditorM ()
getBufferWithNameOrCurrent :: String -> EditorM BufferRef
-- | Close current buffer and window, unless it's the last one.
closeBufferAndWindowE :: EditorM ()
-- | Rotate focus to the next window
nextWinE :: EditorM ()
-- | Rotate focus to the previous window
prevWinE :: EditorM ()
-- | Swaps the focused window with the first window. Useful for layouts
-- such as HPairOneStack, for which the first window is the
-- largest.
swapWinWithFirstE :: EditorM ()
-- | Moves the focused window to the first window, and moves all other
-- windows down the stack.
pushWinToFirstE :: EditorM ()
-- | Swap focused window with the next one
moveWinNextE :: EditorM ()
-- | Swap focused window with the previous one
moveWinPrevE :: EditorM ()
-- | A fake accessor that fixes the current buffer after a change of
-- the current window. Enforces invariant that top of buffer stack is the
-- buffer of the current window.
fixCurrentBufferA_ :: Accessor Editor Editor
-- | Counterpart of fixCurrentBufferA_: fix the current window to point to
-- the right buffer.
fixCurrentWindow :: EditorM ()
withWindowE :: Window -> BufferM a -> EditorM a
findWindowWith :: WindowRef -> Editor -> Window
-- | Return the windows that are currently open on the buffer whose key is
-- given
windowsOnBufferE :: BufferRef -> EditorM [Window]
-- | bring the editor focus the window with the given key.
--
-- Fails if no window with the given key is found.
focusWindowE :: WindowRef -> EditorM ()
-- | Split the current window, opening a second window onto current buffer.
-- TODO: unfold newWindowE here?
splitE :: EditorM ()
-- | Cycle to the next layout manager, or the first one if the current one
-- is nonstandard.
layoutManagersNextE :: EditorM ()
-- | Cycle to the previous layout manager, or the first one if the current
-- one is nonstandard.
layoutManagersPreviousE :: EditorM ()
-- | Helper function for layoutManagersNext and
-- layoutManagersPrevious
withLMStack :: (PointedList AnyLayoutManager -> PointedList AnyLayoutManager) -> EditorM ()
-- | Next variant of the current layout manager, as given by
-- nextVariant
layoutManagerNextVariantE :: EditorM ()
-- | Previous variant of the current layout manager, as given by
-- previousVariant
layoutManagerPreviousVariantE :: EditorM ()
-- | Enlarge the current window
enlargeWinE :: EditorM ()
-- | Shrink the current window
shrinkWinE :: EditorM ()
-- | Sets the given divider position on the current tab
setDividerPosE :: DividerRef -> DividerPosition -> EditorM ()
-- | Creates a new tab containing a window that views the current buffer.
newTabE :: EditorM ()
-- | Moves to the next tab in the round robin set of tabs
nextTabE :: EditorM ()
-- | Moves to the previous tab in the round robin set of tabs
previousTabE :: EditorM ()
-- | Moves the focused tab to the given index, or to the end if the index
-- is not specified.
moveTab :: Maybe Int -> EditorM ()
-- | Deletes the current tab. If there is only one tab open then error out.
-- When the last tab is focused, move focus to the left, otherwise move
-- focus to the right.
deleteTabE :: EditorM ()
-- | Close the current window. If there is only one tab open and the tab
-- contains only one window then do nothing.
tryCloseE :: EditorM ()
-- | Make the current window the only window on the screen
closeOtherE :: EditorM ()
-- | Switch focus to some other window. If none is available, create one.
shiftOtherWindow :: MonadEditor m => m ()
-- | Execute the argument in the context of an other window. Create one if
-- necessary. The current window is re-focused after the argument has
-- completed.
withOtherWindow :: MonadEditor m => m a -> m a
acceptedInputs :: EditorM [String]
-- | Defines an action to be executed when the current buffer is closed.
--
-- Used by the minibuffer to assure the focus is restored to the buffer
-- that spawned the minibuffer.
--
-- todo: These actions are not restored on reload.
--
-- todo: These actions should probably be very careful at what they do.
-- TODO: All in all, this is a very ugly way to achieve the purpose. The
-- nice way to proceed is to somehow attach the miniwindow to the window
-- that has spawned it.
onCloseBufferE :: BufferRef -> EditorM () -> EditorM ()
instance YiVariable TempBufferNameHint
instance Initializable TempBufferNameHint
instance Binary TempBufferNameHint
instance Typeable TempBufferNameHint
instance Show TempBufferNameHint
instance Typeable Editor
instance Typeable1 EditorM
instance Monad EditorM
instance MonadState Editor EditorM
instance MonadReader Config EditorM
instance Functor EditorM
instance MonadEditor EditorM
instance Applicative EditorM
instance Binary Editor
module Yi.UI.Common
-- | Record presenting a frontend's interface.
--
-- The functions layout and refresh are both run by the
-- editor's main loop, in response to user actions and so on. Their
-- relation is a little subtle, and is discussed here:
--
-- -- P(xs) === all (isPrefixOf (commonPrefix xs)) xs -- length s > length (commonPrefix xs) --> not (all (isPrefixOf s) xs) --commonPrefix :: Eq a => [[a]] -> [a] -- | Prefix matching function, for use with completeInList prefixMatch :: String -> String -> Maybe String -- | Infix matching function, for use with completeInList infixMatch :: String -> String -> Maybe String containsMatch' :: Bool -> String -> String -> Maybe String containsMatch :: String -> String -> Maybe String containsMatchCaseInsensitive :: String -> String -> Maybe String mkIsPrefixOf :: Bool -> String -> String -> Bool module Yi.TextCompletion wordComplete :: YiM () wordComplete' :: Bool -> YiM () wordCompleteString :: YiM String wordCompleteString' :: Bool -> YiM String -- | Try to complete the current word with occurences found elsewhere in -- the editor. Further calls try other options. mkWordComplete :: YiM String -> (String -> YiM [String]) -> ([String] -> YiM ()) -> (String -> String -> Bool) -> YiM String -- | Switch out of completion mode. resetComplete :: EditorM () completeWordB :: EditorM () instance Typeable Completion instance Binary Completion instance YiVariable Completion instance Initializable Completion module Yi.UI.TabBar -- | A TabDescr describes the properties of a UI tab independent of the -- particular GUI in use. data TabDescr TabDescr :: String -> Bool -> TabDescr tabText :: TabDescr -> String tabInFocus :: TabDescr -> Bool type TabBarDescr = PointedList TabDescr tabBarDescr :: Editor -> TabBarDescr tabAbbrevTitle :: String -> String -- | This module provides assistance in implementing "hooks" in Yi. This -- module provides no major new functionality -- only assistance in using -- YiConfigVariables more easily to implement hooks. -- -- We consider a simple example. Suppose we have a function -- --
-- promptForFile :: Maybe FilePath -> YiM FilePath ---- -- which prompts the user to select a file from their file system, -- starting with the provided directory (if actually provided). Since -- this is a frequent task in Yi, it is important for it to be as -- user-friendly as possible. If opinions vary on the meaning of -- "user-friendly", then we would really like to provide multiple -- implementations of promptForFile, and allow users to select -- which implementation to use in their config files. -- -- A way to achieve this is using hooks, as follows: -- --
-- -- create a new type
-- newtype FilePrompter = FilePrompter { runFilePrompter :: Maybe FilePath -> YiM FilePath }
-- deriving(Typeable)
-- $(nameDeriveAccessors ''FilePrompter (n -> Just (n ++ "A")))
--
-- -- give some implementations
-- filePrompter1, filePrompter2, filePrompter3 :: FilePrompter
-- ...
--
-- -- declare FilePrompter as a YiConfigVariable (so it can go in the Config)
-- instance YiConfigVariable FilePrompter
--
-- -- specify the default FilePrompter
-- instance Initializable FilePrompter where
-- initial = filePrompter1
--
-- -- replace the old promptForFile function with a shim
-- promptForFile :: Maybe FilePath -> YiM FilePath
-- promptForFile = runHook runFilePrompter
--
-- -- provide a custom-named Field for Yi.Config.Simple (not strictly necessary, but user-friendly)
-- filePrompter :: Field FilePrompter
-- filePrompter = customVariable
--
--
-- The user can write
--
-- -- ... -- filePrompter %= filePrompter2 -- ... ---- -- in their config file, and calls to promptForFile will now use -- the different prompter. Library code which called -- promptForFile does not need to be changed, but it gets the -- new filePrompter2 behaviour automatically. -- -- See Yi.Eval for a real example of hooks. module Yi.Hooks -- | Looks up the configured value for the hook, and runs it. The argument -- to runHook will typically be a record accessor. See -- HookType for the valid hook types. runHook :: (HookType ty, YiConfigVariable var) => (var -> ty) -> ty -- | The class of "valid hooks". This class is exported abstractly, but the -- instances can be phrased quite simply: the functions (of arbitrarily -- many arguments, including zero) which run in either the EditorM -- or YiM monads. -- -- A typical example would be something like -- -- Int -> String -> EditorM String. class HookType ty -- | Accessor for any YiConfigVariable, to be used by modules -- defining YiConfigVariables. Such modules should provide a -- custom-named field. For instance, take the following hypothetical -- YiConfigVariable: -- --
-- newtype UserName = UserName { unUserName :: String }
-- deriving(Typeable, Binary, Initializable)
-- instance YiConfigVariable UserName
--
-- $(nameDeriveAccessors ''UserName (n -> Just (n ++ "A")))
--
-- userName :: Field String
-- userName = unUserNameA . customVariable
--
--
-- Here, the hypothetical library would provide the field
-- userName to be used in preference to customVariable.
customVariable :: YiConfigVariable a => Field a
-- | Fields that can be modified with (%=), get and
-- modify.
type Field a = Accessor Config a
instance HookType b => HookType (a -> b)
instance HookType (YiM a)
instance HookType (EditorM a)
module Yi.History
type Histories = Map String History
data History
History :: Int -> [String] -> String -> History
_historyCurrent :: History -> Int
_historyContents :: History -> [String]
_historyPrefix :: History -> String
dynKeyA :: (Initializable v, Ord k) => k -> Accessor (Map k v) v
miniBuffer :: String
historyUp :: EditorM ()
historyDown :: EditorM ()
historyStart :: EditorM ()
-- | Start an input session with History
historyStartGen :: String -> EditorM ()
historyFinish :: EditorM ()
-- | Finish the current input session with history.
historyFinishGen :: String -> EditorM String -> EditorM ()
debugHist :: EditorM ()
historyFind :: [String] -> Int -> Int -> Int -> String -> Int
historyMove :: String -> Int -> EditorM ()
historyMoveGen :: String -> Int -> EditorM String -> EditorM String
historyPrefixSet :: String -> EditorM ()
historyPrefixSet' :: String -> String -> EditorM ()
instance YiVariable (Map String History)
instance Binary History
instance Typeable History
instance Show History
instance Initializable History
instance (Typeable k, Typeable v) => Initializable (Map k v)
-- | Search/Replace functions
module Yi.Search
-- | Put regex into regex register
setRegexE :: SearchExp -> EditorM ()
-- | Clear the regex register
resetRegexE :: EditorM ()
-- | Return contents of regex register
getRegexE :: EditorM (Maybe SearchExp)
-- | Global searching. Search for regex and move point to that position.
-- Nothing means reuse the last regular expression. Just
-- s means use s as the new regular expression. Direction
-- of search can be specified as either Backward or
-- Forward (forwards in the buffer). Arguments to modify the
-- compiled regular expression can be supplied as well.
type SearchMatch = Region
data SearchResult
PatternFound :: SearchResult
PatternNotFound :: SearchResult
SearchWrapped :: SearchResult
data SearchOption
-- | Compile for matching that ignores char case
IgnoreCase :: SearchOption
-- | Compile for newline-insensitive matching
NoNewLine :: SearchOption
-- | Treat the input not as a regex but as a literal string to search for.
QuoteRegex :: SearchOption
doSearch :: Maybe String -> [SearchOption] -> Direction -> EditorM SearchResult
-- | Set up a search.
searchInit :: String -> Direction -> [SearchOption] -> EditorM (SearchExp, Direction)
-- | Do a search, placing cursor at first char of pattern, if found.
-- Keymaps may implement their own regex language. How do we provide for
-- this? Also, what's happening with ^ not matching sol?
continueSearch :: (SearchExp, Direction) -> BufferM SearchResult
-- | Search and Replace all within the current region. Note the region is
-- the final argument since we might perform the same search and replace
-- over multiple regions however we are unlikely to perform several
-- search and replaces over the same region since the first such may
-- change the bounds of the region.
searchReplaceRegionB :: String -> String -> Region -> BufferM Int
-- | Peform a search and replace on the selection
searchReplaceSelectionB :: String -> String -> BufferM Int
-- | Replace a string by another everywhere in the document
replaceString :: String -> String -> BufferM Int
searchAndRepRegion :: String -> String -> Bool -> Region -> EditorM Bool
-- | Search and replace in the region defined by the given unit. The rest
-- is as in searchAndRepRegion.
searchAndRepUnit :: String -> String -> Bool -> TextUnit -> EditorM Bool
isearchInitE :: Direction -> EditorM ()
isearchIsEmpty :: EditorM Bool
isearchAddE :: String -> EditorM ()
isearchPrevE :: EditorM ()
isearchNextE :: EditorM ()
isearchWordE :: EditorM ()
isearchHistory :: Int -> EditorM ()
isearchDelE :: EditorM ()
isearchCancelE :: EditorM ()
isearchFinishE :: EditorM ()
-- | Find the next match and select it. Point is end, mark is beginning.
qrNext :: Window -> BufferRef -> SearchExp -> EditorM ()
-- | Replace all the remaining occurrences.
qrReplaceAll :: Window -> BufferRef -> SearchExp -> String -> EditorM ()
qrReplaceOne :: Window -> BufferRef -> SearchExp -> String -> EditorM ()
-- | Exit from query/replace.
qrFinish :: EditorM ()
instance Typeable Isearch
instance Binary Isearch
instance YiVariable Isearch
instance Initializable Isearch
module Yi.MiniBuffer
-- | Open a minibuffer window with the given prompt and keymap The third
-- argument is an action to perform after the minibuffer is opened such
-- as move to the first occurence of a searched for string. If you don't
-- need this just supply return ()
spawnMinibufferE :: String -> KeymapEndo -> EditorM BufferRef
withMinibufferFree :: String -> (String -> YiM ()) -> YiM ()
-- | withMinibuffer prompt completer act: open a minibuffer with
-- prompt. Once a string s is obtained, run act
-- s. completer can be used to complete functions: it
-- returns a list of possible matches.
withMinibuffer :: String -> (String -> YiM [String]) -> (String -> YiM ()) -> YiM ()
-- | withMinibufferGen proposal getHint prompt completer act: open
-- a minibuffer with prompt, and initial content
-- proposal. Once a string s is obtained, run act
-- s. completer can be used to complete inputs by returning
-- an incrementally better match, and getHint can give an immediate
-- feedback to the user on the current input.
withMinibufferGen :: String -> (String -> YiM [String]) -> String -> (String -> YiM String) -> (String -> YiM ()) -> YiM ()
-- | Open a minibuffer, given a finite number of suggestions.
withMinibufferFin :: String -> [String] -> (String -> YiM ()) -> YiM ()
noHint :: String -> YiM [String]
noPossibilities :: String -> YiM [String]
mkCompleteFn :: (String -> (String -> Maybe String) -> [String] -> EditorM String) -> (String -> String -> Maybe String) -> (String -> YiM [String]) -> String -> YiM String
simpleComplete :: (String -> YiM [String]) -> String -> YiM String
infixComplete :: (String -> YiM [String]) -> String -> YiM String
infixComplete' :: Bool -> (String -> YiM [String]) -> String -> YiM String
anyModeByName :: String -> YiM AnyMode
getAllModeNames :: YiM [String]
-- | Returns all the buffer names.
matchingBufferNames :: String -> YiM [String]
anyModeByNameM :: String -> YiM (Maybe AnyMode)
anyModeName :: AnyMode -> String
-- | Tag a type with a documentation
newtype (:::) t doc
Doc :: t -> ::: t doc
fromDoc :: ::: t doc -> t
data LineNumber
data RegexTag
data FilePatternTag
data ToKill
newtype CommandArguments
CommandArguments :: [String] -> CommandArguments
instance Typeable2 :::
instance Typeable RegexTag
instance Typeable FilePatternTag
instance Typeable CommandArguments
instance Eq t => Eq (t ::: doc)
instance Num t => Num (t ::: doc)
instance IsString t => IsString (t ::: doc)
instance Promptable CommandArguments
instance DocType FilePatternTag
instance DocType RegexTag
instance DocType ToKill
instance DocType LineNumber
instance (DocType doc, Promptable t) => Promptable (t ::: doc)
instance Show x => Show (x ::: t)
instance (YiAction a x, Promptable r) => YiAction (r -> a) x
instance Promptable BufferRef
instance Promptable AnyMode
instance Promptable Point
instance Promptable TextUnit
instance Promptable Direction
instance Promptable Int
instance Promptable Char
instance Promptable String
-- | Various high-level functions to further classify.
module Yi.Misc
-- | Given a possible starting path (which if not given defaults to the
-- current directory) and a fragment of a path we find all files within
-- the given (or current) directory which can complete the given path
-- fragment. We return a pair of both directory plus the filenames on
-- their own that is without their directories. The reason for this is
-- that if we return all of the filenames then we get a hint
-- which is way too long to be particularly useful.
getAppropriateFiles :: Maybe String -> String -> YiM (String, [String])
-- | Given a path, trim the file name bit if it exists. If no path given,
-- return current directory.
getFolder :: Maybe String -> IO String
-- | Given a possible path and a prefix, return matching file names.
matchingFileNames :: Maybe String -> String -> YiM [String]
adjBlock :: Int -> BufferM ()
-- | A simple wrapper to adjust the current indentation using the mode
-- specific indentation function but according to the given indent
-- behaviour.
adjIndent :: IndentBehaviour -> BufferM ()
-- | Generic emacs style prompt file action. Takes a prompt and a
-- continuation act and prompts the user with file hints
promptFile :: String -> (String -> YiM ()) -> YiM ()
-- | For use as the hint when opening a file using the minibuffer. We
-- essentially return all the files in the given directory which have the
-- given prefix.
findFileHint :: String -> String -> YiM [String]
-- | A Simple Dired Implementation for Yi
module Yi.Dired
dired :: YiM ()
diredDir :: FilePath -> YiM ()
diredDirBuffer :: FilePath -> YiM BufferRef
instance YiVariable DiredOpState
instance Binary DiredOpState
instance Typeable DiredOpState
instance Show DiredOpState
instance Eq DiredOpState
instance Initializable DiredOpState
instance Binary DiredFileInfo
instance Binary DiredEntry
instance YiVariable DiredState
instance Initializable DiredState
instance Binary DiredState
instance Typeable DiredFileInfo
instance Typeable DiredEntry
instance Typeable DiredState
instance Show DiredFileInfo
instance Eq DiredFileInfo
instance Show DiredEntry
instance Eq DiredEntry
instance Show DiredState
instance Eq DiredState
module Yi.File
-- | If file exists, read contents of file into a new buffer, otherwise
-- creating a new empty buffer. Replace the current window with a new
-- window onto the new buffer.
--
-- If the file is already open, just switch to the corresponding buffer.
--
-- Need to clean up semantics for when buffers exist, and how to attach
-- windows to buffers.
editFile :: FilePath -> YiM BufferRef
-- | Try to write a file in the manner of vi/vim Need to catch any
-- exception to avoid losing bindings
viWrite :: YiM ()
-- | Try to write to a named file in the manner of vi/vim
viWriteTo :: String -> YiM ()
-- | Try to write to a named file if it doesn't exist. Error out if it
-- does.
viSafeWriteTo :: String -> YiM ()
-- | Write current buffer to disk, if this buffer is associated with a file
fwriteE :: YiM ()
-- | Write a given buffer to disk if it is associated with a file.
fwriteBufferE :: BufferRef -> YiM ()
-- | Write all open buffers
fwriteAllE :: YiM ()
-- | Write current buffer to disk as f. The file is also set to
-- f
fwriteToE :: String -> YiM ()
-- | Make a backup copy of file
backupE :: FilePath -> YiM ()
-- | Revert to the contents of the file on disk
revertE :: YiM ()
-- | Associate buffer with file; canonicalize the given path name.
setFileName :: BufferRef -> FilePath -> YiM ()
module Yi.Eval
-- | Runs the action, as written by the user.
--
-- The behaviour of this function can be customised by modifying the
-- Evaluator variable.
execEditorAction :: String -> YiM ()
-- | Lists the action names in scope, for use by execEditorAction.
--
-- The behaviour of this function can be customised by modifying the
-- Evaluator variable.
getAllNamesInScope :: YiM [String]
-- | Config variable for customising the behaviour of
-- execEditorAction and getAllNamesInScope.
--
-- Set this variable using evaluator. See ghciEvaluator and
-- finiteListEvaluator for two implementation.
data Evaluator
Evaluator :: (String -> YiM ()) -> YiM [String] -> Evaluator
-- | implementation of execEditorAction
execEditorActionImpl :: Evaluator -> String -> YiM ()
-- | implementation of getAllNamesInScope
getAllNamesInScopeImpl :: Evaluator -> YiM [String]
-- | The evaluator to use for execEditorAction and
-- getAllNamesInScope.
evaluator :: Field Evaluator
-- | Evaluator implemented by calling GHCi. This evaluator can run
-- arbitrary expressions in the class YiAction.
--
-- The following two imports are always present:
--
-- -- import Yi -- import qualified Yi.Keymap as Yi.Keymap ---- -- Also, if the file -- --
-- $HOME/.yi/local/Env.hs ---- -- exists, it is imported unqualified. ghciEvaluator :: Evaluator -- | Evaluator based on a fixed list of published actions. Has a few -- differences from ghciEvaluator: -- --
-- modifyMode mode f = modifyModeByName (modeName mode) f --modifyMode :: Mode syntax -> (forall syntax'. Mode syntax' -> Mode syntax') -> ConfigM () -- | modifyModeByName name f modifies the mode with name -- name using the function f. Consider using -- modifyMode instead. modifyModeByName :: String -> (forall syntax. Mode syntax -> Mode syntax) -> ConfigM () -- | The evaluator to use for execEditorAction and -- getAllNamesInScope. evaluator :: Field Evaluator -- | Evaluator implemented by calling GHCi. This evaluator can run -- arbitrary expressions in the class YiAction. -- -- The following two imports are always present: -- --
-- import Yi -- import qualified Yi.Keymap as Yi.Keymap ---- -- Also, if the file -- --
-- $HOME/.yi/local/Env.hs ---- -- exists, it is imported unqualified. ghciEvaluator :: Evaluator -- | Evaluator based on a fixed list of published actions. Has a few -- differences from ghciEvaluator: -- --