* win.c (check_movement_keys): Remove "additional" argument,

it's always 1.
This commit is contained in:
Pavel Roskin 2003-10-23 22:53:32 +00:00
parent 0e1a39cfd0
commit 2fc70a9dd8
5 changed files with 68 additions and 53 deletions

View File

@ -1,5 +1,8 @@
2003-10-23 Pavel Roskin <proski@gnu.org>
* win.c (check_movement_keys): Remove "additional" argument,
it's always 1.
* view.c: (put_editkey): Rename to ...
(view_handle_editkey): ... this. Move here some logic from ...
(view_handle_key): ... here.

View File

@ -605,7 +605,7 @@ help_handle_key (struct Dlg_head *h, int c)
char *new_item;
if (c != KEY_UP && c != KEY_DOWN &&
check_movement_keys (c, 1, help_lines, currentpoint,
check_movement_keys (c, help_lines, currentpoint,
(movefn) move_backward2,
(movefn) move_forward2,
(movefn) move_to_top,

View File

@ -2346,7 +2346,7 @@ view_handle_key (WView *view, int c)
return MSG_HANDLED;
if (check_movement_keys
(c, 1, vheight, view, (movefn) view_move_backward,
(c, vheight, view, (movefn) view_move_backward,
(movefn) view_move_forward, (movefn) move_to_top,
(movefn) move_to_bottom)) {
return MSG_HANDLED;

104
src/win.c
View File

@ -32,66 +32,78 @@
#include "key.h" /* XCTRL and ALT macros */
#include "layout.h"
/* Return values: 0 = not a movement key, 1 = was a movement key */
int check_movement_keys (int c, int additional, int page_size, void *data,
movefn backfn, movefn forfn, movefn topfn,
movefn bottomfn)
/*
* Common handler for standard movement keys in a text area. Provided
* functions are called with the "data" argument. backfn and forfn also
* get an argument indicating how many lines to scroll. Return 1 if
* the key was handled, 0 otherwise.
*/
int
check_movement_keys (int key, int page_size, void *data, movefn backfn,
movefn forfn, movefn topfn, movefn bottomfn)
{
switch (c){
switch (key) {
case KEY_UP:
case XCTRL ('p'):
(*backfn)(data, 1);
return 1;
(*backfn) (data, 1);
break;
case KEY_DOWN:
case XCTRL ('n'):
(*forfn)(data, 1);
return 1;
(*forfn) (data, 1);
break;
case KEY_PPAGE:
case ALT('v'):
(*backfn)(data, page_size-1);
return 1;
case ALT ('v'):
(*backfn) (data, page_size - 1);
break;
case KEY_NPAGE:
case XCTRL('v'):
(*forfn)(data, page_size-1);
return 1;
case XCTRL ('v'):
(*forfn) (data, page_size - 1);
break;
case KEY_HOME:
case KEY_A1:
case ALT ('<'):
(*topfn)(data, 0);
return 1;
(*topfn) (data, 0);
break;
case KEY_END:
case KEY_C1:
case ALT ('>'):
(*bottomfn)(data, 0);
return 1;
(*bottomfn) (data, 0);
break;
case 'b':
case KEY_BACKSPACE:
(*backfn) (data, page_size - 1);
break;
case ' ':
(*forfn) (data, page_size - 1);
break;
case 'u':
(*backfn) (data, page_size / 2);
break;
case 'd':
(*forfn) (data, page_size / 2);
break;
case 'g':
(*topfn) (data, 0);
break;
case 'G':
(*bottomfn) (data, 0);
break;
default:
return MSG_NOT_HANDLED;
}
if (additional)
switch (c){
case 'b':
case KEY_BACKSPACE:
(*backfn)(data, page_size-1);
return 1;
case ' ':
(*forfn)(data, page_size-1);
return 1;
case 'u':
(*backfn)(data, page_size / 2);
return 1;
case 'd':
(*forfn)(data, page_size / 2);
return 1;
case 'g':
(*topfn)(data, 0);
return 1;
case 'G':
(*bottomfn)(data, 0);
return 1;
}
return 0;
return MSG_HANDLED;
}
/* Classification routines */

View File

@ -1,13 +1,13 @@
#ifndef __WIN_H
#define __WIN_H
/* Keys managing */
typedef void (*movefn)(void *, int);
int check_movement_keys (int c, int additional, int page_size, void *,
movefn backfn, movefn forfn, movefn topfn, movefn bottomfn);
/* Keys management */
typedef void (*movefn) (void *, int);
int check_movement_keys (int key, int page_size, void *data, movefn backfn,
movefn forfn, movefn topfn, movefn bottomfn);
int lookup_key (char *keyname);
/* Terminal managing */
/* Terminal management */
extern int xterm_flag;
void do_enter_ca_mode (void);
void do_exit_ca_mode (void);