Window: add a basic status line

This commit is contained in:
Maxime Coste 2011-10-04 18:49:41 +00:00
parent 4f771b084a
commit c8cf7bbaa9
3 changed files with 33 additions and 0 deletions

View File

@ -123,6 +123,16 @@ void draw_window(Window& window)
clrtoeol(); clrtoeol();
addch('~'); addch('~');
} }
move(max_y, 0);
set_attribute(A_UNDERLINE, 0);
set_attribute(A_REVERSE, 0);
set_attribute(A_BLINK, 0);
set_attribute(A_BOLD, 0);
set_color(Color::Cyan, Color::Black);
clrtoeol();
addstr(window.status_line().c_str());
const WindowCoord& cursor_position = window.cursor_position(); const WindowCoord& cursor_position = window.cursor_position();
move(cursor_position.line, cursor_position.column); move(cursor_position.line, cursor_position.column);

View File

@ -4,6 +4,7 @@
#include "filters.hh" #include "filters.hh"
#include <algorithm> #include <algorithm>
#include <sstream>
namespace Kakoune namespace Kakoune
{ {
@ -327,6 +328,26 @@ void Window::scroll_to_keep_cursor_visible_ifn()
} }
} }
std::string Window::status_line() const
{
BufferCoord cursor = window_to_buffer(cursor_position());
std::ostringstream oss;
oss << m_buffer.name() << " -- " << cursor.line << "," << cursor.column
<< " -- " << m_selections.size() << " sel -- ";
switch (m_select_mode)
{
case SelectMode::Normal:
oss << "[Normal]";
break;
case SelectMode::Append:
oss << "[Append]";
break;
default:
assert(false);
}
return oss.str();
}
IncrementalInserter::IncrementalInserter(Window& window, Mode mode) IncrementalInserter::IncrementalInserter(Window& window, Mode mode)
: m_window(window) : m_window(window)
{ {

View File

@ -86,6 +86,8 @@ public:
SelectMode select_mode() const { return m_select_mode; } SelectMode select_mode() const { return m_select_mode; }
void set_select_mode(SelectMode select_mode) { m_select_mode = select_mode; } void set_select_mode(SelectMode select_mode) { m_select_mode = select_mode; }
std::string status_line() const;
private: private:
friend class Buffer; friend class Buffer;