Add count buffer to keys_getch()
Key commands can be prefixed with a natural number - keys_getch() will store this number in the buffer pointed to by the second parameter. Set this parameter to NULL to disable count prefixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
ba2aa5167b
commit
98651a549f
@ -186,7 +186,7 @@ main (int argc, char **argv)
|
|||||||
wins_reset ();
|
wins_reset ();
|
||||||
}
|
}
|
||||||
|
|
||||||
key = keys_getch (win[STA].p);
|
key = keys_getch (win[STA].p, NULL);
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case KEY_GENERIC_REDRAW:
|
case KEY_GENERIC_REDRAW:
|
||||||
|
@ -712,7 +712,7 @@ void keys_free (void);
|
|||||||
void keys_dump_defaults (char *);
|
void keys_dump_defaults (char *);
|
||||||
char *keys_get_label (enum key);
|
char *keys_get_label (enum key);
|
||||||
enum key keys_get_action (int);
|
enum key keys_get_action (int);
|
||||||
enum key keys_getch (WINDOW *win);
|
enum key keys_getch (WINDOW *win, int *);
|
||||||
int keys_assign_binding (int, enum key);
|
int keys_assign_binding (int, enum key);
|
||||||
void keys_remove_binding (int, enum key);
|
void keys_remove_binding (int, enum key);
|
||||||
int keys_str2int (char *);
|
int keys_str2int (char *);
|
||||||
|
10
src/custom.c
10
src/custom.c
@ -390,7 +390,7 @@ custom_load_conf (struct conf *conf)
|
|||||||
status_mesg (mesg_line1, mesg_line2);
|
status_mesg (mesg_line1, mesg_line2);
|
||||||
wnoutrefresh (win[STA].p);
|
wnoutrefresh (win[STA].p);
|
||||||
wins_doupdate ();
|
wins_doupdate ();
|
||||||
(void)keys_getch (win[STA].p);
|
(void)keys_getch (win[STA].p, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock (&nbar.mutex);
|
pthread_mutex_lock (&nbar.mutex);
|
||||||
@ -579,7 +579,7 @@ custom_layout_config (void)
|
|||||||
display_layout_config (&conf_win, mark, cursor);
|
display_layout_config (&conf_win, mark, cursor);
|
||||||
clear ();
|
clear ();
|
||||||
|
|
||||||
while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT)
|
while ((ch = keys_getch (win[STA].p, NULL)) != KEY_GENERIC_QUIT)
|
||||||
{
|
{
|
||||||
need_reset = 0;
|
need_reset = 0;
|
||||||
switch (ch)
|
switch (ch)
|
||||||
@ -663,7 +663,7 @@ custom_sidebar_config (void)
|
|||||||
keys_display_bindings_bar (win[STA].p, binding, 0, binding_size);
|
keys_display_bindings_bar (win[STA].p, binding, 0, binding_size);
|
||||||
wins_doupdate ();
|
wins_doupdate ();
|
||||||
|
|
||||||
while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT)
|
while ((ch = keys_getch (win[STA].p, NULL)) != KEY_GENERIC_QUIT)
|
||||||
{
|
{
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
@ -902,7 +902,7 @@ custom_color_config (void)
|
|||||||
display_color_config (&conf_win, &mark_fore, &mark_back, cursor, theme_changed);
|
display_color_config (&conf_win, &mark_fore, &mark_back, cursor, theme_changed);
|
||||||
clear ();
|
clear ();
|
||||||
|
|
||||||
while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT)
|
while ((ch = keys_getch (win[STA].p, NULL)) != KEY_GENERIC_QUIT)
|
||||||
{
|
{
|
||||||
need_reset = 0;
|
need_reset = 0;
|
||||||
theme_changed = 0;
|
theme_changed = 0;
|
||||||
@ -1379,7 +1379,7 @@ custom_keys_config (void)
|
|||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
ch = keys_getch (win[STA].p);
|
ch = keys_getch (win[STA].p, NULL);
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case KEY_MOVE_UP:
|
case KEY_MOVE_UP:
|
||||||
|
@ -792,7 +792,7 @@ help_screen (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wins_scrollwin_display (&hwin);
|
wins_scrollwin_display (&hwin);
|
||||||
ch = keys_getch (win[STA].p);
|
ch = keys_getch (win[STA].p, NULL);
|
||||||
}
|
}
|
||||||
wins_scrollwin_delete (&hwin);
|
wins_scrollwin_delete (&hwin);
|
||||||
if (need_resize)
|
if (need_resize)
|
||||||
|
23
src/keys.c
23
src/keys.c
@ -194,11 +194,26 @@ keys_get_action (int pressed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum key
|
enum key
|
||||||
keys_getch (WINDOW *win)
|
keys_getch (WINDOW *win, int *count)
|
||||||
{
|
{
|
||||||
int ch;
|
int ch = '0';
|
||||||
|
|
||||||
|
if (count)
|
||||||
|
{
|
||||||
|
*count = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
*count = *count * 10 + ch - '0';
|
||||||
|
ch = wgetch (win);
|
||||||
|
}
|
||||||
|
while ((ch == '0' && *count > 0) || (ch >= '1' && ch <= '9'));
|
||||||
|
|
||||||
|
if (*count == 0)
|
||||||
|
*count = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ch = wgetch (win);
|
||||||
|
|
||||||
ch = wgetch (win);
|
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case KEY_RESIZE:
|
case KEY_RESIZE:
|
||||||
@ -586,7 +601,7 @@ keys_popup_info (enum key key)
|
|||||||
#define WINCOL (col - 4)
|
#define WINCOL (col - 4)
|
||||||
infowin = popup (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2,
|
infowin = popup (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2,
|
||||||
keydef[key].label, info[key], 1);
|
keydef[key].label, info[key], 1);
|
||||||
(void)keys_getch (infowin);
|
(void)keys_getch (infowin, NULL);
|
||||||
delwin (infowin);
|
delwin (infowin);
|
||||||
#undef WINROW
|
#undef WINROW
|
||||||
#undef WINCOL
|
#undef WINCOL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user