take into account tab characters when counting line row heights

This commit is contained in:
Josh Holtrop 2016-12-21 18:36:47 -05:00
parent f7d0c8189a
commit 9733d577a7

View File

@ -27,16 +27,29 @@ int BufferPane::rows_in_line(const Buffer::Iterator & start_of_line)
{ {
break; break;
} }
int c_width = character_width(code_point); else if (code_point == '\t')
if (((screen_column + c_width) > m_columns) &&
(c_width <= m_columns))
{ {
rows++; uint8_t tabstop = m_buffer->tabstop();
screen_column = c_width; screen_column += tabstop - screen_column % tabstop;
if (screen_column > m_columns)
{
screen_column -= m_columns;
rows++;
}
} }
else else
{ {
screen_column += c_width; int c_width = character_width(code_point);
if (((screen_column + c_width) > m_columns) &&
(c_width <= m_columns))
{
rows++;
screen_column = c_width;
}
else
{
screen_column += c_width;
}
} }
} }
return rows; return rows;
@ -62,16 +75,29 @@ int BufferPane::rows_in_line_with_iterator_offset(const Buffer::Iterator & start
} }
break; break;
} }
int c_width = character_width(code_point); else if (code_point == '\t')
if (((screen_column + c_width) > m_columns) &&
(c_width <= m_columns))
{ {
rows++; uint8_t tabstop = m_buffer->tabstop();
screen_column = c_width; screen_column += tabstop - screen_column % tabstop;
if (screen_column > m_columns)
{
screen_column -= m_columns;
rows++;
}
} }
else else
{ {
screen_column += c_width; int c_width = character_width(code_point);
if (((screen_column + c_width) > m_columns) &&
(c_width <= m_columns))
{
rows++;
screen_column = c_width;
}
else
{
screen_column += c_width;
}
} }
} }
return rows; return rows;