-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | The Haskell-Scriptable Editor -- @package yi @version 0.8.2 module Yi.Char.Unicode greek :: [(String, String)] symbols :: [(String, String)] subscripts :: [(String, String)] superscripts :: [(String, String)] checkAmbs :: [(String, String)] -> [(String, String)] disamb :: [(String, String)] -> [(String, String)] module Yi.Keymap.Vim2.MatchResult data MatchResult a NoMatch :: MatchResult a PartialMatch :: MatchResult a WholeMatch :: a -> MatchResult a lookupBestMatch :: String -> [(String, a)] -> MatchResult a matchesString :: String -> String -> MatchResult () instance Functor MatchResult instance Show (MatchResult a) instance Alternative MatchResult instance Applicative MatchResult module Yi.Keymap.Vim2.Digraph charFromDigraph :: [(String, Char)] -> Char -> Char -> Maybe Char defDigraphs :: [(String, Char)] -- | 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.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 :: MonadBase IO m => String -> m () logError :: MonadBase IO m => String -> m () logStream :: Show a => String -> Chan a -> IO () error :: String -> 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 -- | 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 :: 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 :: 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 -> Lens' (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 Typeable Layout instance Typeable AnyLayoutManager instance Typeable Tall instance Typeable Wide instance Typeable SlidyTall instance Typeable HPairNStack instance Typeable 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 Default AnyLayoutManager instance LayoutManager AnyLayoutManager instance Eq AnyLayoutManager instance Default a => Default (Layout a) instance Show a => Show (Layout a) module Yi.Monad class Ref ref readRef :: (Ref ref, MonadBase IO m) => ref a -> m a writeRef :: (Ref ref, MonadBase IO m) => ref a -> a -> m () modifyRef :: (Ref ref, MonadBase IO 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 -- | 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, MonadBase IO m) => (r -> ref a) -> (a -> a) -> m () modifiesThenReadsRef :: (MonadReader r m, MonadBase IO m) => (r -> IORef a) -> (a -> a) -> m a readsRef :: (Ref ref, MonadReader r m, MonadBase IO 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 r m, MonadBase b m) => (r -> a) -> (a -> b c) -> m c writesRef :: (MonadReader r m, MonadBase IO m) => (r -> IORef a) -> a -> m () instance Ref MVar instance Ref IORef 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 :: Int -> String -> String padRight :: Int -> String -> String module Yi.Utils io :: MonadBase IO m => IO a -> m a fst3 :: (a, b, c) -> a snd3 :: (a, b, c) -> b trd3 :: (a, b, c) -> c class SemiNum absolute relative | absolute -> relative (+~) :: SemiNum absolute relative => absolute -> relative -> absolute (-~) :: SemiNum absolute relative => absolute -> relative -> absolute (~-) :: SemiNum absolute relative => absolute -> absolute -> relative singleton :: a -> [a] list :: b -> (a -> [a] -> b) -> [a] -> b -- | As nub, but with O(n*log(n)) behaviour. nubSet :: Ord a => [a] -> [a] -- | As Map.adjust, but the combining function is applied strictly. mapAdjust' :: Ord k => (a -> 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 -- | 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]] chain :: (a -> a -> Bool) -> [a] -> ([a], [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] -- | Finds the first element satisfying the predicate, and returns a zipper -- pointing at it. findPL :: (a -> Bool) -> [a] -> Maybe (PointedList a) -- | 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) -- | Write nothing. Use with dummyGet dummyPut :: a -> Put -- | Read nothing, and return def. Use with dummyPut. dummyGet :: Default a => Get a makeLensesWithSuffix :: [Char] -> Name -> Q [Dec] instance (Eq k, Hashable k, Binary k, Binary v) => Binary (HashMap k v) 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 Default constraint ensures that, -- even if the user hasn't customised this config variable, a value is -- stil available. class (Default a, Typeable a) => YiConfigVariable a -- | An "extensible record" of YiConfigVariables. Can be constructed -- and accessed with def 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, Functor f) => (a -> f a) -> ConfigVariables -> f ConfigVariables -- | 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 (Default 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 def is used. dynamicValueA :: (YiVariable a, Functor f) => (a -> f a) -> DynamicValues -> f DynamicValues instance Typeable Dynamic instance Typeable DynamicValues instance Monoid ConfigVariables instance Monoid DynamicValues instance Default DynamicValues instance Binary DynamicValues instance Binary Dynamic instance Default ConfigVariables -- | 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: -- -- -- -- The processes can parse input, and write output that depends on it. -- -- The semantics are quite obvious; only disjunction deserve a bit more -- explanation: -- -- in p = (a <|> b), what happens if a and -- b recognize the same input (prefix), but produce conflicting -- output? -- -- module Yi.Interact -- | Interactive process description data I ev w a -- | Operational representation of a process data P event w End :: P event w Chain :: (P event mid) -> (P mid w) -> P event w -- | Abstraction of the automaton state. data InteractState event w Ambiguous :: [(Int, w, P event w)] -> InteractState event w Waiting :: InteractState event w Dead :: InteractState event w Running :: w -> (P event w) -> InteractState event w -- | Abstraction of monadic interactive processes class (PEq w, Monad m, Alternative m, Applicative m, MonadPlus m) => MonadInteract m w e | m -> w e write :: MonadInteract m w e => w -> m () eventBounds :: (MonadInteract m w e, Ord e) => Maybe e -> Maybe e -> m e adjustPriority :: MonadInteract m w e => Int -> m () class PEq a equiv :: PEq a => a -> a -> Bool deprioritize :: MonadInteract f w e => f () (<||) :: MonadInteract f w e => f a -> f a -> f a (||>) :: MonadInteract f w e => f a -> f a -> f a -- | option x p will either parse p or return x -- without consuming any input. option :: MonadInteract m w e => a -> m a -> m a oneOf :: (Ord event, MonadInteract m w event) => [event] -> m event processOneEvent :: PEq w => P event w -> event -> ([w], P event w) computeState :: PEq w => P event w -> InteractState event w -- | Parses and returns the specified character. event :: (Ord event, MonadInteract m w event) => event -> m event -- | Parses and returns the specified list of events (lazily). events :: (Ord event, MonadInteract m w event) => [event] -> m [event] -- | Combines all parsers in the specified list. choice :: MonadInteract m w e => [m a] -> m a mkAutomaton :: PEq w => I ev w a -> P ev w idAutomaton :: (Ord a, PEq a) => P a a runWrite :: PEq w => P event w -> [event] -> [w] anyEvent :: (Ord event, MonadInteract m w event) => m event eventBetween :: (Ord e, MonadInteract m w e) => e -> e -> m e accepted :: Show ev => Int -> P ev w -> [[String]] instance (Show w, Show ev) => Show (P ev w) instance Monoid (InteractState event w) instance PEq w => MonadInteract (I event w) w event instance PEq w => MonadPlus (I event w) instance Monad (I event w) instance Alternative (I ev w) instance Applicative (I ev w) instance Functor (I event w) instance MonadInteract m w e => MonadInteract (StateT s m) w e module Yi.Paths -- | Get path to environment file that defines namespace used by Yi command -- evaluator. getEvaluatorContextFilename :: MonadBase IO m => m FilePath -- | Get Yi master configuration script. getConfigFilename :: MonadBase IO m => m FilePath getConfigModules :: MonadBase IO m => m FilePath -- | Get articles.db database of locations to visit (for Yi.IReader.) getArticleDbFilename :: MonadBase IO m => m FilePath -- | Get path to Yi history that stores state between runs. getPersistentStateFilename :: MonadBase IO m => m FilePath getConfigDir :: MonadBase IO m => m FilePath -- | Given a path relative to application configuration directory, this -- function finds a path to a given configuration file. getConfigPath :: MonadBase IO m => FilePath -> m FilePath -- | Given an action that retrieves config path, and a path relative to it, -- this function joins the two together to create a config file path. getCustomConfigPath :: MonadBase IO m => m FilePath -> FilePath -> m FilePath -- | Given a path relative to application data directory, this function -- finds a path to a given data file. getDataPath :: MonadBase IO m => FilePath -> m FilePath -- | 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 Default 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 -- | 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.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.JumpList type JumpList = Maybe (PointedList Jump) data Jump Jump :: Mark -> BufferRef -> Jump jumpMark :: Jump -> Mark jumpBufferRef :: Jump -> BufferRef addJump :: Jump -> JumpList -> JumpList jumpBack :: JumpList -> JumpList jumpForward :: JumpList -> JumpList instance Show Jump instance Binary Jump module Yi.Window -- | A window onto a buffer. data Window Window :: !Bool -> !BufferRef -> ![BufferRef] -> Int -> Region -> !WindowRef -> Int -> JumpList -> 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 jumpList :: Window -> JumpList -- | 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 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 :: Functor f => (PointedList Window -> f (PointedList Window)) -> Tab -> f Tab -- | Accessor for the layout manager. When setting, will trigger a relayout -- if the layout manager has changed. tabLayoutManagerA :: Functor f => (AnyLayoutManager -> f AnyLayoutManager) -> Tab -> f Tab -- | 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 -> Lens' 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 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 -> [SearchOption] -> SearchExp seInput :: SearchExp -> String seCompiled :: SearchExp -> Regex seBackCompiled :: SearchExp -> Regex seOptions :: SearchExp -> [SearchOption] 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 Uniplate Pattern instance Binary SearchExp instance Binary SearchOption instance Eq SearchOption -- | 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 :: Color -> Style -- | A style that sets the background. withBg :: Color -> Style -- | A style that sets the font to bold withBd :: Bool -> Style -- | A style that sets the style to underlined withReverse :: Bool -> Style -- | A style that sets the style to underlined withUnderline :: Bool -> Style -- | A style that sets the style to italics 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 :: Color yellow :: Color brown :: Color green :: Color darkgreen :: Color red :: Color darkred :: Color lightGrey :: Color grey :: Color darkblue :: Color brightwhite :: Color white :: Color cyan :: Color darkcyan :: Color magenta :: Color purple :: Color blue :: Color instance Eq Color instance Ord Color instance Show Color instance Eq Attributes instance Ord Attributes instance Show Attributes -- | 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 Span instance Foldable Span instance Traversable Span instance Functor (Scanner st) -- | 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 -- | Utilities to turn a lexer generated by Alex into a scanner that can be -- used by Yi. module Yi.Lexer.Alex type AlexInput = (Char, IndexedStr) alexGetChar :: AlexInput -> Maybe (Char, AlexInput) alexInputPrevChar :: AlexInput -> Char -- | Lexer state data AlexState lexerState AlexState :: lexerState -> !Point -> !Posn -> AlexState lexerState stLexer :: AlexState lexerState -> lexerState lookedOffset :: AlexState lexerState -> !Point stPosn :: AlexState lexerState -> !Posn -- | unfold lexer function into a function that returns a stream of (state -- x token) unfoldLexer :: ((AlexState lexState, input) -> Maybe (token, (AlexState lexState, input))) -> (AlexState lexState, input) -> [(AlexState lexState, token)] -- | Combine a character scanner with a lexer to produce a token scanner. -- May be used together with mkHighlighter to produce a -- Highlighter, or with linearSyntaxMode to produce a -- Mode. lexScanner :: ((AlexState lexerState, AlexInput) -> Maybe (token, (AlexState lexerState, AlexInput))) -> lexerState -> Scanner Point Char -> Scanner (AlexState lexerState) token alexCollectChar :: AlexInput -> [Char] -- | Return a constant token actionConst :: token -> Action lexState token -- | Return a constant token, and modify the lexer state actionAndModify :: (lexState -> lexState) -> token -> Action lexState token -- | Convert the parsed string into a token, and also modify the lexer -- state actionStringAndModify :: (lexState -> lexState) -> (String -> token) -> Action lexState token -- | Convert the parsed string into a token actionStringConst :: (String -> token) -> Action lexState token data Tok t Tok :: t -> Size -> Posn -> Tok t tokT :: Tok t -> t tokLen :: Tok t -> Size tokPosn :: Tok t -> Posn tokBegin :: Tok t -> Point tokEnd :: Tok t -> Point tokFromT :: t -> Tok t tokRegion :: Tok t -> Region data Posn Posn :: !Point -> !Int -> !Int -> Posn posnOfs :: Posn -> !Point posnLine :: Posn -> !Int posnCol :: Posn -> !Int startPosn :: Posn moveStr :: Posn -> IndexedStr -> Posn type ASI s = (AlexState s, AlexInput) (+~) :: SemiNum absolute relative => absolute -> relative -> absolute (~-) :: SemiNum absolute relative => absolute -> absolute -> relative -- | Size of a buffer region newtype Size Size :: Int -> Size fromSize :: Size -> Int type Stroke = Span StyleName tokToSpan :: Tok t -> Span t alexGetByte :: AlexInput -> Maybe (Word8, AlexInput) instance Eq Posn instance Ix Posn instance Functor Tok instance Show lexerState => Show (AlexState lexerState) instance Show Posn instance Ord Posn instance Show t => Show (Tok t) module Yi.IncrementalParse -- | 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 () type State st token result = (st, Process token result) type P s a = Parser s a -- | 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 -- | Lexer state data AlexState lexerState AlexState :: lexerState -> !Point -> !Posn -> AlexState lexerState stLexer :: AlexState lexerState -> lexerState lookedOffset :: AlexState lexerState -> !Point stPosn :: AlexState lexerState -> !Posn scanner :: Parser token result -> Scanner st token -> Scanner (State st token result) result module Yi.Lexer.Compilation initState :: () -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) data Token Report :: String -> Int -> Int -> String -> Token Text :: String -> Token instance Show Token instance Functor AlexLastAcc -- | Generic syntax tree handling functions module Yi.Syntax.Tree class Foldable tree => IsTree tree where subtrees = fst . uniplate subtrees :: IsTree tree => tree t -> [tree t] uniplate :: IsTree tree => tree t -> ([tree t], [tree t] -> tree t) emptyNode :: IsTree tree => tree t toksAfter :: Foldable t1 => t -> t1 a -> [a] allToks :: Foldable t => t a -> [a] tokAtOrBefore :: Foldable t => Point -> t (Tok t1) -> Maybe (Tok t1) toksInRegion :: Foldable t1 => Region -> t1 (Tok t) -> [Tok t] sepBy :: Alternative f => f a -> f v -> f [a] sepBy1 :: Alternative f => f a -> f v -> f [a] getLastOffset :: Foldable t => t (Tok t1) -> Point getFirstOffset :: Foldable t => t (Tok t1) -> Point -- | Return the 1st token of a subtree. getFirstElement :: Foldable t => t a -> Maybe a -- | Return the last token of a subtree. getLastElement :: Foldable t => t a -> Maybe a -- | Search the given list, and return the last tree before the given -- point; with path to the root. (Root is at the start of the path) getLastPath :: IsTree tree => [tree (Tok t)] -> Point -> Maybe [tree (Tok t)] -- | Return all subtrees in a tree, in preorder. getAllSubTrees :: IsTree tree => tree t -> [tree t] tokenBasedAnnots :: Foldable t1 => (a1 -> Maybe a) -> t1 a1 -> t -> [a] tokenBasedStrokes :: Foldable t3 => (a -> b) -> t3 a -> t -> t2 -> t1 -> [b] subtreeRegion :: Foldable t => t (Tok t1) -> Region -- | Search the tree in pre-order starting at a given node, until finding a -- leaf which is at or after the given point. An effort is also made to -- return a leaf as close as possible to p. TODO: rename to -- fromLeafToLeafAt fromLeafToLeafAfter :: IsTree tree => Point -> Node (tree (Tok a)) -> Node (tree (Tok a)) -- | Given an approximate path to a leaf at the end of the region, return: -- (path to leaf at the end of the region,path from focused node to the -- leaf, small node encompassing the region) fromNodeToFinal :: IsTree tree => Region -> Node (tree (Tok a)) -> Node (tree (Tok a)) instance Show a => Show (Test a) instance Eq a => Eq (Test a) instance Foldable Test instance Show NTTT instance Arbitrary NTTT instance Arbitrary Region instance Eq (Tok a) instance Arbitrary (Test TT) instance IsTree Test module Yi.Syntax.OnlineTree data Tree a Bin :: (Tree a) -> (Tree a) -> Tree a Leaf :: a -> Tree a Tip :: Tree a manyToks :: P (Tok t) (Tree (Tok t)) tokAtOrBefore :: Foldable t => Point -> t (Tok t1) -> Maybe (Tok t1) instance (Show x, Show (f x)) => Show (MaybeOneMore f x) instance Show a => Show (Tree a) instance Functor Tree instance Foldable Tree instance Traversable Tree instance IsTree Tree instance Arbitrary Point -- | This module defines implementations of syntax-awareness drivers. module Yi.Syntax.Driver type Path = [Int] data Cache state tree tt Cache :: Map WindowRef Path -> [state] -> tree (Tok tt) -> !(Map WindowRef (tree (Tok tt))) -> Cache state tree tt path :: Cache state tree tt -> Map WindowRef Path cachedStates :: Cache state tree tt -> [state] root :: Cache state tree tt -> tree (Tok tt) focused :: Cache state tree tt -> !(Map WindowRef (tree (Tok tt))) mkHighlighter :: (IsTree tree, Show state) => (Scanner Point Char -> Scanner state (tree (Tok tt))) -> Highlighter (Cache state tree tt) (tree (Tok tt)) unzipFM :: Ord k => [(k, (u, v))] -> (Map k u, Map k v) zipWithFM :: Ord k => (u -> v -> w) -> v -> Map k u -> Map k v -> [(k, w)] module Yi.Syntax.Layout -- | Transform a scanner into a scanner that also adds opening, closing and -- "next" tokens to indicate layout. layoutHandler :: (Show t, Eq t) => (t -> Bool) -> [(t, t)] -> (Tok t -> Bool) -> (t, t, t) -> (Tok t -> Bool) -> Scanner (AlexState lexState) (Tok t) -> Scanner (State t lexState) (Tok t) type State t lexState = (IState t, AlexState lexState) instance Show t => Show (BlockOpen t) instance Show t => Show (IState t) module Yi.Lexer.Abella initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) tokenToStyle :: Token -> StyleName tokenToText :: Token -> Maybe String type TT = Tok Token isComment :: Token -> Bool data Token Number :: Token VarIdent :: Token ConsIdent :: Token Reserved :: !Reserved -> Token ReservedOp :: !ReservedOp -> Token CommentLine :: Token Skip :: Token Unrecognized :: Token type HlState = Int data Reserved Forall :: Reserved Exists :: Reserved Other :: Reserved data ReservedOp Or :: ReservedOp And :: ReservedOp BackSlash :: ReservedOp RightArrow :: ReservedOp DoubleRightArrow :: ReservedOp Dot :: ReservedOp OtherOp :: ReservedOp instance Eq Reserved instance Show Reserved instance Eq ReservedOp instance Show ReservedOp instance Eq Token instance Show Token instance Functor AlexLastAcc module Yi.Lexer.Cabal initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Functor AlexLastAcc module Yi.Lexer.C initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Functor AlexLastAcc module Yi.Lexer.ObjectiveC initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Functor AlexLastAcc module Yi.Lexer.Cplusplus initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Functor AlexLastAcc module Yi.Lexer.Haskell initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) tokenToStyle :: Token -> StyleName tokenToText :: Token -> Maybe String type TT = Tok Token isErrorTok :: Token -> Bool isSpecial :: String -> Token -> Bool startsLayout :: Token -> Bool isComment :: Token -> Bool data Token Number :: Token CharTok :: Token StringTok :: Token VarIdent :: Token ConsIdent :: Token Reserved :: !ReservedType -> Token ReservedOp :: !OpType -> Token Special :: Char -> Token ConsOperator :: String -> Token Operator :: String -> Token Comment :: !CommentType -> Token THQuote :: Token CppDirective :: Token Unrecognized :: Token type HlState = Int data CommentType Open :: CommentType Close :: CommentType Text :: CommentType Line :: CommentType data ReservedType Hiding :: ReservedType Qualified :: ReservedType As :: ReservedType Import :: ReservedType Data :: ReservedType NewType :: ReservedType Type :: ReservedType Where :: ReservedType Let :: ReservedType In :: ReservedType Do :: ReservedType Of :: ReservedType OtherLayout :: ReservedType Deriving :: ReservedType Module :: ReservedType Forall :: ReservedType Other :: ReservedType Class :: ReservedType Instance :: ReservedType data OpType Pipe :: OpType Equal :: OpType BackSlash :: OpType LeftArrow :: OpType RightArrow :: OpType DoubleRightArrow :: OpType DoubleColon :: OpType DoubleDot :: OpType Arobase :: OpType Tilda :: OpType instance Eq CommentType instance Show CommentType instance Eq ReservedType instance Show ReservedType instance Eq OpType instance Show OpType instance Eq Token instance Show Token instance Functor AlexLastAcc module Yi.Syntax.Haskell type PModule = Exp type PModuleDecl = Exp type PImport = Exp -- | Exp can be expression or declaration data Exp t PModule :: [t] -> Maybe (PModule t) -> Exp t comments :: Exp t -> [t] progMod :: Exp t -> Maybe (PModule t) ProgMod :: PModuleDecl t -> PModule t -> Exp t modDecl :: Exp t -> PModuleDecl t -- | The module declaration part body :: Exp t -> PModule t Body :: Exp t -> Block t -> Block t -> Exp t imports :: Exp t -> Exp t content :: Exp t -> Block t -- | The body of the module extraContent :: Exp t -> Block t PModuleDecl :: PAtom t -> PAtom t -> Exp t -> Exp t -> Exp t moduleKeyword :: Exp t -> PAtom t name :: Exp t -> PAtom t exports :: Exp t -> Exp t whereKeyword :: Exp t -> Exp t PImport :: PAtom t -> Exp t -> PAtom t -> Exp t -> Exp t -> Exp t importKeyword :: Exp t -> PAtom t qual :: Exp t -> Exp t name' :: Exp t -> PAtom t as :: Exp t -> Exp t specification :: Exp t -> Exp t -- | Type signature TS :: t -> [Exp t] -> Exp t -- | Type declaration PType :: PAtom t -> Exp t -> PAtom t -> Exp t -> Exp t typeKeyword :: Exp t -> PAtom t typeCons :: Exp t -> Exp t equal :: Exp t -> PAtom t btype :: Exp t -> Exp t -- | Data declaration PData :: PAtom t -> Exp t -> Exp t -> Exp t -> Exp t dataKeyword :: Exp t -> PAtom t dtypeCons :: Exp t -> Exp t dEqual :: Exp t -> Exp t dataRhs :: Exp t -> Exp t PData' :: PAtom t -> Exp t -> Exp t dEqual :: Exp t -> PAtom t -- | Data declaration RHS dataCons :: Exp t -> Exp t PClass :: PAtom t -> Exp t -> Exp t -> Exp t cKeyword :: Exp t -> PAtom t cHead :: Exp t -> Exp t -- | Class declaration cwhere :: Exp t -> Exp t -- | A parenthesized, bracked or braced Paren :: (PAtom t) -> [Exp t] -> (PAtom t) -> Exp t -- | A block of things separated by layout Block :: [Exp t] -> Exp t -- | An atom is a token followed by many comments PAtom :: t -> [t] -> Exp t Expr :: [Exp t] -> Exp t -- | Where clause PWhere :: (PAtom t) -> (Exp t) -> (Exp t) -> Exp t Bin :: (Exp t) -> (Exp t) -> Exp t PError :: t -> t -> [t] -> Exp t errorTok :: Exp t -> t marker :: Exp t -> t -- | An wrapper for errors commentList :: Exp t -> [t] -- | Righthandside of functions with = RHS :: (PAtom t) -> (Exp t) -> Exp t -- | An optional Opt :: (Maybe (Exp t)) -> Exp t -- | Module identifier Modid :: t -> [t] -> Exp t Context :: (Exp t) -> (Exp t) -> (PAtom t) -> Exp t -- | Righthandside of functions with | the PAtom in PGuard' does not -- contain any comments PGuard :: [PGuard t] -> Exp t PGuard' :: (PAtom t) -> (Exp t) -> (PAtom t) -> Exp t -- | Type constructor data constructor same as with the TC constructor TC :: (Exp t) -> Exp t -- | Data constructor DC :: (Exp t) -> Exp t -- | let expression PLet :: (PAtom t) -> (Exp t) -> (Exp t) -> Exp t PIn :: t -> [Exp t] -> Exp t type Tree = PModule -- | The parser parse :: P TT (Tree TT) indentScanner :: Scanner (AlexState lexState) TT -> Scanner (State Token lexState) TT instance Show t => Show (Exp t) instance Foldable Exp instance IsTree Exp module Yi.Lexer.JavaScript initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) -- | Takes a Token and returns a style to be used for that type of -- token. -- -- TODO: The elem check is potentially unnecessarily slow. We -- could split the Const constructor into two different ones, one for -- builtins and one for others. tokenToStyle :: Token -> UIStyle -> Style type TT = Tok Token -- | The different tokens. data Token Unknown :: Token Res :: !Reserved -> Token Str :: !String -> Token Rex :: !String -> Token Op :: !Operator -> Token Special :: !Char -> Token Number :: !String -> Token ValidName :: !String -> Token Comment :: !CommentType -> Token Const :: !String -> Token -- | The constructors for Reserved have an apostrophe as a suffix -- because Default is already used. Also note that -- Undefined' is not intended as some sort of "backup" reserved -- word for things we don't care about -- it really means the "undefined" -- built-in in JavaScript. data Reserved Break' :: Reserved Case' :: Reserved Catch' :: Reserved Continue' :: Reserved Default' :: Reserved Delete' :: Reserved Do' :: Reserved Else' :: Reserved Finally' :: Reserved For' :: Reserved Function' :: Reserved If' :: Reserved In' :: Reserved InstanceOf' :: Reserved New' :: Reserved Return' :: Reserved Switch' :: Reserved This' :: Reserved Throw' :: Reserved Try' :: Reserved TypeOf' :: Reserved Var' :: Reserved Void' :: Reserved While' :: Reserved With' :: Reserved True' :: Reserved False' :: Reserved Null' :: Reserved Undefined' :: Reserved -- | The constructors for Operator have an apostrophe as a suffix -- because e.g. LT is already used by Prelude. data Operator Add' :: Operator Subtract' :: Operator Multiply' :: Operator Divide' :: Operator Modulo' :: Operator Increment' :: Operator Decrement' :: Operator Assign' :: Operator AddAssign' :: Operator SubtractAssign' :: Operator MultiplyAssign' :: Operator DivideAssign' :: Operator ModuloAssign' :: Operator Equals' :: Operator NotEquals' :: Operator GT' :: Operator GTE' :: Operator LT' :: Operator LTE' :: Operator EqualsType' :: Operator NotEqualsType' :: Operator And' :: Operator Or' :: Operator Not' :: Operator BitAnd' :: Operator BitOr' :: Operator BitXor' :: Operator LeftShift' :: Operator RightShift' :: Operator RightShiftZ' :: Operator BitNot' :: Operator Qualify' :: Operator -- | HlState is 0 when outside of a multi-line comment and -1 when -- inside one. type HlState = Int -- | Prefix operators. NOTE: Add' is also a valid prefix operator, but -- since it's completely useless in the real world, we don't care about -- it here. Doing this makes parsing much, much easier. prefixOperators :: [Operator] -- | Infix operators. infixOperators :: [Operator] -- | Postfix operators. postfixOperators :: [Operator] instance Show CommentType instance Eq CommentType instance Show Reserved instance Eq Reserved instance Show Operator instance Eq Operator instance Show Token instance Eq Token instance Functor AlexLastAcc module Yi.Lexer.Java initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Functor AlexLastAcc module Yi.Lexer.JSON initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) type Token = StyleName instance Functor AlexLastAcc module Yi.Lexer.Latex initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) data Token Comment :: Token Text :: Token Special :: !Char -> Token Command :: !String -> Token Begin :: !String -> Token End :: !String -> Token NewCommand :: Token type HlState = Int tokenToText :: Token -> Maybe [Char] instance Eq Token instance Show Token instance Ord Token instance Functor AlexLastAcc module Yi.Lexer.LiterateHaskell initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) data HlState instance Eq HlState instance Show HlState instance Functor AlexLastAcc module Yi.Lexer.GitCommit initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) type Token = StyleName instance Show HlState instance Eq HlState instance Functor AlexLastAcc module Yi.Lexer.GNUMake initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Show HlState instance Functor AlexLastAcc module Yi.Lexer.OCaml initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) tokenToStyle :: Token -> StyleName data Token Number :: Token CharTok :: Token StringTok :: Token VarIdent :: Token ConsIdent :: Token IndentReserved :: Token Reserved :: Token ReservedOp :: Token Special :: Char -> Token ConsOperator :: Token Operator :: Token Comment :: Token instance Eq Token instance Show Token instance Functor AlexLastAcc module Yi.Lexer.Ott initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Functor AlexLastAcc module Yi.Lexer.Perl initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Show HlState instance Functor AlexLastAcc module Yi.Lexer.Python initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Functor AlexLastAcc module Yi.Lexer.Ruby initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Functor AlexLastAcc module Yi.Lexer.Srmc initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Functor AlexLastAcc module Yi.Lexer.SVNCommit initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Show HlState instance Functor AlexLastAcc module Yi.Lexer.Whitespace initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Functor AlexLastAcc module Yi.Syntax.Strokes.Haskell getStrokes :: Point -> Point -> Point -> Tree TT -> [Stroke] tokenToAnnot :: TT -> Maybe (Span String) -- | Parser for haskell that takes in account only parenthesis and layout module Yi.Syntax.Paren indentScanner :: Scanner (AlexState lexState) TT -> Scanner (State Token lexState) TT isBrace :: TT -> Bool ignoredToken :: TT -> Bool isNoise :: Token -> Bool type Expr t = [Tree t] data Tree t Paren :: t -> (Expr t) -> t -> Tree t Block :: ([Tree t]) -> Tree t Atom :: t -> Tree t Error :: t -> Tree t Expr :: [Tree t] -> Tree t -- | Search the given list, and return the 1st tree after the given point -- on the given line. This is the tree that will be moved if something is -- inserted at the point. Precondition: point is in the given line. getIndentingSubtree :: Tree TT -> Point -> Int -> Maybe (Tree TT) -- | Given a tree, return (first offset, number of lines). getSubtreeSpan :: Tree TT -> (Point, Int) parse :: P TT (Tree TT) parse' :: (TT -> Token) -> (Token -> TT) -> P TT [Tree TT] getStrokes :: Point -> Point -> Point -> Tree TT -> [Stroke] tokenToStroke :: TT -> Stroke modStroke :: StyleName -> Stroke -> Stroke tokenToAnnot :: TT -> Maybe (Span String) -- | Create a special error token. (e.g. fill in where there is no correct -- token to parse) Note that the position of the token has to be correct -- for correct computation of node spans. errTok :: Parser (Tok t) (Tok Token) instance Show t => Show (Tree t) instance Foldable Tree instance Functor Tree instance IsTree Tree module Yi.Syntax.JavaScript -- | Instances of Strokable are datatypes which can be syntax -- highlighted. class Strokable a toStrokes :: Strokable a => a -> Endo [Stroke] -- | Instances of Failable can represent failure. This is a useful -- class for future work, since then we can make stroking much easier. class Failable f stupid :: Failable f => t -> f t hasFailed :: Failable f => f t -> Bool type BList a = [a] type Tree t = BList (Statement t) type Semicolon t = Maybe t data Statement t FunDecl :: t -> t -> (Parameters t) -> (Block t) -> Statement t VarDecl :: t -> (BList (VarDecAss t)) -> (Semicolon t) -> Statement t Return :: t -> (Maybe (Expr t)) -> (Semicolon t) -> Statement t While :: t -> (ParExpr t) -> (Block t) -> Statement t DoWhile :: t -> (Block t) -> t -> (ParExpr t) -> (Semicolon t) -> Statement t For :: t -> t -> (Expr t) -> (ForContent t) -> t -> (Block t) -> Statement t If :: t -> (ParExpr t) -> (Block t) -> (Maybe (Statement t)) -> Statement t Else :: t -> (Block t) -> Statement t With :: t -> (ParExpr t) -> (Block t) -> Statement t Comm :: t -> Statement t Expr :: (Expr t) -> (Semicolon t) -> Statement t data Parameters t Parameters :: t -> (BList t) -> t -> Parameters t ParErr :: t -> Parameters t data ParExpr t ParExpr :: t -> (BList (Expr t)) -> t -> ParExpr t ParExprErr :: t -> ParExpr t data ForContent t ForNormal :: t -> (Expr t) -> t -> (Expr t) -> ForContent t ForIn :: t -> (Expr t) -> ForContent t ForErr :: t -> ForContent t data Block t Block :: t -> (BList (Statement t)) -> t -> Block t BlockOne :: (Statement t) -> Block t BlockErr :: t -> Block t -- | Represents either a variable name or a variable name assigned to an -- expression. AssBeg is a variable name maybe followed -- by an assignment. AssRst is an equals sign and an expression. -- (AssBeg x (Just (AssRst '=' '5'))) means x = -- 5. data VarDecAss t AssBeg :: t -> (Maybe (VarDecAss t)) -> VarDecAss t AssRst :: t -> (Expr t) -> VarDecAss t AssErr :: t -> VarDecAss t data Expr t ExprObj :: t -> (BList (KeyValue t)) -> t -> Expr t ExprPrefix :: t -> (Expr t) -> Expr t ExprNew :: t -> (Expr t) -> Expr t ExprSimple :: t -> (Maybe (Expr t)) -> Expr t ExprParen :: t -> (Expr t) -> t -> (Maybe (Expr t)) -> Expr t ExprAnonFun :: t -> (Parameters t) -> (Block t) -> Expr t ExprTypeOf :: t -> (Expr t) -> Expr t ExprFunCall :: t -> (ParExpr t) -> (Maybe (Expr t)) -> Expr t OpExpr :: t -> (Expr t) -> Expr t ExprCond :: t -> (Expr t) -> t -> (Expr t) -> Expr t ExprArr :: t -> (Maybe (Array t)) -> t -> (Maybe (Expr t)) -> Expr t PostExpr :: t -> Expr t ExprErr :: t -> Expr t data Array t ArrCont :: (Expr t) -> (Maybe (Array t)) -> Array t ArrRest :: t -> (Array t) -> (Maybe (Array t)) -> Array t ArrErr :: t -> Array t data KeyValue t KeyValue :: t -> t -> (Expr t) -> KeyValue t KeyValueErr :: t -> KeyValue t -- | TODO: This code is *screaming* for some generic programming. -- -- TODO: Somehow fix Failable and failStroker to be more "generic". This -- will make these instances much nicer and we won't have to make ad-hoc -- stuff like this. -- | Normal stroker. normal :: TT -> Endo [Stroke] -- | Error stroker. error :: TT -> Endo [Stroke] one :: (t -> a) -> t -> Endo [a] -- | Given a new style and a stroke, return a stroke with the new style -- appended to the old one. modStroke :: StyleName -> Stroke -> Stroke -- | Given a list of tokens to check for errors (xs) and a list of -- tokens to stroke (xs'), returns normal strokes for -- xs' if there were no errors. Otherwise returns error strokes -- for xs'. nError :: [TT] -> [TT] -> Endo [Stroke] -- | Given a list of TT, if any of them is an error, returns an -- error stroker, otherwise a normal stroker. Using e.g. existentials, we -- could make this more general and have support for heterogeneous lists -- of elements which implement Failable, but I haven't had the time to -- fix this. failStroker :: [TT] -> TT -> Endo [Stroke] -- | Given a TT, return a Stroke for it. tokenToStroke :: TT -> Stroke -- | The main stroking function. getStrokes :: Tree TT -> Point -> Point -> Point -> [Stroke] -- | Main parser. parse :: P TT (Tree TT) -- | Parser for statements such as "return", "while", "do-while", "for", -- etc. statement :: P TT (Statement TT) -- | Parser for "blocks", i.e. a bunch of statements wrapped in curly -- brackets or just a single statement. -- -- Note that this works for JavaScript 1.8 "lambda" style function bodies -- as well, e.g. "function hello() 5", since expressions are also -- statements and we don't require a trailing semi-colon. -- -- TODO: function hello() var x; is not a valid program. block :: P TT (Block TT) -- | Parser for expressions which may be statements. In reality, any -- expression is also a valid statement, but this is a slight compromise -- to get rid of the massive performance loss which is introduced when -- allowing JavaScript objects to be valid statements. stmtExpr :: P TT (Expr TT) -- | The basic idea here is to parse "the rest" of expressions, e.g. + -- 3 in x + 3 or [i] in x[i]. Anything -- which is useful in such a scenario goes here. TODO: This accepts [], -- but shouldn't, since x[] is invalid. opExpr :: P TT (Expr TT) -- | Parser for expressions. expression :: P TT (Expr TT) -- | Parses both empty and non-empty arrays. Should probably be split up -- into further parts to allow for the separation of [] and -- [1, 2, 3]. array :: P TT (Expr TT) -- | Parses a semicolon if it's there. semicolon :: P TT (Maybe TT) -- | Parses a comma-separated list of valid identifiers. parameters :: P TT (Parameters TT) parExpr :: P TT (ParExpr TT) -- | Parses a comment. comment :: P TT TT -- | Parses a prefix operator. preOp :: P TT TT -- | Parses a infix operator. inOp :: P TT TT -- | Parses a postfix operator. postOp :: P TT TT -- | Parses any literal. opTok :: P TT TT -- | Parses any literal. simpleTok :: P TT TT -- | Parses any string. strTok :: P TT TT -- | Parses any valid number. numTok :: P TT TT -- | Parses any valid identifier. name :: P TT TT -- | Parses any boolean. boolean :: P TT TT -- | Parses a reserved word. res :: Reserved -> P TT TT -- | Parses a special token. spc :: Char -> P TT TT -- | Parses an operator. oper :: Operator -> P TT TT -- | Expects a token x, recovers with errorToken. plzTok :: P TT TT -> P TT TT -- | Expects a special token. plzSpc :: Char -> P TT TT -- | Expects an expression. plzExpr :: P TT (Expr TT) plz :: Failable f => P TT (f TT) -> P TT (f TT) -- | General recovery parser, inserts an error token. anything :: P s TT -- | Weighted recovery. hate :: Int -> P s a -> P s a fromBlock :: Block t -> [Statement t] firstTok :: Foldable f => f t -> t errorToken :: TT isError :: TT -> Bool -- | Better name for tokFromT. toTT :: t -> Tok t -- | Better name for tokT. fromTT :: Tok t -> t instance Typeable Parameters instance Typeable KeyValue instance Typeable Expr instance Typeable Array instance Typeable Block instance Typeable Statement instance Typeable VarDecAss instance Typeable ForContent instance Typeable ParExpr instance Show t => Show (Parameters t) instance Data t => Data (Parameters t) instance Foldable Parameters instance Show t => Show (KeyValue t) instance Data t => Data (KeyValue t) instance Foldable KeyValue instance Show t => Show (Expr t) instance Data t => Data (Expr t) instance Foldable Expr instance Show t => Show (Array t) instance Data t => Data (Array t) instance Foldable Array instance Show t => Show (Block t) instance Data t => Data (Block t) instance Foldable Block instance Show t => Show (Statement t) instance Data t => Data (Statement t) instance Foldable Statement instance Show t => Show (VarDecAss t) instance Data t => Data (VarDecAss t) instance Foldable VarDecAss instance Show t => Show (ForContent t) instance Data t => Data (ForContent t) instance Foldable ForContent instance Show t => Show (ParExpr t) instance Data t => Data (ParExpr t) instance Foldable ParExpr instance Strokable (Array TT) instance Strokable (Tok Token) instance Strokable (KeyValue TT) instance Strokable (ParExpr TT) instance Strokable (Parameters TT) instance Strokable (Expr TT) instance Strokable (VarDecAss TT) instance Strokable (Block TT) instance Strokable (ForContent TT) instance Strokable (Statement TT) instance Failable KeyValue instance Failable Expr instance Failable ParExpr instance Failable Parameters instance Failable VarDecAss instance Failable Block instance Failable ForContent instance IsTree Statement module Yi.Verifier.JavaScript data Error MultipleFunctionDeclaration :: String -> [Posn] -> Error data Warning UnreachableCode :: Posn -> Warning data Report Err :: Error -> Report Warn :: Warning -> Report -- | The main verifier which calls the sub-verifiers. verify :: Tree TT -> Writer (DList Report) () -- | Given a list of function declarations, checks for multiple function -- declarations, including the functions' subfunctions. checkMultipleFuns :: [Statement TT] -> Writer (DList Report) () checkUnreachable :: [Statement TT] -> Writer (DList Report) () -- | Given two Tok t, compares the ts. ttEq :: Eq t => Tok t -> Tok t -> Bool say :: MonadWriter (DList a) m => a -> m () isReturn :: Statement t -> Bool -- | Returns a list of the functions in the given block. findFunctions :: [Statement t] -> [Statement t] -- | Given a FunDecl, returns the token representing the name. funName :: Statement t -> t -- | Given a FunDecl, returns its inner body as a list. funBody :: Statement t -> [Statement t] -- | Given a ValidName returns the string representing the name. nameOf :: Token -> String -- | Like dropWhile but drops the first element in the result. dropWhile' :: (a -> Bool) -> [a] -> [a] dupsBy :: (a -> a -> Bool) -> [a] -> [a] instance Eq Error instance Eq Warning instance Eq Report instance Show Report instance Show Warning instance Show Error module Yi.Syntax.Latex isNoise :: Token -> Bool type TT = Tok Token type Expr t = [Tree t] data Tree t Paren :: t -> (Tree t) -> t -> Tree t Atom :: t -> Tree t Error :: t -> Tree t Expr :: (Expr t) -> Tree t parse :: P TT (Tree TT) getStrokes :: Point -> Point -> Point -> Tree TT -> [Stroke] modStroke :: StyleName -> Stroke -> Stroke tokenToStroke :: TT -> Stroke tokenToAnnot :: TT -> Maybe (Span String) tokenToStyle :: Token -> StyleName isSpecial :: [Char] -> Token -> Bool isBegin :: Token -> Bool isEnd :: Token -> Bool isErrorTok :: Token -> Bool instance Show t => Show (Tree t) instance Functor Tree instance Foldable Tree instance IsTree Tree -- | The Buffer module defines monadic editing operations over -- one-dimensional buffers, maintaining a current point. module Yi.Buffer.Misc data FBuffer FBuffer :: !(Mode syntax) -> !(BufferImpl syntax) -> !Attributes -> FBuffer -- | The BufferM monad writes the updates performed. newtype BufferM a BufferM :: RWS Window [Update] FBuffer a -> BufferM a fromBufferM :: BufferM a -> RWS Window [Update] FBuffer a type WinMarks = MarkSet Mark data MarkSet a MarkSet :: !a -> !a -> !a -> MarkSet a fromMark :: MarkSet a -> !a insMark :: MarkSet a -> !a selMark :: MarkSet a -> !a bkey :: FBuffer -> BufferRef getMarks :: Window -> BufferM (Maybe WinMarks) -- | Execute a BufferM value on a given buffer and window. The new -- state of the buffer is returned alongside the result of the -- computation. runBuffer :: Window -> FBuffer -> BufferM a -> (a, FBuffer) runBufferFull :: Window -> FBuffer -> BufferM a -> (a, [Update], FBuffer) -- | Execute a BufferM value on a given buffer, using a dummy -- window. The new state of the buffer is discarded. runBufferDummyWindow :: FBuffer -> BufferM a -> a -- | Return the current line number curLn :: BufferM Int -- | Current column. Note that this is different from offset or number of -- chars from sol. (This takes into account tabs, unicode chars, etc.) curCol :: BufferM Int colOf :: Point -> BufferM Int lineOf :: Point -> BufferM Int lineCountB :: BufferM Int -- | Point of eof sizeB :: BufferM Point -- | Extract the current point pointB :: BufferM Point pointOfLineColB :: Int -> Int -> BufferM Point -- | Returns start of line point for a given point p solPointB :: Point -> BufferM Point -- | Return line numbers of marks markLines :: BufferM (MarkSet Int) -- | Move point in buffer to the given index moveTo :: Point -> BufferM () moveToColB :: Int -> BufferM () moveToLineColB :: Int -> Int -> BufferM () -- | Move point down by n lines. n can be negative. -- Returns the actual difference in lines which we moved which may be -- negative if the requested line difference is negative. lineMoveRel :: Int -> BufferM Int -- | Move point up one line lineUp :: BufferM () -- | Move point down one line lineDown :: BufferM () -- | Create buffer named nm with contents s newB :: BufferRef -> BufferId -> Rope -> FBuffer data MarkValue MarkValue :: !Point -> !Direction -> MarkValue markPoint :: MarkValue -> !Point markGravity :: MarkValue -> !Direction data Overlay data OvlLayer UserLayer :: OvlLayer HintLayer :: OvlLayer -- | Create an "overlay" for the style sty between points -- s and e mkOverlay :: OvlLayer -> Region -> StyleName -> Overlay -- | Go to line number n. n is indexed from 1. Returns -- the actual line we went to (which may be not be the requested line, if -- it was out of range) gotoLn :: Int -> BufferM Int -- | Go to line indexed from current point Returns the actual moved -- difference which of course may be negative if the requested difference -- was negative. gotoLnFrom :: Int -> BufferM Int -- | Move point -1 leftB :: BufferM () -- | Move cursor +1 rightB :: BufferM () -- | Move point by the given number of characters. A negative offset moves -- backwards a positive one forward. moveN :: Int -> BufferM () -- | Move cursor -n leftN :: Int -> BufferM () -- | Move cursor +n rightN :: Int -> BufferM () insertN' :: Rope -> BufferM () -- | Insert the list at current point, extending size of buffer insertN :: String -> BufferM () insertNAt' :: Rope -> Point -> BufferM () -- | Insert the list at specified point, extending size of buffer insertNAt :: String -> Point -> BufferM () -- | Insert the char at current point, extending size of buffer insertB :: Char -> BufferM () -- | Delete n characters forward from the current point deleteN :: Int -> BufferM () -- | Return n elems starting at i of the buffer as a list nelemsB :: Int -> Point -> BufferM String nelemsB' :: Int -> Point -> BufferM Rope -- | Write an element into the buffer at the current point. writeB :: Char -> BufferM () -- | Write the list into the buffer at current point. writeN :: String -> BufferM () -- | Insert newline at current point. newlineB :: BufferM () -- | deleteNAt n p deletes n characters forwards from -- position p deleteNAt :: Direction -> Int -> Point -> BufferM () -- | Read the character at the current point readB :: BufferM Char -- | Return the contents of the buffer as a list elemsB :: BufferM String undosA :: Lens' FBuffer URList undoB :: BufferM () redoB :: BufferM () getMarkB :: Maybe String -> BufferM Mark setMarkHereB :: BufferM Mark setNamedMarkHereB :: String -> BufferM () mayGetMarkB :: String -> BufferM (Maybe Mark) getMarkValueB :: Mark -> BufferM MarkValue -- | Set the given mark's point. setMarkPointB :: Mark -> Point -> BufferM () modifyMarkB :: Mark -> (MarkValue -> MarkValue) -> BufferM () newMarkB :: MarkValue -> BufferM Mark deleteMarkB :: Mark -> BufferM () -- | Highlight the selection setVisibleSelection :: Bool -> BufferM () isUnchangedBuffer :: FBuffer -> Bool -- | Set the mode setAnyMode :: AnyMode -> BufferM () setMode :: Mode syntax -> BufferM () setMode0 :: Mode syntax -> FBuffer -> FBuffer -- | Modify the mode modifyMode :: (forall syntax. Mode syntax -> Mode syntax) -> BufferM () -- | Return indices of strings in buffer matched by regex in the given -- region. regexRegionB :: SearchExp -> Region -> BufferM [Region] -- | Return indices of next string in buffer matched by regex in the given -- direction regexB :: Direction -> SearchExp -> BufferM [Region] -- | Read the character at the given index This is an unsafe operation: -- character NUL is returned when out of bounds readAtB :: Point -> BufferM Char -- | Given a buffer, and some information update the modeline -- -- N.B. the contents of modelines should be specified by user, and not -- hardcoded. getModeLine :: [String] -> BufferM String -- | Given a point, and the file size, gives us a percent string getPercent :: Point -> Point -> String setInserting :: Bool -> BufferM () savingPrefCol :: BufferM a -> BufferM a forgetPreferCol :: BufferM () movingToPrefCol :: BufferM a -> BufferM a getPrefCol :: BufferM (Maybe Int) setPrefCol :: Maybe Int -> BufferM () -- | Mark the current point in the undo list as a saved state. markSavedB :: UTCTime -> BufferM () -- | Adds an "overlay" to the buffer addOverlayB :: Overlay -> BufferM () -- | Remove an existing "overlay" delOverlayB :: Overlay -> BufferM () delOverlayLayerB :: OvlLayer -> BufferM () -- | perform a BufferM a, and return to the current point. (by -- using a mark) savingExcursionB :: BufferM a -> BufferM a -- | perform an BufferM a, and return to the current point savingPointB :: BufferM a -> BufferM a pendingUpdatesA :: Lens' FBuffer [UIUpdate] highlightSelectionA :: Lens' FBuffer Bool rectangleSelectionA :: Lens' FBuffer Bool readOnlyA :: Lens' FBuffer Bool insertingA :: Lens' FBuffer Bool pointFollowsWindowA :: Lens' FBuffer (WindowRef -> Bool) -- | Revert all the pending updates; don't touch the point. revertPendingUpdatesB :: BufferM () askWindow :: (Window -> a) -> BufferM a -- | update the syntax information (clear the dirty "flag") clearSyntax :: FBuffer -> FBuffer focusSyntax :: Map WindowRef Region -> FBuffer -> FBuffer -- | A Mode customizes the Yi interface for editing a particular data -- format. It specifies when the mode should be used and controls -- file-specific syntax highlighting and command input, among other -- things. data Mode syntax Mode :: String -> (FilePath -> String -> Bool) -> ExtHL syntax -> (syntax -> BufferM ()) -> (KeymapSet -> KeymapSet) -> (syntax -> IndentBehaviour -> BufferM ()) -> (syntax -> Int -> BufferM ()) -> (syntax -> Action) -> IndentSettings -> YiM () -> (syntax -> Point -> Point -> Point -> [Stroke]) -> (syntax -> Point -> [Span String]) -> (syntax -> BufferM ()) -> BufferM () -> ([String] -> BufferM String) -> Mode syntax -- | so this can be serialized, debugged. modeName :: Mode syntax -> String -- | What type of files does this mode apply to? modeApplies :: Mode syntax -> FilePath -> String -> Bool -- | Syntax highlighter modeHL :: Mode syntax -> ExtHL syntax -- | Prettify current "paragraph" modePrettify :: Mode syntax -> syntax -> BufferM () -- | Buffer-local keymap modification modeKeymap :: Mode syntax -> KeymapSet -> KeymapSet -- | emacs-style auto-indent line modeIndent :: Mode syntax -> syntax -> IndentBehaviour -> BufferM () -- | adjust the indentation after modification modeAdjustBlock :: Mode syntax -> syntax -> Int -> BufferM () -- | Follow a "link" in the file. (eg. go to location of error message) modeFollow :: Mode syntax -> syntax -> Action modeIndentSettings :: Mode syntax -> IndentSettings modeToggleCommentSelection :: Mode syntax -> YiM () -- | Strokes that should be applied when displaying a syntax element modeGetStrokes :: Mode syntax -> syntax -> Point -> Point -> Point -> [Stroke] modeGetAnnotations :: Mode syntax -> syntax -> Point -> [Span String] modePrintTree :: Mode syntax -> syntax -> BufferM () -- | An action that is to be executed when this mode is set modeOnLoad :: Mode syntax -> BufferM () -- | buffer-local modeline formatting method modeModeLine :: Mode syntax -> [String] -> BufferM String modeNameA :: Lens' (Mode syntax_a2aC4) String modeAppliesA :: Lens' (Mode syntax_a2aC4) (FilePath -> String -> Bool) modeHLA :: Lens' (Mode syntax_a2aC4) (ExtHL syntax_a2aC4) modePrettifyA :: Lens' (Mode syntax_a2aC4) (syntax_a2aC4 -> BufferM ()) modeKeymapA :: Lens' (Mode syntax_a2aC4) (KeymapSet -> KeymapSet) modeIndentA :: Lens' (Mode syntax_a2aC4) (syntax_a2aC4 -> IndentBehaviour -> BufferM ()) modeAdjustBlockA :: Lens' (Mode syntax_a2aC4) (syntax_a2aC4 -> Int -> BufferM ()) modeFollowA :: Lens' (Mode syntax_a2aC4) (syntax_a2aC4 -> Action) modeIndentSettingsA :: Lens' (Mode syntax_a2aC4) IndentSettings modeToggleCommentSelectionA :: Lens' (Mode syntax_a2aC4) (YiM ()) modeGetStrokesA :: Lens' (Mode syntax_a2aC4) (syntax_a2aC4 -> Point -> Point -> Point -> [Stroke]) modeGetAnnotationsA :: Lens' (Mode syntax_a2aC4) (syntax_a2aC4 -> Point -> [Span String]) modePrintTreeA :: Lens' (Mode syntax_a2aC4) (syntax_a2aC4 -> BufferM ()) modeOnLoadA :: Lens' (Mode syntax_a2aC4) (BufferM ()) modeModeLineA :: Lens' (Mode syntax_a2aC4) ([String] -> BufferM String) data AnyMode AnyMode :: (Mode syntax) -> AnyMode -- | Used to specify the behaviour of the automatic indent command. data IndentBehaviour -- | Increase the indentation to the next higher indentation hint. If we -- are currently at the highest level of indentation then cycle back to -- the lowest. IncreaseCycle :: IndentBehaviour -- | Decrease the indentation to the next smaller indentation hint. If we -- are currently at the smallest level then cycle back to the largest DecreaseCycle :: IndentBehaviour -- | Increase the indentation to the next higher hint if no such hint -- exists do nothing. IncreaseOnly :: IndentBehaviour -- | Decrease the indentation to the next smaller indentation hint, if no -- such hint exists do nothing. DecreaseOnly :: IndentBehaviour -- | Currently duplicates some of Vim's indent settings. Allowing a buffer -- to - specify settings that are more dynamic, perhaps via closures, -- could be - useful. data IndentSettings IndentSettings :: Bool -> Int -> Int -> IndentSettings -- | Insert spaces instead of tabs as possible expandTabs :: IndentSettings -> Bool -- | Size of a Tab tabSize :: IndentSettings -> Int -- | Indent by so many columns shiftWidth :: IndentSettings -> Int -- | Mode applies function that always returns True. modeAlwaysApplies :: FilePath -> String -> Bool -- | Mode applies function that always returns False. modeNeverApplies :: FilePath -> String -> Bool emptyMode :: Mode syntax withModeB :: (forall syntax. Mode syntax -> BufferM a) -> BufferM a withMode0 :: (forall syntax. Mode syntax -> a) -> FBuffer -> a onMode :: (forall syntax. Mode syntax -> Mode syntax) -> AnyMode -> AnyMode withSyntaxB :: (forall syntax. Mode syntax -> syntax -> a) -> BufferM a withSyntaxB' :: (forall syntax. Mode syntax -> syntax -> BufferM a) -> BufferM a keymapProcessA :: Lens' FBuffer KeymapProcess strokesRangesB :: Maybe SearchExp -> Region -> BufferM [[Stroke]] streamB :: Direction -> Point -> BufferM Rope indexedStreamB :: Direction -> Point -> BufferM [(Point, Char)] getMarkPointB :: Mark -> BufferM Point askMarks :: BufferM WinMarks pointAt :: BufferM a -> BufferM Point data SearchExp -- | Use in readonly! lastActiveWindowA :: Lens' FBuffer Window -- | Access to a value into the extensible state, keyed by its type. This -- allows you to save or retrieve inside a BufferM monad, ie: -- --
--   assign bufferDynamicValueA updatedvalue
--   value <- use bufferDynamicValueA
--   
bufferDynamicValueA :: YiVariable a => Lens' FBuffer a shortIdentString :: [a] -> FBuffer -> String identString :: FBuffer -> String miniIdentString :: FBuffer -> String identA :: Lens' FBuffer BufferId -- | maybe a filename associated with this buffer. Filename is -- canonicalized. type BufferId = Either String FilePath file :: FBuffer -> Maybe FilePath lastSyncTimeA :: Lens' FBuffer UTCTime replaceCharB :: Char -> BufferM () replaceCharWithBelowB :: BufferM () replaceCharWithAboveB :: BufferM () insertCharWithBelowB :: BufferM () insertCharWithAboveB :: BufferM () pointAfterCursorB :: Point -> BufferM Point -- | What would be the point after doing the given action? The argument -- must not modify the buffer. destinationOfMoveB :: BufferM a -> BufferM Point withEveryLineB :: BufferM () -> BufferM () startUpdateTransactionB :: BufferM () commitUpdateTransactionB :: BufferM () instance Typeable IndentSettings instance Typeable 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_1627906588 => Binary (MarkSet a_1627906588) instance Traversable MarkSet instance Foldable MarkSet instance Functor 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 readRegionB' :: Region -> BufferM Rope 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] joinLinesB :: Region -> BufferM () concatLinesB :: Region -> BufferM () module Yi.Buffer.TextUnit -- | 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 GenUnit :: TextUnit -> (Direction -> BufferM Bool) -> TextUnit genEnclosingUnit :: TextUnit -> TextUnit genUnitBoundary :: TextUnit -> Direction -> BufferM Bool -- | 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 regionWithTwoMovesB :: BufferM a -> BufferM b -> 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 checkPeekB :: Int -> [Char -> Bool] -> Direction -> BufferM Bool halfUnit :: Direction -> TextUnit -> TextUnit deleteUnitB :: TextUnit -> Direction -> BufferM () instance Typeable TextUnit instance Eq BoundarySide -- | 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 GenUnit :: TextUnit -> (Direction -> BufferM Bool) -> TextUnit genEnclosingUnit :: TextUnit -> TextUnit genUnitBoundary :: TextUnit -> Direction -> BufferM Bool -- | 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 checkPeekB :: Int -> [Char -> Bool] -> Direction -> BufferM Bool data RegionStyle LineWise :: RegionStyle Inclusive :: RegionStyle Exclusive :: RegionStyle Block :: RegionStyle mkRegionOfStyleB :: Point -> Point -> RegionStyle -> BufferM Region convertRegionToStyleB :: Region -> 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 :: Lens' FBuffer RegionStyle instance YiVariable RegionStyle instance Default RegionStyle instance Binary RegionStyle 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 () gotoCharacterB :: Char -> Direction -> RegionStyle -> Bool -> BufferM () -- | Move to the next occurence of c nextCInc :: Char -> BufferM () nextCInLineInc :: Char -> BufferM () -- | Move to the character before the next occurence of c nextCExc :: Char -> BufferM () nextCInLineExc :: Char -> BufferM () -- | Move to the previous occurence of c prevCInc :: Char -> BufferM () prevCInLineInc :: Char -> BufferM () -- | Move to the character after the previous occurence of c prevCExc :: Char -> BufferM () prevCInLineExc :: 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 () -- | True if current line consists of just a newline (no whitespace) isCurrentLineEmptyB :: BufferM Bool -- | Note: Returns False if line doesn't have any characters besides a -- newline isCurrentLineAllWhiteSpaceB :: BufferM Bool -- | 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 -- | True if point at the last line atLastLine :: BufferM Bool -- | Get the current line and column number getLineAndCol :: BufferM (Int, Int) getLineAndColOfPoint :: Point -> 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 readCurrentWordB :: BufferM String 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 () -- | switch the case of the letter under the cursor switchCaseCharB :: BufferM () switchCaseChar :: Char -> Char -- | 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 -> YiM () -- | 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 shapeOfBlockRegionB :: Region -> BufferM (Point, [Int]) leftEdgesOfRegionB :: RegionStyle -> Region -> BufferM [Point] rightEdgesOfRegionB :: RegionStyle -> Region -> BufferM [Point] splitBlockRegionToContiguousSubRegionsB :: Region -> BufferM [Region] deleteRegionWithStyleB :: Region -> RegionStyle -> BufferM Point readRegionRopeWithStyleB :: Region -> RegionStyle -> BufferM Rope insertRopeWithStyleB :: Rope -> RegionStyle -> BufferM () flipRectangleB :: Point -> Point -> BufferM (Point, Point) movePercentageFileB :: Int -> BufferM () findMatchingPairB :: BufferM () 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 () -- | Indent as much as the previous line indentAsNextB :: BufferM () indentAsNeighborLineB :: Direction -> 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 module Yi.Process runProgCommand :: String -> [String] -> IO (ExitCode, String, String) runShellCommand :: String -> IO (ExitCode, String, String) -- | 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 module Yi.Keymap.Vim2.StyledRegion data StyledRegion StyledRegion :: !RegionStyle -> !Region -> StyledRegion normalizeRegion :: StyledRegion -> BufferM StyledRegion transformCharactersInRegionB :: StyledRegion -> (Char -> Char) -> BufferM () transformCharactersInLineN :: Int -> (Char -> Char) -> BufferM () module Yi.Keymap.Vim2.TextObject data TextObject TextObject :: !RegionStyle -> !TextUnit -> TextObject data CountedTextObject CountedTextObject :: !Int -> !TextObject -> CountedTextObject regionOfTextObjectB :: CountedTextObject -> BufferM StyledRegion changeTextObjectCount :: Int -> CountedTextObject -> CountedTextObject changeTextObjectStyle :: (RegionStyle -> RegionStyle) -> TextObject -> TextObject stringToTextObject :: String -> Maybe TextObject module Yi.Mode.Haskell.Dollarify dollarify :: Tree TT -> BufferM () dollarifyWithin :: Tree TT -> BufferM () data QueuedUpdate QueuedUpdate :: Point -> String -> Int -> QueuedUpdate qUpdatePoint :: QueuedUpdate -> Point qInsert :: QueuedUpdate -> String qDelete :: QueuedUpdate -> Int runQ :: [QueuedUpdate] -> BufferM () openParen :: Token closeParen :: Token isNormalParen :: Tree TT -> Bool isTuple :: Tree TT -> Bool queueDelete :: TT -> QueuedUpdate queueReplaceWith :: String -> TT -> QueuedUpdate stripComments :: Expr TT -> Expr TT dollarifyTop :: Tree TT -> [QueuedUpdate] dollarifyExpr :: Expr TT -> [QueuedUpdate] isSimple :: Tree TT -> Bool isCollapsible :: Expr TT -> Bool selectedTree :: Expr TT -> Region -> Maybe (Tree TT) findLargestWithin :: Region -> [Tree TT] -> Tree TT within :: Region -> Tree TT -> Bool safeLast :: [a] -> Maybe a dollarifyP :: Tree TT -> BufferM () dollarifyWithinP :: Exp TT -> BufferM () isNormalParenP :: Exp TT -> Bool isTupleP :: Exp TT -> Bool stripCommentsP :: [Exp TT] -> [Exp TT] dollarifyTopP :: Exp TT -> [QueuedUpdate] dollarifyExprP :: [Exp TT] -> [QueuedUpdate] isSimpleP :: Exp TT -> Bool isCollapsibleP :: [Exp TT] -> Bool selectedTreeP :: [Exp TT] -> Region -> Maybe (Exp TT) findLargestWithinP :: Region -> [Exp TT] -> Exp TT withinP :: Region -> Exp TT -> Bool safeLastP :: [a] -> Maybe a instance Eq QueuedUpdate instance Ord QueuedUpdate instance Show QueuedUpdate -- | 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.Style.Library type Theme = Proto UIStyle -- | Abstract theme that provides useful defaults. defaultTheme :: Theme -- | A Theme inspired by the darkblue colorscheme of Vim. darkBlueTheme :: Theme 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 -> 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 configCheckExternalChangesObsessively :: 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 startFrontEndA :: Lens' Config UIBoot startActionsA :: Lens' Config [Action] modeTableA :: Lens' Config [AnyMode] layoutManagersA :: Lens' Config [AnyLayoutManager] initialActionsA :: Lens' Config [Action] defaultKmA :: Lens' Config KeymapSet debugModeA :: Lens' Config Bool configVarsA :: Lens' Config ConfigVariables configUIA :: Lens' Config UIConfig configRegionStyleA :: Lens' Config RegionStyle configKillringAccumulateA :: Lens' Config Bool configInputPreprocessA :: Lens' Config (P Event Event) configCheckExternalChangesObsessivelyA :: Lens' Config Bool bufferUpdateHandlerA :: Lens' Config [[Update] -> BufferM ()] configWindowFillA :: Lens' UIConfig Char configVtyEscDelayA :: Lens' UIConfig Int configThemeA :: Lens' UIConfig Theme configScrollWheelAmountA :: Lens' UIConfig Int configScrollStyleA :: Lens' UIConfig (Maybe ScrollStyle) configLineWrapA :: Lens' UIConfig Bool configLeftSideScrollBarA :: Lens' UIConfig Bool configFontSizeA :: Lens' UIConfig (Maybe Int) configFontNameA :: Lens' UIConfig (Maybe String) configCursorStyleA :: Lens' UIConfig CursorStyle configAutoHideTabBarA :: Lens' UIConfig Bool configAutoHideScrollBarA :: Lens' UIConfig Bool -- | 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 :: ReaderT Config (State Editor) a -> EditorM a fromEditorM :: EditorM a -> ReaderT Config (State 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) tabs_A :: Lens' Editor (PointedList Tab) statusLinesA :: Lens' Editor Statuses searchDirectionA :: Lens' Editor Direction refSupplyA :: Lens' Editor Int pendingEventsA :: Lens' Editor [Event] onCloseActionsA :: Lens' Editor (Map BufferRef (EditorM ())) maxStatusHeightA :: Lens' Editor Int killringA :: Lens' Editor Killring dynamicA :: Lens' Editor DynamicValues currentRegexA :: Lens' Editor (Maybe SearchExp) buffersA :: Lens' Editor (Map BufferRef FBuffer) bufferStackA :: Lens' Editor [BufferRef] windows :: Editor -> PointedList Window windowsA :: Lens' Editor (PointedList Window) tabsA :: Lens' Editor (PointedList Tab) currentTabA :: Lens' Editor Tab askConfigVariableA :: (YiConfigVariable b, MonadEditor m) => m b dynA :: YiVariable a => Lens' 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 withEveryBufferE :: BufferM a -> EditorM [a] currentWindowA :: Lens' 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_ :: Lens' 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 () addJumpHereE :: EditorM () addJumpAtE :: Point -> EditorM () jumpBackE :: EditorM () jumpForwardE :: EditorM () modifyJumpListE :: (JumpList -> JumpList) -> EditorM () instance YiVariable TempBufferNameHint instance Default TempBufferNameHint instance Binary TempBufferNameHint instance Typeable TempBufferNameHint instance Show TempBufferNameHint instance Typeable Editor instance Typeable 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: -- -- -- -- The Yi core provides no guarantee about the OS thread from which the -- functions layout and refresh are called from. In -- particular, subprocesses (e.g. compilation, ghci) will run -- layout and refresh from new OS threads (see -- startSubprocessWatchers in Yi.Core). The frontend must -- be preparaed for this: for instance, Gtk-based frontends should wrap -- GUI updates in postGUIAsync. data UI UI :: IO () -> (Bool -> IO ()) -> IO () -> (Editor -> IO ()) -> IO () -> (Editor -> IO Editor) -> (FilePath -> IO ()) -> UI -- | Main loop main :: UI -> IO () -- | Clean up, and also terminate if given true end :: UI -> Bool -> IO () -- | Suspend (or minimize) the program suspend :: UI -> IO () -- | Refresh the UI with the given state refresh :: UI -> Editor -> IO () -- | User force-refresh (in case the screen has been messed up from -- outside) userForceRefresh :: UI -> IO () -- | Set window width and height layout :: UI -> Editor -> IO Editor -- | Reload cabal project views reloadProject :: UI -> FilePath -> IO () dummyUI :: UI module Yi.Completion -- | Complete a string given a user input string, a matching function and a -- list of possibilites. Matching function should return the part of the -- string that matches the user string. completeInList :: String -> (String -> Maybe String) -> [String] -> EditorM String completeInList' :: String -> (String -> Maybe String) -> [String] -> EditorM String -- | Same as completeInList, but maps showFunction on -- possible matches when printing completeInListCustomShow :: (String -> String) -> String -> (String -> Maybe String) -> [String] -> EditorM String -- | 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] -- | Prefix matching function, for use with completeInList prefixMatch :: String -> String -> Maybe String -- | Infix matching function, for use with completeInList infixMatch :: String -> String -> Maybe String -- | Example: "abc" matches "a1b2c" subsequenceMatch :: String -> String -> Bool containsMatch' :: Bool -> String -> String -> Maybe String containsMatch :: String -> String -> Maybe String containsMatchCaseInsensitive :: String -> String -> Maybe String mkIsPrefixOf :: Bool -> String -> String -> Bool 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 :: (Default v, Ord k) => k -> Lens' (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 () 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 Default History -- | emacs-style rectangle manipulation functions. module Yi.Rectangle alignRegion :: String -> BufferM () -- | Align each line of the region on the given regex. Fails if it is not -- found in any line. alignRegionOn :: String -> BufferM () -- | Get the selected region as a rectangle. Returns the region extended to -- lines, plus the start and end columns of the rectangle. getRectangle :: BufferM (Region, Int, Int) -- | Split a list at the boundaries given multiSplit :: [Int] -> [a] -> [[a]] onRectangle :: (Int -> Int -> String -> String) -> BufferM () openRectangle :: BufferM () stringRectangle :: String -> BufferM () killRectangle :: EditorM () yankRectangle :: EditorM () -- | A module for CTags integration module Yi.Tag -- | Find the location of a tag using the tag table. Returns a full path -- and line number lookupTag :: Tag -> TagTable -> Maybe (FilePath, Int) -- | Read in a tag file from the system importTagTable :: FilePath -> IO TagTable -- | Gives all the possible expanded tags that could match a given -- prefix hintTags :: TagTable -> String -> [String] -- | Extends the string to the longest certain length completeTag :: TagTable -> String -> String type Tag = String data TagTable TagTable :: FilePath -> FilePath -> Map Tag (FilePath, Int) -> Trie -> TagTable -- | local name of the tag file TODO: reload if this file is changed tagFileName :: TagTable -> FilePath -- | path to the tag file directory tags are relative to this path tagBaseDir :: TagTable -> FilePath -- | map from tags to files tagFileMap :: TagTable -> Map Tag (FilePath, Int) -- | trie to speed up tag hinting tagTrie :: TagTable -> Trie -- | Get the currently registered tag table getTags :: EditorM (Maybe TagTable) -- | Set a new TagTable setTags :: TagTable -> EditorM () -- | Reset the TagTable resetTags :: EditorM () getTagsFileList :: EditorM [FilePath] setTagsFileList :: String -> EditorM () instance YiVariable TagsFileList instance YiVariable Tags instance Binary TagsFileList instance Binary TagTable instance Binary Tags instance Typeable TagsFileList instance Typeable TagTable instance Typeable Tags instance Default TagsFileList instance Default Tags module Yi.Keymap.Vim.TagStack newtype VimTagStack VimTagStack :: [(FilePath, Point)] -> VimTagStack tagsStack :: VimTagStack -> [(FilePath, Point)] getTagStack :: EditorM VimTagStack setTagStack :: VimTagStack -> EditorM () listTagStack :: EditorM [(FilePath, Point)] pushTagStack :: FilePath -> Point -> EditorM () peekTagStack :: EditorM (Maybe (FilePath, Point)) popTagStack :: Int -> EditorM (Maybe (FilePath, Point)) instance Typeable VimTagStack instance Binary VimTagStack instance YiVariable VimTagStack instance Default VimTagStack 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 module Yi.Keymap data Action YiA :: (YiM a) -> Action EditorA :: (EditorM a) -> Action BufferA :: (BufferM a) -> Action emptyAction :: Action type Interact ev a = I ev Action a type KeymapM a = Interact Event a type Keymap = KeymapM () type KeymapEndo = Keymap -> Keymap type KeymapProcess = P Event Action data KeymapSet KeymapSet :: Keymap -> Keymap -> Keymap -> Keymap -> KeymapSet -- | Content of the top-level loop. topKeymap :: KeymapSet -> Keymap -- | Startup when entering insert mode startInsertKeymap :: KeymapSet -> Keymap -- | For insertion-only modes insertKeymap :: KeymapSet -> Keymap -- | Startup bit, to execute only once at the beginning. startTopKeymap :: KeymapSet -> Keymap topKeymapA :: Lens' KeymapSet Keymap startInsertKeymapA :: Lens' KeymapSet Keymap insertKeymapA :: Lens' KeymapSet Keymap startTopKeymapA :: Lens' KeymapSet Keymap extractTopKeymap :: KeymapSet -> Keymap modelessKeymapSet :: Keymap -> KeymapSet -- | The type of user-bindable functions TODO: doc how these are actually -- user-bindable are they? newtype YiM a YiM :: ReaderT Yi IO a -> YiM a runYiM :: YiM a -> ReaderT Yi IO a withUI :: (UI -> IO a) -> YiM a unsafeWithEditor :: Config -> MVar YiVar -> EditorM a -> IO a withGivenBuffer :: MonadEditor m => BufferRef -> BufferM a -> m a withBuffer :: MonadEditor m => BufferM a -> m a readEditor :: MonadEditor m => (Editor -> a) -> m a catchDynE :: Exception exception => YiM a -> (exception -> YiM a) -> YiM a catchJustE :: Exception e => (e -> Maybe b) -> YiM a -> (b -> YiM a) -> YiM a handleJustE :: Exception e => (e -> Maybe b) -> (b -> YiM a) -> YiM a -> YiM a -- | Shut down all of our threads. Should free buffers etc. shutdown :: YiM () class YiAction a x | a -> x makeAction :: (YiAction a x, Show x) => a -> Action data Yi Yi :: UI -> (Event -> IO ()) -> ([Action] -> IO ()) -> Config -> MVar YiVar -> Yi yiUi :: Yi -> UI -- | input stream input :: Yi -> Event -> IO () -- | output stream output :: Yi -> [Action] -> IO () yiConfig :: Yi -> Config -- | The only mutable state in the program yiVar :: Yi -> MVar YiVar data YiVar YiVar :: !Editor -> ![ThreadId] -> !SubprocessId -> !(Map SubprocessId SubprocessInfo) -> YiVar yiEditor :: YiVar -> !Editor -- | all our threads threads :: YiVar -> ![ThreadId] yiSubprocessIdSupply :: YiVar -> !SubprocessId yiSubprocesses :: YiVar -> !(Map SubprocessId SubprocessInfo) -- | write a returns a keymap that just outputs the action -- a. write :: (MonadInteract m Action ev, YiAction a x, Show x) => a -> m () -- | withModeY f runs f on the current buffer's mode. As -- this runs in the YiM monad, we're able to do more than with just -- withModeB such as prompt the user for something before running -- the action. withModeY :: (forall syntax. Mode syntax -> YiM ()) -> YiM () instance Typeable YiM instance Typeable Yi instance Typeable Action instance Monad YiM instance Applicative YiM instance MonadReader Yi YiM instance MonadBase IO YiM instance Functor YiM instance PEq Event instance YiAction Action () instance YiAction (BufferM x) x instance YiAction (EditorM x) x instance YiAction (YiM x) x instance YiAction (IO x) x instance MonadEditor YiM instance MonadState Editor YiM instance Show Action instance PEq Action -- | This module defines a list type and operations on it; it further -- provides functions which write in and out the list. The goal is to -- make it easy for the user to store a large number of text buffers and -- cycle among them, making edits as she goes. The idea is inspired by -- "incremental reading", see -- http://en.wikipedia.org/wiki/Incremental_reading. module Yi.IReader type Article = ByteString newtype ArticleDB ADB :: Seq Article -> ArticleDB unADB :: ArticleDB -> Seq Article -- | Take an ArticleDB, and return the first Article and an -- ArticleDB - *without* that article. split :: ArticleDB -> (Article, ArticleDB) -- | Get the first article in the list. We use the list to express relative -- priority; the first is the most, the last least. We then just cycle -- through - every article gets equal time. getLatestArticle :: ArticleDB -> Article -- | We remove the old first article, and we stick it on the end of the -- list using the presumably modified version. removeSetLast :: ArticleDB -> Article -> ArticleDB shift :: Int -> ArticleDB -> ArticleDB -- | Insert a new article with top priority (that is, at the front of the -- list). insertArticle :: ArticleDB -> Article -> ArticleDB -- | Serialize given ArticleDB out. writeDB :: ArticleDB -> YiM () -- | Read in database from getArticleDbFilename and then parse it -- into an ArticleDB. readDB :: YiM ArticleDB -- | Returns the database as it exists on the disk, and the current Yi -- buffer contents. Note that the Default typeclass gives us an empty -- Seq. So first we try the buffer state in the hope we can avoid a very -- expensive read from disk, and if we find nothing (that is, if we get -- an empty Seq), only then do we call readDB. oldDbNewArticle :: YiM (ArticleDB, Article) -- | Given an ArticleDB, dump the scheduled article into the buffer -- (replacing previous contents). setDisplayedArticle :: ArticleDB -> YiM () -- | Go to next one. This ignores the buffer, but it doesn't remove -- anything from the database. However, the ordering does change. nextArticle :: YiM () -- | Delete current article (the article as in the database), and go to -- next one. deleteAndNextArticle :: YiM () -- | The main action. We fetch the old database, we fetch the modified -- article from the buffer, then we call the function -- updateSetLast which removes the first article and pushes our -- modified article to the end of the list. saveAndNextArticle :: Int -> YiM () -- | Assume the buffer is an entirely new article just imported this -- second, and save it. We don't want to use updateSetLast since -- that will erase an article. saveAsNewArticle :: YiM () instance Typeable ArticleDB instance Binary ArticleDB instance YiVariable ArticleDB instance Default ArticleDB -- | Combinators for building keymaps. module Yi.Keymap.Keys printableChar :: MonadInteract m w Event => m Char -- | Parse any character that can be inserted in the text. textChar :: KeymapM Char charOf :: MonadInteract m w Event => (Event -> Event) -> Char -> Char -> m Char shift :: Event -> Event meta :: Event -> Event ctrl :: Event -> Event super :: Event -> Event hyper :: Event -> Event -- | Convert a special key into an event spec :: Key -> Event char :: Char -> Event (>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => m b -> a -> m () (>>=!) :: (MonadInteract m Action Event, YiAction a x, Show x) => m b -> (b -> a) -> m () (?>>) :: MonadInteract m action Event => Event -> m a -> m a (?>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => Event -> a -> m () (?*>>) :: MonadInteract m action Event => [Event] -> m a -> m a (?*>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => [Event] -> a -> m () ctrlCh :: Char -> Event metaCh :: Char -> Event hyperCh :: Char -> Event -- | optMod f ev produces a MonadInteract that consumes -- ev or f ev optMod :: MonadInteract m w Event => (Event -> Event) -> Event -> m Event pString :: MonadInteract m w Event => String -> m [Event] -- | The core actions of yi. This module is the link between the editor and -- the UI. Key bindings, and libraries should manipulate Yi through the -- interface defined here. module Yi.Core -- | Start up the editor, setting any state with the user preferences and -- file names passed in, and turning on the UI startEditor :: Config -> Maybe Editor -> IO () -- | Quit. quitEditor :: YiM () -- | Redraw refreshEditor :: YiM () -- | Suspend the program suspendEditor :: YiM () userForceRefresh :: YiM () msgEditor :: String -> YiM () -- | Show an error on the status line and log it. errorEditor :: String -> YiM () -- | Close the current window. If this is the last window open, quit the -- program. CONSIDER: call quitEditor when there are no other window in -- the interactive function. (Not possible since the windowset -- type disallows it -- should it be relaxed?) closeWindow :: YiM () -- | Pipe a string through an external command, returning the stdout chomp -- any trailing newline (is this desirable?) -- -- Todo: varients with marks? runProcessWithInput :: String -> String -> YiM String -- | Start a subprocess with the given command and arguments. startSubprocess :: FilePath -> [String] -> (Either SomeException ExitCode -> YiM x) -> YiM BufferRef sendToProcess :: BufferRef -> String -> YiM () runAction :: Action -> YiM () withSyntax :: (Show x, YiAction a x) => (forall syntax. Mode syntax -> syntax -> a) -> YiM () focusAllSyntax :: Editor -> Editor -- | 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 -- | Create a SearchExp that matches exactly its argument makeSimpleSearch :: String -> SearchExp -- | 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 given region. If the input boolean is True, -- then the replace is done globally, otherwise only the first match is -- replaced. Returns the number of replacements done. searchAndRepRegion0 :: SearchExp -> String -> Bool -> Region -> BufferM Int -- | 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 () -- | Cancel a search. Also see isearchCancelWithE. isearchCancelE :: EditorM () -- | Succesfully finish a search. Also see isearchFinishWithE. isearchFinishE :: EditorM () -- | Wrapper over isearchEndWith that passes through the action and -- marks the search as unsuccessful (i.e. when the user wants to jump -- back to where the search started). isearchCancelWithE :: EditorM a -> EditorM () -- | Wrapper over isearchEndWith that passes through the action and -- accepts the search as successful (i.e. when the user wants to stay at -- the result). isearchFinishWithE :: EditorM a -> 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 Eq SearchResult instance Binary Isearch instance YiVariable Isearch instance Default Isearch module Yi.Keymap.Vim2.Search doVimSearch :: Maybe String -> [SearchOption] -> Direction -> EditorM () continueVimSearch :: (SearchExp, Direction) -> BufferM () -- | Provides functions for calling Hoogle on the commandline, and -- processing results into a form useful for completion or insertion. module Yi.Hoogle -- | Remove anything starting with uppercase letter. These denote either -- module names or types. caseSensitize :: [String] -> [String] -- | Hoogle's output includes a sort of type keyword, telling whether a hit -- is a package name, syntax, a module name, etc. But we care primarily -- about the function names, so we filter out anything containing the -- keywords. gv :: [String] -> [String] -- | Query Hoogle, with given search and options. This errors out on no -- results or if the hoogle command is not on path. hoogleRaw :: String -> String -> IO [String] -- | Filter the output of hoogleRaw to leave just functions. hoogleFunctions :: String -> IO [String] -- | Return module-function pairs. hoogleFunModule :: String -> IO [(String, String)] -- | Call out to hoogleFunModule, and overwrite the word at point -- with the first returned function. hoogle :: YiM String -- | Call out to hoogleRaw, and print inside the Minibuffer the -- results of searching Hoogle with the word at point. hoogleSearch :: YiM () 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 :: CompletionScope -> EditorM () data CompletionScope FromCurrentBuffer :: CompletionScope FromAllBuffers :: CompletionScope instance Typeable Completion instance Binary Completion instance Eq CompletionScope instance Show CompletionScope instance YiVariable Completion instance Default Completion module Yi.Mode.Buffers listBuffers :: YiM () module Yi.Keymap.Emacs.KillRing -- | C-w killRegion :: BufferM () -- | C-k killLineE :: Maybe Int -> YiM () killringPut :: Direction -> String -> EditorM () -- | Kill the rest of line killRestOfLine :: BufferM () -- | C-y yankE :: EditorM () -- | M-w killRingSaveE :: EditorM () -- | M-y yankPopE :: EditorM () -- | C-M-w appendNextKillE :: EditorM () module Yi.Keymap.Readline -- | Readline-like movement bindings intended for minibuffer keymaps standardMovementBindings :: Keymap module Yi.Keymap.Vim2.Common data VimMode Normal :: VimMode NormalOperatorPending :: OperatorName -> VimMode -- | char denotes how state got into insert mode (i, a, -- etc.) Insert :: Char -> VimMode Replace :: VimMode ReplaceSingleChar :: VimMode -- | after C-o InsertNormal :: VimMode -- | after C-o and one of v, V, C-v InsertVisual :: VimMode Visual :: RegionStyle -> VimMode Ex :: VimMode Search :: VimMode -> Direction -> VimMode previousMode :: VimMode -> VimMode direction :: VimMode -> Direction data VimBinding VimBindingY :: (EventString -> VimState -> MatchResult (YiM RepeatToken)) -> VimBinding VimBindingE :: (EventString -> VimState -> MatchResult (EditorM RepeatToken)) -> VimBinding data GotoCharCommand GotoCharCommand :: !Char -> !Direction -> !RegionStyle -> GotoCharCommand data VimState VimState :: !VimMode -> !(Maybe Int) -> !EventString -> !EventString -> !(HashMap RegisterName Register) -> !RegisterName -> !(Maybe RepeatableAction) -> !EventString -> !Bool -> !EventString -> !(Maybe GotoCharCommand) -> !EventString -> ![Point] -> !Bool -> VimState vsMode :: VimState -> !VimMode vsCount :: VimState -> !(Maybe Int) -- | for repeat and potentially macros vsAccumulator :: VimState -> !EventString vsTextObjectAccumulator :: VimState -> !EventString vsRegisterMap :: VimState -> !(HashMap RegisterName Register) vsActiveRegister :: VimState -> !RegisterName vsRepeatableAction :: VimState -> !(Maybe RepeatableAction) -- | see Yi.Keymap.Vim2.vimEval comment vsStringToEval :: VimState -> !EventString -- | is set on $, allows j and k walk the right edge of lines vsStickyEol :: VimState -> !Bool vsOngoingInsertEvents :: VimState -> !EventString vsLastGotoCharCommand :: VimState -> !(Maybe GotoCharCommand) vsBindingAccumulator :: VimState -> !EventString vsSecondaryCursors :: VimState -> ![Point] -- | like vim's :help paste vsPaste :: VimState -> !Bool data Register Register :: RegionStyle -> Rope -> Register regRegionStyle :: Register -> RegionStyle regContent :: Register -> Rope data RepeatToken Finish :: RepeatToken Drop :: RepeatToken Continue :: RepeatToken data RepeatableAction RepeatableAction :: !Int -> !EventString -> RepeatableAction raPreviousCount :: RepeatableAction -> !Int raActionString :: RepeatableAction -> !EventString data MatchResult a NoMatch :: MatchResult a PartialMatch :: MatchResult a WholeMatch :: a -> MatchResult a type EventString = String type OperatorName = String type RegisterName = Char instance Show RepeatToken instance YiVariable VimState instance Binary VimState instance Default VimState instance Binary VimMode instance Default VimMode instance Binary GotoCharCommand instance Binary Register instance Binary RepeatableAction instance Typeable RepeatableAction instance Typeable VimMode instance Typeable VimState instance Eq RepeatableAction instance Show RepeatableAction instance Eq VimMode instance Show VimMode module Yi.Keymap.Vim2.EventUtils stringToEvent :: String -> Event eventToString :: Event -> String parseEvents :: String -> [Event] stringToRepeatableAction :: String -> RepeatableAction normalizeCount :: String -> String splitCountedCommand :: String -> (Int, String) module Yi.Keymap.Vim2.StateUtils switchMode :: VimMode -> VimState -> VimState switchModeE :: VimMode -> EditorM () resetCount :: VimState -> VimState resetCountE :: EditorM () setCountE :: Int -> EditorM () modifyStateE :: (VimState -> VimState) -> EditorM () getMaybeCountE :: EditorM (Maybe Int) getCountE :: EditorM Int accumulateEventE :: Event -> EditorM () accumulateBindingEventE :: Event -> EditorM () accumulateTextObjectEventE :: EventString -> EditorM () flushAccumulatorIntoRepeatableActionE :: EditorM () dropAccumulatorE :: EditorM () dropBindingAccumulatorE :: EditorM () dropTextObjectAccumulatorE :: EditorM () setRegisterE :: RegisterName -> RegionStyle -> Rope -> EditorM () getRegisterE :: RegisterName -> EditorM (Maybe Register) normalizeCountE :: Maybe Int -> EditorM () setStickyEolE :: Bool -> EditorM () maybeMult :: Num a => Maybe a -> Maybe a -> Maybe a updateModeIndicatorE :: VimMode -> EditorM () saveInsertEventStringE :: EventString -> EditorM () module Yi.Keymap.Vim2.Eval scheduleActionStringForEval :: String -> EditorM () module Yi.Keymap.Vim2.Motion data Move Move :: !RegionStyle -> !Bool -> (Maybe Int -> BufferM ()) -> Move moveStyle :: Move -> !RegionStyle moveIsJump :: Move -> !Bool moveAction :: Move -> Maybe Int -> BufferM () data CountedMove CountedMove :: !(Maybe Int) -> !Move -> CountedMove stringToMove :: String -> MatchResult Move regionOfMoveB :: CountedMove -> BufferM StyledRegion changeMoveStyle :: (RegionStyle -> RegionStyle) -> Move -> Move instance Functor ((,,) a b) module Yi.Keymap.Vim2.Utils mkBindingE :: VimMode -> RepeatToken -> (Event, EditorM (), VimState -> VimState) -> VimBinding mkBindingY :: VimMode -> (Event, YiM (), VimState -> VimState) -> VimBinding mkStringBindingE :: VimMode -> RepeatToken -> (String, EditorM (), VimState -> VimState) -> VimBinding mkStringBindingY :: VimMode -> (String, YiM (), VimState -> VimState) -> VimBinding splitCountedCommand :: String -> (Int, String) selectBinding :: String -> VimState -> [VimBinding] -> MatchResult (YiM RepeatToken) -- | All impure bindings will be ignored. selectPureBinding :: EventString -> VimState -> [VimBinding] -> MatchResult (EditorM RepeatToken) matchFromBool :: Bool -> MatchResult () mkMotionBinding :: RepeatToken -> (VimMode -> Bool) -> VimBinding mkChooseRegisterBinding :: (VimState -> Bool) -> VimBinding pasteInclusiveB :: Rope -> RegionStyle -> BufferM () addNewLineIfNecessary :: Rope -> Rope indentBlockRegionB :: Int -> Region -> BufferM () addVimJumpHereE :: EditorM () module Yi.Keymap.Vim2.InsertMap defInsertMap :: [(String, Char)] -> [VimBinding] module Yi.Keymap.Vim2.ReplaceMap defReplaceMap :: [VimBinding] module Yi.Keymap.Vim2.ReplaceSingleCharMap defReplaceSingleMap :: [VimBinding] module Yi.Keymap.Vim2.SearchMotionMap defSearchMotionMap :: [VimBinding] module Yi.Keymap.Vim2.Ex.Types data ExCommand ExCommand :: YiM [String] -> Bool -> Action -> Bool -> String -> ExCommand cmdComplete :: ExCommand -> YiM [String] cmdIsPure :: ExCommand -> Bool cmdAction :: ExCommand -> Action cmdAcceptsRange :: ExCommand -> Bool cmdShow :: ExCommand -> String data LineRange -- | 'a,'b MarkRange :: String -> String -> LineRange -- | % FullRange :: LineRange CurrentLineRange :: LineRange stringToExCommand :: [String -> Maybe ExCommand] -> String -> Maybe ExCommand instance Show ExCommand module Yi.Keymap.Vim2.Ex.Eval exEvalE :: [String -> Maybe ExCommand] -> String -> EditorM () exEvalY :: [String -> Maybe ExCommand] -> String -> YiM () 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 onTyping -- 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. -- -- on Typing is an extra action which will fire with every user -- key-press and receives minibuffer contents. Use something like -- const $ return () if you don't need this. withMinibufferGen :: String -> (String -> YiM [String]) -> String -> (String -> YiM String) -> (String -> YiM ()) -> (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 Typeable (:::) 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 () matchFile :: String -> String -> Maybe String completeFile :: String -> String -> YiM String -- | 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] onCharLetterCode :: (Int -> Int) -> Char -> Char rot13Char :: Char -> Char printFileInfoE :: EditorM () -- | 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 Default DiredOpState instance Binary DiredFileInfo instance Binary DiredEntry instance YiVariable DiredState instance Default 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.Keymap.Vim2.Operator data VimOperator VimOperator :: !OperatorName -> (Int -> StyledRegion -> EditorM RepeatToken) -> VimOperator operatorName :: VimOperator -> !OperatorName operatorApplyToRegionE :: VimOperator -> Int -> StyledRegion -> EditorM RepeatToken defOperators :: [VimOperator] opDelete :: VimOperator opChange :: VimOperator opYank :: VimOperator opFormat :: VimOperator stringToOperator :: [VimOperator] -> OperatorName -> Maybe VimOperator mkCharTransformOperator :: OperatorName -> (Char -> Char) -> VimOperator operatorApplyToTextObjectE :: VimOperator -> Int -> CountedTextObject -> EditorM RepeatToken lastCharForOperator :: VimOperator -> String module Yi.Keymap.Vim2.NormalOperatorPendingMap defNormalOperatorPendingMap :: [VimOperator] -> [VimBinding] module Yi.Keymap.Vim2.Ex.Commands.Common parse :: GenParser Char () ExCommand -> String -> Maybe ExCommand parseWithBang :: GenParser Char () a -> (a -> Bool -> GenParser Char () ExCommand) -> String -> Maybe ExCommand parseRange :: GenParser Char () LineRange data OptionAction Set :: !Bool -> OptionAction Invert :: OptionAction Ask :: OptionAction parseOption :: String -> (OptionAction -> Action) -> String -> Maybe ExCommand filenameComplete :: FilePath -> YiM [FilePath] forAllBuffers :: MonadEditor m => (BufferRef -> m ()) -> m () pureExCommand :: ExCommand impureExCommand :: ExCommand -- | Show the common error message about an unsaved file on the status -- line. errorNoWrite :: EditorM () module Yi.Keymap.Vim2.Ex.Commands.Buffer parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.Buffers parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.BufferDelete parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.Delete parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.Edit parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.GotoLine parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.Nohl parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.Paste parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.Quit parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.Reload parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.Substitute parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.Global parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex.Commands.Write parse :: String -> Maybe ExCommand module Yi.Modes type TokenBasedMode tok = Mode (Tree (Tok tok)) fundamentalMode :: Mode syntax cMode :: StyleBasedMode objectiveCMode :: StyleBasedMode cppMode :: StyleBasedMode cabalMode :: StyleBasedMode srmcMode :: StyleBasedMode ocamlMode :: TokenBasedMode Token ottMode :: StyleBasedMode gnuMakeMode :: StyleBasedMode perlMode :: StyleBasedMode pythonMode :: StyleBasedMode javaMode :: StyleBasedMode jsonMode :: StyleBasedMode -- | When applied to an extensions list, creates a modeApplies -- function. anyExtension :: [String] -> FilePath -> String -> Bool -- | When applied to an extensions list and regular expression pattern, -- creates a modeApplies function. extensionOrContentsMatch :: [String] -> String -> FilePath -> String -> Bool linearSyntaxMode :: Show lexerState => lexerState -> ((AlexState lexerState, AlexInput) -> Maybe (Tok t, (AlexState lexerState, AlexInput))) -> (t -> StyleName) -> Mode (Tree (Tok t)) svnCommitMode :: StyleBasedMode -- | Adds a hook to all matching hooks in a list hookModes :: (AnyMode -> Bool) -> BufferM () -> [AnyMode] -> [AnyMode] -- | Apply a list of mode hooks to a list of AnyModes applyModeHooks :: [(AnyMode -> Bool, BufferM ())] -> [AnyMode] -> [AnyMode] -- | Check whether a mode of the same name is already in modeTable and -- returns the original mode, if it isn't the case. lookupMode :: AnyMode -> YiM AnyMode whitespaceMode :: TokenBasedMode StyleName removeAnnots :: Mode a -> Mode a gitCommitMode :: Mode (Tree (Tok Token)) rubyMode :: StyleBasedMode -- | A simple text mode; it does very little besides define a comment -- syntax. We have it as a separate mode so users can bind the commands -- to this mode specifically. module Yi.Mode.IReader abstract :: Mode syntax ireaderMode :: Mode syntax ireadMode :: YiM () module Yi.Mode.Compilation mode :: Mode (Tree (Tok Token)) module Yi.Mode.Interactive mode :: Mode (Tree (Tok Token)) interactId :: String interactHistoryMove :: Int -> EditorM () interactHistoryFinish :: EditorM () interactHistoryStart :: EditorM () getInputRegion :: BufferM Region getInput :: BufferM String setInput :: String -> BufferM () -- | Open a new buffer for interaction with a process. spawnProcess :: String -> [String] -> YiM BufferRef -- | open a new buffer for interaction with a process, using any -- interactive-derived mode spawnProcessMode :: Mode syntax -> FilePath -> [String] -> YiM BufferRef -- | Send the type command to the process feedCommand :: YiM () -- | Send command, recieve reply queryReply :: BufferRef -> String -> YiM String -- | Various high-level functions to further classify. module Yi.Command -- | Changing the buffer name quite useful if you have several the same. -- This also breaks the relation with the file. changeBufferNameE :: YiM () -- | shell-command with argument prompt shellCommandE :: YiM () -- | shell-command with a known argument shellCommandV :: String -> YiM () newtype CabalBuffer CabalBuffer :: Maybe BufferRef -> CabalBuffer cabalBuffer :: CabalBuffer -> Maybe BufferRef -- | cabal-configure cabalConfigureE :: CommandArguments -> YiM () configureExit :: Either SomeException ExitCode -> YiM () reloadProjectE :: String -> YiM () -- | Run the given commands with args and pipe the ouput into the build -- buffer, which is shown in an other window. buildRun :: String -> [String] -> (Either SomeException ExitCode -> YiM x) -> YiM () makeBuild :: CommandArguments -> YiM () cabalRun :: String -> (Either SomeException ExitCode -> YiM x) -> CommandArguments -> YiM () -- | cabal-build cabalBuildE :: CommandArguments -> YiM () shell :: YiM BufferRef -- | Search the source files in the project. searchSources :: String ::: RegexTag -> YiM () -- | Perform a find+grep operation grepFind :: String ::: FilePatternTag -> String ::: RegexTag -> YiM () instance Typeable CabalBuffer instance Default CabalBuffer instance Binary CabalBuffer instance YiVariable CabalBuffer -- | a mode for GHCi, implemented as tweaks on Interaction mode module Yi.Mode.GHCi mode :: Mode (Tree (Tok Token)) -- | The GHCi prompt always begins with ">"; this goes to just before -- it, or if one is already at the start of the prompt, goes to the -- beginning of the line. (If at the beginning of the line, this pushes -- you forward to it.) homeKey :: BufferM () spawnProcess :: FilePath -> [String] -> YiM BufferRef -- | Haskell-specific modes and commands. module Yi.Mode.Haskell haskellAbstract :: Mode (tree TT) -- | Clever haskell mode, using the paren-matching syntax. cleverMode :: Mode (Tree (Tok Token)) -- | Experimental Haskell mode, using a rather precise parser for the -- syntax. preciseMode :: Mode (Tree TT) literateMode :: Mode (Tree TT) fastMode :: Mode (Tree TT) -- | Return GHCi's buffer; create it if necessary. Show it in another -- window. ghciGet :: YiM BufferRef -- | Send a command to GHCi ghciSend :: String -> YiM () -- | Load current buffer in GHCi ghciLoadBuffer :: YiM () ghciInferType :: YiM () instance Typeable GhciBuffer instance Default GhciBuffer instance Binary GhciBuffer instance YiVariable GhciBuffer module Yi.Mode.JavaScript javaScriptMode :: Mode (Tree TT) -- | Hooks for the JavaScript mode. hooks :: Mode (Tree TT) -> Mode (Tree TT) instance Typeable JSBuffer instance Default JSBuffer instance Binary JSBuffer instance YiVariable JSBuffer module Yi.Mode.Latex -- | syntax-based latex mode latexMode3 :: Mode (Tree TT) -- | syntax-based latex mode latexMode2 :: Mode (Tree TT) fastMode :: Mode (Tree TT) module Yi.Keymap.Vim2.NormalMap defNormalMap :: [VimOperator] -> [VimBinding] module Yi.Keymap.Vim2.VisualMap defVisualMap :: [VimOperator] -> [VimBinding] module Yi.Keymap.Vim2.Ex.Commands.Cabal parse :: String -> Maybe ExCommand -- | This module defines a user interface implemented using vty. module Yi.UI.Vty -- | Initialise the ui start :: UIBoot module Yi.UI.Batch -- | Initialise the ui start :: UIBoot -- | 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 all lens machinery. type Field a = Lens' 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, Default) 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 MonadBase IO ConfigM -- | This module implements persistence across different Yi runs. It -- includes minibuffer command history, marks, VimTagStack etc. Warning: -- Current version will _not_ check whether two or more instances of Yi -- are run at the same time. module Yi.PersistentState -- | Loads a persistent state, and sets Yi state variables accordingly. loadPersistentState :: YiM () -- | Here is a persistent history saving part. We assume each command is a -- single line. To add new components, one has to: -- -- savePersistentState :: YiM () maxHistoryEntries :: Field Int instance Typeable MaxHistoryEntries instance Binary MaxHistoryEntries instance YiConfigVariable MaxHistoryEntries instance Default MaxHistoryEntries instance Binary PersistentState -- | 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 Default FilePrompter where
--      def = 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, Default) 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 all lens machinery. type Field a = Lens' Config a instance HookType b => HookType (a -> b) instance HookType (YiM a) instance HookType (EditorM a) 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/.config/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: -- -- publishedActionsEvaluator :: Evaluator -- | Accessor for the published actions. Consider using -- publishAction. publishedActions :: Field (HashMap String Action) -- | Publish the given action, by the given name. This will overwrite any -- existing actions by the same name. publishAction :: (YiAction a x, Show x) => String -> a -> ConfigM () jumpToErrorE :: YiM () jumpToE :: String -> Int -> Int -> YiM () consoleKeymap :: Keymap instance YiConfigVariable PublishedActions instance Typeable Evaluator instance Typeable NamesCache instance Typeable PublishedActions instance Binary NamesCache instance Monoid PublishedActions instance Default PublishedActions instance YiVariable NamesCache instance Default NamesCache instance YiConfigVariable Evaluator instance Default Evaluator -- | This module is aimed at being a helper for the Emacs keybindings. In -- particular this should be useful for anyone that has a custom keymap -- derived from or based on the Emacs one. module Yi.Keymap.Emacs.Utils type UnivArgument = Maybe Int -- | Convert the universal argument to a number of repetitions argToInt :: UnivArgument -> Int -- | Quits the editor if there are no unmodified buffers if there are -- unmodified buffers then we ask individually for each modified buffer -- whether or not the user wishes to save it or not. If we get to the end -- of this list and there are still some modified buffers then we ask -- again if the user wishes to quit, but this is then a simple yes or no. askQuitEditor :: YiM () -- | Quits the editor if there are no unmodified buffers if there are -- unmodified buffers then we ask individually for each modified buffer -- whether or not the user wishes to save it or not. If we get to the end -- of this list and there are still some modified buffers then we ask -- again if the user wishes to quit, but this is then a simple yes or no. askSaveEditor :: YiM () -- | Quits the editor if there are no unmodified buffers if there are then -- simply confirms with the user that they with to quit. modifiedQuitEditor :: 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 () queryReplaceE :: YiM () isearchKeymap :: Direction -> Keymap -- | cabal-configure cabalConfigureE :: CommandArguments -> YiM () -- | cabal-build cabalBuildE :: CommandArguments -> YiM () reloadProjectE :: String -> YiM () executeExtendedCommandE :: YiM () evalRegionE :: YiM () readUniversalArg :: KeymapM (Maybe Int) scrollDownE :: UnivArgument -> BufferM () scrollUpE :: UnivArgument -> BufferM () switchBufferE :: YiM () killBufferE :: BufferRef ::: ToKill -> YiM () -- | Insert next character, "raw" insertNextC :: UnivArgument -> KeymapM () -- | Open a file using the minibuffer. We have to set up some stuff to -- allow hints and auto-completion. findFile :: YiM () -- | Open a file in a new tab using the minibuffer. findFileNewTab :: YiM () -- | 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 () -- | Prompt the user to give a tag and then jump to that tag promptTag :: YiM () -- | If on separators (space, tab, unicode seps), reduce multiple -- separators to just a single separator. If we aren't looking at a -- separator, insert a single space. This kind of behaves as emacs -- ‘just-one-space’ function with the argument of ‘1’ but it prefers to -- use the separator we're looking at instead of assuming a space. justOneSep :: BufferM () -- | Join this line to previous (or next N if universal) joinLinesE :: UnivArgument -> BufferM () module Yi.Keymap.Cua keymap :: KeymapSet -- | Introduce a keymap that is compatible with both windows and osx, by -- parameterising the event modifier required for commands portableKeymap :: (Event -> Event) -> KeymapSet customizedCuaKeymapSet :: Keymap -> KeymapSet cut :: EditorM () paste :: EditorM () copy :: EditorM () del :: EditorM () module Yi.Keymap.Vim2.Ex.Commands.Yi parse :: String -> Maybe ExCommand module Yi.Keymap.Vim2.Ex exEvalE :: [String -> Maybe ExCommand] -> String -> EditorM () exEvalY :: [String -> Maybe ExCommand] -> String -> YiM () stringToExCommand :: [String -> Maybe ExCommand] -> String -> Maybe ExCommand data ExCommand ExCommand :: YiM [String] -> Bool -> Action -> Bool -> String -> ExCommand cmdComplete :: ExCommand -> YiM [String] cmdIsPure :: ExCommand -> Bool cmdAction :: ExCommand -> Action cmdAcceptsRange :: ExCommand -> Bool cmdShow :: ExCommand -> String defExCommandParsers :: [String -> Maybe ExCommand] module Yi.Keymap.Vim2.ExMap defExMap :: [String -> Maybe ExCommand] -> [VimBinding] -- | This module aims at a mode that should be (mostly) intuitive to emacs -- users, but mapping things into the Yi world when convenient. Hence, do -- not go into the trouble of trying 100% emulation. For example, M-x -- gives access to Yi (Haskell) functions, with their native names. module Yi.Keymap.Emacs keymap :: KeymapSet mkKeymap :: Proto ModeMap -> KeymapSet defKeymap :: Proto ModeMap data ModeMap ModeMap :: Keymap -> Bool -> ModeMap _eKeymap :: ModeMap -> Keymap _completionCaseSensitive :: ModeMap -> Bool eKeymap :: Lens' ModeMap Keymap completionCaseSensitive :: Lens' ModeMap Bool -- | Vim keymap for Yi. Emulates vim :set nocompatible module Yi.Keymap.Vim keymapSet :: KeymapSet -- | Try to write a file in the manner of vi/vim Need to catch any -- exception to avoid losing bindings viWrite :: YiM () defKeymap :: Proto ModeMap leaveInsRep :: VimMode -- | Leave a mode. This always has priority over catch-all actions inside -- the mode. leave :: VimMode -- | The Vim keymap is divided into several parts, roughly corresponding to -- the different modes of vi. Each mode is in turn broken up into -- separate VimProcs for each phase of key input in that mode. data ModeMap ModeMap :: VimMode -> VimMode -> VimOpts -> VimExCmdMap -> ModeMap -- | Top level mode v_top_level :: ModeMap -> VimMode -- | vim insert mode v_ins_char :: ModeMap -> VimMode v_opts :: ModeMap -> VimOpts v_ex_cmds :: ModeMap -> VimExCmdMap data VimOpts VimOpts :: Bool -> Bool -> Bool -> VimOpts tildeop :: VimOpts -> Bool completeCaseSensitive :: VimOpts -> Bool enableTagStack :: VimOpts -> Bool data VimExCmd VimExCmd :: [String] -> (String -> YiM ()) -> Maybe (String -> YiM ()) -> VimExCmd cmdNames :: VimExCmd -> [String] cmdFn :: VimExCmd -> String -> YiM () completeFn :: VimExCmd -> Maybe (String -> YiM ()) nilCmd :: VimExCmd exCmd :: String -> (String -> YiM ()) -> Maybe (String -> YiM ()) -> VimExCmd exCmds :: [(String, String -> YiM (), Maybe (String -> YiM ()))] -> VimExCmdMap exSimpleComplete :: (String -> YiM [String]) -> String -> YiM () exInfixComplete' :: Bool -> (String -> YiM [String]) -> String -> YiM () exInfixComplete :: (String -> YiM [String]) -> String -> YiM () mkExHistComplete :: (String -> String -> Bool) -> (String -> YiM [String]) -> String -> YiM () exHistComplete' :: Bool -> (String -> YiM [String]) -> String -> YiM () exHistComplete :: (String -> YiM [String]) -> String -> YiM () exHistInfixComplete' :: Bool -> (String -> YiM [String]) -> String -> YiM () exHistInfixComplete :: (String -> YiM [String]) -> String -> YiM () -- | The given buffer action should be an insertion action. savingInsertB :: BufferM () -> BufferM () savingInsertCharB :: Char -> BufferM () savingInsertStringB :: String -> BufferM () -- | The given action should be a deletion action. The only well tested -- buffer actions are deleting one character, or one word, forward or -- backward. savingDeleteB :: BufferM () -> BufferM () savingDeleteCharB :: Direction -> BufferM () savingDeleteWordB :: Direction -> BufferM () savingCommandY :: (Int -> YiM ()) -> Int -> YiM () savingCommandE :: (Int -> EditorM ()) -> Int -> EditorM () mkKeymap :: Proto ModeMap -> KeymapSet beginIns :: (Show x, YiAction a x) => ModeMap -> a -> I Event Action () beginInsE :: ModeMap -> EditorM () -> I Event Action () beginInsB :: ModeMap -> BufferM () -> I Event Action () listTagStack :: EditorM [(FilePath, Point)] pushTagStack :: FilePath -> Point -> EditorM () popTagStack :: Int -> EditorM (Maybe (FilePath, Point)) peekTagStack :: EditorM (Maybe (FilePath, Point)) exMode :: ModeMap -> String -> EditorM () -- | eval an ex command to an YiM (), also appends to the ex history exEval :: ModeMap -> String -> YiM () instance Typeable ViMove instance Typeable ViCmd instance Typeable ViInsertion instance Typeable MViInsertion instance Default MViInsertion instance YiVariable MViInsertion instance Binary MViInsertion instance YiVariable ViCmd instance Default ViCmd instance Binary ViCmd module Yi.Mode.Abella abellaModeVim :: TokenBasedMode Token abellaModeEmacs :: TokenBasedMode Token -- | Start Abella in a buffer abella :: CommandArguments -> YiM BufferRef abellaEval :: YiM () abellaEvalFromProofPoint :: YiM () abellaUndo :: YiM () -- | Return Abella's buffer; create it if necessary. Show it in another -- window. abellaGet :: YiM BufferRef -- | Send a command to Abella abellaSend :: String -> YiM () instance Typeable AbellaBuffer instance Default AbellaBuffer instance Binary AbellaBuffer instance YiVariable AbellaBuffer module Yi.Snippets type SnippetCmd = RWST (Int, Int) [MarkInfo] () BufferM data SnippetMark SimpleMark :: !Int -> SnippetMark ValuedMark :: !Int -> String -> SnippetMark DependentMark :: !Int -> SnippetMark data MarkInfo SimpleMarkInfo :: !Int -> !Mark -> MarkInfo userIndex :: MarkInfo -> !Int startMark :: MarkInfo -> !Mark ValuedMarkInfo :: !Int -> !Mark -> !Mark -> MarkInfo userIndex :: MarkInfo -> !Int startMark :: MarkInfo -> !Mark endMark :: MarkInfo -> !Mark DependentMarkInfo :: !Int -> !Mark -> !Mark -> MarkInfo userIndex :: MarkInfo -> !Int startMark :: MarkInfo -> !Mark endMark :: MarkInfo -> !Mark newtype BufferMarks BufferMarks :: [MarkInfo] -> BufferMarks bufferMarks :: BufferMarks -> [MarkInfo] newtype DependentMarks DependentMarks :: [[MarkInfo]] -> DependentMarks marks :: DependentMarks -> [[MarkInfo]] cursor :: Int -> SnippetMark cursorWith :: Int -> String -> SnippetMark dep :: Int -> SnippetMark isDependentMark :: MarkInfo -> Bool bufferMarkers :: MarkInfo -> [Mark] class MkSnippetCmd a b | a -> b mkSnippetCmd :: MkSnippetCmd a b => a -> SnippetCmd b mkMark :: MonadTrans t => t BufferM Mark text :: String -> SnippetCmd () (&) :: (MkSnippetCmd a any, MkSnippetCmd b c) => a -> b -> SnippetCmd c (&>) :: (MkSnippetCmd a b, MkSnippetCmd c d) => a -> (b -> c) -> SnippetCmd d runSnippet :: Bool -> SnippetCmd a -> BufferM a updateUpdatedMarks :: [Update] -> BufferM () findEditedMarks :: [Update] -> BufferM [MarkInfo] dependentSiblings :: MarkInfo -> [[MarkInfo]] -> [MarkInfo] updateDependents :: MarkInfo -> BufferM () updateDependents' :: MarkInfo -> [[MarkInfo]] -> BufferM () markText :: MarkInfo -> BufferM String setMarkText :: String -> MarkInfo -> BufferM () withSimpleRegion :: MarkInfo -> (Region -> BufferM Region) -> BufferM Region markRegion :: MarkInfo -> BufferM Region safeMarkRegion :: MarkInfo -> BufferM Region adjMarkRegion :: MarkInfo -> BufferM Region findOverlappingMarksWith :: (MarkInfo -> BufferM Region) -> ([[MarkInfo]] -> [MarkInfo]) -> Bool -> Region -> MarkInfo -> BufferM [MarkInfo] findOverlappingMarks :: ([[MarkInfo]] -> [MarkInfo]) -> Bool -> Region -> MarkInfo -> BufferM [MarkInfo] regionsOverlappingMarks :: Bool -> Region -> MarkInfo -> BufferM [MarkInfo] overlappingMarks :: Bool -> Bool -> MarkInfo -> BufferM [MarkInfo] allOverlappingMarks :: Bool -> MarkInfo -> BufferM [MarkInfo] dependentOverlappingMarks :: Bool -> MarkInfo -> BufferM [MarkInfo] nextBufferMark :: Bool -> BufferM (Maybe MarkInfo) isDependentMarker :: MonadState FBuffer m => Mark -> m Bool safeDeleteMarkB :: Mark -> BufferM () moveToNextBufferMark :: Bool -> BufferM () newtype SupertabExt Supertab :: (String -> Maybe (BufferM ())) -> SupertabExt superTab :: MonadInteract m Action Event => Bool -> SupertabExt -> m () -- | Convert snippet description list into a SuperTab extension fromSnippets :: Bool -> [(String, SnippetCmd ())] -> SupertabExt snippet :: MkSnippetCmd a b => a -> SnippetCmd b instance Typeable BufferMarks instance Typeable DependentMarks instance Eq BufferMarks instance Show BufferMarks instance Monoid BufferMarks instance Binary BufferMarks instance Eq DependentMarks instance Show DependentMarks instance Monoid DependentMarks instance Binary DependentMarks instance Monoid SupertabExt instance MkSnippetCmd SnippetMark () instance MkSnippetCmd (SnippetCmd a) a instance MkSnippetCmd String () instance Ord MarkInfo instance YiVariable DependentMarks instance YiVariable BufferMarks instance Default DependentMarks instance Default BufferMarks instance Binary MarkInfo instance Eq MarkInfo instance Show MarkInfo module Yi.Snippets.Haskell hsFunction :: SnippetCmd () hsClass :: SnippetCmd () module Yi.Keymap.Vim2 keymapSet :: KeymapSet mkKeymapSet :: Proto VimConfig -> KeymapSet defVimConfig :: Proto VimConfig data VimBinding VimBindingY :: (EventString -> VimState -> MatchResult (YiM RepeatToken)) -> VimBinding VimBindingE :: (EventString -> VimState -> MatchResult (EditorM RepeatToken)) -> VimBinding data VimOperator VimOperator :: !OperatorName -> (Int -> StyledRegion -> EditorM RepeatToken) -> VimOperator operatorName :: VimOperator -> !OperatorName operatorApplyToRegionE :: VimOperator -> Int -> StyledRegion -> EditorM RepeatToken data VimConfig VimConfig :: Keymap -> [VimBinding] -> [VimOperator] -> [String -> Maybe ExCommand] -> [(String, Char)] -> VimConfig vimKeymap :: VimConfig -> Keymap vimBindings :: VimConfig -> [VimBinding] vimOperators :: VimConfig -> [VimOperator] vimExCommandParsers :: VimConfig -> [String -> Maybe ExCommand] vimDigraphs :: VimConfig -> [(String, Char)] pureEval :: VimConfig -> String -> EditorM () impureEval :: VimConfig -> String -> YiM () module Yi.Config.Default defaultConfig :: Config availableFrontends :: [(String, UIBoot)] defaultEmacsConfig :: Config defaultVimConfig :: Config defaultCuaConfig :: Config toVimStyleConfig :: Config -> Config toVim2StyleConfig :: Config -> Config toEmacsStyleConfig :: Config -> Config toCuaStyleConfig :: Config -> Config -- | This is the main module of Yi, called with configuration from the -- user. Here we mainly process command line arguments. module Yi.Main -- | Static main. This is the front end to the statically linked -- application, and the real front end, in a sense. dynamic_main -- calls this after setting preferences passed from the boot loader. main :: (Config, ConsoleConfig) -> Maybe Editor -> IO () -- | Transform the config with options do_args :: Config -> [String] -> Either Err (Config, ConsoleConfig) -- | Configuration information which can be set in the command-line, but -- not in the user's configuration file. data ConsoleConfig ConsoleConfig :: [String] -> Bool -> IO FilePath -> ConsoleConfig ghcOptions :: ConsoleConfig -> [String] selfCheck :: ConsoleConfig -> Bool userConfigDir :: ConsoleConfig -> IO FilePath data Err Err :: String -> ExitCode -> Err instance Error Err -- | Boot process of Yi. Uses Dyre to implement the XMonad-style dynamic -- reconfiguration. module Yi.Boot yi :: Config -> IO () -- | Used by both the yi executable and the custom yi that is built from -- the user's configuration. The yi executable uses a default config. yiDriver :: Config -> IO () -- | "reloads" the configuration -- -- Serializes the editor state and relaunches Yi using the serialized -- state. The launch of Yi will result in recompilation of the user's -- custom yi. This, in effect, "reloads" the configuration. reload :: YiM () -- | A simplified configuration interface for Yi. module Yi.Config.Simple -- | The configuration monad. Run it with configMain. data ConfigM a -- | Starts with the given initial config, makes the described -- modifications, then starts yi. configMain :: Config -> ConfigM () -> IO () -- | Fields that can be modified with all lens machinery. type Field a = Lens' Config a -- | Sets the frontend to the first frontend from the list which is -- installed. -- -- Available frontends are a subset of: "vty", "pango", and "batch". setFrontendPreferences :: [String] -> ConfigM () -- | Sets the frontend, if it is available. setFrontend :: String -> ConfigM () -- | Adds the given key bindings to the `global keymap'. The bindings will -- override existing bindings in the case of a clash. globalBindKeys :: Keymap -> ConfigM () -- | modeBindKeys mode keys adds the keybindings in keys -- to all modes with the same name as mode. -- -- As with modifyMode, a mode by the given name must already be -- registered, or the function will have no effect, and issue a -- command-line warning. modeBindKeys :: Mode syntax -> Keymap -> ConfigM () -- | modeBindKeysByName name keys adds the keybindings in -- keys to all modes with name name (if it is -- registered). Consider using modeBindKeys instead. modeBindKeysByName :: String -> Keymap -> ConfigM () -- | Register the given mode. It will be preferred over any modes already -- defined. addMode :: Mode syntax -> ConfigM () -- | modifyMode mode f modifies all modes with the same name as -- mode, using the function f. -- -- Note that the mode argument is only used by its -- modeName. In particular, a mode by the given name must already -- be registered, or this function will have no effect, and issue a -- command-line warning. -- --
--   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/.config/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: -- -- publishedActionsEvaluator :: Evaluator -- | Publish the given action, by the given name. This will overwrite any -- existing actions by the same name. publishAction :: (YiAction a x, Show x) => String -> a -> ConfigM () -- | Accessor for the published actions. Consider using -- publishAction. publishedActions :: Field (HashMap String Action) -- | Just the font name, or Nothing for default. fontName :: Field (Maybe String) -- | Just the font size, or Nothing for default. fontSize :: Field (Maybe Int) -- | Amount to move the buffer when using the scroll wheel. scrollWheelAmount :: Field Int -- | Just the scroll style, or Nothing for default. scrollStyle :: Field (Maybe ScrollStyle) data ScrollStyle SnapToCenter :: ScrollStyle SingleLine :: ScrollStyle -- | See CursorStyle for documentation. cursorStyle :: Field CursorStyle -- | 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 data Side LeftSide :: Side RightSide :: Side -- | Which side to display the scroll bar on. scrollBarSide :: Field Side -- | Should the scroll bar autohide? autoHideScrollBar :: Field Bool -- | Should the tab bar autohide? autoHideTabBar :: Field Bool -- | Should lines be wrapped? lineWrap :: Field Bool -- | The character with which to fill empty window space. Usually '~' for -- vi-like editors, ' ' for everything else. windowFill :: Field Char -- | UI colour theme. theme :: Field Theme -- | List of registered layout managers. When cycling through layouts, this -- list will be consulted. layoutManagers :: Field [AnyLayoutManager] -- | Produce a .yi.dbg file with debugging information? debug :: Field Bool -- | Run when the editor is started (this is run after all actions which -- have already been registered) runOnStartup :: Action -> ConfigM () -- | Run after the startup actions have completed, or on reload (this is -- run after all actions which have already been registered) runAfterStartup :: Action -> ConfigM () -- | Actions to run when the editor is started. Consider using -- runOnStartup or runManyOnStartup instead. startActions :: Field [Action] -- | Actions to run after startup or reload. Consider using -- runAfterStartup or runManyAfterStartup instead. initialActions :: Field [Action] -- | Default keymap to use. defaultKm :: Field KeymapSet -- | ? inputPreprocess :: Field (P Event Event) -- | List of modes by order of preference. Consider using addMode, -- modeBindKeys, or modifyMode instead. modes :: Field [AnyMode] -- | Set to Exclusive for an emacs-like behaviour. Consider starting -- with defaultEmacsConfig, defaultVimConfig, or -- defaultCuaConfig to instead. regionStyle :: Field RegionStyle -- | Set to True for an emacs-like behaviour, where all deleted text -- is accumulated in a killring. Consider starting with -- defaultEmacsConfig, defaultVimConfig, or -- defaultCuaConfig instead. killringAccumulate :: Field Bool -- | ? bufferUpdateHandler :: Field [[Update] -> BufferM ()] -- | Facade of the Yi library, for use by confguration file. Just -- re-exports a bunch of modules. -- -- You should therefore: import Yi in your ~.configyi/ scripts module Yi -- | 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
--     }
--   
-- -- Calling extractValue o1 would then produce O {f1 = -- 1, f2 = 2, f3 = 3}. 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