diff --git a/src/scripting/smjs/action_object.c b/src/scripting/smjs/action_object.c index d95564d2..00ae7a42 100644 --- a/src/scripting/smjs/action_object.c +++ b/src/scripting/smjs/action_object.c @@ -64,7 +64,7 @@ smjs_action_fn_callback(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, int32 val; if (JS_TRUE == JS_ValueToInt32(smjs_ctx, argv[0], &val)) { - hop->ses->kbdprefix.repeat_count = val; + set_kbd_repeat_count(hop->ses, val); } } diff --git a/src/session/session.c b/src/session/session.c index ea6e1e39..22ef620e 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -1440,9 +1440,18 @@ eat_kbd_repeat_count(struct session *ses) { int count = ses->kbdprefix.repeat_count; - ses->kbdprefix.repeat_count = 0; + set_kbd_repeat_count(ses, 0); /* Clear status bar when prefix is eaten (bug 930) */ print_screen_status(ses); return count; } + +/** @relates session */ +int +set_kbd_repeat_count(struct session *ses, int new_count) +{ + ses->kbdprefix.repeat_count = new_count; + + return new_count; +} diff --git a/src/session/session.h b/src/session/session.h index a37cc170..41cbd7b2 100644 --- a/src/session/session.h +++ b/src/session/session.h @@ -300,4 +300,8 @@ unsigned char *get_homepage_url(void); /** Returns current keyboard repeat count and reset it. */ int eat_kbd_repeat_count(struct session *ses); +/** Set current keyboard repeat count to given value and update link + * highlighting and status bar. */ +int set_kbd_repeat_count(struct session *ses, int new_count); + #endif diff --git a/src/viewer/action.c b/src/viewer/action.c index d22db6de..5ec1fa70 100644 --- a/src/viewer/action.c +++ b/src/viewer/action.c @@ -134,7 +134,8 @@ do_action(struct session *ses, enum main_action action_id, int verbose) /* Clear the highlighting. */ draw_formatted(ses, 0); - ses->kbdprefix.repeat_count /= 10; + set_kbd_repeat_count(ses, + ses->kbdprefix.repeat_count / 10); if (ses->kbdprefix.repeat_count) highlight_links_with_prefixes_that_start_with_n( diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index c2fce60d..a73643bd 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -1247,7 +1247,7 @@ try_document_key(struct session *ses, struct document_view *doc_view, struct link *link = &doc_view->document->links[i]; if (key == link->accesskey) { - ses->kbdprefix.repeat_count = 0; + set_kbd_repeat_count(ses, 0); goto_link_number_do(ses, doc_view, i); return FRAME_EVENT_REFRESH; } @@ -1256,7 +1256,7 @@ try_document_key(struct session *ses, struct document_view *doc_view, struct link *link = &doc_view->document->links[i]; if (key == link->accesskey) { - ses->kbdprefix.repeat_count = 0; + set_kbd_repeat_count(ses, 0); goto_link_number_do(ses, doc_view, i); return FRAME_EVENT_REFRESH; } diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index 9bd9436f..b776357d 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -1012,7 +1012,7 @@ try_mark_key(struct session *ses, struct document_view *doc_view, break; } - ses->kbdprefix.repeat_count = 0; + set_kbd_repeat_count(ses, 0); ses->kbdprefix.mark = KP_MARK_NOTHING; return FRAME_EVENT_REFRESH; @@ -1045,13 +1045,13 @@ try_prefix_key(struct session *ses, struct document_view *doc_view, /* Clear the highlighting for the previous partial prefix. */ if (ses->kbdprefix.repeat_count) draw_formatted(ses, 0); - ses->kbdprefix.repeat_count *= 10; - ses->kbdprefix.repeat_count += digit; + 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) - ses->kbdprefix.repeat_count = 0; + 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, @@ -1064,7 +1064,7 @@ try_prefix_key(struct session *ses, struct document_view *doc_view, int nlinks = document->nlinks, length; unsigned char d[2] = { get_kbd_key(ev), 0 }; - ses->kbdprefix.repeat_count = 0; + set_kbd_repeat_count(ses, 0); if (!nlinks) return FRAME_EVENT_OK; @@ -1575,7 +1575,7 @@ send_event(struct session *ses, struct term_event *ev) #endif /* CONFIG_MOUSE */ /* @ses may disappear ie. in close_tab() */ - if (ses) ses->kbdprefix.repeat_count = 0; + if (ses) set_kbd_repeat_count(ses, 0); } enum frame_event_status