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
{
draw_cursor(col_x(0), row_y(0));
draw_cursor(col_x(0), row_y(0), 0, 1);
}
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');
int row = draw_row;
int col = screen_column;
int w = insert_mode() ? 1 : std::max(1, character_width);
while (w--)
int w = std::max(1, character_width);
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++;
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))
{
@ -402,15 +402,31 @@ void BufferPane::draw_cursor(int x, int y)
int width = m_window->font()->get_advance();
int height = m_window->font()->get_line_height();
if (insert_mode())
{
if (i == 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
}
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
{
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);
}
}
}
void BufferPane::exit_insert_mode()

View File

@ -41,7 +41,7 @@ protected:
void draw_character(uint32_t character, int screen_row, int screen_column);
int character_width(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_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);