diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-23 14:30:49 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-23 14:30:49 -0500 |
commit | 88f7f5f8675a15d567837bd076e39e09bfe1aa74 (patch) | |
tree | 2b12ed6c901fbed71abe88a5420c5e2841155b6f /buffer.c | |
parent | f4172376d933c5c9033ff421f04db828825f9017 (diff) |
goto line preview
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -864,7 +864,15 @@ void buffer_scroll_to_pos(TextBuffer *buffer, BufferPos pos) { } // scroll in such a way that this position is in the center of the screen -void buffer_scroll_center_pos(TextBuffer *buffer) { +void buffer_scroll_center_pos(TextBuffer *buffer, BufferPos pos) { + double line = pos.line; + double col = buffer_index_to_column(buffer, pos.line, pos.index); + + double display_lines = buffer_display_lines(buffer); + double display_cols = buffer_display_cols(buffer); + buffer->scroll_x = col - display_cols * 0.5; + buffer->scroll_y = line - display_lines * 0.5; + buffer_correct_scroll(buffer); } // if the cursor is offscreen, this will scroll to make it onscreen. |