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.

add-command

(add-command label fun)
Add a command to be availble for commandapp typeahead.
add-interactive is in most cases more suitable.

add-file

(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")

add-interactive

(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.

add-keybinding

(add-keybinding mapid key bind)
Fx: (editor/add-keybinding "dk.salza.liq.keymappings.normal" "i" editor/forward-char)

add-keymap

(add-keymap keymap)

add-rootfolder

(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-searchpath

(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")

add-snippet

(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)")

add-to-setting

(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.

add-window

(add-window window)(add-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.

apply-to-slider

(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.

backward-char

(backward-char amount)(backward-char)
Moves the cursor backward the given amount,
or 1 step, if no arguments are given.

backward-line

(backward-line)
Moves cursor backward one line
in the current active buffer.

backward-word

(backward-word)

backward-word2

(backward-word2)
Moves the cursor to the beginning
of the previous word.

beginning-of-buffer

(beginning-of-buffer)
Moves the cursor to the beginning of the buffer.

beginning-of-line

(beginning-of-line)
Moves the cursor to the beginning
of the current line.

buffer-names

(buffer-names)
The names of the buffers as a list

changed-on-disk?

(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.

clear

(clear)
Clears the whole buffer.

context-action

(context-action)

copy-context

(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.

copy-file

(copy-file)
If the current buffer is connected to a file,
the filename is send to the clipboard.

copy-line

(copy-line)
Sends the current line to the clipboard.

copy-selection

(copy-selection)
If there is a selection, the selected
text will be send to clipboard.

create-buffer-from-file

(create-buffer-from-file filepath)
Creates a new buffer, connects it to the
given filepath and loads the content into
the buffer.

current-buffer

(current-buffer)
Returns the current active buffer.
Since buffers are immutable, this will
be a copy of the actual buffer.

current-window

(current-window)
Get the current active window.
Mostly used to get the dimensions
for the related buffer.

delete

(delete amount)(delete)
Deletes given amount of characters backwards.
If no amount is supplied just one character
will be deleted.

delete-char

(delete-char)
Deletes the character after the cursor.

delete-line

(delete-line)
Deletes the current line.

delete-selection

(delete-selection)
If there is a selection, the selected
content will be deleted.

delete-to-end-of-line

(delete-to-end-of-line)

delete-window

(delete-window)

dirty-buffers

(dirty-buffers)
The names of the dirty buffers as a list.

dirty?

(dirty?)
Returns weather current buffer is dirty.

drop-tmp-keymap

(drop-tmp-keymap)
Drop the current temporary keymap.

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.

end-of-buffer

(end-of-buffer)
Moved the cursor to the end of the buffer.

end-of-buffer?

(end-of-buffer?)
Returns true of the current point is the
end of the current buffer.

end-of-line

(end-of-line)
Moves the cursor to the end of the
current line. The next hard line break.

end-of-word

(end-of-word)

end-of-word2

(end-of-word2)
Moves the cursor to the end of the current
word.

enlarge-window-below

(enlarge-window-below amount)

enlarge-window-right

(enlarge-window-right amount)

escape

(escape)

eval-last-sexp

(eval-last-sexp)
Evaluate the current s-expression.

eval-safe

(eval-safe fun)
Evaluate a function, catching errors if thrown.

eval-sexp

(eval-sexp sexp)
Evaluate the given s-expression in the current
namespace.

evaluate-file

(evaluate-file filepath)(evaluate-file)
Evaluate the given file. How evaluation is done
depends on the file type.

evaluate-file-raw

(evaluate-file-raw filepath)(evaluate-file-raw)
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.

find-char-previous

(find-char-previous c)

find-continue

(find-continue)

find-continue-opposite

(find-continue-opposite)

find-file

(find-file filepath)
Opens the file with the given name
with the default app.

find-next

(find-next search)(find-next)

find-prev

(find-prev search)(find-prev)

first-non-blank

(first-non-blank)

force-quit

(force-quit)

force-reopen-file

(force-reopen-file)
Reopening file in buffer,
ignore dirty flag.

forward-char

(forward-char amount)(forward-char)
Moves the cursor forward the given amount,
or 1 step, if no arguments are given.

forward-line

(forward-line)
Moves cursor forward one line
in the current active buffer.

forward-page

(forward-page)
Moves one page forward on the current buffer.
A page is what is visible in the current window.

forward-word

(forward-word)

forward-word2

(forward-word2)
Moves the cursor to the beginning
of the next word.

fullupdate?

(fullupdate?)
If a full update of the ui has been requested.
Resets the value afterwards.

get-action

(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.

get-available-functions

(get-available-functions)

get-buffer

(get-buffer name)
Get a buffer by its name.
Since buffers are immutable, the buffer given
will be a copy of the buffer.

get-char

(get-char)
Return the char at the point as a string.

get-content

(get-content)
Return the content of the current buffer
as a string.

get-context

(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.

get-default-app

(get-default-app)
Get the app to be used as default,
if none has been specified.

get-default-highlighter

(get-default-highlighter)
Get the default highlighter function.
Mostly used to set highlight on buffer
until some is set by user or app.

get-default-typeahead-function

(get-default-typeahead-function)
Get the default function for typeahead.

get-filename

(get-filename)
The filename if one is associated with the current
buffer, otherwise nil.

get-folder

(get-folder)
The folder part if a filename is associated with
the current buffer, otherwise nil.

get-frame-columns

(get-frame-columns)
Get the number of columns in the current frame.

get-frame-rows

(get-frame-rows)
Get the number of rows in the current frame.

get-highlighter

(get-highlighter)
Returns the highlighter function from
the current buffer.

get-key-list

(get-key-list)
List of all typed keys

get-keymap

(get-keymap)
Returns the active keymap on from the current buffer.
This is used by the editor to determine what action
to take.

get-line

(get-line)
Returns the current line as a string.

get-mark

(get-mark name)
Returns the named mark on the current buffer
as a number, the position of the mark.

get-name

(get-name)
Returns the name of the current buffer.

get-point

(get-point)
Returns the point as a number.

get-rootfolders

(get-rootfolders)
Returns the list of root folders. Used by apps to
navigate directly to these folders.

get-searchpaths

(get-searchpaths)
Returns the list of searchpaths.

get-selection

(get-selection)
Get current selected text as a string.
Returns nil if nothing is selected.

get-slider

(get-slider)
Get the slider from the current buffer.

get-spacemap

(get-spacemap)

get-top-of-window

(get-top-of-window keyw)
Used by renderer to get the position
of the first char to be rendered.

get-windows

(get-windows)
Returns the list of windows in the editor.
Used by views to get the dimensions of the
visible buffers.

goto-definition

(goto-definition funname)

handle-input

(handle-input keyw)

hide-selection

(hide-selection)
Hide the current selection.
Will be collapsed into a symbol with
3 dots.

highlight-sexp-at-point

(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.

insert

(insert string)
Inserts a string to the current active buffer
at the cursor position.

insert-line

(insert-line)
Inserts an empty line below the current
and move the cursor down.

insert-line-above

(insert-line-above)
Inserts an empty line above the current
and move the cursor up.

join-lines

(join-lines)

kill-buffer

(kill-buffer)

new-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.

other-window

(other-window)
Navigates to the next window and changes
buffer accordingly.

paste

(paste)
Insert the text from the clipboard
at the current position.

paste-after

(paste-after)

paste-before

(paste-before)

point-to-mark

(point-to-mark name)
Move the point to the mark on the current buffer.

previous-buffer

(previous-buffer)
Navigates to the previous buffer used.

previous-real-buffer

(previous-real-buffer)
Navigates to the prevous buffer, but skip over
buffer with names containing dashes.

previous-real-buffer-same-window

(previous-real-buffer-same-window)
Navigates to the prevous buffer, but skip over
buffer with names containing dashes.

prompt-append

(prompt-append & string)
Append the given strings to the prompt buffer.

prompt-input

(prompt-input & string)

prompt-set

(prompt-set & string)
Set the prompt buffer to the given strings.

prompt-to-tmp

(prompt-to-tmp)

quit

(quit)

quit-on-exception

macro

(quit-on-exception & body)

record-macro

(record-macro)

remove-buffer

(remove-buffer buffername)

remove-mark

(remove-mark name)
Removes the named mark from the current buffer.

reopen-all-files

(reopen-all-files)
Reopen all files which are not dirty.

reopen-file

(reopen-file)
Reopen file in buffer,
if the file is not dirty.

replace-char

(replace-char s)
Replaces the char at current point
with the given one.

request-fullupdate

(request-fullupdate)
Used notify the ui to do a full updated.

reset

(reset)
Resets the editor. Mostly for testing purposes.

run-macro

(run-macro)

save-file

(save-file)
If the current buffer is connected to a file,
saves the content of the buffer to the
file.

search-files

(search-files search)

select-sexp-at-point

(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.

selection-active?

(selection-active?)
If something is selected.

selection-cancel

(selection-cancel)
Removes the selection point.
Nothing will be selected afterwards.

selection-set

(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.

selection-toggle

(selection-toggle)
If something is selected, the selection
will be cancelled.
If nothing is selected a selection
will be initiated.

set-default-app

(set-default-app app)
Set the default app to be used when a new
buffer is created.

set-default-highlighter

(set-default-highlighter highlighter)
Set the highlighter function to be used as
default when a new buffer is created.

set-default-keymap

(set-default-keymap keymap)
Set the keymap to be used as default when a
new buffer is created.

set-default-typeahead-function

(set-default-typeahead-function typeaheadfn)
Set the typeahead function to be used of none
has been set.

set-eval-function

(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" %))

set-frame-dimensions

(set-frame-dimensions rows columns)
Setting rows and columns of the window frame.

set-global-key

(set-global-key keyw fun)(set-global-key keyw1 keyw2 fun)
Define a global keybinding.
It takes a keyword like :f5 and a function
to call when that key is pressed.

set-highlighter

(set-highlighter highlighter)
Set the highlighter function on the current
buffer. This determines how the content
in the buffer is syntax highlighted.

set-keymap

(set-keymap keymap)
Sets the keymap on the current buffer.

set-mark

(set-mark name)
Sets a named mark at the current point
on the current buffer

set-setting

(set-setting keyw value)
Set keyw to value in the
settings part of the editor.

set-slider

(set-slider sl)
Replace the slider in the current buffer
with the given.

set-spacekey

(set-spacekey ks info action)

set-tmp-keymap

(set-tmp-keymap keymap)
Overrule the current keymap temporarily.
This keymap has highest priority.

set-top-of-window

(set-top-of-window keyw val)
Used by the renderer to store the position
of the first char to be rendered.

set-undo-point

(set-undo-point)

setting

(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.

sexp-at-point

(sexp-at-point)
Returns the s-expression at the cursor position.

shrink-window-below

(shrink-window-below amount)

shrink-window-right

(shrink-window-right amount)

split-window-below

(split-window-below amount)(split-window-below)

split-window-right

(split-window-right amount)(split-window-right)

swap-line-down

(swap-line-down)
Swaps the current line with the one below.
The cursor follows the the current line down.

swap-line-up

(swap-line-up)
Swaps the current line with the line above.
The cursor follows the current line up.

swap-windows

(swap-windows)

switch-to-buffer

(switch-to-buffer buffername)
Switch to the buffer with the given name.

switch-to-buffer-same-window

(switch-to-buffer-same-window buffername)
Switch to the buffer with the given name.
Use the same window.

tmp-do-macro

(tmp-do-macro)

tmp-test

(tmp-test)

top-align-page

(top-align-page)
Scrolls so the current line is at the top
of the window.

top-next-headline

(top-next-headline)

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.

typeahead

(typeahead items tostringfun callback)

undo

(undo)
Execute an undo on the current buffer.

unhide

(unhide)
If the current position has collapsed content
it will be expanded.

update-mem-col

(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.

updated

(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.

updates

Variable to be increased when updates
are done to the editor, to allow easy
check if redraw is needed.