Skip to content

Latest commit

 

History

History
444 lines (281 loc) · 12.6 KB

File metadata and controls

444 lines (281 loc) · 12.6 KB

src/editor/buffer.ml

Home · Files

Provides editor buffer facilities for this project.

Package: editor.buffer

Reachable from entry: no

Imports

  • std/fs.ml as fs../MiniLangCompilerML/std/fs.ml — external dependency
  • std/string.ml as s../MiniLangCompilerML/std/string.ml — external dependency

Declarations

_insert_line

function _insert_line(buf, idx, text)

Insert a line into the buffer at a clamped index.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.
idx dynamic idx value consumed by this operation.
text dynamic Text consumed by the operation.

View source

_lines_from_text

function _lines_from_text(text)

Split normalized text into editable buffer lines.

Parameter Type Default Description
text dynamic Text consumed by the operation.

View source

_normalize_text

function _normalize_text(text)

Normalize line endings to MiniIDE internal newline format.

Parameter Type Default Description
text dynamic Text consumed by the operation.

View source

_remove_line

function _remove_line(buf, idx)

Remove one line while keeping the buffer non-empty.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.
idx dynamic idx value consumed by this operation.

View source

_set_line

function _set_line(buf, idx, text)

Replace one buffer line and mark the buffer dirty.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.
idx dynamic idx value consumed by this operation.
text dynamic Text consumed by the operation.

View source

_text_from_lines

function _text_from_lines(lines)

Join buffer lines back into normalized text.

Parameter Type Default Description
lines dynamic lines value consumed by this operation.

View source

backspace

function backspace(buf)

Delete the character before the cursor or merge with the previous line.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

clamp_cursor

function clamp_cursor(buf)

Clamp cursor and scroll fields so they stay within the buffer.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

current_line

function current_line(buf)

Return the current cursor line from a text buffer.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

delete_forward

function delete_forward(buf)

Delete forward.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

ensure_cursor_visible

function ensure_cursor_visible(buf, visible_lines)

Ensure cursor visible.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.
visible_lines dynamic visible_lines value consumed by this operation.

View source

insert_text

function insert_text(buf, text)

Insert text at the current cursor position.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.
text dynamic Text consumed by the operation.

View source

line_count

function line_count(buf)

Return the number of lines in a text buffer.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

load_file

function load_file(path)

Load a file into a normalized text buffer.

Parameter Type Default Description
path dynamic Path of the file or directory used by the operation.

View source

move_down

function move_down(buf)

Move down.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

move_end

function move_end(buf)

Move end.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

move_home

function move_home(buf)

Move home.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

move_left

function move_left(buf)

Move left.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

move_right

function move_right(buf)

Move right.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

move_up

function move_up(buf)

Move up.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

new_buffer

function new_buffer(path, text)

Create a normalized text buffer for a path and initial contents.

Parameter Type Default Description
path dynamic Path of the file or directory used by the operation.
text dynamic Text consumed by the operation.

View source

newline

function newline(buf)

Split the current line at the cursor and move to the new line.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

save

function save(buf)

Persist a text buffer to disk and clear its dirty flag on success.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source

scroll

function scroll(buf, delta)

Return the scroll.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.
delta dynamic delta value consumed by this operation.

View source

set_cursor

function set_cursor(buf, line, col)

Set cursor.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.
line dynamic line value consumed by this operation.
col dynamic col value consumed by this operation.

View source

word_prefix

function word_prefix(buf)

Return the word prefix.

Parameter Type Default Description
buf dynamic buf value consumed by this operation.

View source