yi-core-0.19.4: Yi editor core library

License | GPL-2
Maintainer | yi-devel@googlegroups.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Extensions

- TemplateHaskell
- TemplateHaskellQuotes
- OverloadedStrings
- LambdaCase

Yi.Editor

Contents

- Orphan instances

Description

The top level editor state, and operations on it. This is inside an internal module for easy re-export with Yi.Types bits.

Synopsis

- data Editor = Editor {
  - bufferStack :: !(NonEmpty BufferRef)
  - buffers :: !(Map BufferRef FBuffer)
  - refSupply :: !Int
  - tabs_ :: !(PointedList Tab)
  - dynamic :: !DynamicState
  - statusLines :: !Statuses
  - maxStatusHeight :: !Int
  - killring :: !Killring
  - currentRegex :: !(Maybe SearchExp)
  - searchDirection :: !Direction
  - pendingEvents :: ![Event]
  - onCloseActions :: !(Map BufferRef (EditorM ()))
  }
- data EditorM a
- class (Monad m, MonadState Editor m) => MonadEditor (m :: Type -> Type) where
  - askCfg :: m Config
  - withEditor :: EditorM a -> m a
  - withEditor_ :: EditorM a -> m ()
- runEditor :: Config -> EditorM a -> Editor -> (Editor, a)
- acceptedInputsOtherWindow :: EditorM ()
- addJumpAtE :: Point -> EditorM ()
- addJumpHereE :: EditorM ()
- alternateBufferE :: Int -> EditorM ()
- askConfigVariableA :: (YiConfigVariable b, MonadEditor m) => m b
- bufferSet :: Editor -> [FBuffer]
- buffersA :: Lens' Editor (Map BufferRef FBuffer)
- closeBufferAndWindowE :: EditorM ()
- closeBufferE :: Text -> EditorM ()
- closeOtherE :: EditorM ()
- clrStatus :: EditorM ()
- commonNamePrefix :: Editor -> [FilePath]
- currentBuffer :: Editor -> BufferRef
- currentRegexA :: Lens' Editor (Maybe SearchExp)
- currentWindowA :: Lens' Editor Window
- deleteBuffer :: MonadEditor m => BufferRef -> m ()
- deleteTabE :: EditorM ()
- doesBufferNameExist :: Text -> Editor -> Bool
- emptyEditor :: Editor
- findBuffer :: MonadEditor m => BufferRef -> m (Maybe FBuffer)
- findBufferWith :: BufferRef -> Editor -> FBuffer
- findBufferWithName :: Text -> Editor -> [BufferRef]
- findWindowWith :: WindowRef -> Editor -> Window
- focusWindowE :: WindowRef -> EditorM ()
- getBufferStack :: MonadEditor m => m (NonEmpty FBuffer)
- getBufferWithName :: MonadEditor m => Text -> m BufferRef
- getBufferWithNameOrCurrent :: MonadEditor m => Text -> m BufferRef
- getEditorDyn :: (MonadEditor m, YiVariable a, Default a, Functor m) => m a
- getRegE :: EditorM YiString
- jumpBackE :: EditorM ()
- jumpForwardE :: EditorM ()
- killringA :: Lens' Editor Killring
- layoutManagerNextVariantE :: EditorM ()
- layoutManagerPreviousVariantE :: EditorM ()
- layoutManagersNextE :: EditorM ()
- layoutManagersPreviousE :: EditorM ()
- layoutManagersPrintMsgE :: EditorM ()
- maxStatusHeightA :: Lens' Editor Int
- moveTabE :: Maybe Int -> EditorM ()
- moveWinNextE :: EditorM ()
- moveWinPrevE :: EditorM ()
- newBufferE :: BufferId -> YiString -> EditorM BufferRef
- newEmptyBufferE :: BufferId -> EditorM BufferRef
- newTabE :: EditorM ()
- newTempBufferE :: EditorM BufferRef
- newWindowE :: Bool -> BufferRef -> EditorM Window
- nextTabE :: EditorM ()
- nextWinE :: EditorM ()
- onCloseActionsA :: Lens' Editor (Map BufferRef (EditorM ()))
- pendingEventsA :: Lens' Editor [Event]
- prevWinE :: EditorM ()
- previousTabE :: EditorM ()
- printMsg :: MonadEditor m => Text -> m ()
- printMsgs :: MonadEditor m => [Text] -> m ()
- printStatus :: MonadEditor m => Status -> m ()
- pushWinToFirstE :: EditorM ()
- putEditorDyn :: (MonadEditor m, YiVariable a, Functor m) => a -> m ()
- searchDirectionA :: Lens' Editor Direction
- setDividerPosE :: DividerRef -> DividerPosition -> EditorM ()
- setRegE :: YiString -> EditorM ()
- setStatus :: MonadEditor m => Status -> m ()
- shiftOtherWindow :: MonadEditor m => m ()
- splitE :: EditorM ()
- statusLine :: Editor -> [Text]
- statusLineInfo :: Editor -> Status
- statusLinesA :: Lens' Editor Statuses
- stringToNewBuffer :: MonadEditor m => BufferId -> YiString -> m BufferRef
- swapWinWithFirstE :: EditorM ()
- switchToBufferE :: BufferRef -> EditorM ()
- switchToBufferWithNameE :: Text -> EditorM ()
- tabsA :: Lens' Editor (PointedList Tab)
- tryCloseE :: EditorM ()
- windows :: Editor -> PointedList Window
- windowsA :: Lens' Editor (PointedList Window)
- windowsOnBufferE :: BufferRef -> EditorM [Window]
- withCurrentBuffer :: MonadEditor m => BufferM a -> m a
- withEveryBuffer :: MonadEditor m => BufferM a -> m [a]
- withGivenBuffer :: MonadEditor m => BufferRef -> BufferM a -> m a
- withGivenBufferAndWindow :: MonadEditor m => Window -> BufferRef -> BufferM a -> m a
- withOtherWindow :: MonadEditor m => m a -> m a
- withWindowE :: Window -> BufferM a -> EditorM a

# Documentation

data Editor Source #

The Editor state

Constructors

Editor |

Fields

- bufferStack :: !(NonEmpty BufferRef)

  Stack of all the buffers. Invariant: first buffer is the current one.

- buffers :: !(Map BufferRef FBuffer)
- refSupply :: !Int

  Supply for buffer, window and tab ids.

- tabs_ :: !(PointedList Tab)

  current tab contains the visible windows pointed list.

- dynamic :: !DynamicState

  dynamic components

- statusLines :: !Statuses
- maxStatusHeight :: !Int
- killring :: !Killring
- currentRegex :: !(Maybe SearchExp)

  currently highlighted regex (also most recent regex for use in vim bindings)

- searchDirection :: !Direction
- pendingEvents :: ![Event]

  Processed events that didn't yield any action yet.

- onCloseActions :: !(Map BufferRef (EditorM ()))

  Actions to be run when the buffer is closed; should be scrapped.

#### Instances

Instances details

Binary Editor Source # |
Instance details Defined in Yi.Editor Methods put :: Editor -> Put Source # get :: Get Editor Source # putList :: [Editor] -> Put Source #
MonadState Editor EditorM Source # |
Instance details Defined in Yi.Types Methods get :: EditorM Editor Source # put :: Editor -> EditorM () Source # state :: (Editor -> (a, Editor)) -> EditorM a Source #
MonadState Editor YiM Source # |
Instance details Defined in Yi.Types Methods get :: YiM Editor Source # put :: Editor -> YiM () Source # state :: (Editor -> (a, Editor)) -> YiM a Source #

data EditorM a Source #

#### Instances

Instances details

Applicative EditorM Source # |
Instance details Defined in Yi.Types Methods pure :: a -> EditorM a Source # (<*>) :: EditorM (a -> b) -> EditorM a -> EditorM b Source # liftA2 :: (a -> b -> c) -> EditorM a -> EditorM b -> EditorM c Source # (*>) :: EditorM a -> EditorM b -> EditorM b Source # (<*) :: EditorM a -> EditorM b -> EditorM a Source #
Functor EditorM Source # |
Instance details Defined in Yi.Types Methods fmap :: (a -> b) -> EditorM a -> EditorM b Source # (<$) :: a -> EditorM b -> EditorM a Source #
Monad EditorM Source # |
Instance details Defined in Yi.Types Methods (>>=) :: EditorM a -> (a -> EditorM b) -> EditorM b Source # (>>) :: EditorM a -> EditorM b -> EditorM b Source # return :: a -> EditorM a Source #
MonadFail EditorM Source # |
Instance details Defined in Yi.Types Methods fail :: String -> EditorM a Source #
MonadEditor EditorM Source # |
Instance details Defined in Yi.Types Methods askCfg :: EditorM Config Source # withEditor :: EditorM a -> EditorM a Source # withEditor_ :: EditorM a -> EditorM () Source #
MonadReader Config EditorM Source # |
Instance details Defined in Yi.Types Methods ask :: EditorM Config Source # local :: (Config -> Config) -> EditorM a -> EditorM a Source # reader :: (Config -> a) -> EditorM a Source #
MonadState Editor EditorM Source # |
Instance details Defined in Yi.Types Methods get :: EditorM Editor Source # put :: Editor -> EditorM () Source # state :: (Editor -> (a, Editor)) -> EditorM a Source #
HookType (EditorM a) Source # |
Instance details Defined in Yi.Hooks Methods runHookImpl :: YiConfigVariable var => (var -> EditorM a) -> EditorM a
YiAction (EditorM x) x Source # |
Instance details Defined in Yi.Keymap Methods makeAction :: EditorM x -> Action Source #

class (Monad m, MonadState Editor m) => MonadEditor (m :: Type -> Type) where Source #

Minimal complete definition

askCfg

Methods

askCfg :: m Config Source #

withEditor :: EditorM a -> m a Source #

withEditor_ :: EditorM a -> m () Source #

#### Instances

Instances details

MonadEditor EditorM Source # |
Instance details Defined in Yi.Types Methods askCfg :: EditorM Config Source # withEditor :: EditorM a -> EditorM a Source # withEditor_ :: EditorM a -> EditorM () Source #
MonadEditor YiM Source # |
Instance details Defined in Yi.Types Methods askCfg :: YiM Config Source # withEditor :: EditorM a -> YiM a Source # withEditor_ :: EditorM a -> YiM () Source #

runEditor :: Config -> EditorM a -> Editor -> (Editor, a) Source #

acceptedInputsOtherWindow :: EditorM () Source #

Shows the current key bindings in a new window

addJumpAtE :: Point -> EditorM () Source #

addJumpHereE :: EditorM () Source #

alternateBufferE :: Int -> EditorM () Source #

askConfigVariableA :: (YiConfigVariable b, MonadEditor m) => m b Source #

bufferSet :: Editor -> [FBuffer] Source #

Return the buffers we have, in no particular order

buffersA :: Lens' Editor (Map BufferRef FBuffer) Source #

closeBufferAndWindowE :: EditorM () Source #

Close current buffer and window, unless it's the last one.

closeBufferE :: Text -> EditorM () Source #

Close a buffer. Note: close the current buffer if the empty string is given

closeOtherE :: EditorM () Source #

Make the current window the only window on the screen

clrStatus :: EditorM () Source #

Clear the status line

commonNamePrefix :: Editor -> [FilePath] Source #

Return a prefix that can be removed from all buffer paths while keeping them unique.

currentBuffer :: Editor -> BufferRef Source #

Return the current buffer

currentRegexA :: Lens' Editor (Maybe SearchExp) Source #

currentWindowA :: Lens' Editor Window Source #

deleteBuffer :: MonadEditor m => BufferRef -> m () Source #

Delete a buffer (and release resources associated with it).

deleteTabE :: EditorM () Source #

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.

doesBufferNameExist :: Text -> Editor -> Bool Source #

emptyEditor :: Editor Source #

The initial state

findBuffer :: MonadEditor m => BufferRef -> m (Maybe FBuffer) Source #

findBufferWith :: BufferRef -> Editor -> FBuffer Source #

Find buffer with this key

findBufferWithName :: Text -> Editor -> [BufferRef] Source #

Find buffers with this name

findWindowWith :: WindowRef -> Editor -> Window Source #

focusWindowE :: WindowRef -> EditorM () Source #

bring the editor focus the window with the given key.

Fails if no window with the given key is found.

getBufferStack :: MonadEditor m => m (NonEmpty FBuffer) Source #

getBufferWithName :: MonadEditor m => Text -> m BufferRef Source #

Find buffer with given name. Fail if not found.

getBufferWithNameOrCurrent :: MonadEditor m => Text -> m BufferRef Source #

getEditorDyn :: (MonadEditor m, YiVariable a, Default a, Functor m) => m a Source #

Dynamically-extensible state components.

These hooks are used by keymaps to store values that result from Actions (i.e. that result 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

getRegE :: EditorM YiString Source #

Return the contents of the yank register

jumpBackE :: EditorM () Source #

jumpForwardE :: EditorM () Source #

killringA :: Lens' Editor Killring Source #

layoutManagerNextVariantE :: EditorM () Source #

Next variant of the current layout manager, as given by `nextVariant`

layoutManagerPreviousVariantE :: EditorM () Source #

Previous variant of the current layout manager, as given by `previousVariant`

layoutManagersNextE :: EditorM () Source #

Cycle to the next layout manager, or the first one if the current one is nonstandard.

layoutManagersPreviousE :: EditorM () Source #

Cycle to the previous layout manager, or the first one if the current one is nonstandard.

layoutManagersPrintMsgE :: EditorM () Source #

Prints the description of the current layout manager in the status bar

maxStatusHeightA :: Lens' Editor Int Source #

moveTabE :: Maybe Int -> EditorM () Source #

Moves the focused tab to the given index, or to the end if the index is not specified.

moveWinNextE :: EditorM () Source #

Swap focused window with the next one

moveWinPrevE :: EditorM () Source #

Swap focused window with the previous one

newBufferE Source #

Arguments

:: BufferId | buffer name
-> YiString | buffer contents
-> EditorM BufferRef |

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)

newEmptyBufferE :: BufferId -> EditorM BufferRef Source #

Like `newBufferE` but defaults to empty contents.

newTabE :: EditorM () Source #

Creates a new tab containing a window that views the current buffer.

newTempBufferE :: EditorM BufferRef Source #

Creates an in-memory buffer with a unique name.

newWindowE :: Bool -> BufferRef -> EditorM Window Source #

Create a new window onto the given buffer.

nextTabE :: EditorM () Source #

Moves to the next tab in the round robin set of tabs

nextWinE :: EditorM () Source #

Rotate focus to the next window

onCloseActionsA :: Lens' Editor (Map BufferRef (EditorM ())) Source #

pendingEventsA :: Lens' Editor [Event] Source #

prevWinE :: EditorM () Source #

Rotate focus to the previous window

previousTabE :: EditorM () Source #

Moves to the previous tab in the round robin set of tabs

printMsg :: MonadEditor m => Text -> m () Source #

Prints a message with `defaultStyle`.

printMsgs :: MonadEditor m => [Text] -> m () Source #

Prints a all given messages with `defaultStyle`.

printStatus :: MonadEditor m => Status -> m () Source #

pushWinToFirstE :: EditorM () Source #

Moves the focused window to the first window, and moves all other windows down the stack.

putEditorDyn :: (MonadEditor m, YiVariable a, Functor m) => a -> m () Source #

Insert a value into the extensible state, keyed by its type

searchDirectionA :: Lens' Editor Direction Source #

setDividerPosE :: DividerRef -> DividerPosition -> EditorM () Source #

Sets the given divider position on the current tab

setRegE :: YiString -> EditorM () Source #

Put string into yank register

setStatus :: MonadEditor m => Status -> m () Source #

Set the "background" status line

shiftOtherWindow :: MonadEditor m => m () Source #

Switch focus to some other window. If none is available, create one.

splitE :: EditorM () Source #

Split the current window, opening a second window onto current buffer. TODO: unfold newWindowE here?

statusLine :: Editor -> [Text] Source #

statusLineInfo :: Editor -> Status Source #

statusLinesA :: Lens' Editor Statuses Source #

stringToNewBuffer Source #

Arguments

:: MonadEditor m |
=> BufferId | The buffer indentifier
-> YiString | The contents with which to populate the buffer
-> m 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.

swapWinWithFirstE :: EditorM () Source #

Swaps the focused window with the first window. Useful for layouts such as `HPairOneStack`, for which the first window is the largest.

switchToBufferE :: BufferRef -> EditorM () Source #

Attach the specified buffer to the current window

switchToBufferWithNameE :: Text -> EditorM () Source #

Switch to the buffer specified as parameter. If the buffer name is empty, switch to the next buffer.

tabsA :: Lens' Editor (PointedList Tab) Source #

tryCloseE :: EditorM () Source #

Close the current window. If there is only one tab open and the tab contains only one window then do nothing.

windows :: Editor -> PointedList Window Source #

windowsA :: Lens' Editor (PointedList Window) Source #

windowsOnBufferE :: BufferRef -> EditorM [Window] Source #

Return the windows that are currently open on the buffer whose key is given

withCurrentBuffer :: MonadEditor m => BufferM a -> m a Source #

Perform action with current window's buffer

withEveryBuffer :: MonadEditor m => BufferM a -> m [a] Source #

withGivenBuffer :: MonadEditor m => BufferRef -> BufferM a -> m a Source #

Perform action with any given buffer, using the last window that was used for that buffer.

withGivenBufferAndWindow :: MonadEditor m => Window -> BufferRef -> BufferM a -> m a Source #

Perform action with any given buffer

withOtherWindow :: MonadEditor m => m a -> m a Source #

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.

withWindowE :: Window -> BufferM a -> EditorM a Source #

# Orphan instances

Binary Editor Source # |
Instance details Methods put :: Editor -> Put Source # get :: Get Editor Source # putList :: [Editor] -> Put Source #