1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-28 03:06:20 -04: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:
Miciah Dashiel Butler Masters 2010-09-16 01:36:10 +00:00
parent d6bd7987d4
commit b1422adf20
4 changed files with 27 additions and 21 deletions

2
NEWS
View File

@ -45,6 +45,8 @@ Miscellaneous:
toggle-* actions no longer affect other tabs or other terminals. toggle-* actions no longer affect other tabs or other terminals.
* Do not crash when document.browse.minimum_refresh_time = 0 and * Do not crash when document.browse.minimum_refresh_time = 0 and
a document has a meta refresh with a delay of 0. 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 * enhancement 15: Domain-specific options. Use set_domain in
elinks.conf to e.g. disable cookies for google.com. The option elinks.conf to e.g. disable cookies for google.com. The option
manager window does not yet support this. manager window does not yet support this.

View File

@ -1451,7 +1451,26 @@ eat_kbd_repeat_count(struct session *ses)
int int
set_kbd_repeat_count(struct session *ses, int new_count) 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; 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; return new_count;
} }

View File

@ -131,19 +131,9 @@ do_action(struct session *ses, enum main_action action_id, int verbose)
if (!ses->kbdprefix.repeat_count) break; if (!ses->kbdprefix.repeat_count) break;
/* Clear the highlighting. */
draw_formatted(ses, 0);
set_kbd_repeat_count(ses, set_kbd_repeat_count(ses,
ses->kbdprefix.repeat_count / 10); 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. */ /* Keep send_event from resetting repeat_count. */
status = FRAME_EVENT_SESSION_DESTROYED; status = FRAME_EVENT_SESSION_DESTROYED;

View File

@ -1037,25 +1037,20 @@ try_prefix_key(struct session *ses, struct document_view *doc_view,
* entering a prefix. */ * entering a prefix. */
|| !doc_opts->num_links_key || !doc_opts->num_links_key
|| (doc_opts->num_links_key == 1 && !doc_opts->links_numbering)) { || (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. /* Repeat count.
* ses->kbdprefix.repeat_count is initialized to zero * ses->kbdprefix.repeat_count is initialized to zero
* the first time by init_session() calloc() call. * the first time by init_session() calloc() call.
* When used, it has to be reset to zero. */ * 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 /* If too big, just restart from zero, so pressing
* '0' six times or more will reset the count. */ * '0' six times or more will reset the count. */
if (ses->kbdprefix.repeat_count > 99999) if (ses->kbdprefix.repeat_count > 99999)
set_kbd_repeat_count(ses, 0); new_count = 0;
else if (ses->kbdprefix.repeat_count)
highlight_links_with_prefixes_that_start_with_n( set_kbd_repeat_count(ses, new_count);
ses->tab->term, doc_view,
ses->kbdprefix.repeat_count);
return FRAME_EVENT_OK; return FRAME_EVENT_OK;
} }