yi-0.6.2.3: The Haskell-Scriptable EditorSource codeContentsIndex
Yi.Editor
Description
The top level editor state, and operations on it.
Synopsis
type Status = ([String], StyleName)
type Statuses = DelayList Status
data Editor = Editor {
bufferStack :: ![BufferRef]
buffers :: !(Map BufferRef FBuffer)
refSupply :: !Int
tabs_ :: !(PointedList (PointedList Window))
dynamic :: !DynamicValues
statusLines :: !Statuses
maxStatusHeight :: !Int
killring :: !Killring
currentRegex :: !(Maybe SearchExp)
searchDirection :: !Direction
pendingEvents :: ![Event]
onCloseActions :: !(Map BufferRef (EditorM ()))
}
newtype EditorM a = EditorM {
fromEditorM :: RWS Config () Editor a
}
class (Monad m, MonadState Editor m) => MonadEditor m where
askCfg :: m Config
withEditor :: EditorM a -> m a
liftEditor :: MonadEditor m => EditorM a -> m a
emptyEditor :: Editor
runEditor :: Config -> EditorM a -> Editor -> (Editor, a)
onCloseActionsA :: T Editor (Map BufferRef (EditorM ()))
pendingEventsA :: T Editor ([] Event)
searchDirectionA :: T Editor Direction
currentRegexA :: T Editor (Maybe SearchExp)
killringA :: T Editor Killring
maxStatusHeightA :: T Editor Int
statusLinesA :: T Editor Statuses
dynamicA :: T Editor DynamicValues
tabs_A :: T Editor (PointedList (PointedList Window))
refSupplyA :: T Editor Int
buffersA :: T Editor (Map BufferRef FBuffer)
bufferStackA :: T Editor ([] BufferRef)
windows :: Editor -> PointedList Window
windowsA :: Accessor Editor (PointedList Window)
tabsA :: Accessor Editor (PointedList (PointedList Window))
dynA :: Initializable a => Accessor Editor a
newRef :: EditorM Int
newBufRef :: EditorM BufferRef
stringToNewBuffer :: BufferId -> Rope -> EditorM BufferRef
insertBuffer :: FBuffer -> EditorM ()
forceFold1 :: Foldable t => t a -> t a
forceFold2 :: (Foldable t1, Foldable t2) => t1 (t2 a) -> t1 (t2 a)
deleteBuffer :: BufferRef -> EditorM ()
bufferSet :: Editor -> [FBuffer]
commonNamePrefix :: Editor -> [String]
getBufferStack :: EditorM [FBuffer]
findBuffer :: BufferRef -> EditorM (Maybe FBuffer)
findBufferWith :: BufferRef -> Editor -> FBuffer
findBufferWithName :: String -> Editor -> [BufferRef]
getBufferWithName :: String -> EditorM BufferRef
openAllBuffersE :: EditorM ()
shiftBuffer :: Int -> EditorM ()
withGivenBuffer0 :: BufferRef -> BufferM a -> EditorM a
withGivenBufferAndWindow0 :: Window -> BufferRef -> BufferM a -> EditorM a
withBuffer0 :: BufferM a -> EditorM a
currentWindowA :: Accessor Editor Window
currentBuffer :: Editor -> BufferRef
printMsg :: String -> EditorM ()
printMsgs :: [String] -> EditorM ()
printStatus :: Status -> EditorM ()
setStatus :: Status -> EditorM ()
clrStatus :: EditorM ()
statusLine :: Editor -> [String]
statusLineInfo :: Editor -> Status
setTmpStatus :: Int -> Status -> EditorM ()
setRegE :: String -> EditorM ()
getRegE :: EditorM String
getDynamic :: Initializable a => EditorM a
setDynamic :: Initializable a => a -> EditorM ()
nextBufW :: EditorM ()
prevBufW :: EditorM ()
newBufferE :: BufferId -> Rope -> EditorM BufferRef
newTempBufferE :: EditorM BufferRef
data TempBufferNameHint = TempBufferNameHint {
tmp_name_base :: String
tmp_name_index :: Int
}
alternateBufferE :: Int -> EditorM ()
newWindowE :: Bool -> BufferRef -> EditorM Window
switchToBufferE :: BufferRef -> EditorM ()
switchToBufferOtherWindowE :: BufferRef -> EditorM ()
switchToBufferWithNameE :: String -> EditorM ()
closeBufferE :: String -> EditorM ()
getBufferWithNameOrCurrent :: String -> EditorM BufferRef
closeBufferAndWindowE :: EditorM ()
nextWinE :: EditorM ()
prevWinE :: EditorM ()
fixCurrentBufferA_ :: Accessor Editor Editor
fixCurrentWindow :: EditorM ()
withWindowE :: Window -> BufferM a -> EditorM a
findWindowWith :: WindowRef -> Editor -> Window
windowsOnBufferE :: BufferRef -> EditorM [Window]
focusWindowE :: WindowRef -> EditorM ()
splitE :: EditorM ()
enlargeWinE :: EditorM ()
shrinkWinE :: EditorM ()
newTabE :: EditorM ()
nextTabE :: EditorM ()
previousTabE :: EditorM ()
moveTab :: Maybe Int -> EditorM ()
deleteTabE :: EditorM ()
tryCloseE :: EditorM ()
closeOtherE :: EditorM ()
shiftOtherWindow :: MonadEditor m => m ()
withOtherWindow :: MonadEditor m => m a -> m a
acceptedInputs :: EditorM [String]
onCloseBufferE :: BufferRef -> EditorM () -> EditorM ()
Documentation
type Status = ([String], StyleName)Source
type Statuses = DelayList StatusSource
data Editor Source
The Editor state
Constructors
Editor
bufferStack :: ![BufferRef]Stack of all the buffers. Invariant: never empty Invariant: first buffer is the current one.
buffers :: !(Map BufferRef FBuffer)
refSupply :: !IntSupply for buffer and window ids.
tabs_ :: !(PointedList (PointedList Window))current tab contains the visible windows pointed list.
dynamic :: !DynamicValuesdynamic 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.
show/hide Instances
newtype EditorM a Source
Constructors
EditorM
fromEditorM :: RWS Config () Editor a
show/hide Instances
class (Monad m, MonadState Editor m) => MonadEditor m whereSource
Methods
askCfg :: m ConfigSource
withEditor :: EditorM a -> m aSource
show/hide Instances
liftEditor :: MonadEditor m => EditorM a -> m aSource
emptyEditor :: EditorSource
The initial state
runEditor :: Config -> EditorM a -> Editor -> (Editor, a)Source
onCloseActionsA :: T Editor (Map BufferRef (EditorM ()))Source
pendingEventsA :: T Editor ([] Event)Source
searchDirectionA :: T Editor DirectionSource
currentRegexA :: T Editor (Maybe SearchExp)Source
killringA :: T Editor KillringSource
maxStatusHeightA :: T Editor IntSource
statusLinesA :: T Editor StatusesSource
dynamicA :: T Editor DynamicValuesSource
tabs_A :: T Editor (PointedList (PointedList Window))Source
refSupplyA :: T Editor IntSource
buffersA :: T Editor (Map BufferRef FBuffer)Source
bufferStackA :: T Editor ([] BufferRef)Source
windows :: Editor -> PointedList WindowSource
windowsA :: Accessor Editor (PointedList Window)Source
tabsA :: Accessor Editor (PointedList (PointedList Window))Source
dynA :: Initializable a => Accessor Editor aSource
newRef :: EditorM IntSource
newBufRef :: EditorM BufferRefSource
stringToNewBufferSource
:: BufferIdThe buffer indentifier
-> RopeThe contents with which to populate the buffer
-> 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.
insertBuffer :: FBuffer -> EditorM ()Source
forceFold1 :: Foldable t => t a -> t aSource
forceFold2 :: (Foldable t1, Foldable t2) => t1 (t2 a) -> t1 (t2 a)Source
deleteBuffer :: BufferRef -> EditorM ()Source
Delete a buffer (and release resources associated with it).
bufferSet :: Editor -> [FBuffer]Source
Return the buffers we have, in no particular order
commonNamePrefix :: Editor -> [String]Source
Return a prefix that can be removed from all buffer paths while keeping them unique.
getBufferStack :: EditorM [FBuffer]Source
findBuffer :: BufferRef -> EditorM (Maybe FBuffer)Source
findBufferWith :: BufferRef -> Editor -> FBufferSource
Find buffer with this key
findBufferWithName :: String -> Editor -> [BufferRef]Source
Find buffer with this name
getBufferWithName :: String -> EditorM BufferRefSource
Find buffer with given name. Fail if not found.
openAllBuffersE :: EditorM ()Source
Make all buffers visible by splitting the current window list. FIXME: rename to displayAllBuffersE; make sure buffers are not open twice.
shiftBuffer :: Int -> EditorM ()Source
Rotate the buffer stack by the given amount.
withGivenBuffer0 :: BufferRef -> BufferM a -> EditorM aSource
Perform action with any given buffer, using the last window that was used for that buffer.
withGivenBufferAndWindow0 :: Window -> BufferRef -> BufferM a -> EditorM aSource
Perform action with any given buffer
withBuffer0 :: BufferM a -> EditorM aSource
Perform action with current window's buffer
currentWindowA :: Accessor Editor WindowSource
currentBuffer :: Editor -> BufferRefSource
Return the current buffer
printMsg :: String -> EditorM ()Source
Display a transient message
printMsgs :: [String] -> EditorM ()Source
printStatus :: Status -> EditorM ()Source
setStatus :: Status -> EditorM ()Source
Set the background status line
clrStatus :: EditorM ()Source
Clear the status line
statusLine :: Editor -> [String]Source
statusLineInfo :: Editor -> StatusSource
setTmpStatus :: Int -> Status -> EditorM ()Source
setRegE :: String -> EditorM ()Source
Put string into yank register
getRegE :: EditorM StringSource
Return the contents of the yank register
getDynamic :: Initializable a => EditorM aSource

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

setDynamic :: Initializable a => a -> EditorM ()Source
Insert a value into the extensible state, keyed by its type
nextBufW :: EditorM ()Source
Attach the next buffer in the buffer stack to the current window.
prevBufW :: EditorM ()Source
Attach the previous buffer in the stack list to the current window.
newBufferESource
:: BufferIdbuffer name
-> Ropebuffer 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)
newTempBufferE :: EditorM BufferRefSource

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?

data TempBufferNameHint Source
Specifies the hint for the next temp buffer's name.
Constructors
TempBufferNameHint
tmp_name_base :: String
tmp_name_index :: Int
show/hide Instances
alternateBufferE :: Int -> EditorM ()Source
newWindowE :: Bool -> BufferRef -> EditorM WindowSource
Create a new window onto the given buffer.
switchToBufferE :: BufferRef -> EditorM ()Source
Attach the specified buffer to the current window
switchToBufferOtherWindowE :: BufferRef -> EditorM ()Source
Attach the specified buffer to some other window than the current one
switchToBufferWithNameE :: String -> EditorM ()Source
Switch to the buffer specified as parameter. If the buffer name is empty, switch to the next buffer.
closeBufferE :: String -> EditorM ()Source
Close a buffer. Note: close the current buffer if the empty string is given
getBufferWithNameOrCurrent :: String -> EditorM BufferRefSource
closeBufferAndWindowE :: EditorM ()Source
Close current buffer and window, unless it's the last one.
nextWinE :: EditorM ()Source
Rotate focus to the next window
prevWinE :: EditorM ()Source
Rotate focus to the previous window
fixCurrentBufferA_ :: Accessor Editor EditorSource
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.
fixCurrentWindow :: EditorM ()Source
Counterpart of fixCurrentBufferA_: fix the current window to point to the right buffer.
withWindowE :: Window -> BufferM a -> EditorM aSource
findWindowWith :: WindowRef -> Editor -> WindowSource
windowsOnBufferE :: BufferRef -> EditorM [Window]Source
Return the windows that are currently open on the buffer whose key is given
focusWindowE :: WindowRef -> EditorM ()Source

bring the editor focus the window with the given key.

Fails if no window with the given key is found.

splitE :: EditorM ()Source
Split the current window, opening a second window onto current buffer. TODO: unfold newWindowE here?
enlargeWinE :: EditorM ()Source
Enlarge the current window
shrinkWinE :: EditorM ()Source
Shrink the current window
newTabE :: EditorM ()Source
Creates a new tab containing a window that views the current buffer.
nextTabE :: EditorM ()Source
Moves to the next tab in the round robin set of tabs
previousTabE :: EditorM ()Source
Moves to the previous tab in the round robin set of tabs
moveTab :: Maybe Int -> EditorM ()Source
Moves the focused tab to the given index, or to the end if the index is not specified.
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.
tryCloseE :: EditorM ()Source
Close the current window. If there is only one tab open and the tab contains only one window then do nothing.
closeOtherE :: EditorM ()Source
Make the current window the only window on the screen
shiftOtherWindow :: MonadEditor m => m ()Source
Switch focus to some other window. If none is available, create one.
withOtherWindow :: MonadEditor m => m a -> m aSource
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.
acceptedInputs :: EditorM [String]Source
onCloseBufferE :: BufferRef -> EditorM () -> EditorM ()Source

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.

Produced by Haddock version 2.6.1