License | GPL-2 |
---|---|
Maintainer | yi-devel@googlegroups.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Extensions |
|
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 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
The Editor state
Editor | |
|
Instances
MonadFail EditorM Source # | |
Applicative EditorM Source # | |
Functor EditorM Source # | |
Monad EditorM Source # | |
MonadEditor EditorM Source # | |
MonadReader Config EditorM Source # | |
MonadState Editor EditorM Source # | |
HookType (EditorM a) Source # | |
Defined in Yi.Hooks runHookImpl :: YiConfigVariable var => (var -> EditorM a) -> EditorM a | |
YiAction (EditorM x) x Source # | |
class (Monad m, MonadState Editor m) => MonadEditor m where Source #
withEditor :: EditorM a -> m a Source #
withEditor_ :: EditorM a -> m () Source #
Instances
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 #
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
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
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.
emptyEditor :: Editor Source #
The initial state
findBuffer :: MonadEditor m => BufferRef -> m (Maybe FBuffer) 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
jumpForwardE :: EditorM () 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
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
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.
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.
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
setDividerPosE :: DividerRef -> DividerPosition -> EditorM () Source #
Sets the given divider position on the current tab
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.
Split the current window, opening a second window onto current buffer. TODO: unfold newWindowE here?
statusLine :: Editor -> [Text] Source #
statusLineInfo :: Editor -> Status Source #
:: 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.
tryCloseE :: EditorM () Source #
Close the current window. If there is only one tab open and the tab contains only one window then do nothing.
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.