Merge remote-tracking branch 'lenormf/buffer-padding'
This commit is contained in:
commit
815924e4da
|
@ -941,6 +941,7 @@ There are some builtins faces used by internal Kakoune functionalities:
|
|||
* `Prompt`: face used prompt displayed on the status line
|
||||
* `MatchingChar`: face used by the show_matching highlighter
|
||||
* `Search`: face used to highlight search results
|
||||
* `BufferPadding`: face applied on the characters that follow the last line of a buffer
|
||||
|
||||
Advanced topics
|
||||
---------------
|
||||
|
|
|
@ -64,5 +64,6 @@
|
|||
face StatusCursor ${black_lighterer},${cyan_light}
|
||||
face Prompt ${black_light},${cyan_light}
|
||||
face MatchingChar ${cyan_light},${black_light}+b
|
||||
face BufferPadding ${cyan_light},${black_lighter}
|
||||
"
|
||||
}
|
||||
|
|
|
@ -43,3 +43,4 @@ face StatusLineValue green,default
|
|||
face StatusCursor black,cyan
|
||||
face Prompt yellow,default
|
||||
face MatchingChar default,default+b
|
||||
face BufferPadding blue,default
|
||||
|
|
|
@ -43,3 +43,4 @@ face StatusCursor rgb:434343,rgb:CDCDFD
|
|||
face Prompt rgb:F8F8FF,rgb:4078C0
|
||||
face MatchingChar rgb:F8F8FF,rgb:4078C0+b
|
||||
face Search default,default+u
|
||||
face BufferPadding rgb:A0A0A0,rgb:F8F8FF
|
||||
|
|
|
@ -66,5 +66,6 @@
|
|||
face StatusCursor default,${lucius_blue}
|
||||
face Prompt ${lucius_lighter_grey}
|
||||
face MatchingChar ${lucius_lighter_grey},${lucius_bright_green}
|
||||
face BufferPadding ${lucius_green},${lucius_darker_grey}
|
||||
"
|
||||
}
|
||||
|
|
|
@ -64,5 +64,6 @@
|
|||
face StatusCursor ${orange},${white_light}
|
||||
face Prompt ${black_light}
|
||||
face MatchingChar default+b
|
||||
face BufferPadding ${grey_dark},${white}
|
||||
"
|
||||
}
|
||||
|
|
|
@ -64,5 +64,6 @@
|
|||
face StatusCursor ${base00},${base3}
|
||||
face Prompt yellow
|
||||
face MatchingChar default+b
|
||||
face BufferPadding ${base01},${base03}
|
||||
"
|
||||
}
|
||||
|
|
|
@ -67,5 +67,6 @@
|
|||
face StatusCursor ${zencursor}
|
||||
face Prompt yellow
|
||||
face MatchingChar default+b
|
||||
face BufferPadding ${zenkeyword},${zenbackground}
|
||||
"
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ Here are the data structures used:
|
|||
|
||||
Here are the requests that can be written by the json ui on stdout:
|
||||
|
||||
* draw(Array<Line> lines, Face default_face)
|
||||
* draw(Array<Line> lines, Face default_face, Face padding_face)
|
||||
* draw_status(Line status_line, Line mode_line,
|
||||
Face default_face)
|
||||
* menu_show(Array<Line> items, Coord anchor, Face fg, Face bg,
|
||||
|
|
|
@ -94,3 +94,6 @@ areas of the user interface:
|
|||
|
||||
*Search*::
|
||||
face used to highlight search results
|
||||
|
||||
*BufferPadding*::
|
||||
face applied on the characters that follow the last line of a buffer
|
||||
|
|
|
@ -190,7 +190,8 @@ void Client::redraw_ifn()
|
|||
|
||||
if (m_ui_pending & Draw)
|
||||
{
|
||||
m_ui->draw(window.update_display_buffer(context()), get_face("Default"));
|
||||
m_ui->draw(window.update_display_buffer(context()),
|
||||
get_face("Default"), get_face("BufferPadding"));
|
||||
|
||||
if (not m_menu.items.empty() and m_menu.style == MenuStyle::Inline and
|
||||
m_menu.ui_anchor != window.display_position(m_menu.anchor))
|
||||
|
|
|
@ -120,6 +120,7 @@ FaceRegistry::FaceRegistry()
|
|||
{ "StatusCursor", Face{ Color::Black, Color::Cyan } },
|
||||
{ "Prompt", Face{ Color::Yellow, Color::Default } },
|
||||
{ "MatchingChar", Face{ Color::Default, Color::Default, Attribute::Bold } },
|
||||
{ "BufferPadding", Face{ Color::Blue, Color::Default } },
|
||||
}
|
||||
{}
|
||||
|
||||
|
|
|
@ -168,9 +168,9 @@ JsonUI::JsonUI()
|
|||
}
|
||||
|
||||
void JsonUI::draw(const DisplayBuffer& display_buffer,
|
||||
const Face& default_face)
|
||||
const Face& default_face, const Face& padding_face)
|
||||
{
|
||||
rpc_call("draw", display_buffer.lines(), default_face);
|
||||
rpc_call("draw", display_buffer.lines(), default_face, padding_face);
|
||||
}
|
||||
|
||||
void JsonUI::draw_status(const DisplayLine& status_line,
|
||||
|
|
|
@ -19,7 +19,8 @@ public:
|
|||
JsonUI& operator=(const JsonUI&) = delete;
|
||||
|
||||
void draw(const DisplayBuffer& display_buffer,
|
||||
const Face& default_face) override;
|
||||
const Face& default_face,
|
||||
const Face& buffer_padding) override;
|
||||
|
||||
void draw_status(const DisplayLine& status_line,
|
||||
const DisplayLine& mode_line,
|
||||
|
|
|
@ -258,7 +258,9 @@ void register_options()
|
|||
" ncurses_set_title bool\n"
|
||||
" ncurses_enable_mouse bool\n"
|
||||
" ncurses_wheel_up_button int\n"
|
||||
" ncurses_wheel_down_button int\n",
|
||||
" ncurses_wheel_down_button int\n"
|
||||
" ncurses_buffer_padding_str str\n"
|
||||
" ncurses_buffer_padding_type fill|single|off\n",
|
||||
UserInterface::Options{});
|
||||
reg.declare_option("modelinefmt", "format string used to generate the modeline",
|
||||
"%val{bufname} %val{cursor_line}:%val{cursor_char_column} "_str);
|
||||
|
@ -308,7 +310,7 @@ std::unique_ptr<UserInterface> make_ui(UIType ui_type)
|
|||
void info_show(StringView, StringView, CharCoord, Face, InfoStyle) override {}
|
||||
void info_hide() override {}
|
||||
|
||||
void draw(const DisplayBuffer&, const Face&) override {}
|
||||
void draw(const DisplayBuffer&, const Face&, const Face&) override {}
|
||||
void draw_status(const DisplayLine&, const DisplayLine&, const Face&) override {}
|
||||
CharCoord dimensions() override { return {24,80}; }
|
||||
bool is_key_available() override { return false; }
|
||||
|
|
|
@ -343,8 +343,11 @@ void NCursesUI::draw_line(NCursesWin* window, const DisplayLine& line,
|
|||
}
|
||||
}
|
||||
|
||||
static const DisplayLine empty_line = String(" ");
|
||||
|
||||
void NCursesUI::draw(const DisplayBuffer& display_buffer,
|
||||
const Face& default_face)
|
||||
const Face& default_face,
|
||||
const Face& padding_face)
|
||||
{
|
||||
wbkgdset(m_window, COLOR_PAIR(get_color_pair(default_face)));
|
||||
|
||||
|
@ -359,12 +362,18 @@ void NCursesUI::draw(const DisplayBuffer& display_buffer,
|
|||
++line_index;
|
||||
}
|
||||
|
||||
set_face(m_window, { Color::Blue, Color::Default }, default_face);
|
||||
set_face(m_window, padding_face, default_face);
|
||||
|
||||
const DisplayLine padding_line = m_buffer_padding_str;
|
||||
const DisplayLine* padding_line_ptr = m_buffer_padding_type != BufferPaddingType::None ?
|
||||
&padding_line : &empty_line;
|
||||
while (line_index < m_dimensions.line + (m_status_on_top ? 1 : 0))
|
||||
{
|
||||
wmove(m_window, (int)line_index++, 0);
|
||||
wclrtoeol(m_window);
|
||||
waddch(m_window, '~');
|
||||
draw_line(m_window, *padding_line_ptr, 0, m_dimensions.column, padding_face);
|
||||
if (m_buffer_padding_type == BufferPaddingType::Single)
|
||||
padding_line_ptr = &empty_line;
|
||||
}
|
||||
|
||||
m_dirty = true;
|
||||
|
@ -982,6 +991,20 @@ void NCursesUI::set_ui_options(const Options& options)
|
|||
m_wheel_down_button = wheel_down_it != options.end() ?
|
||||
str_to_int_ifp(wheel_down_it->value).value_or(5) : 5;
|
||||
}
|
||||
|
||||
{
|
||||
auto padding_str_it = options.find("ncurses_buffer_padding_str");
|
||||
m_buffer_padding_str = padding_str_it == options.end() or !padding_str_it->value.length() ?
|
||||
"~" : padding_str_it->value;
|
||||
|
||||
auto padding_type_it = options.find("ncurses_buffer_padding_type");
|
||||
if (padding_type_it == options.end() or padding_type_it->value == "fill")
|
||||
m_buffer_padding_type = BufferPaddingType::Fill;
|
||||
else if (padding_type_it->value == "single")
|
||||
m_buffer_padding_type = BufferPaddingType::Single;
|
||||
else
|
||||
m_buffer_padding_type = BufferPaddingType::None;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace Kakoune
|
|||
|
||||
struct NCursesWin;
|
||||
|
||||
enum BufferPaddingType { None, Single, Fill };
|
||||
|
||||
class NCursesUI : public UserInterface
|
||||
{
|
||||
public:
|
||||
|
@ -23,7 +25,8 @@ public:
|
|||
NCursesUI& operator=(const NCursesUI&) = delete;
|
||||
|
||||
void draw(const DisplayBuffer& display_buffer,
|
||||
const Face& default_face) override;
|
||||
const Face& default_face,
|
||||
const Face& padding_face) override;
|
||||
|
||||
void draw_status(const DisplayLine& status_line,
|
||||
const DisplayLine& mode_line,
|
||||
|
@ -126,6 +129,9 @@ private:
|
|||
int m_wheel_up_button = 4;
|
||||
int m_wheel_down_button = 5;
|
||||
|
||||
String m_buffer_padding_str = "~";
|
||||
BufferPaddingType m_buffer_padding_type = BufferPaddingType::None;
|
||||
|
||||
bool m_set_title = true;
|
||||
|
||||
bool m_dirty = false;
|
||||
|
|
|
@ -249,7 +249,8 @@ public:
|
|||
void info_hide() override;
|
||||
|
||||
void draw(const DisplayBuffer& display_buffer,
|
||||
const Face& default_face) override;
|
||||
const Face& default_face,
|
||||
const Face& padding_face) override;
|
||||
|
||||
void draw_status(const DisplayLine& status_line,
|
||||
const DisplayLine& mode_line,
|
||||
|
@ -334,12 +335,14 @@ void RemoteUI::info_hide()
|
|||
}
|
||||
|
||||
void RemoteUI::draw(const DisplayBuffer& display_buffer,
|
||||
const Face& default_face)
|
||||
const Face& default_face,
|
||||
const Face& padding_face)
|
||||
{
|
||||
Message msg(m_socket_watcher.fd());
|
||||
msg.write(RemoteUIMsg::Draw);
|
||||
msg.write(display_buffer);
|
||||
msg.write(default_face);
|
||||
msg.write(padding_face);
|
||||
}
|
||||
|
||||
void RemoteUI::draw_status(const DisplayLine& status_line,
|
||||
|
@ -505,7 +508,8 @@ void RemoteClient::process_next_message()
|
|||
{
|
||||
auto display_buffer = read<DisplayBuffer>(socket);
|
||||
auto default_face = read<Face>(socket);
|
||||
m_ui->draw(display_buffer, default_face);
|
||||
auto padding_face = read<Face>(socket);
|
||||
m_ui->draw(display_buffer, default_face, padding_face);
|
||||
break;
|
||||
}
|
||||
case RemoteUIMsg::DrawStatus:
|
||||
|
|
|
@ -53,7 +53,8 @@ public:
|
|||
virtual void info_hide() = 0;
|
||||
|
||||
virtual void draw(const DisplayBuffer& display_buffer,
|
||||
const Face& default_face) = 0;
|
||||
const Face& default_face,
|
||||
const Face& padding_face) = 0;
|
||||
|
||||
virtual void draw_status(const DisplayLine& status_line,
|
||||
const DisplayLine& mode_line,
|
||||
|
|
Loading…
Reference in New Issue
Block a user