Draw cursor as hollow when the buffer pane is not focused

This commit is contained in:
Josh Holtrop 2017-01-18 21:15:00 -05:00
parent 212215bf4d
commit 0d5b0e0437
2 changed files with 26 additions and 10 deletions

View File

@ -294,7 +294,7 @@ void BufferPane::draw()
} }
else else
{ {
draw_cursor(col_x(0), row_y(0)); draw_cursor(col_x(0), row_y(0), 0, 1);
} }
if (m_show_status_bar) if (m_show_status_bar)
{ {
@ -315,10 +315,10 @@ int BufferPane::draw_buffer_line(int screen_row, const Buffer::Iterator & start_
bool wrap = (code_point == '\t'); bool wrap = (code_point == '\t');
int row = draw_row; int row = draw_row;
int col = screen_column; int col = screen_column;
int w = insert_mode() ? 1 : std::max(1, character_width); int w = std::max(1, character_width);
while (w--) for (int i = 0; i < w; i++)
{ {
draw_cursor(col_x(col), row_y(row)); draw_cursor(col_x(col), row_y(row), i, w);
col++; col++;
if (wrap && (col >= m_columns)) if (wrap && (col >= m_columns))
{ {
@ -393,7 +393,7 @@ void BufferPane::draw_buffer_character(int screen_column, int screen_row, uint32
} }
} }
void BufferPane::draw_cursor(int x, int y) void BufferPane::draw_cursor(int x, int y, int i, int columns)
{ {
if (m_command_mode && (!m_focused)) if (m_command_mode && (!m_focused))
{ {
@ -403,13 +403,29 @@ void BufferPane::draw_cursor(int x, int y)
int height = m_window->font()->get_line_height(); int height = m_window->font()->get_line_height();
if (insert_mode()) if (insert_mode())
{ {
m_window->gl()->draw_rect(win_x(x), win_y(y), 1, height, 1.0, 0.2, 1.0, 1.0); if (i == 0)
m_window->gl()->draw_rect(win_x(x + 1), win_y(y + height - 1), 2, 1, 1.0, 0.2, 1.0, 1.0); {
m_window->gl()->draw_rect(win_x(x + 1), win_y(y), 2, 1, 1.0, 0.2, 1.0, 1.0); m_window->gl()->draw_rect(win_x(x), win_y(y), 1, height, 1.0, 0.2, 1.0, 1.0);
m_window->gl()->draw_rect(win_x(x + 1), win_y(y + height - 1), 2, 1, 1.0, 0.2, 1.0, 1.0);
m_window->gl()->draw_rect(win_x(x + 1), win_y(y), 2, 1, 1.0, 0.2, 1.0, 1.0);
}
}
else if (m_focused)
{
m_window->gl()->draw_rect(win_x(x), win_y(y), width, height, 1.0, 0.2, 1.0, 1.0);
} }
else else
{ {
m_window->gl()->draw_rect(win_x(x), win_y(y), width, height, 1.0, 0.2, 1.0, 1.0); m_window->gl()->draw_rect(win_x(x), win_y(y), width, 1, 1.0, 0.2, 1.0, 1.0);
m_window->gl()->draw_rect(win_x(x), win_y(y) + height - 1, width, 1, 1.0, 0.2, 1.0, 1.0);
if (i == 0)
{
m_window->gl()->draw_rect(win_x(x), win_y(y), 1, height, 1.0, 0.2, 1.0, 1.0);
}
if (i == (columns - 1))
{
m_window->gl()->draw_rect(win_x(x) + width - 1, win_y(y), 1, height, 1.0, 0.2, 1.0, 1.0);
}
} }
} }

View File

@ -41,7 +41,7 @@ protected:
void draw_character(uint32_t character, int screen_row, int screen_column); void draw_character(uint32_t character, int screen_row, int screen_column);
int character_width(uint32_t character); int character_width(uint32_t character);
void draw_buffer_character(int screen_column, int screen_row, uint32_t character); void draw_buffer_character(int screen_column, int screen_row, uint32_t character);
void draw_cursor(int x, int y); void draw_cursor(int x, int y, int i, int columns);
int calculate_rows_in_line(const Buffer::Iterator & start_of_line); int calculate_rows_in_line(const Buffer::Iterator & start_of_line);
int calculate_rows_in_cursor_line(const Buffer::Iterator & start_of_line); int calculate_rows_in_cursor_line(const Buffer::Iterator & start_of_line);
int calculate_rows_in_line_with_iterator_offset(const Buffer::Iterator & start_of_line, const Buffer::Iterator & reference, int * iterator_row_offset); int calculate_rows_in_line_with_iterator_offset(const Buffer::Iterator & start_of_line, const Buffer::Iterator & reference, int * iterator_row_offset);