1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Introduce set_kbd_repeat_count

Introduce and use ses_kbd_repeat_count to change
ses->kbdprefix.repeat_count instead of setting it directly.

This change should not cause any change in behaviour.
This commit is contained in:
Miciah Dashiel Butler Masters 2010-09-16 00:47:12 +00:00
parent ffcfe4a86b
commit d6bd7987d4
6 changed files with 25 additions and 11 deletions

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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

View File

@ -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(

View File

@ -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;
}

View File

@ -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