Buffer Documentation

Namespace: dk.salza.liq.buffer 

 

  A buffer could be considered a slider (see slider) with
  some extra attributes, besides attributes to keep track
  of name, filename, dirtyness, undo information it consists
  of

    * A slider
    * A highlighter function
    * A keymap

  The slider is used to keep track of the text, the highlighter
  function is used by the view to apply highlight and the
  keymap is used to decide which function a keypress should
  be mapped to.

  On runtime the highlighter function and the keymap can be
  replaced.
  
  The buffer structure is immutable, so every operation that
  changes the buffer will return a new one.

 

get-content
  ([buffer])
  Returns the content (text) of the buffer
  as a string.
get-selection
  ([buffer])
  Returns the selection region as a string.
forward-visual-line
  ([buffer columns])
  Returns a buffer where the cursor has been moved
  forward one visual (soft) line, taking wrap at given
  columns into account.
delete-selection
  ([buffer])
  Returns a buffer where the selected content
  is deleted.
point-to-mark
  ([buffer name])
  Returns a new buffer where the cursor has been
  moved to the given mark.
get-region
  ([buffer name])
  Returns the region between the cursor and the
  named mark, as a string.
clear
  ([buffer])
  Returns a new buffer where all the content has
  been deleted.
set-keymap
  ([buffer keymap])
  Returns a new buffer with the given
  keymap set.
update-mem-col
  ([buffer columns])
  The mem-col is the column position of the cursor,
  from the last time the cursor was moved not up and
  down.

  When moving the cursor up and down and passing by
  shorter lines the column position, when reaching a
  longer line again, should be restored.
  
  This allows one to keep the current column and
  avoid the cursor from staying at the beginning of
  the line when passing an empty line.
get-char
  ([buffer])
  Returns the current char at point as a string.
backward-word
  ([buffer])
  Returns a new buffer with the cursor moved backward
  to the beginning of the previous word.
get-mark
  ([buffer name])
  Returns the position af the given mark.
get-dirty
  ([buffer])
  Returns the dirty state of the buffer.
insert
  ([buffer string])
  Returns a new buffer with the given string
  inserted a the cursor position.
update-modified
  ([buffer])
  
backward-visual-line
  ([buffer columns])
  Returns a buffer where the cursor has been moved
  backward one visual (soft) line, taking wrap at given
  columns into account.
get-name
  ([buffer])
  Returns the name associated with the buffer.
insert-line
  ([buffer])
  Returns a new buffer where a new line has been
  inserted below the current line, and the cursor
  has been moved to that line.
changed-on-disk?
  ([buffer])
  
get-linenumber
  ([buffer])
  Returns the line number at the cursor position.
select-sexp-at-point
  ([buffer])
  Returns a buffer where the s-expression at the point (cursor)
  has been selected.
  The cursor is moved backwards until the first
  startparenthesis where selection starts, and then
  forward until the selection has balanced parenthesis.
end-of-buffer
  ([buffer])
  Returns a new buffer where the cursor is
  moved to the end of the buffer.
create
  ([name])
  Creates an empty buffer with the given
  name.
end-of-line
  ([buffer])
  Returns a new buffer where the cursor has been
  moved to the end of the line.
reopen-file
  ([buffer])
  Reopen file in buffer,
  if the file is not dirty.
set-slider
  ([buffer sl])
  
force-reopen-file
  ([buffer])
  Reopening file in buffer,
  ignore dirty flag.
delete-line
  ([buffer])
  Returns a buffer where the current lines is deleted
  and the cursor is moved to the next line.
find-next
  ([buffer search])
  Returns a new buffer where the cursor is moved
  to the next occurrence of the search frase.
create-slider-from-file
  ([path])
  
get-visible-content
  ([buffer])
  Not in use yet, since there is no functionality
  for hiding lines, yet.
create-from-file
  ([path])
  Creates a buffer and loads the content of a given file.
  The filename is stored also, to be used for save
  functionality.
delete-char
  ([buffer])
  Returns a new buffer where the character after
  the curser is removed.
delete
  ([buffer amount])
  Returns a new buffer with the given amount of
  characters deleted behind the cursor.
get-highlighter
  ([buffer])
  Returns the highlighter function associated
  with the buffer.
apply-to-slider
  ([buffer fun])
  Apply function to the slider in the buffer.
  It should take a slider as input and produce a slider
  as output.
get-line
  ([buffer])
  Returns the current line as a string.
beginning-of-line
  ([buffer])
  Returns a new buffer where the cursor has been
  moved to the beginning of the line.
forward-char
  ([buffer amount])
  Returns a new buffer where the cursor has been
  moved amount steps forward.
get-context
  ([buffer])
  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.
save-buffer
  ([buffer])
  If there is a filename connected with the buffer,
  the content of the buffer will be saved to that file.
hide-selection
  ([buffer])
  
end-of-buffer?
  ([buffer])
  Return true if the cursor is at the
  end of the buffer.
beginning-of-buffer
  ([buffer])
  Returns a new buffer where the cursor is
  moved to the beginning of the buffer.
highlight-sexp-at-point
  ([buffer])
  Returns a buffer where the highlight marks
  have been set matching the current s-expression.
  It spans same text as select-sexp-at-point.
get-action
  ([buffer keyw])
  If the keymap has an action (function)
  for the given keyword, it will be returned.
set-point
  ([buffer point])
  Returns a new buffer where the cursor has been
  moved to the given point.
unhide
  ([buffer])
  
end-of-word
  ([buffer])
  Returns a new buffer with the cursor moved
  to the end of the current word.
get-slider
  ([buffer])
  Returns the slider in the buffer datastructure.
  The slider is responsible for storing and manipulating
  the text in the buffer.
get-point
  ([buffer])
  Returns the point (cursor position) as a number.
sexp-at-point
  ([buffer])
  Returns the s-expression at the cursor position.
undo
  ([buffer])
  Returns the first buffer in the undo stack.
get-keymap
  ([buffer])
  Returns the keymap associated with the buffer.
tmp-buffer
  ([buffer columns])
  
forward-word
  ([buffer])
  Returns a new buffer with the cursor moved past
  next whitespace.
get-filename
  ([buffer])
  Returns the filename associated with the buffer.
set-mark
  ([buffer name])
  Returns a new buffer with a mark set at the cursor position.
set-dirty
  ([buffer dirty] [buffer])
  Sets dirty flag on the buffer.
  Used to mark if content has changed
  since last save.
set-highlighter
  ([buffer highlighter])
  Returns a new buffer with the given highlighter set.
backward-char
  ([buffer amount])
  Returns a new buffer where the cursor has been
  moved amount steps backward.
remove-mark
  ([buffer name])
  Returns a new buffer with the named mark removed.