diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/dged/buffer_view.c | 5 | ||||
| -rw-r--r-- | src/main/cmds.c | 26 |
2 files changed, 25 insertions, 6 deletions
diff --git a/src/dged/buffer_view.c b/src/dged/buffer_view.c index 9d998fe..9129147 100644 --- a/src/dged/buffer_view.c +++ b/src/dged/buffer_view.c @@ -475,8 +475,9 @@ bool buffer_view_update(struct buffer_view *view, if (view->dot.col >= view->scroll.col + width || view->dot.col < view->scroll.col) { - view->scroll.col = - buffer_clamp(view->buffer, view->dot.line, view->dot.col).col; + view->scroll.col = buffer_clamp(view->buffer, view->dot.line, + (int64_t)view->dot.col - params->width / 2) + .col; } timer_stop(render_linenumbers_timer); diff --git a/src/main/cmds.c b/src/main/cmds.c index 7d63661..fa3ceaa 100644 --- a/src/main/cmds.c +++ b/src/main/cmds.c @@ -22,6 +22,7 @@ #include "completion/buffer.h" #include "completion/command.h" #include "completion/path.h" +#include "dged/window.h" #include "search-replace.h" static void (*g_terminate_cb)(void) = NULL; @@ -626,8 +627,15 @@ static int32_t scroll_up_cmd(struct command_ctx ctx, int argc, (void)argc; (void)argv; - buffer_view_backward_nlines(window_buffer_view(ctx.active_window), - window_height(ctx.active_window) - 1); + uint32_t height = window_height(ctx.active_window); + uint32_t amount = height; + if (height > 3) { + amount = height - 3; + } + + struct buffer_view *bv = window_buffer_view(ctx.active_window); + buffer_view_backward_nlines(bv, amount); + bv->scroll.line = bv->dot.line; return 0; } @@ -636,8 +644,18 @@ static int32_t scroll_down_cmd(struct command_ctx ctx, int argc, (void)argc; (void)argv; - buffer_view_forward_nlines(window_buffer_view(ctx.active_window), - window_height(ctx.active_window) - 1); + uint32_t height = window_height(ctx.active_window); + uint32_t amount = height; + if (height > 3) { + amount = height - 3; + } + + struct buffer_view *bv = window_buffer_view(ctx.active_window); + buffer_view_forward_nlines(bv, amount); + if (bv->dot.line < buffer_num_lines(bv->buffer)) { + bv->scroll.line = bv->dot.line; + } + return 0; } |
