2016-03-06 17:43:14 +03:00
|
|
|
Json-Rpc user interface
|
|
|
|
=======================
|
|
|
|
|
|
|
|
Kakoune user interfaces can be implemented through the json-rpc 2.0 protocol.
|
|
|
|
|
2016-04-09 11:05:19 +03:00
|
|
|
By launching kakoune in client mode with the `-ui json` option, the launched
|
2016-07-04 21:49:14 +03:00
|
|
|
client will write newline separated json-rpc requests on stdout and read
|
|
|
|
json-rpc requests on stdin. Errors will be reported on stderr (not in
|
|
|
|
json format).
|
2016-03-06 17:43:14 +03:00
|
|
|
|
|
|
|
Kakoune requests are always using positional parameters, never named, and
|
2017-01-07 00:21:14 +03:00
|
|
|
Kakoune won't be able to parse named parameters in requests.
|
2016-03-06 17:43:14 +03:00
|
|
|
|
|
|
|
Here are the data structures used:
|
|
|
|
|
2017-01-07 00:21:14 +03:00
|
|
|
* Color: a string, either a named color, or #rrggbb, or 'default'
|
2016-03-06 17:43:14 +03:00
|
|
|
* Attribute: one of {exclusive, underline, reverse, blink, bold, dim, italic}
|
|
|
|
* Face { Color fg; Color bg; Array<Attribute> attributes; }
|
|
|
|
* Atom { Face face; String contents; }
|
|
|
|
* Line : Array of Atom
|
|
|
|
* Coord { int line; int column }
|
|
|
|
|
|
|
|
Here are the requests that can be written by the json ui on stdout:
|
|
|
|
|
2016-04-11 15:44:10 +03:00
|
|
|
* draw(Array<Line> lines, Face default_face, Face padding_face)
|
2017-01-07 00:21:14 +03:00
|
|
|
padding_face is the face of the padding characters '~' in the
|
|
|
|
terminal UI.
|
2016-03-06 17:43:14 +03:00
|
|
|
* draw_status(Line status_line, Line mode_line,
|
|
|
|
Face default_face)
|
2017-01-07 00:21:14 +03:00
|
|
|
* menu_show(Array<Line> items, Coord anchor, Face selected_item_face, Face menu_face,
|
2016-03-06 17:43:14 +03:00
|
|
|
String style)
|
|
|
|
style can be:
|
|
|
|
- prompt: display the menu as a prompt menu (anchor is ignored)
|
|
|
|
- inline: display the menu next to (above or below) the anchor coordinate
|
|
|
|
* menu_select(int selected)
|
|
|
|
* menu_hide()
|
|
|
|
* info_show(String title, String content, Coord anchor, Face face, String style)
|
|
|
|
style can be:
|
|
|
|
- prompt: display the info as a prompt info (anchor is ignored)
|
|
|
|
- inline: display the info next to (above or below) the anchor coordinate
|
|
|
|
- inlineAbove: display the info next to (above) the anchor coordinate
|
|
|
|
- inlineBelow: display the info next to (below) the anchor coordinate
|
|
|
|
- menuDoc: display the info next to the menu, as a documentation for it
|
2017-01-07 04:26:52 +03:00
|
|
|
- modal: display the info in a way that shows Kakoune is waiting for a
|
|
|
|
special action related to it.
|
2016-03-06 17:43:14 +03:00
|
|
|
* info_hide()
|
2017-04-12 12:46:27 +03:00
|
|
|
* set_cursor(String mode, Coord coord)
|
|
|
|
set the main cursor position
|
|
|
|
mode can be:
|
|
|
|
- prompt: the coordinate line should be 0, and the cursor is in the prompt area
|
|
|
|
- buffer: the cursor is in the buffer display area
|
2018-04-29 13:38:47 +03:00
|
|
|
* set_ui_options(Map<String, String> options)
|
|
|
|
called when ui_options changed with a map of options name to option values
|
2018-03-25 10:29:21 +03:00
|
|
|
* refresh(bool force)
|
2016-03-06 17:43:14 +03:00
|
|
|
|
|
|
|
The requests that the json ui can interpret on stdin are:
|
|
|
|
|
|
|
|
* keys(String key1, String key2...): keystrokes
|
2016-08-25 03:14:50 +03:00
|
|
|
* resize(int rows, int columns): notify ui resize
|
2018-05-03 15:17:24 +03:00
|
|
|
* mouse(String type, int line, int column): mouse event, type
|
|
|
|
can be: 'move', 'press', 'release', 'wheel_up', 'wheel_down',
|
|
|
|
line, column is the cursor position.
|
2018-05-03 15:22:12 +03:00
|
|
|
* menu_select(int index): explicit select of given menu entry
|