move status line generation code to client manager
This commit is contained in:
parent
b43fdc7eb6
commit
b08749285e
|
@ -188,6 +188,24 @@ Context& ClientManager::get_client_context(const String& name)
|
||||||
throw runtime_error("no client named: " + name);
|
throw runtime_error("no client named: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String generate_status_line(const Context& context)
|
||||||
|
{
|
||||||
|
BufferCoord cursor = context.editor().selections().back().last().coord();
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << context.buffer().name()
|
||||||
|
<< " " << (int)cursor.line+1 << "," << (int)cursor.column+1;
|
||||||
|
if (context.buffer().is_modified())
|
||||||
|
oss << " [+]";
|
||||||
|
if (context.input_handler().is_recording())
|
||||||
|
oss << " [recording]";
|
||||||
|
if (context.buffer().flags() & Buffer::Flags::New)
|
||||||
|
oss << " [new file]";
|
||||||
|
oss << " [" << context.editor().selections().size() << " sel]";
|
||||||
|
if (context.editor().is_editing())
|
||||||
|
oss << " [insert]";
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
void ClientManager::redraw_clients() const
|
void ClientManager::redraw_clients() const
|
||||||
{
|
{
|
||||||
for (auto& client : m_clients)
|
for (auto& client : m_clients)
|
||||||
|
@ -200,8 +218,9 @@ void ClientManager::redraw_clients() const
|
||||||
return;
|
return;
|
||||||
context.window().set_dimensions(dimensions);
|
context.window().set_dimensions(dimensions);
|
||||||
context.window().update_display_buffer();;
|
context.window().update_display_buffer();;
|
||||||
|
|
||||||
context.ui().draw(context.window().display_buffer(),
|
context.ui().draw(context.window().display_buffer(),
|
||||||
context.window().status_line());
|
generate_status_line(context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,22 +171,6 @@ DisplayCoord Window::display_position(const BufferIterator& iterator)
|
||||||
return { 0, 0 };
|
return { 0, 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
String Window::status_line() const
|
|
||||||
{
|
|
||||||
BufferCoord cursor = selections().back().last().coord();
|
|
||||||
std::ostringstream oss;
|
|
||||||
oss << buffer().name()
|
|
||||||
<< " " << (int)cursor.line+1 << "," << (int)cursor.column+1;
|
|
||||||
if (buffer().is_modified())
|
|
||||||
oss << " [+]";
|
|
||||||
if (buffer().flags() & Buffer::Flags::New)
|
|
||||||
oss << " [new file]";
|
|
||||||
oss << " [" << selections().size() << " sel]";
|
|
||||||
if (is_editing())
|
|
||||||
oss << " [insert]";
|
|
||||||
return oss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::on_option_changed(const String& name, const Option& option)
|
void Window::on_option_changed(const String& name, const Option& option)
|
||||||
{
|
{
|
||||||
String desc = name + "=" + option.as_string();
|
String desc = name + "=" + option.as_string();
|
||||||
|
|
|
@ -38,8 +38,6 @@ public:
|
||||||
|
|
||||||
DisplayCoord display_position(const BufferIterator& it);
|
DisplayCoord display_position(const BufferIterator& it);
|
||||||
|
|
||||||
String status_line() const;
|
|
||||||
|
|
||||||
HighlighterGroup& highlighters() { return m_highlighters; }
|
HighlighterGroup& highlighters() { return m_highlighters; }
|
||||||
|
|
||||||
OptionManager& options() { return m_options; }
|
OptionManager& options() { return m_options; }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user