-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A modular text editor -- -- A modular text editor This is only a snippet, see the project's -- README. -- -- Rasa is a text editor project with a few interesting goals. For better -- or worse it attempts to be as modular as possible. This means that -- most functionality which would typically be considered to be -- core in other editors is implemented as extensions in Rasa. -- This approach comes with its own share of pros and cons, for instance: -- -- Pros -- -- -- -- Cons -- -- -- -- While highly experimental, I've found the current API to be quite -- expressive and adaptable; for instance I was able to implement the -- notion of multiple cursors using the extension API in less than a day. -- I hope to keep the learning curve low as development continues. -- -- Getting Started -- -- First clone the Github repo and try running the example-config -- included there. Once you get it running (see the README) then -- you can customize your keymap to add a few mappings you like. Then I'd -- check out the Building your own extensions guide. It goes in -- depth into everything you'd want to know! -- -- If you have any issues (and I'm sure there'll be a few; it's a new -- project!) please report them here and we'll talk about it! @package rasa @version 0.1.12 module Rasa.Internal.Text -- | An iso which converts to/from YiString -> Text asText :: Iso' YiString Text -- | An iso which converts to/from YiString -> String asString :: Iso' YiString String -- | An iso which converts to/from YiString -> [YiString] asLines :: Iso' YiString [YiString] module Rasa.Internal.Range -- | A type alias to Coord' which specializes the types to integers. type Coord = Coord' Int Int -- | (Coord Row Column) represents a char in a block of text. (zero -- indexed) e.g. Coord 0 0 is the first character in the text, Coord 2 1 -- is the second character of the third row data Coord' a b Coord :: a -> b -> Coord' a b [_coordRow] :: Coord' a b -> a [_coordCol] :: Coord' a b -> b -- | Applies a function over the row of a Coord overRow :: (Int -> Int) -> Coord -> Coord -- | Applies a function over the column of a Coord overCol :: (Int -> Int) -> Coord -> Coord -- | Applies a function over both functors in any Bifunctor. overBoth :: Bifunctor f => (a -> b) -> f a a -> f b b coordRow :: forall a_agqk b_agql a_agzi. Lens (Coord' a_agqk b_agql) (Coord' a_agzi b_agql) a_agqk a_agzi coordCol :: forall a_agqk b_agql b_agzh. Lens (Coord' a_agqk b_agql) (Coord' a_agqk b_agzh) b_agql b_agzh -- | An Offset represents an exact position in a file as a number of -- characters from the start. newtype Offset Offset :: Int -> Offset -- | Given the text you're operating over, creates an iso from an -- Offset to a Coord. asCoord :: YiString -> Iso' Offset Coord -- | This will restrict a given Coord to a valid one which lies -- within the given text. clampCoord :: YiString -> Coord -> Coord -- | This will restrict a given Range to a valid one which lies -- within the given text. clampRange :: YiString -> CrdRange -> CrdRange -- | This represents a range between two coordinates (Coord) data Range a b Range :: a -> b -> Range a b [_rStart] :: Range a b -> a [_rEnd] :: Range a b -> b -- | A type alias to Range' which specializes the types to -- Coords. type CrdRange = Range Coord Coord -- | A lens over text which is encompassed by a Range range :: CrdRange -> Lens' YiString YiString rStart :: forall a_aelx b_aely a_agh2. Lens (Range a_aelx b_aely) (Range a_agh2 b_aely) a_aelx a_agh2 rEnd :: forall a_aelx b_aely b_agh1. Lens (Range a_aelx b_aely) (Range a_aelx b_agh1) b_aely b_agh1 -- | Returns the number of rows and columns that a chunk of text spans as a -- Coord sizeOf :: YiString -> Coord -- | Returns the number of rows and columns that a Range spans as a -- Coord sizeOfR :: CrdRange -> Coord -- | Moves a Range by a given Coord It may be unintuitive, -- but for (Coord row col) a given range will be moved down by row and to -- the right by col. moveRange :: Coord -> CrdRange -> CrdRange -- | Moves a range forward by the given amount moveRangeByN :: Int -> CrdRange -> CrdRange -- | Moves a Coord forward by the given amount of columns moveCursorByN :: Int -> Coord -> Coord -- | Adds the rows and columns of the given two Coords. moveCursor :: Coord -> Coord -> Coord -- | A span which maps a piece of Monoidal data over a range. data Span a b Span :: a -> b -> Span a b -- | Combines a list of spans containing some monoidal data into a list of -- offsets with with the data that applies from each Offset forwards. combineSpans :: forall a. Monoid a => [Span CrdRange a] -> [(Coord, a)] -- | clamp min max val restricts val to be within min and max -- (inclusive) clamp :: Int -> Int -> Int -> Int -- | A lens over text before a given Coord beforeC :: Coord -> Lens' YiString YiString -- | A lens over text after a given Coord afterC :: Coord -> Lens' YiString YiString instance GHC.Classes.Eq Rasa.Internal.Range.Marker instance GHC.Show.Show Rasa.Internal.Range.Marker instance GHC.Base.Functor (Rasa.Internal.Range.Span a) instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (Rasa.Internal.Range.Span a b) instance (GHC.Show.Show b, GHC.Show.Show a) => GHC.Show.Show (Rasa.Internal.Range.Span a b) instance GHC.Classes.Eq Rasa.Internal.Range.Offset instance GHC.Show.Show Rasa.Internal.Range.Offset instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Rasa.Internal.Range.Coord' a b) instance Data.Bifunctor.Bifunctor Rasa.Internal.Range.Coord' instance Data.Biapplicative.Biapplicative Rasa.Internal.Range.Coord' instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Rasa.Internal.Range.Coord' a b) instance Data.Bifunctor.Bifunctor Rasa.Internal.Range.Span instance (GHC.Num.Num a, GHC.Num.Num b) => GHC.Num.Num (Rasa.Internal.Range.Coord' a b) instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (Rasa.Internal.Range.Coord' a b) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Rasa.Internal.Range.Range a b) instance Data.Bifunctor.Bifunctor Rasa.Internal.Range.Range instance Data.Bifoldable.Bifoldable Rasa.Internal.Range.Range instance Data.Bitraversable.Bitraversable Rasa.Internal.Range.Range instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Rasa.Internal.Range.Range a b) instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (Rasa.Internal.Range.Range a b) module Rasa.Internal.Buffer -- | A buffer, holds the text in the buffer and any extension states that -- are set on the buffer. data Buffer type BufAction a = Action Buffer a -- | This allows creation of polymorphic lenses over any type which has -- access to a Buffer class HasBuffer a buffer :: HasBuffer a => Lens' a Buffer -- | An opaque reference to a buffer. When operating over a BufRef Rasa -- checks if the Buffer still exists and simply ignores any -- operations over non-existent buffers; typically returning -- Nothing newtype BufRef BufRef :: Int -> BufRef -- | This lens focuses the text of the in-scope buffer. text :: HasBuffer b => Lens' b YiString -- | Creates a new buffer from the given text. mkBuffer :: YiString -> BufRef -> Buffer ref :: Lens' Buffer BufRef -- | A lens over the map of available buffers buffers :: HasStates s => Lens' s (IntMap Buffer) nextBufId :: HasStates s => Lens' s Int instance Data.Default.Class.Default Rasa.Internal.Buffer.Buffers instance GHC.Show.Show Rasa.Internal.Buffer.Buffers instance Eve.Internal.States.HasStates Rasa.Internal.Buffer.Buffer instance Eve.Internal.States.HasEvents Rasa.Internal.Buffer.Buffer instance Rasa.Internal.Buffer.HasBuffer Rasa.Internal.Buffer.Buffer instance GHC.Show.Show Rasa.Internal.Buffer.Buffer instance GHC.Show.Show Rasa.Internal.Buffer.NextBufId instance GHC.Classes.Ord Rasa.Internal.Buffer.BufRef instance GHC.Classes.Eq Rasa.Internal.Buffer.BufRef instance GHC.Show.Show Rasa.Internal.Buffer.BufRef instance Data.Default.Class.Default Rasa.Internal.Buffer.NextBufId module Rasa.Internal.Events -- | This event is dispatched immediately before dispatching the -- OnRender event. data BeforeRender BeforeRender :: BeforeRender -- | This event is dispatched when it's time for extensions to render to -- screen. data OnRender OnRender :: OnRender -- | This event is dispatched immediately after dispatching -- OnRender. data AfterRender AfterRender :: AfterRender -- | This event is dispatched after adding a new buffer. The contained -- BufRef refers to the new buffer. data BufAdded BufAdded :: BufRef -> BufAdded -- | This event is dispatched in response to keyboard key presses. It -- contains both the char that was pressed and any modifiers (Mod) -- that where held when the key was pressed. data Keypress Keypress :: Char -> [Mod] -> Keypress KEsc :: [Mod] -> Keypress KBS :: [Mod] -> Keypress KEnter :: [Mod] -> Keypress KLeft :: [Mod] -> Keypress KRight :: [Mod] -> Keypress KUp :: [Mod] -> Keypress KDown :: [Mod] -> Keypress KPrtScr :: [Mod] -> Keypress KHome :: [Mod] -> Keypress KPageUp :: [Mod] -> Keypress KDel :: [Mod] -> Keypress KEnd :: [Mod] -> Keypress KPageDown :: [Mod] -> Keypress KUnknown :: Keypress -- | This represents each modifier key that could be pressed along with a -- key. data Mod Ctrl :: Mod Alt :: Mod Shift :: Mod Meta :: Mod -- | This is triggered when text in a buffer is changed. The Event data -- includes the CrdRange that changed and the new text which is -- now contined in that range. data BufTextChanged BufTextChanged :: CrdRange -> YiString -> BufTextChanged instance GHC.Classes.Eq Rasa.Internal.Events.BufTextChanged instance GHC.Show.Show Rasa.Internal.Events.BufTextChanged instance GHC.Classes.Eq Rasa.Internal.Events.Keypress instance GHC.Show.Show Rasa.Internal.Events.Keypress instance GHC.Classes.Eq Rasa.Internal.Events.Mod instance GHC.Show.Show Rasa.Internal.Events.Mod instance GHC.Classes.Eq Rasa.Internal.Events.BufAdded instance GHC.Show.Show Rasa.Internal.Events.BufAdded instance GHC.Classes.Eq Rasa.Internal.Events.AfterRender instance GHC.Show.Show Rasa.Internal.Events.AfterRender instance GHC.Classes.Eq Rasa.Internal.Events.OnRender instance GHC.Show.Show Rasa.Internal.Events.OnRender instance GHC.Classes.Eq Rasa.Internal.Events.BeforeRender instance GHC.Show.Show Rasa.Internal.Events.BeforeRender module Rasa.Internal.Listeners -- | Registers an action to be performed BEFORE each render phase. -- -- This is a good spot to add information useful to the renderer since -- all actions have been performed. Only cosmetic changes should occur -- during this phase. beforeEveryRender :: App a -> App ListenerId beforeEveryRender_ :: App a -> App () -- | Dispatch the BeforeRender action. dispatchBeforeRender :: App () -- | Registers an action to be performed during each render phase. -- -- This phase should only be used by extensions which actually render -- something. onEveryRender :: App a -> App ListenerId onEveryRender_ :: App a -> App () -- | Dispatch the OnRender action. dispatchOnRender :: App () -- | Registers an action to be performed AFTER each render phase. -- -- This is useful for cleaning up extension state that was registered for -- the renderer, but needs to be cleared before the next iteration. afterEveryRender :: App a -> App ListenerId afterEveryRender_ :: App a -> App () -- | Dispatch the AfterRender action. dispatchAfterRender :: App () -- | Registers an action to be run before shutdown. Any asynchronous -- combinators used in this block will NOT be run. onExit :: (HasEvents zoomed, Typeable (* -> *) m, Typeable * base, Monad m) => ActionT base zoomed m a -> ActionT base zoomed m () -- | Trigger an App on a Keypress onKeypress :: (Keypress -> App result) -> App ListenerId -- | Dispatch a Keypress event. dispatchKeypress :: Keypress -> App () module Rasa.Internal.BufActions -- | Runs function over given range of text overRange :: CrdRange -> (YiString -> YiString) -> BufAction () -- | Replaces the text in the given range with the given text. replaceRange :: CrdRange -> YiString -> BufAction () -- | Deletes the text in the given range from the buffer. deleteRange :: CrdRange -> BufAction () -- | Inserts text into the buffer at the given Coord. insertAt :: Coord -> YiString -> BufAction () -- | Returns the number of rows and columns that a chunk of text spans as a -- Coord sizeOf :: YiString -> Coord -- | Gets the range representing a given row (if that row exists) getLineRange :: Row -> BufAction (Maybe CrdRange) -- | This lifts a BufAction to an App which performs the -- BufAction on the buffer referred to by the BufRef If the -- buffer referred to no longer exists this returns: Nothing. bufDo :: BufRef -> BufAction a -> App (Maybe a) bufDo_ :: BufRef -> BufAction a -> App () -- | This lifts a BufAction to an App which performs the -- BufAction on every buffer and collects the return values as a -- list. buffersDo :: BufAction a -> App [a] buffersDo_ :: BufAction a -> App () -- | Returns an up-to-date list of all BufRefs getBufRefs :: App [BufRef] -- | Gets BufRef that comes after the one provided nextBufRef :: BufRef -> App BufRef -- | Gets BufRef that comes before the one provided prevBufRef :: BufRef -> App BufRef -- | Retrieve some buffer extension state getBufExt :: (Typeable s, Show s, Default s) => BufAction s -- | Set some buffer extension state setBufExt :: (Typeable s, Show s, Default s) => s -> BufAction () -- | Set some buffer extension state overBufExt :: (Typeable s, Show s, Default s) => (s -> s) -> BufAction () -- | Gets the current buffer's BufRef getBufRef :: BufAction BufRef -- | Gets the range of text from the buffer getRange :: CrdRange -> BufAction YiString -- | Adds a new buffer and returns the BufRef addBuffer :: YiString -> App BufRef -- | Retrieve a buffer. This is read-only for -- loggingrenderingdebugging purposes only. getBuffer :: BufRef -> App (Maybe Buffer) -- | Dispatches an event of any type to the BufAction's buffer. See -- dispatchEvent dispatchBufEvent :: (Monoid result, Typeable eventType, Typeable result) => (eventType -> BufAction result) -- | Adds a listener to the BufAction's buffer. See addListener addBufListener :: (Typeable eventType, Typeable result, Monoid result) => (eventType -> BufAction result) -> BufAction ListenerId addBufListener_ :: (Typeable eventType, Typeable result, Monoid result) => (eventType -> BufAction result) -> BufAction () -- | Removes a listener from the BufAction's buffer. See -- removeListener removeBufListener :: ListenerId -> BufAction () -- | Registers an action to be performed after a new buffer is added. -- -- The supplied function will be called with a BufRef to the new -- buffer, and the resulting App will be run. onBufAdded :: (BufAdded -> App result) -> App ListenerId onBufAdded_ :: (BufAdded -> App result) -> App () -- | Dispatch the BufAdded action. dispatchBufAdded :: BufAdded -> App () -- | Run the given BufAction over all new buffers onEveryNewBuffer :: BufAction a -> App ListenerId onEveryNewBuffer_ :: BufAction a -> App () -- | This is fired every time text in a buffer changes. -- -- The range of text which was altered and the new value of that text are -- provided inside a BufTextChanged event. onBufTextChanged :: (BufTextChanged -> BufAction result) -> BufAction ListenerId -- | Dispatch the BufBufTextChanged action. dispatchBufTextChanged :: BufTextChanged -> BufAction () -- | Returns the text of the current buffer getText :: BufAction YiString module Rasa.Internal.Styles -- | Create a new Style with the given Color as the -- foreground. fg :: Color -> Style -- | Create a new Style with the given Color as the -- background. bg :: Color -> Style -- | Create a new Style with the given Flair as its flair. flair :: Flair -> Style -- | These represent the possible colors for fg or bg. -- DefColor represents the renderer's default color. data Color Black :: Color Red :: Color Green :: Color Yellow :: Color Blue :: Color Magenta :: Color Cyan :: Color White :: Color DefColor :: Color -- | These represent the possible extra attributes which may be applied. -- DefFlair represents the renderer's default text attributes. data Flair Standout :: Flair Underline :: Flair ReverseVideo :: Flair Blink :: Flair Dim :: Flair Bold :: Flair DefFlair :: Flair -- | A container which holds a foreground color, background color, and a -- flair. a Nothing represents that we should not change that -- attribute. newtype Style Style :: (Maybe Color, Maybe Color, Maybe Flair) -> Style type Styles = [Span CrdRange Style] -- | Pass this a BufAction which computes styles based on the -- current buffer and they'll be collected for the renderer. addStyleProvider :: BufAction Styles -> BufAction ListenerId -- | Collect all provided styles, this is useful for renderers. getStyles :: BufAction Styles instance GHC.Base.Monoid Rasa.Internal.Styles.StyleMap instance GHC.Classes.Eq Rasa.Internal.Styles.StyleMap instance GHC.Show.Show Rasa.Internal.Styles.StyleMap instance GHC.Classes.Eq Rasa.Internal.Styles.Style instance GHC.Show.Show Rasa.Internal.Styles.Style instance GHC.Classes.Eq Rasa.Internal.Styles.Flair instance GHC.Show.Show Rasa.Internal.Styles.Flair instance GHC.Classes.Eq Rasa.Internal.Styles.Color instance GHC.Show.Show Rasa.Internal.Styles.Color instance Data.Default.Class.Default Rasa.Internal.Styles.Style instance GHC.Base.Monoid Rasa.Internal.Styles.Style instance Data.Default.Class.Default Rasa.Internal.Styles.StyleMap module Rasa.Internal.Utility type Width = Int type Height = Int -- | Represents how to render an entity class Renderable r render :: Renderable r => Width -> Height -> ScrollPos -> r -> App (Maybe RenderInfo) -- | RenderInfo is the data necessary to render something; it consists of a -- block of text with its associated styles. It is a Monoid and can be -- appended with other RenderInfos. data RenderInfo RenderInfo :: YiString -> Styles -> RenderInfo type ScrollPos = Int -- | Crop text verticaly to only the visible portion according to viewport -- height and scroll position. cropToViewport :: Height -> ScrollPos -> RenderInfo -> RenderInfo -- | Add a style to some text resulting in a RenderInfo styleText :: YiString -> Style -> RenderInfo instance GHC.Base.Monoid Rasa.Internal.Utility.RenderInfo instance Rasa.Internal.Utility.Renderable r => Rasa.Internal.Utility.Renderable (GHC.Base.Maybe r) instance Rasa.Internal.Utility.Renderable Rasa.Internal.Buffer.BufRef instance Rasa.Internal.Utility.Renderable Yi.Rope.YiString instance Rasa.Internal.Utility.Renderable Rasa.Internal.Utility.RenderInfo -- | This module contains the public API for building an extension for -- Rasa. It re-exports the parts of rasa that are public API for creating -- extensions. -- -- There are two main things that an extension can do, either react to -- editor events, or expose useful actions and/or state for other -- extensions to use. -- -- Whether performing its own actions or being used by a different -- extension an extension will want to define some Actions to -- perform. Actions can operate over buffers or even perform IO and -- comprise the main way in which extensons do what they need to do. Read -- more here: Action, BufAction. -- -- To sum it all up, Here's an example of a simple logging extension that -- simply writes each keypress to a file. -- --
--   logKeypress :: Keypress -> Action ()
--   logKeypress (Keypress char _) = liftIO $ appendFile "logs" ("You pressed " ++ [char] ++ "\n")
--   logKeypress _ = return ()
--   
--   logger :: Action ()
--   logger = do
--     liftIO $ writeFile "logs" "==Logs==\n"
--     onKeypress logKeypress
--     onExit $ liftIO $ appendFile "logs" "==Done=="
--   
-- -- Check out this tutorial on building extensions, it's also just a great -- way to learn how the editor works: Extension-Guide. module Rasa.Ext -- | Retrieve a buffer. This is read-only for -- loggingrenderingdebugging purposes only. getBuffer :: BufRef -> App (Maybe Buffer) -- | Adds a new buffer and returns the BufRef addBuffer :: YiString -> App BufRef -- | Gets BufRef that comes after the one provided nextBufRef :: BufRef -> App BufRef -- | Gets BufRef that comes before the one provided prevBufRef :: BufRef -> App BufRef -- | Returns an up-to-date list of all BufRefs getBufRefs :: App [BufRef] -- | A buffer, holds the text in the buffer and any extension states that -- are set on the buffer. data Buffer -- | This allows creation of polymorphic lenses over any type which has -- access to a Buffer class HasBuffer a buffer :: HasBuffer a => Lens' a Buffer -- | An opaque reference to a buffer. When operating over a BufRef Rasa -- checks if the Buffer still exists and simply ignores any -- operations over non-existent buffers; typically returning -- Nothing data BufRef -- | This lens focuses the text of the in-scope buffer. text :: HasBuffer b => Lens' b YiString -- | Returns the text of the current buffer getText :: BufAction YiString -- | Gets the range of text from the buffer getRange :: CrdRange -> BufAction YiString -- | Gets the current buffer's BufRef getBufRef :: BufAction BufRef type BufAction a = Action Buffer a -- | This lifts a BufAction to an App which performs the -- BufAction on the buffer referred to by the BufRef If the -- buffer referred to no longer exists this returns: Nothing. bufDo :: BufRef -> BufAction a -> App (Maybe a) bufDo_ :: BufRef -> BufAction a -> App () -- | This lifts a BufAction to an App which performs the -- BufAction on every buffer and collects the return values as a -- list. buffersDo :: BufAction a -> App [a] buffersDo_ :: BufAction a -> App () -- | Runs function over given range of text overRange :: CrdRange -> (YiString -> YiString) -> BufAction () -- | Replaces the text in the given range with the given text. replaceRange :: CrdRange -> YiString -> BufAction () -- | Deletes the text in the given range from the buffer. deleteRange :: CrdRange -> BufAction () -- | Inserts text into the buffer at the given Coord. insertAt :: Coord -> YiString -> BufAction () -- | Returns the number of rows and columns that a chunk of text spans as a -- Coord sizeOf :: YiString -> Coord -- | Gets the range representing a given row (if that row exists) getLineRange :: Row -> BufAction (Maybe CrdRange) -- | Retrieve some buffer extension state getBufExt :: (Typeable s, Show s, Default s) => BufAction s -- | Set some buffer extension state setBufExt :: (Typeable s, Show s, Default s) => s -> BufAction () -- | Set some buffer extension state overBufExt :: (Typeable s, Show s, Default s) => (s -> s) -> BufAction () -- | Dispatches an event of any type to the BufAction's buffer. See -- dispatchEvent dispatchBufEvent :: (Monoid result, Typeable eventType, Typeable result) => (eventType -> BufAction result) -- | Adds a listener to the BufAction's buffer. See addListener addBufListener :: (Typeable eventType, Typeable result, Monoid result) => (eventType -> BufAction result) -> BufAction ListenerId addBufListener_ :: (Typeable eventType, Typeable result, Monoid result) => (eventType -> BufAction result) -> BufAction () -- | Removes a listener from the BufAction's buffer. See -- removeListener removeBufListener :: ListenerId -> BufAction () -- | This event is dispatched in response to keyboard key presses. It -- contains both the char that was pressed and any modifiers (Mod) -- that where held when the key was pressed. data Keypress Keypress :: Char -> [Mod] -> Keypress KEsc :: [Mod] -> Keypress KBS :: [Mod] -> Keypress KEnter :: [Mod] -> Keypress KLeft :: [Mod] -> Keypress KRight :: [Mod] -> Keypress KUp :: [Mod] -> Keypress KDown :: [Mod] -> Keypress KPrtScr :: [Mod] -> Keypress KHome :: [Mod] -> Keypress KPageUp :: [Mod] -> Keypress KDel :: [Mod] -> Keypress KEnd :: [Mod] -> Keypress KPageDown :: [Mod] -> Keypress KUnknown :: Keypress -- | This represents each modifier key that could be pressed along with a -- key. data Mod Ctrl :: Mod Alt :: Mod Shift :: Mod Meta :: Mod -- | Dispatch a Keypress event. dispatchKeypress :: Keypress -> App () -- | This event is dispatched after adding a new buffer. The contained -- BufRef refers to the new buffer. data BufAdded BufAdded :: BufRef -> BufAdded -- | This is triggered when text in a buffer is changed. The Event data -- includes the CrdRange that changed and the new text which is -- now contined in that range. data BufTextChanged BufTextChanged :: CrdRange -> YiString -> BufTextChanged -- | Registers an action to be performed BEFORE each render phase. -- -- This is a good spot to add information useful to the renderer since -- all actions have been performed. Only cosmetic changes should occur -- during this phase. beforeEveryRender :: App a -> App ListenerId beforeEveryRender_ :: App a -> App () -- | Registers an action to be performed during each render phase. -- -- This phase should only be used by extensions which actually render -- something. onEveryRender :: App a -> App ListenerId onEveryRender_ :: App a -> App () -- | Registers an action to be performed AFTER each render phase. -- -- This is useful for cleaning up extension state that was registered for -- the renderer, but needs to be cleared before the next iteration. afterEveryRender :: App a -> App ListenerId afterEveryRender_ :: App a -> App () -- | Registers an action to be performed after a new buffer is added. -- -- The supplied function will be called with a BufRef to the new -- buffer, and the resulting App will be run. onBufAdded :: (BufAdded -> App result) -> App ListenerId onBufAdded_ :: (BufAdded -> App result) -> App () -- | Run the given BufAction over all new buffers onEveryNewBuffer :: BufAction a -> App ListenerId onEveryNewBuffer_ :: BufAction a -> App () -- | This is fired every time text in a buffer changes. -- -- The range of text which was altered and the new value of that text are -- provided inside a BufTextChanged event. onBufTextChanged :: (BufTextChanged -> BufAction result) -> BufAction ListenerId -- | Trigger an App on a Keypress onKeypress :: (Keypress -> App result) -> App ListenerId -- | This represents a range between two coordinates (Coord) data Range a b Range :: a -> b -> Range a b [_rStart] :: Range a b -> a [_rEnd] :: Range a b -> b -- | A type alias to Range' which specializes the types to -- Coords. type CrdRange = Range Coord Coord -- | A type alias to Coord' which specializes the types to integers. type Coord = Coord' Int Int -- | (Coord Row Column) represents a char in a block of text. (zero -- indexed) e.g. Coord 0 0 is the first character in the text, Coord 2 1 -- is the second character of the third row data Coord' a b Coord :: a -> b -> Coord' a b [_coordRow] :: Coord' a b -> a [_coordCol] :: Coord' a b -> b -- | An Offset represents an exact position in a file as a number of -- characters from the start. newtype Offset Offset :: Int -> Offset -- | A span which maps a piece of Monoidal data over a range. data Span a b Span :: a -> b -> Span a b -- | Applies a function over the row of a Coord overRow :: (Int -> Int) -> Coord -> Coord -- | Applies a function over the column of a Coord overCol :: (Int -> Int) -> Coord -> Coord coordRow :: forall a_agqk b_agql a_agzi. Lens (Coord' a_agqk b_agql) (Coord' a_agzi b_agql) a_agqk a_agzi coordCol :: forall a_agqk b_agql b_agzh. Lens (Coord' a_agqk b_agql) (Coord' a_agqk b_agzh) b_agql b_agzh -- | Applies a function over both functors in any Bifunctor. overBoth :: Bifunctor f => (a -> b) -> f a a -> f b b -- | Combines a list of spans containing some monoidal data into a list of -- offsets with with the data that applies from each Offset forwards. combineSpans :: forall a. Monoid a => [Span CrdRange a] -> [(Coord, a)] -- | Given the text you're operating over, creates an iso from an -- Offset to a Coord. asCoord :: YiString -> Iso' Offset Coord -- | This will restrict a given Coord to a valid one which lies -- within the given text. clampCoord :: YiString -> Coord -> Coord -- | This will restrict a given Range to a valid one which lies -- within the given text. clampRange :: YiString -> CrdRange -> CrdRange rStart :: forall a_aelx b_aely a_agh2. Lens (Range a_aelx b_aely) (Range a_agh2 b_aely) a_aelx a_agh2 rEnd :: forall a_aelx b_aely b_agh1. Lens (Range a_aelx b_aely) (Range a_aelx b_agh1) b_aely b_agh1 -- | Returns the number of rows and columns that a Range spans as a -- Coord sizeOfR :: CrdRange -> Coord -- | A lens over text after a given Coord afterC :: Coord -> Lens' YiString YiString -- | A lens over text before a given Coord beforeC :: Coord -> Lens' YiString YiString -- | Moves a Range by a given Coord It may be unintuitive, -- but for (Coord row col) a given range will be moved down by row and to -- the right by col. moveRange :: Coord -> CrdRange -> CrdRange -- | Moves a range forward by the given amount moveRangeByN :: Int -> CrdRange -> CrdRange -- | Moves a Coord forward by the given amount of columns moveCursorByN :: Int -> Coord -> Coord -- | Create a new Style with the given Color as the -- foreground. fg :: Color -> Style -- | Create a new Style with the given Color as the -- background. bg :: Color -> Style -- | Create a new Style with the given Flair as its flair. flair :: Flair -> Style -- | These represent the possible colors for fg or bg. -- DefColor represents the renderer's default color. data Color Black :: Color Red :: Color Green :: Color Yellow :: Color Blue :: Color Magenta :: Color Cyan :: Color White :: Color DefColor :: Color -- | These represent the possible extra attributes which may be applied. -- DefFlair represents the renderer's default text attributes. data Flair Standout :: Flair Underline :: Flair ReverseVideo :: Flair Blink :: Flair Dim :: Flair Bold :: Flair DefFlair :: Flair -- | A container which holds a foreground color, background color, and a -- flair. a Nothing represents that we should not change that -- attribute. newtype Style Style :: (Maybe Color, Maybe Color, Maybe Flair) -> Style type Styles = [Span CrdRange Style] -- | Pass this a BufAction which computes styles based on the -- current buffer and they'll be collected for the renderer. addStyleProvider :: BufAction Styles -> BufAction ListenerId -- | Collect all provided styles, this is useful for renderers. getStyles :: BufAction Styles -- | Add a style to some text resulting in a RenderInfo styleText :: YiString -> Style -> RenderInfo -- | An iso which converts to/from YiString -> Text asText :: Iso' YiString Text -- | An iso which converts to/from YiString -> String asString :: Iso' YiString String -- | An iso which converts to/from YiString -> [YiString] asLines :: Iso' YiString [YiString] -- | clamp min max val restricts val to be within min and max -- (inclusive) clamp :: Int -> Int -> Int -> Int -- | Crop text verticaly to only the visible portion according to viewport -- height and scroll position. cropToViewport :: Height -> ScrollPos -> RenderInfo -> RenderInfo type Width = Int type Height = Int type ScrollPos = Int -- | RenderInfo is the data necessary to render something; it consists of a -- block of text with its associated styles. It is a Monoid and can be -- appended with other RenderInfos. data RenderInfo RenderInfo :: YiString -> Styles -> RenderInfo -- | Represents how to render an entity class Renderable r render :: Renderable r => Width -> Height -> ScrollPos -> r -> App (Maybe RenderInfo) module Rasa -- | The main function to run rasa. -- --
--   rasa eventProviders extensions
--   
-- -- This should be imported by a user-config with and called with an -- Action containing any extensions which have event listeners. -- --
--   rasa $ do
--     cursor
--     vim
--     slate
--   
rasa :: App () -> IO ()