Draw crosshair for the current line to the end of the screen row

This commit is contained in:
Josh Holtrop 2017-01-24 22:09:10 -05:00
parent 210a7b82c5
commit 9a34bfe4ba

View File

@ -307,28 +307,23 @@ void BufferPane::draw()
int BufferPane::draw_buffer_line(int screen_row, const Buffer::Iterator & start_of_line)
{
int saved_row_offset = 0;
walk_line(start_of_line, [this, &saved_row_offset, &screen_row](int row_offset, int screen_column, int virtual_column, int character_width, const Buffer::Iterator & i) {
int last_drawn_crosshair_row = -1;
walk_line(start_of_line, [this, &saved_row_offset, &screen_row, &last_drawn_crosshair_row](int row_offset, int screen_column, int virtual_column, int character_width, const Buffer::Iterator & i) {
uint32_t code_point = *i;
int draw_row = screen_row + row_offset;
if ((draw_row >= 0) && (draw_row <= m_rows))
{
if (i.line() == m_iterator->line())
{
int row = draw_row;
int col = screen_column;
int c_w = character_width;
if (insert_mode() && (code_point == '\n'))
if ((code_point != '\n') && (code_point != Buffer::Iterator::INVALID_CODE_POINT))
{
c_w = 1;
}
for (int i = 0; i < c_w; i++)
{
draw_crosshair(col_x(col), row_y(row));
col++;
if (col >= m_columns)
if (draw_row > last_drawn_crosshair_row)
{
row++;
col = 0;
for (int col = screen_column; col < m_columns; col++)
{
draw_crosshair(col_x(col), row_y(draw_row));
}
last_drawn_crosshair_row = draw_row;
}
}
}