# Grid Text Editor

The Grid text editor sits on [text/ed] and adds a visual and interactive
interface through the Grid [io/grid].

The basic idea is that text around current Edbuf selection is always displayed
using the whole grid except for the bottom line (the status line). There are
quick one letter keybindings for frequent and simple movements and
manipulations, but for fancier operations, you go in command mode with ":",
which simply prompts for a line to interpret (in which you'll probably use
commands from [text/ed], but you can also use others).

To use it, you load your EdBuf with some contents and then run "ged", which
enters the grid keybindings loop.

## text/ed bubbling up

Upon invoking "ged", the unit "text/ed" is called so that we bubble up its
convenience layer. [text/gedx] has the same behavior.

This is needed to avoid bizarre behavior caused by bubbling up other units
during development. A notable example is [asm/x86] which shadows "dl".

## Visual mode

Pressing "v" toggles the visual mode. When toggled on, current position is
marked and when moving selection afterwards, the range between the mark and the
selection is shown visually.

Some bindings such as "D" only work in visual mode.

## The Gutter

Source code in Dusk doesn't exceed 80 characters per line. Screens with a grid
larger than that need a visual clue to help stay within that limit. That's
called the Gutter.

The Gutter is a vertical line drawn at the position determined by the "gutter"
value, defaulting to 80. You can change that value to move the gutter.

Drawing a gutter and its right part while also avoiding visual glitches turns
out to be a bit complex, so we don't bother. text/ged doesn't draw text after
the gutter.

To facilitate detection of lines longer than the gutter, we allow lines longer
than the gutter to "breach" it for one character. Holes in the gutter thus
indicate that a line exceeds the gutter.

## Keybindings

"C+" means "hold left Control while you press the key".

Descriptions below are kept short because those actions often correspond to
words in [text/ed], which you can use as a complete reference.

q   Quit
h   Go left
j   Go down
k   Go up
l   Go right
J   Activate visual mode, go to "bol", then down one line
K   Activate visual mode, go to "bol", the up one line
H   Move to previous word
L   Move to next word
C+h Go to the beginning of the line
C+l Go to the end of the line or to gutter, whichever comes first
g   Type a number then go to that line (1-indexed)
r   Wait for keypress then replace character at cursor with that key
i   Insert
o   Insert line after
O   Insert line before
\   Join line (jl)
|   Split line (sl)
f   Find
n   Find next
z   zoom. Reframe the editor so that selection is in the middle of the screen
Z   zoom to top. Reframe so selection is on top
v   Toggle visual mode
y   Copy visual selection to clipboard
p   Paste clipboard to current position
D   Delete visually selected text
X   Delete character at cursor
]   move 1 page down
[   move 1 page up
W   Run "edsave", that is, save active buffer to file
:   enter a single line of command that will be interpreted as forth
C+b Print buffer list
C+q Close active buffer
C+] Cycle to next buffer in list

## API

### Values

gutter  horizontal position of the gutter. Default 80.

### Words

ged ( -- )
  Clear the screen and run the Grid Editor, displaying current active text/ed
  buffer.
