Slider Documentation
Namespace: dk.salza.liq.slider
The slider is a basic construction resembling the most fundamental actions of a text edtior. The slider is immutable, so every slider function in this namespace will take a slider as input together with some parameters and evaluate to a new slider. By having the slider as first parameter a series of actions can be performed by using the threading operator "->", like: (-> sl (end-of-line) (forward-char 3)) Some of the basic operations are: * Moving cursor * Inserting and removing content * Setting marks and moving cursor to marks * Marking regions The sliderutil contains more slider related functions, which are more complex and usually composed of the basic functions in this file.
get-content ([sl]) The full content of the slider as text.
end ([sl]) Moves the point to the end of the slider.
left-until ([sl pred]) Moves the cursor backward, until for the current char: (pred char) is true. The cursor will be places just before the character. The function only mathces single characters, not character sequences! If there is no match, the cursor will move all the way to the beginning of the slider. Example (cursor = ^): aaacde^aacf -- left-until c --> aa^cdeaacf.
forward-line ([sl columns] [sl])
mark-paren-start ([sl name]) Marks the paren-start of the current s-exp. In this case: aaa (aaa (aa) a|aa The first paren start is selected.
before ([sl]) Returns a slider with content before cursor.
is-newline? ([c]) Check if \n or {:char \n}
update-top-of-window ([sl rows columns tow]) Returns slider where cursor marks has been set and point moved to top of window.
forward-visual-column ([sl columns column]) Moves the point forward one line, where the lines are wrapped. The parameter columns is how many chars are allowed on one line. The parameter column is the current selected column. The visual result of this function is the cursor will be located on the same column on the next line, nomatter if the line was wrapped or not.
slider? ([sl]) Returns true if the input has shape/properties like a slider.
point-to-mark ([sl name]) Moves the point to the mark with the given name. If the mark does not exist nothing is changed.
get-region ([sl markname]) Returns the content between the mark with the given name and the point. If there is no mark with the given name nil is returned.
set-meta ([sl key val]) Set a meta value on the current char. If char is a string it will be converted to a map.
clear-marks ([sl]) Removes all marks.
clear ([sl]) Erases everything in the slider, content and marks.
left ([sl] [sl amount]) Moves the point to the left the given amount of times. So moving one character left is achieved with (left sl 1).
insert-space ([sl]) Special funcon to insert a space without too much overhead.
get-char ([sl]) Returns the first character after the point. If point is at the end of the slider, nil will be returned.
beginning ([sl]) Moves the point (cursor) to the beginning of the slider.
get-mark ([sl name]) The position of the mark with the given name.
backward-visual-column ([sl columns column]) Moves the point backward one line, where the lines are wrapped. The parameter columns is how many chars are allowed on one line. The parameter column is the current selected column. The visual result of this function is the cursor will be located on the same column on the previous line, nomatter if the line was wrapped or not.
insert ([sl text]) Insert text at the point. The point will be moved to the end of the inserted text.
get-region-as-slider ([sl markname])
wrap ([sl columns]) Wrap all lines. Cursor will be at end.
look-ahead ([sl amount]) Returns char after the cursor given amount forward. If amount = 0 the char right after the cursor will be returned. Non strings will be filtered away. If there is no result, nil is returned.
get-linenumber ([sl]) Return the linenumber of the point. It will always be equal to one more than the number of newline characters in ::before.
select-sexp-at-point ([sl]) Selects the smallest valid s-expression containing the point (cursor position). The function take into account that the parenthesis should be balanced.
hide-region ([sl markname]) Hides/collapses the given region: The content between the cursor and the given mark
end? ([sl]) True if and only if the point is at the end of the slider.
create ([text] []) Creates a new slider with given text as text. The point will be placed at the beginning. A slider basically consists of two lists: before: A list of characters (strings) before the point, where the first element is the character just before the point. after: A list of characters (strings) after the point, where the first element is the character just after the point. So moving the point is more or less to take characters from one of the lists and put into the other. This text: abc|def will look like this: before = (c b a), after = (d e f). Moving the curser to the right will result in: before = (d c b a), after = (e f).
end-of-line ([sl]) Moves the point to the end of the line. Right before the next line break.
delete-line ([sl]) Deletes the current line. The point will be placed at the beginning of the next line.
insert-newline ([sl]) Special function to insert newline without too much overhead.
find-next ([sl search]) Moves the point to the next search match from the current point position.
get-visible-content ([sl]) This is not really in use yet, since there is not yet a hide lines functionality.
beginning? ([sl]) True if and only if the point is at the beginning of the slider.
pad-right ([sl columns]) Pad to the right with spaces
slide-marks ([marks point amount]) This function will move marks strictly after point with the given amount. Marks at point will not be moved. When text is inserted, marks should be moved accordingly.
look-behind ([sl amount]) Returns char behind the cursor given amount back. If amount = 1 the char right behind the cursor will be returned. Non strings will be filtered away. If there is no result, nil is returned.
delete ([sl amount]) Deletes amount of characters to the left of the cursor. So delete 3 of aaabbb|ccc wil result in aaa|ccc.
beginning-of-line ([sl]) Moves the point to the beginning of the current line.
get-meta ([sl key]) Get a meta value from a char. If the value does not exist, nil will be returned.
get-context ([sl]) Calculates a context object like a filepath, url, checkbox, code collapse and returns the type and the matched string. Output like {:type :file :value /tmp/tmp.txt}
mark-paren-end ([sl name]) Marks the paren-end of the current s-exp. In this case: aa (aa (aa|aa(aa)) The last paren will be selected.
get-visual-column ([sl columns])
get-after-list ([sl])
highlight-sexp-at-point ([sl]) Setting marks hl0 and hl1 on parenthesis matching the current s-expression for a view to use to highlight the the boundries of the s-expression.
set-point ([sl newpoint]) Moves point the the given location. Not further than beginning of the slider and the end of the slider.
unhide ([sl]) If current position contains hidden/collapsed content it will be expanded.
take-lines ([sl rows columns]) Generate list of lines with at most columns chars. When exeeding end empty lines will be provided.
after ([sl]) Returns a slider with content after cursor.
get-point ([sl]) Returns the point. If at the beginning of the slider the result is 0. If at the end of the slider the result is the number of characters.
sexp-at-point ([sl]) Returns the sexp at the current point. If there is no s-expression nil will be returned.
insert-slider ([sl1 sl2]) Insert second slider into first. Point is moved to match second slider. Marks are lost
forward-word ([sl]) Moves the point to beginning of next word or end-of-buffer
hidden? ([sl]) Checks if current position is a hidden region.
insert-subslider ([sl subsl])
string-ahead ([sl amount]) Returns next amount of chars as string. Non string will be filtered away.
set-mark ([sl name]) Sets a named mark at the point. When inserting or deleting text strectly left to the mark, the mark will be moved accordingly.
right ([sl] [sl amount]) Moves the point to the right (forward) the given amount of times.
delete-region ([sl markname]) Deletes the region between the given mark and the point. If the mark does not exist, nothing is deleted.
right-until ([sl pred]) Moves the cursor forward, until for the current char: (pred char) is true. The cursor will be placed just before the character. The function only matches single characters, not character sequences! If there is no match, the cursor will move all the way to the end of the slider. Example (cursor = ^): aaacde^aacf -- right-until c --> aacdeaa^cf.
remove-mark ([sl name]) Removes the mark with the given name.