pass a color pair when displaying an information window
This commit is contained in:
parent
b58f614f40
commit
1822b81d58
|
@ -407,6 +407,7 @@ there are some builtins color aliases:
|
|||
* +LineNumbers+: colors used by the number_lines highlighter
|
||||
* +MenuForeground+: colors for the selected element in menus
|
||||
* +MenuBackground+: colors for the not selected elements in menus
|
||||
* +Information+: colors the informations windows
|
||||
|
||||
Shell expansion
|
||||
---------------
|
||||
|
|
|
@ -48,6 +48,7 @@ ColorRegistry::ColorRegistry()
|
|||
{ "LineNumbers", { Color::Black, Color::White } },
|
||||
{ "MenuForeground", { Color::Blue, Color::Cyan } },
|
||||
{ "MenuBackground", { Color::Cyan, Color::Blue } },
|
||||
{ "Information", { Color::Black, Color::Yellow } },
|
||||
}
|
||||
{}
|
||||
|
||||
|
|
|
@ -684,7 +684,8 @@ void info(const CommandParameters& params, Context& context)
|
|||
pos = context.window().display_position(it);
|
||||
}
|
||||
const String& message = parser.has_option("assist") ? assist(parser[0], dimensions.column) : parser[0];
|
||||
context.ui().info_show(message, pos, style);
|
||||
ColorPair colors = ColorRegistry::instance()["Information"];
|
||||
context.ui().info_show(message, pos, colors, style);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -810,7 +811,7 @@ public:
|
|||
void menu_select(int) override {}
|
||||
void menu_hide() override {}
|
||||
|
||||
void info_show(const String&, const DisplayCoord&, MenuStyle) override {}
|
||||
void info_show(const String&, DisplayCoord, ColorPair, MenuStyle) override {}
|
||||
void info_hide() override {}
|
||||
|
||||
DisplayCoord dimensions() override { return { 0, 0 }; }
|
||||
|
|
|
@ -485,7 +485,8 @@ static DisplayCoord compute_pos(const DisplayCoord& anchor,
|
|||
return pos;
|
||||
}
|
||||
|
||||
void NCursesUI::info_show(const String& content, const DisplayCoord& anchor, MenuStyle style)
|
||||
void NCursesUI::info_show(const String& content, DisplayCoord anchor,
|
||||
ColorPair colors, MenuStyle style)
|
||||
{
|
||||
assert(m_info_win == nullptr);
|
||||
|
||||
|
@ -498,7 +499,7 @@ void NCursesUI::info_show(const String& content, const DisplayCoord& anchor, Men
|
|||
m_info_win = newwin((int)size.line, (int)size.column,
|
||||
(int)pos.line, (int)pos.column);
|
||||
|
||||
wbkgd(m_info_win, COLOR_PAIR(get_color_pair({ Color::Black, Color::Yellow })));
|
||||
wbkgd(m_info_win, COLOR_PAIR(get_color_pair(colors)));
|
||||
wmove(m_info_win, 0, 0);
|
||||
addutf8str(m_info_win, Utf8Iterator(content.begin()),
|
||||
Utf8Iterator(content.end()));
|
||||
|
|
|
@ -32,8 +32,8 @@ public:
|
|||
void menu_select(int selected) override;
|
||||
void menu_hide() override;
|
||||
|
||||
void info_show(const String& content,
|
||||
const DisplayCoord& anchor, MenuStyle style) override;
|
||||
void info_show(const String& content, DisplayCoord anchor,
|
||||
ColorPair colors, MenuStyle style) override;
|
||||
void info_hide() override;
|
||||
|
||||
void set_input_callback(InputCallback callback) override;
|
||||
|
|
|
@ -194,8 +194,8 @@ public:
|
|||
void menu_select(int selected) override;
|
||||
void menu_hide() override;
|
||||
|
||||
void info_show(const String& content,
|
||||
const DisplayCoord& anchor, MenuStyle style) override;
|
||||
void info_show(const String& content, DisplayCoord anchor,
|
||||
ColorPair colors, MenuStyle style) override;
|
||||
void info_hide() override;
|
||||
|
||||
void draw(const DisplayBuffer& display_buffer,
|
||||
|
@ -260,13 +260,14 @@ void RemoteUI::menu_hide()
|
|||
msg.write(RemoteUIMsg::MenuHide);
|
||||
}
|
||||
|
||||
void RemoteUI::info_show(const String& content,
|
||||
const DisplayCoord& anchor, MenuStyle style)
|
||||
void RemoteUI::info_show(const String& content, DisplayCoord anchor,
|
||||
ColorPair colors, MenuStyle style)
|
||||
{
|
||||
Message msg(m_socket_watcher.fd());
|
||||
msg.write(RemoteUIMsg::InfoShow);
|
||||
msg.write(content);
|
||||
msg.write(anchor);
|
||||
msg.write(colors);
|
||||
msg.write(style);
|
||||
}
|
||||
|
||||
|
@ -369,8 +370,9 @@ void RemoteClient::process_next_message()
|
|||
{
|
||||
auto choices = read<String>(socket);
|
||||
auto anchor = read<DisplayCoord>(socket);
|
||||
auto colors = read<ColorPair>(socket);
|
||||
auto style = read<MenuStyle>(socket);
|
||||
m_ui->info_show(choices, anchor, style);
|
||||
m_ui->info_show(choices, anchor, colors, style);
|
||||
break;
|
||||
}
|
||||
case RemoteUIMsg::InfoHide:
|
||||
|
|
|
@ -34,8 +34,8 @@ public:
|
|||
virtual void menu_select(int selected) = 0;
|
||||
virtual void menu_hide() = 0;
|
||||
|
||||
virtual void info_show(const String& content,
|
||||
const DisplayCoord& anchor, MenuStyle style) = 0;
|
||||
virtual void info_show(const String& content, DisplayCoord anchor,
|
||||
ColorPair colors, MenuStyle style) = 0;
|
||||
virtual void info_hide() = 0;
|
||||
|
||||
virtual void draw(const DisplayBuffer& display_buffer,
|
||||
|
|
Loading…
Reference in New Issue
Block a user