Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/json_ui.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ Here are the data structures used:

Here are the requests that can be written by the json ui on stdout:

* draw(Array<Line> lines, Coord cursor_pos, Face default_face, Face padding_face, int widget_columns)
* draw(Array<Line> lines, Coord cursor_pos, Face default_face, Face padding_face, int widget_columns,
int first_buffer_line, int last_buffer_line, int buffer_line_count)
padding_face is the face of the padding characters '~' in the
terminal UI.
cursor_pos is the main cursor coordinates
widget_columns is the number of columns at the start of each line used by flag-lines highlighters.
first_buffer_line and last_buffer_line are the 0-based buffer line numbers of the first
and last lines visible in the viewport.
buffer_line_count is the total number of lines in the buffer.
* draw_status(Line prompt, Line content, int cursor_pos, Line mode_line, Face default_face,
String style)
cursor_pos is the location of the cursor in the content, the UI is expected to trim
Expand Down
6 changes: 5 additions & 1 deletion src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,12 @@ void Client::redraw_ifn()
{
auto& display_buffer = window.update_display_buffer(context());
auto cursor_pos = window.display_coord(context().selections().main().cursor()).value_or(DisplayCoord{});
auto& db_lines = display_buffer.lines();
m_ui->draw(display_buffer, cursor_pos, faces["Default"], faces["BufferPadding"],
window.last_display_setup().widget_columns);
window.last_display_setup().widget_columns,
db_lines.empty() ? 0_line : window.last_display_setup().first_line,
db_lines.empty() ? 0_line : db_lines.back().range().begin.line,
context().buffer().line_count());
}

const bool update_menu_anchor = (m_ui_pending & Draw) and not (m_ui_pending & MenuHide) and
Expand Down
12 changes: 10 additions & 2 deletions src/json_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ String to_json(ColumnCount column)
return format("{}", column);
}

String to_json(LineCount line)
{
return format("{}", line);
}

String to_json(DisplayCoord coord)
{
return format(R"(\{ "line": {}, "column": {} })", coord.line, coord.column);
Expand Down Expand Up @@ -154,10 +159,13 @@ JsonUI::JsonUI()

void JsonUI::draw(const DisplayBuffer& display_buffer, DisplayCoord cursor_pos,
const Face& default_face, const Face& padding_face,
ColumnCount widget_columns)
ColumnCount widget_columns,
LineCount first_buffer_line,
LineCount last_buffer_line,
LineCount buffer_line_count)
{
rpc_call("draw", display_buffer.lines(), cursor_pos, default_face, padding_face,
widget_columns);
widget_columns, first_buffer_line, last_buffer_line, buffer_line_count);
}

void JsonUI::draw_status(const DisplayLine& prompt,
Expand Down
5 changes: 4 additions & 1 deletion src/json_ui.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public:
DisplayCoord cursor_pos,
const Face& default_face,
const Face& buffer_padding,
ColumnCount widget_columns) override;
ColumnCount widget_columns,
LineCount first_buffer_line,
LineCount last_buffer_line,
LineCount buffer_line_count) override;

void draw_status(const DisplayLine& prompt,
const DisplayLine& content,
Expand Down
3 changes: 2 additions & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ UniquePtr<UserInterface> make_ui(UIType ui_type)
void info_show(const DisplayLine&, const DisplayLineList&, DisplayCoord, Face, InfoStyle) override {}
void info_hide() override {}

void draw(const DisplayBuffer&, DisplayCoord, const Face&, const Face&, ColumnCount) override {}
void draw(const DisplayBuffer&, DisplayCoord, const Face&, const Face&, ColumnCount,
LineCount, LineCount, LineCount) override {}
void draw_status(const DisplayLine&, const DisplayLine&, const ColumnCount, const DisplayLine&, const Face&, StatusStyle) override {}
DisplayCoord dimensions() override { return {24,80}; }
void refresh(bool) override {}
Expand Down
13 changes: 10 additions & 3 deletions src/remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ class RemoteUI : public UserInterface
DisplayCoord cursor_pos,
const Face& default_face,
const Face& padding_face,
ColumnCount widget_columns) override;
ColumnCount widget_columns,
LineCount first_buffer_line,
LineCount last_buffer_line,
LineCount buffer_line_count) override;

void draw_status(const DisplayLine& prompt,
const DisplayLine& content,
Expand Down Expand Up @@ -568,9 +571,13 @@ void RemoteUI::draw(const DisplayBuffer& display_buffer,
DisplayCoord cursor_pos,
const Face& default_face,
const Face& padding_face,
ColumnCount widget_columns)
ColumnCount widget_columns,
LineCount first_buffer_line,
LineCount last_buffer_line,
LineCount buffer_line_count)
{
send_message(MessageType::Draw, display_buffer, cursor_pos, default_face, padding_face, widget_columns);
send_message(MessageType::Draw, display_buffer, cursor_pos, default_face, padding_face,
widget_columns, first_buffer_line, last_buffer_line, buffer_line_count);
}

void RemoteUI::draw_status(const DisplayLine& prompt,
Expand Down
5 changes: 4 additions & 1 deletion src/terminal_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,10 @@ void TerminalUI::draw(const DisplayBuffer& display_buffer,
DisplayCoord cursor_pos,
const Face& default_face,
const Face& padding_face,
ColumnCount)
ColumnCount,
LineCount,
LineCount,
LineCount)
{
check_resize();

Expand Down
5 changes: 4 additions & 1 deletion src/terminal_ui.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public:
DisplayCoord cursor_pos,
const Face& default_face,
const Face& padding_face,
ColumnCount widget_columns) override;
ColumnCount widget_columns,
LineCount first_buffer_line,
LineCount last_buffer_line,
LineCount buffer_line_count) override;

void draw_status(const DisplayLine& prompt,
const DisplayLine& content,
Expand Down
5 changes: 4 additions & 1 deletion src/user_interface.hh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public:
DisplayCoord cursor_pos,
const Face& default_face,
const Face& padding_face,
ColumnCount widget_columns) = 0;
ColumnCount widget_columns,
LineCount first_buffer_line,
LineCount last_buffer_line,
LineCount buffer_line_count) = 0;

virtual void draw_status(const DisplayLine& prompt,
const DisplayLine& content,
Expand Down
2 changes: 1 addition & 1 deletion test/commands/edit-fifo-noscroll-noeol/script
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [true] }'
exec 5>fifo

printf '* noeol' >&5
ui_out -until '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "*" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " noeol\u000a" }]], { "line": 0, "column": 0 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0] }'
ui_out -until '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "*" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " noeol\u000a" }]], { "line": 0, "column": 0 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0, 0, 0, 1] }'

exec 5>&-
ui_out -until '{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [], -1, [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "*fifo* 1:1 " }, { "face": { "fg": "black", "bg": "yellow", "underline": "default", "attributes": [] }, "contents": "[scratch]" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " - client0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "underline": "default", "attributes": [] }, "status"] }'
4 changes: 2 additions & 2 deletions test/commands/edit-fifo-noscroll/script
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [true] }'
exec 5>fifo

echo '* line1' >&5
ui_out -until '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "*" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " line1\u000a" }]], { "line": 0, "column": 0 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0] }'
ui_out -until '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "*" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " line1\u000a" }]], { "line": 0, "column": 0 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0, 0, 0, 1] }'
ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [false] }'

echo '* line2' >&5
ui_out -until '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "*" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " line1\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "* line2\u000a" }]], { "line": 0, "column": 0 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0] }'
ui_out -until '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "*" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " line1\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "* line2\u000a" }]], { "line": 0, "column": 0 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0, 0, 1, 2] }'
ui_out -until '{ "jsonrpc": "2.0", "method": "refresh", "params": [false] }'

dd if=/dev/zero bs=2049 count=1 2>/dev/null | sed s/././g >&5
Expand Down
2 changes: 1 addition & 1 deletion test/display/horizontal-scroll-onto-tab/script
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ui_out '{ "jsonrpc": "2.0", "method": "set_ui_options", "params": [{}] }'
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "90123456789012345678901234567890123456789012345678901234567890123456789012345678" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "90123456789012345678901234567890123456789012345678901234567890123456" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": " " }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "90" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "7890\u000a" }]], { "line": 1, "column": 72 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0] }'
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "90123456789012345678901234567890123456789012345678901234567890123456789012345678" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "90123456789012345678901234567890123456789012345678901234567890123456" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": " " }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "90" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "7890\u000a" }]], { "line": 1, "column": 72 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0, 0, 2, 3] }'
ui_out '{ "jsonrpc": "2.0", "method": "menu_hide", "params": [] }'
ui_out '{ "jsonrpc": "2.0", "method": "info_hide", "params": [] }'
ui_out '{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [], -1, [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "out 2:78 " }, { "face": { "fg": "black", "bg": "yellow", "underline": "default", "attributes": [] }, "contents": "" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " - client0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "underline": "default", "attributes": [] }, "status"] }'
Expand Down
2 changes: 1 addition & 1 deletion test/display/horizontal-scroll-with-tab/script
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ui_out '{ "jsonrpc": "2.0", "method": "set_ui_options", "params": [{}] }'
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1234567890123456789012345678901234567890123456789012345678901234567890123456789" }, { "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "0" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "7890\u000a" }]], { "line": 0, "column": 79 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0] }'
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1234567890123456789012345678901234567890123456789012345678901234567890123456789" }, { "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "0" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "7890\u000a" }]], { "line": 0, "column": 79 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0, 0, 1, 2] }'
ui_out '{ "jsonrpc": "2.0", "method": "menu_hide", "params": [] }'
ui_out '{ "jsonrpc": "2.0", "method": "info_hide", "params": [] }'
ui_out '{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [], -1, [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "out 1:90 " }, { "face": { "fg": "black", "bg": "yellow", "underline": "default", "attributes": [] }, "contents": "" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " - client0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "underline": "default", "attributes": [] }, "status"] }'
Expand Down
2 changes: 1 addition & 1 deletion test/display/horizontal-scroll/script
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ui_out '{ "jsonrpc": "2.0", "method": "set_ui_options", "params": [{}] }'
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "x" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "xxxxxxxxxx\u000a" }]], { "line": 0, "column": 79 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0] }'
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "x" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "xxxxxxxxxx\u000a" }]], { "line": 0, "column": 79 }, { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, 0, 0, 1, 2] }'
ui_out '{ "jsonrpc": "2.0", "method": "menu_hide", "params": [] }'
ui_out '{ "jsonrpc": "2.0", "method": "info_hide", "params": [] }'
ui_out '{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [], -1, [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "out 1:90 " }, { "face": { "fg": "black", "bg": "yellow", "underline": "default", "attributes": [] }, "contents": "" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " - client0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "underline": "default", "attributes": [] }, "status"] }'
Expand Down
Loading
Loading