linux-qubasis
linux oasis port as a qubes template
git clone https://9o.is/git/linux-qubasis.git
0002-center-scrolling.patch
(1814B)
1 From 5b9e811551524283fab11d656304445831f9001a Mon Sep 17 00:00:00 2001
2 From: Jul <jul@qh.is>
3 Date: Tue, 5 Aug 2025 02:50:21 -0400
4 Subject: [PATCH] center scrolling
5
6 ---
7 src/options.c | 1 -
8 src/options.h | 1 -
9 src/tty_interface.c | 5 +++--
10 3 files changed, 3 insertions(+), 4 deletions(-)
11
12 diff --git a/src/options.c b/src/options.c
13 index 485fc98..5fd9d2a 100644
14 --- a/src/options.c
15 +++ b/src/options.c
16 @@ -47,7 +47,6 @@ void options_init(options_t *options) {
17 options->filter = NULL;
18 options->init_search = NULL;
19 options->show_scores = 0;
20 - options->scrolloff = 1;
21 options->tty_filename = DEFAULT_TTY;
22 options->num_lines = DEFAULT_NUM_LINES;
23 options->prompt = DEFAULT_PROMPT;
24 diff --git a/src/options.h b/src/options.h
25 index 1a0886e..bfc3fa4 100644
26 --- a/src/options.h
27 +++ b/src/options.h
28 @@ -12,7 +12,6 @@ typedef struct {
29 const char *tty_filename;
30 int show_scores;
31 unsigned int num_lines;
32 - unsigned int scrolloff;
33 const char *prompt;
34 unsigned int workers;
35 char input_delimiter;
36 diff --git a/src/tty_interface.c b/src/tty_interface.c
37 index 59c9c74..02c26a0 100644
38 --- a/src/tty_interface.c
39 +++ b/src/tty_interface.c
40 @@ -82,9 +82,10 @@ static void draw(tty_interface_t *state) {
41
42 unsigned int num_lines = options->num_lines;
43 size_t start = 0;
44 + size_t scroll_threshold = (num_lines / 2) + 1;
45 size_t current_selection = choices->selection;
46 - if (current_selection + options->scrolloff >= num_lines) {
47 - start = current_selection + options->scrolloff - num_lines + 1;
48 + if (current_selection >= scroll_threshold) {
49 + start = current_selection - scroll_threshold + 1;
50 size_t available = choices_available(choices);
51 if (start + num_lines >= available && available > 0) {
52 start = available - num_lines;
53 --
54 2.51.0
55