Skip to main content

Crate dartboard_editor

Crate dartboard_editor 

Source
Expand description

§dartboard-editor

Host-neutral editor state and dispatch for the dartboard terminal drawing tool. This crate has no terminal-I/O dependencies — hosts construct AppIntent values from their own input layer and feed them to the editor.

§Host wiring

  1. Own an EditorSession and a dartboard_core::Canvas.
  2. Translate your host’s input events into AppKey and AppPointerEvent. Pointer coordinates are 0-based cell positions in the host’s display grid; the host is responsible for any terminal protocol conversion (e.g., SGR 1-based → 0-based).
  3. Route key input through KeyMap::resolve plus handle_editor_action (or handle_editor_key_press for the default keymap path).
  4. Route pointer input through handle_editor_pointer; if your host has overlay UI (swatches, menus), hit-test those first and only forward events that should reach the editor. Use EditorSession::viewport_contains for canvas hit-testing.
  5. Inspect EditorPointerDispatch::outcome: PointerOutcome::Consumed means suppress outer UI; PointerOutcome::Passthrough means the editor did not act on the event and the host may bubble it to outer layers.

§Default pointer policy

handle_editor_pointer implements the hover policy most hosts want: passive AppPointerKind::Moved events over the canvas do not move the caret when no floating preview is armed, and do follow the cursor when one is (so brush/stamp previews track the pointer). Layered hosts should simply forward every AppPointerEvent they want the editor to see and rely on PointerOutcome to decide whether to bubble.

Crossterm adapters for the reference CLI live in the dartboard-cli crate. Non-crossterm hosts (e.g., VTE-based shells) construct AppIntent values directly from their own parsed events.

Re-exports§

pub use keymap::ActionSpec;
pub use keymap::BindingContext;
pub use keymap::EditorContext;
pub use keymap::HelpEntry;
pub use keymap::HelpSection;
pub use keymap::KeyBinding;
pub use keymap::KeyMap;
pub use keymap::KeyTrigger;
pub use session_mirror::ConnectState;
pub use session_mirror::MirrorEvent;
pub use session_mirror::SessionMirror;

Modules§

keymap
session_mirror

Structs§

AppKey
AppModifiers
AppPointerEvent
A pointer event in the host’s display grid.
Bounds
Clipboard
EditorKeyDispatch
EditorPointerDispatch
EditorSession
FloatingSelection
PanDrag
Selection
Swatch
Viewport

Enums§

AppIntent
AppKeyCode
AppPointerButton
AppPointerKind
EditorAction
HostEffect
Mode
MoveDir
PointerOutcome
Whether handle_editor_pointer consumed the event or left it for the host to bubble to outer UI layers.
PointerStrokeHint
SelectionShape
SwatchActivation

Constants§

SWATCH_CAPACITY

Functions§

backspace
begin_paint_stroke
capture_bounds
capture_selection
copy_selection_or_cell
cut_selection_or_cell
delete_at_cursor
diff_canvas_op
dismiss_floating
draw_border
draw_selection_border
end_paint_stroke
export_bounds_as_text
export_selection_as_text
export_system_clipboard_text
fill_bounds
fill_selection
fill_selection_or_cell
handle_editor_action
handle_editor_key_press
handle_editor_pointer
Apply a pointer event to the editor and return the dispatch outcome plus any paint-stroke grouping hint the host should honor for undo bookkeeping.
insert_char
paint_floating_drag
paste_primary_swatch
paste_text_block
pull_from_down
pull_from_left
pull_from_right
pull_from_up
push_down
push_left
push_right
push_up
smart_fill
smart_fill_glyph
stamp_clipboard
stamp_floating
transpose_selection_corner