Editor Documentation

Namespace: dk.salza.liq.editor 

 

  The editor is the central point of Liquid.
  Most of the data is immutable, but the editor has
  a ref, also called editor. It contains the state of
  the editor.

  Most actions on the editor will replace content of this state
  with a transformed content.

  For example:

    When (forward-char 1) is called, the current buffer will be
    replaced with a new buffer, where the cursor is moved one char
    ahead.

 

get-content
  ([])
  Return the content of the current buffer
  as a string.
get-frame-columns
  ([])
  Get the number of columns in the current frame.
previous-real-buffer-same-window
  ([])
  Navigates to the prevous buffer, but skip over
  buffer with names containing dashes.
dirty-buffers
  ([])
  The names of the dirty buffers as a list.
remove-buffer
  ([buffername])
  
copy-line
  ([])
  Sends the current line to the clipboard.
buffer-names
  ([])
  The names of the buffers as a list
quit
  ([])
  
request-fullupdate
  ([])
  Used notify the ui to do a full updated.
create-buffer-from-file
  ([filepath])
  Creates a new buffer, connects it to the
  given filepath and loads the content into
  the buffer.
top-of-window
  Atom to keep track of the position
  of the first char visible in a window.
  Keys are generated from window and buffer
  names.
selection-toggle
  ([])
  If something is selected, the selection
  will be cancelled.
  If nothing is selected a selection
  will be initiated.
forward-line
  ([])
  Moves cursor forward one line
  in the current active buffer.
new-buffer
  ([name])
  Create a new buffer with the given name.
  The buffer will be set as the current buffer
  in the current window.
  Default highlighter and keymaps are assign.
  They can be overridden afterwards.
set-default-app
  ([app])
  Set the default app to be used when a new
  buffer is created.
get-selection
  ([])
  Get current selected text as a string.
  Returns nil if nothing is selected.
updates
  Variable to be increased when updates
  are done to the editor, to allow easy
  check if redraw is needed.
backward-line
  ([])
  Moves cursor backward one line
  in the current active buffer.
delete-selection
  ([])
  If there is a selection, the selected
  content will be deleted.
search-files
  ([search])
  
point-to-mark
  ([name])
  Move the point to the mark on the current buffer.
get-default-highlighter
  ([])
  Get the default highlighter function.
  Mostly used to set highlight on buffer
  until some is set by user or app.
switch-to-buffer
  ([buffername])
  Switch to the buffer with the given name.
add-window
  ([window] [name top left rows columns buffername])
  Add a window to the editor.
  It takes as input a window created using
  dk.salza.liq.window/create function.
get-frame-rows
  ([])
  Get the number of rows in the current frame.
clear
  ([])
  Clears the whole buffer.
eval-safe
  ([fun])
  Evaluate a function, catching errors if thrown.
prompt-append
  ([& string])
  Append the given strings to the prompt buffer.
set-keymap
  ([keymap])
  Sets the keymap on the current buffer.
find-file
  ([filepath])
  Opens the file with the given name
  with the default app.
set-default-keymap
  ([keymap])
  Set the keymap to be used as default when a
  new buffer is created.
get-default-typeahead-function
  ([])
  Get the default function for typeahead.
other-window
  ([])
  Navigates to the next window and changes
  buffer accordingly.
escape
  ([])
  
update-mem-col
  ([])
  Stores the current cursor position on the current line.
  Primarily used for forward-line and backward-line to
  remember the cursor position when navigation is done
  past shorter lines.
  That is what makes the cursor in and out when using
  arrow down.
split-window-right
  ([amount] [])
  
add-interactive
  ([label fun & arglabels])
  Add an interactive function.
  The label will be shown in typeahead.
  The user will be prompted to provide and
  input for each of the lables in arglabels.
  The function will be called with the input
  values as arguments.
get-char
  ([])
  Return the char at the point as a string.
copy-selection
  ([])
  If there is a selection, the selected
  text will be send to clipboard.
selection-cancel
  ([])
  Removes the selection point.
  Nothing will be selected afterwards.
switch-to-buffer-same-window
  ([buffername])
  Switch to the buffer with the given name.
  Use the same window.
backward-word
  ([])
  Moves the cursor to the beginning
  of the previous word.
get-mark
  ([name])
  Returns the named mark on the current buffer
  as a number, the position of the mark.
force-quit
  ([])
  
copy-context
  ([])
  Send the context to the clipboard.
  The context could be a filename, a
  function, an url depending on how the
  context is resolved.
set-default-highlighter
  ([highlighter])
  Set the highlighter function to be used as
  default when a new buffer is created.
set-frame-dimensions
  ([rows columns])
  Setting rows and columns of the window frame.
insert
  ([string])
  Inserts a string to the current active buffer
  at the cursor position.
drop-tmp-keymap
  ([])
  Drop the current temporary keymap.
swap-line-up
  ([])
  Swaps the current line with the line above.
  The cursor follows the current line up.
get-name
  ([])
  Returns the name of the current buffer.
prompt-to-tmp
  ([])
  
set-eval-function
  ([extension fun])
  Associate an extension with a function. The function
  is assumed to take one input - the filepath.
  EXAMPLE (To associate files with "py" extension with the
           python command):
    (editor/set-eval-function "py" #(cshell/cmd "python" %))
insert-line
  ([])
  Inserts an empty line below the current
  and move the cursor down.
get-windows
  ([])
  Returns the list of windows in the editor.
  Used by views to get the dimensions of the
  visible buffers.
run-macro
  ([])
  
get-buffer
  ([name])
  Get a buffer by its name.
  Since buffers are immutable, the buffer given
  will be a copy of the buffer.
changed-on-disk?
  ([])
  If the current buffer is from a file, it
  returns if the file has changed on the disk,
  maybe by another program.
set-top-of-window
  ([keyw val])
  Used by the renderer to store the position
  of the first char to be rendered.
add-file
  ([f])
  Add a single file to be availalbe through typeahead
  from the commandapp. When chosen the file will
  be opened.
  EXAMPLE: (editor/add-file "/home/mogens/.liq")
reset
  ([])
  Resets the editor. Mostly for testing purposes.
select-sexp-at-point
  ([])
  Selects the s-expression at the point (cursor)
  The cursor is moved backwards until the first
  startparenthesis where selection starts, and then
  forward until the selection has balanced parenthesis.
end-of-buffer
  ([])
  Moved the cursor to the end of the buffer.
get-top-of-window
  ([keyw])
  Used by renderer to get the position
  of the first char to be rendered.
selection-set
  ([])
  Sets selection mark at the current point.
  This will be the starting point of a selection.
  Cursor position will be the end point of the
  selection.
goto-definition
  ([funname])
  
current-window
  ([])
  Get the current active window.
  Mostly used to get the dimensions
  for the related buffer.
prompt-set
  ([& string])
  Set the prompt buffer to the given strings.
end-of-line
  ([])
  Moves the cursor to the end of the
  current line. The next hard line break.
shrink-window-below
  ([amount])
  
reopen-file
  ([])
  Reopen file in buffer,
  if the file is not dirty.
set-slider
  ([sl])
  Replace the slider in the current buffer
  with the given.
force-reopen-file
  ([])
  Reopening file in buffer,
  ignore dirty flag.
updated
  ([])
  Call this function to proclaim that an
  update has been made to the editor.
  This can be used by views to check for updates.
add-searchpath
  ([s])
  Add a folder to searchpaths.
  When using the commandapp files below
  folders in the searchpath will be available
  through typeahead.
  EXAMPLE: (editor/add-searchpath "/tmp")
set-tmp-keymap
  ([keymap])
  Overrule the current keymap temporarily.
  This keymap has highest priority.
delete-line
  ([])
  Deletes the current line.
replace-char
  ([s])
  Replaces the char at current point
  with the given one.
find-next
  ([search] [])
  
swap-windows
  ([])
  
dirty?
  ([])
  Returns weather current buffer is dirty.
tmp-test
  ([])
  
add-snippet
  ([s])
  Add a snippet to list of snippets.
  They will be available through typeahead
  from the commandapp.
  When chosen the snippet text will be inserted.
  EXAMPLE: (editor/add-snippet "(ns user)")
enlarge-window-right
  ([amount])
  
top-align-page
  ([])
  Scrolls so the current line is at the top
  of the window.
evaluate-file-raw
  ([filepath] [])
  Evaluate a given file raw, without using
  with-out-str or other injected functionality.
  If no filepath is supplied the path connected
  to the current buffer will be used.
typeahead
  ([items tostringfun callback])
  
delete-char
  ([])
  Deletes the character after the cursor.
delete
  ([amount] [])
  Deletes given amount of characters backwards.
  If no amount is supplied just one character
  will be deleted.
previous-buffer
  ([])
  Navigates to the previous buffer used.
get-highlighter
  ([])
  Returns the highlighter function from
  the current buffer.
paste
  ([])
  Insert the text from the clipboard
  at the current position.
apply-to-slider
  ([fun])
  Apply function to the slider in the current buffer.
  It should take a slider as input and produce a slider
  as output.
set-global-key
  ([keyw fun] [keyw1 keyw2 fun])
  Define a global keybinding.
  It takes a keyword like :f5 and a function
  to call when that key is pressed.
get-line
  ([])
  Returns the current line as a string.
beginning-of-line
  ([])
  Moves the cursor to the beginning
  of the current line.
forward-char
  ([amount] [])
  Moves the cursor forward the given amount,
  or 1 step, if no arguments are given.
get-rootfolders
  ([])
  Returns the list of root folders. Used by apps to
  navigate directly to these folders.
get-context
  ([])
  Returns a context map like
  {:type :file :value /tmp/tmp.txt}
  with a type and a value generated by analysing
  the context of the cursor.
record-macro
  ([])
  
eval-sexp
  ([sexp])
  Evaluate the given s-expression in the current
  namespace.
search
  ([])
  
setting
  ([keyw])
  Get the setting with the given key.

  Settings are used as a key value store
  in the editor.

  Items like snippets or search paths are
  store in this.
hide-selection
  ([])
  Hide the current selection.
  Will be collapsed into a symbol with
  3 dots.
get-searchpaths
  ([])
  Returns the list of searchpaths.
copy-file
  ([])
  If the current buffer is connected to a file,
  the filename is send to the clipboard.
end-of-buffer?
  ([])
  Returns true of the current point is the
  end of the current buffer.
beginning-of-buffer
  ([])
  Moves the cursor to the beginning of the buffer.
get-folder
  ([])
  The folder part if a filename is associated with
  the current buffer, otherwise nil.
forward-page
  ([])
  Moves one page forward on the current buffer.
  A page is what is visible in the current window.
highlight-sexp-at-point
  ([])
  Like select-sexp-at-point but only highlights
  start and end of s-expression.
  Toggle this to see current s-expression.
fullupdate?
  ([])
  If a full update of the ui has been requested.
  Resets the value afterwards.
get-action
  ([keyw])
  If the current buffer has an action for the given
  keyword the action (function) is return, otherwise,
  if there is a global action for the given keyword
  that will be returned.
swap-line-down
  ([])
  Swaps the current line with the one below.
  The cursor follows the the current line down.
tmp-do-macro
  ([])
  
unhide
  ([])
  If the current position has collapsed content
  it will be expanded.
shrink-window-right
  ([amount])
  
enlarge-window-below
  ([amount])
  
end-of-word
  ([])
  Moves the cursor to the end of the current
  word.
get-slider
  ([])
  Get the slider from the current buffer.
get-point
  ([])
  Returns the point as a number.
save-file
  ([])
  If the current buffer is connected to a file,
  saves the content of the buffer to the
  file.
sexp-at-point
  ([])
  Returns the s-expression at the cursor position.
undo
  ([])
  Execute an undo on the current buffer.
evaluate-file
  ([filepath] [])
  Evaluate the given file. How evaluation is done
  depends on the file type.
selection-active?
  ([])
  If something is selected.
get-keymap
  ([])
  Returns the active keymap on from the current buffer.
  This is used by the editor to determine what action
  to take.
get-default-app
  ([])
  Get the app to be used as default,
  if none has been specified.
handle-input
  ([keyw])
  
top-next-headline
  ([])
  
delete-window
  ([])
  
reopen-all-files
  ([])
  Reopen all files which are not dirty.
context-action
  ([])
  
forward-word
  ([])
  Moves the cursor to the beginning
  of the next word.
get-available-functions
  ([])
  
get-filename
  ([])
  The filename if one is associated with the current
  buffer, otherwise nil.
set-setting
  ([keyw value])
  Set keyw to value in the
  settings part of the editor.
split-window-below
  ([amount] [])
  
editor
  The ref which contains the editor data, that is
  
  * List of buffers
  * List of windows
  * Global keymap
  * Map of functions to evaluate different filetypes
  * Settings with searchpaths, searchfiles, snippets,
    commands and interactive commands for typeahead.

  Most functions in the editor namespace manipulates
  this ref.
set-default-typeahead-function
  ([typeaheadfn])
  Set the typeahead function to be used of none
  has been set.
prompt-input
  ([& string])
  
set-mark
  ([name])
  Sets a named mark at the current point
  on the current buffer
current-buffer
  ([])
  Returns the current active buffer.
  Since buffers are immutable, this will
  be a copy of the actual buffer.
get-key-list
  ([])
  List of all typed keys
set-highlighter
  ([highlighter])
  Set the highlighter function on the current
  buffer. This determines how the content
  in the buffer is syntax highlighted.
backward-char
  ([amount] [])
  Moves the cursor backward the given amount,
  or 1 step, if no arguments are given.
kill-buffer
  ([])
  
add-rootfolder
  ([s])
  Add a folder to rootfolders.
  When using find file app, the rootfolders
  can be directly accessed through typeahead.
  EXAMPLE: (editor/add-rootfolder "/tmp")
add-to-setting
  ([keyw entry])
  When a setting with a given key is a list,
  items can be added to that list using this
  function.
previous-real-buffer
  ([])
  Navigates to the prevous buffer, but skip over
  buffer with names containing dashes.
remove-mark
  ([name])
  Removes the named mark from the current buffer.
add-command
  ([fun])
  Add a command to be availble for commandapp typeahead.
  add-interactive is in most cases more suitable.
eval-last-sexp
  ([])
  Evaluate the current s-expression.