For short files that fit entirely in the window, adjust H/M/L jump points to within the file
This commit is contained in:
parent
65be7c3a6f
commit
c72308c9c3
@ -192,13 +192,25 @@ bool BufferView::cursor_move(CursorMovement which, uint32_t c, bool allow_eol)
|
||||
moved = m_iterator->go_backward_in_line_on_to_char(c);
|
||||
break;
|
||||
case CursorMovement::TOP_OF_SCREEN:
|
||||
moved = cursor_move_to_screen_position(0, effective_scroll_offset(), allow_eol);
|
||||
{
|
||||
int n_lines = n_screen_rows_with_content();
|
||||
int y = (n_lines < m_height) ? 0 : effective_scroll_offset();
|
||||
moved = cursor_move_to_screen_position(0, y, allow_eol);
|
||||
}
|
||||
break;
|
||||
case CursorMovement::MIDDLE_OF_SCREEN:
|
||||
moved = cursor_move_to_screen_position(0, m_height / 2, allow_eol);
|
||||
{
|
||||
int n_lines = n_screen_rows_with_content();
|
||||
int y = (n_lines < m_height) ? (n_lines / 2) : (m_height / 2);
|
||||
moved = cursor_move_to_screen_position(0, y, allow_eol);
|
||||
}
|
||||
break;
|
||||
case CursorMovement::BOTTOM_OF_SCREEN:
|
||||
moved = cursor_move_to_screen_position(0, m_height - effective_scroll_offset() - 1, allow_eol);
|
||||
{
|
||||
int n_lines = n_screen_rows_with_content();
|
||||
int y = (n_lines < m_height) ? (n_lines - 1) : (m_height - effective_scroll_offset() - 1);
|
||||
moved = cursor_move_to_screen_position(0, y, allow_eol);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (moved)
|
||||
@ -582,3 +594,13 @@ int BufferView::calculate_rows_below_screen(int stop_at)
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
int BufferView::n_screen_rows_with_content() const
|
||||
{
|
||||
if (m_lines.size() > 0u)
|
||||
{
|
||||
auto line_desc = m_lines.rbegin();
|
||||
return line_desc->row_offset + line_desc->n_rows;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -142,6 +142,7 @@ protected:
|
||||
bool allow_eol);
|
||||
int calculate_rows_above_screen(int stop_at);
|
||||
int calculate_rows_below_screen(int stop_at);
|
||||
int n_screen_rows_with_content() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user