mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Move screen update code into set_kbd_repeat_count
Make set_kbd_repeat_count update the status bar and link highlighting iff the repeat count is changed to a different value. Delete code to do the same updates from do_action and try_prefix_key. Besides simplifying the code, this change also fixes some issues with the status bar and link highlighting not being properly updated in some situations.
This commit is contained in:
parent
d6bd7987d4
commit
b1422adf20
2
NEWS
2
NEWS
@ -45,6 +45,8 @@ Miscellaneous:
|
||||
toggle-* actions no longer affect other tabs or other terminals.
|
||||
* Do not crash when document.browse.minimum_refresh_time = 0 and
|
||||
a document has a meta refresh with a delay of 0.
|
||||
* Properly update link highlighting and status bar information when the
|
||||
repeat prefix is changed.
|
||||
* enhancement 15: Domain-specific options. Use set_domain in
|
||||
elinks.conf to e.g. disable cookies for google.com. The option
|
||||
manager window does not yet support this.
|
||||
|
@ -1451,7 +1451,26 @@ eat_kbd_repeat_count(struct session *ses)
|
||||
int
|
||||
set_kbd_repeat_count(struct session *ses, int new_count)
|
||||
{
|
||||
int old_count = ses->kbdprefix.repeat_count;
|
||||
|
||||
if (new_count == old_count)
|
||||
return old_count;
|
||||
|
||||
ses->kbdprefix.repeat_count = new_count;
|
||||
|
||||
/* Update the status bar. */
|
||||
print_screen_status(ses);
|
||||
|
||||
/* Clear the old link highlighting. */
|
||||
draw_formatted(ses, 0);
|
||||
|
||||
if (new_count != 0) {
|
||||
struct document_view *doc_view = current_frame(ses);
|
||||
|
||||
highlight_links_with_prefixes_that_start_with_n(ses->tab->term,
|
||||
doc_view,
|
||||
new_count);
|
||||
}
|
||||
|
||||
return new_count;
|
||||
}
|
||||
|
@ -131,19 +131,9 @@ do_action(struct session *ses, enum main_action action_id, int verbose)
|
||||
|
||||
if (!ses->kbdprefix.repeat_count) break;
|
||||
|
||||
/* Clear the highlighting. */
|
||||
draw_formatted(ses, 0);
|
||||
|
||||
set_kbd_repeat_count(ses,
|
||||
ses->kbdprefix.repeat_count / 10);
|
||||
|
||||
if (ses->kbdprefix.repeat_count)
|
||||
highlight_links_with_prefixes_that_start_with_n(
|
||||
term, doc_view,
|
||||
ses->kbdprefix.repeat_count);
|
||||
|
||||
print_screen_status(ses);
|
||||
|
||||
/* Keep send_event from resetting repeat_count. */
|
||||
status = FRAME_EVENT_SESSION_DESTROYED;
|
||||
|
||||
|
@ -1037,25 +1037,20 @@ try_prefix_key(struct session *ses, struct document_view *doc_view,
|
||||
* entering a prefix. */
|
||||
|| !doc_opts->num_links_key
|
||||
|| (doc_opts->num_links_key == 1 && !doc_opts->links_numbering)) {
|
||||
int old_count = ses->kbdprefix.repeat_count;
|
||||
int new_count = old_count * 10 + digit;
|
||||
|
||||
/* Repeat count.
|
||||
* ses->kbdprefix.repeat_count is initialized to zero
|
||||
* the first time by init_session() calloc() call.
|
||||
* When used, it has to be reset to zero. */
|
||||
|
||||
/* Clear the highlighting for the previous partial prefix. */
|
||||
if (ses->kbdprefix.repeat_count) draw_formatted(ses, 0);
|
||||
|
||||
set_kbd_repeat_count(ses,
|
||||
ses->kbdprefix.repeat_count * 10 + digit);
|
||||
|
||||
/* If too big, just restart from zero, so pressing
|
||||
* '0' six times or more will reset the count. */
|
||||
if (ses->kbdprefix.repeat_count > 99999)
|
||||
set_kbd_repeat_count(ses, 0);
|
||||
else if (ses->kbdprefix.repeat_count)
|
||||
highlight_links_with_prefixes_that_start_with_n(
|
||||
ses->tab->term, doc_view,
|
||||
ses->kbdprefix.repeat_count);
|
||||
new_count = 0;
|
||||
|
||||
set_kbd_repeat_count(ses, new_count);
|
||||
|
||||
return FRAME_EVENT_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user