Skip to content

Commit 1a374ae

Browse files
gobenjimichal42
authored andcommitted
menuconfig: Do not open code textbox scroll up/down
We don't need to explicitely use ncurses' scroll(). ncurses performs vertical-motion optimization at wrefresh() time. Using strace I confirmed that with the following patch curses still sends only the new line of text to the terminal when scrolling up/down one line at a time. Signed-off-by: Benjamin Poirier <bpoirier@suse.de> Signed-off-by: Michal Marek <mmarek@suse.cz>
1 parent 5e609ad commit 1a374ae

File tree

1 file changed

+11
-44
lines changed

1 file changed

+11
-44
lines changed

scripts/kconfig/lxdialog/textbox.c

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -166,40 +166,12 @@ int dialog_textbox(const char *title, const char *tbuf, int initial_height,
166166
case 'K': /* Previous line */
167167
case 'k':
168168
case KEY_UP:
169-
if (!begin_reached) {
170-
int passed_end = 0;
171-
172-
back_lines(page_length + 1);
173-
174-
/* We don't call print_page() here but use
175-
* scrolling to ensure faster screen update.
176-
* However, 'end_reached' and 'page_length'
177-
* should still be updated, and 'page' should
178-
* point to start of next page. This is done
179-
* by calling get_line() in the following
180-
* 'for' loop. */
181-
scrollok(box, TRUE);
182-
wscrl(box, -1); /* Scroll box region down one line */
183-
scrollok(box, FALSE);
184-
page_length = 0;
185-
for (i = 0; i < boxh; i++) {
186-
if (!i) {
187-
/* print first line of page */
188-
print_line(box, 0, boxw);
189-
wnoutrefresh(box);
190-
} else
191-
/* Called to update 'end_reached' and 'page' */
192-
get_line();
193-
if (!passed_end)
194-
page_length++;
195-
if (end_reached && !passed_end)
196-
passed_end = 1;
197-
}
169+
if (begin_reached)
170+
break;
198171

199-
print_position(dialog);
200-
wmove(dialog, cur_y, cur_x); /* Restore cursor position */
201-
wrefresh(dialog);
202-
}
172+
back_lines(page_length + 1);
173+
refresh_text_box(dialog, box, boxh, boxw, cur_y,
174+
cur_x);
203175
break;
204176
case 'B': /* Previous page */
205177
case 'b':
@@ -214,17 +186,12 @@ int dialog_textbox(const char *title, const char *tbuf, int initial_height,
214186
case 'J': /* Next line */
215187
case 'j':
216188
case KEY_DOWN:
217-
if (!end_reached) {
218-
begin_reached = 0;
219-
scrollok(box, TRUE);
220-
scroll(box); /* Scroll box region up one line */
221-
scrollok(box, FALSE);
222-
print_line(box, boxh - 1, boxw);
223-
wnoutrefresh(box);
224-
print_position(dialog);
225-
wmove(dialog, cur_y, cur_x); /* Restore cursor position */
226-
wrefresh(dialog);
227-
}
189+
if (end_reached)
190+
break;
191+
192+
back_lines(page_length - 1);
193+
refresh_text_box(dialog, box, boxh, boxw, cur_y,
194+
cur_x);
228195
break;
229196
case KEY_NPAGE: /* Next page */
230197
case ' ':

0 commit comments

Comments
 (0)