From b08749285e76d77ebdab4ea1c56092438d953ff9 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 18 Feb 2013 19:03:39 +0100 Subject: [PATCH] move status line generation code to client manager --- src/client_manager.cc | 21 ++++++++++++++++++++- src/window.cc | 16 ---------------- src/window.hh | 2 -- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/client_manager.cc b/src/client_manager.cc index 62324b7c..519cd00a 100644 --- a/src/client_manager.cc +++ b/src/client_manager.cc @@ -188,6 +188,24 @@ Context& ClientManager::get_client_context(const String& 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 { for (auto& client : m_clients) @@ -200,8 +218,9 @@ void ClientManager::redraw_clients() const return; context.window().set_dimensions(dimensions); context.window().update_display_buffer();; + context.ui().draw(context.window().display_buffer(), - context.window().status_line()); + generate_status_line(context)); } } } diff --git a/src/window.cc b/src/window.cc index 9435c525..e0f11ab2 100644 --- a/src/window.cc +++ b/src/window.cc @@ -171,22 +171,6 @@ DisplayCoord Window::display_position(const BufferIterator& iterator) 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) { String desc = name + "=" + option.as_string(); diff --git a/src/window.hh b/src/window.hh index 7eb13860..3e3c187f 100644 --- a/src/window.hh +++ b/src/window.hh @@ -38,8 +38,6 @@ public: DisplayCoord display_position(const BufferIterator& it); - String status_line() const; - HighlighterGroup& highlighters() { return m_highlighters; } OptionManager& options() { return m_options; }