NCurses: When mode line is too long, trim it rather hiding it
This commit is contained in:
parent
e0f7a6f0be
commit
840e58e0b1
|
@ -169,11 +169,11 @@ CharCount DisplayLine::length() const
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayLine::trim(CharCount first_char, CharCount char_count)
|
void DisplayLine::trim(CharCount first_char, CharCount char_count, bool only_buffer)
|
||||||
{
|
{
|
||||||
for (auto it = begin(); first_char > 0 and it != end(); )
|
for (auto it = begin(); first_char > 0 and it != end(); )
|
||||||
{
|
{
|
||||||
if (not it->has_buffer_range())
|
if (only_buffer and not it->has_buffer_range())
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -114,7 +114,7 @@ public:
|
||||||
|
|
||||||
// remove first_char from the begining of the line, and make sure
|
// remove first_char from the begining of the line, and make sure
|
||||||
// the line is less that char_count character
|
// the line is less that char_count character
|
||||||
void trim(CharCount first_char, CharCount char_count);
|
void trim(CharCount first_char, CharCount char_count, bool only_buffer);
|
||||||
|
|
||||||
void optimize();
|
void optimize();
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -388,14 +388,25 @@ void NCursesUI::draw(const DisplayBuffer& display_buffer,
|
||||||
wmove(m_window, status_line_pos, 0);
|
wmove(m_window, status_line_pos, 0);
|
||||||
wclrtoeol(m_window);
|
wclrtoeol(m_window);
|
||||||
draw_line(status_line, 0);
|
draw_line(status_line, 0);
|
||||||
CharCount status_len = mode_line.length();
|
const auto mode_len = mode_line.length();
|
||||||
// only draw mode_line if it does not overlap one status line
|
const auto remaining = m_dimensions.column - status_line.length();
|
||||||
if (m_dimensions.column - status_line.length() > status_len + 1)
|
if (mode_len < remaining)
|
||||||
{
|
{
|
||||||
CharCount col = m_dimensions.column - status_len;
|
CharCount col = m_dimensions.column - mode_len;
|
||||||
wmove(m_window, status_line_pos, (int)col);
|
wmove(m_window, status_line_pos, (int)col);
|
||||||
draw_line(mode_line, col);
|
draw_line(mode_line, col);
|
||||||
}
|
}
|
||||||
|
else if (remaining > 2)
|
||||||
|
{
|
||||||
|
DisplayLine trimmed_mode_line = mode_line;
|
||||||
|
trimmed_mode_line.trim(mode_len + 2 - remaining, remaining - 2, false);
|
||||||
|
trimmed_mode_line.insert(trimmed_mode_line.begin(), { "<" });
|
||||||
|
kak_assert(trimmed_mode_line.length() == remaining - 1);
|
||||||
|
|
||||||
|
CharCount col = m_dimensions.column - remaining + 1;
|
||||||
|
wmove(m_window, status_line_pos, (int)col);
|
||||||
|
draw_line(trimmed_mode_line, col);
|
||||||
|
}
|
||||||
|
|
||||||
const char* tsl = tigetstr((char*)"tsl");
|
const char* tsl = tigetstr((char*)"tsl");
|
||||||
const char* fsl = tigetstr((char*)"fsl");
|
const char* fsl = tigetstr((char*)"fsl");
|
||||||
|
|
|
@ -83,7 +83,7 @@ void Window::update_display_buffer(const Context& context)
|
||||||
|
|
||||||
// cut the start of the line before m_position.column
|
// cut the start of the line before m_position.column
|
||||||
for (auto& line : lines)
|
for (auto& line : lines)
|
||||||
line.trim(m_position.column, m_dimensions.column);
|
line.trim(m_position.column, m_dimensions.column, true);
|
||||||
m_display_buffer.optimize();
|
m_display_buffer.optimize();
|
||||||
|
|
||||||
m_timestamp = buffer().timestamp();
|
m_timestamp = buffer().timestamp();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user