Wed Apr 1 00:15:30 1998 Norbert Warmuth <k3190@fh-sw.de>

* key.c, key.h (numeric_keypad_mode, application_keypad_mode): New
functions which encapsulate two hardcoded escape sequences from main.c.

* main.c (main): Use the two new functions from key.c

* main.c, screen.c: Moved all file selection keys from the default
keymap to the keymap for panels in listing mode.
Changed *_selection_cmd to *_selection_cmd_panel in panel_keymap
(functions in panel_keymap get a WPanel * as first parameter,
i.e. the indirection with cpanel isn't necessary).

* main.c (midnight_callback): Keys '*' and '-' were not treated
when only_leading_plus_minus==0;
Optimized the if-clauses a little bit (i.e. removed duplicate
checks). More optimation is possible but it would make the whole
stuff completly unreadable.

* key.c (correct_key_code): KP_ADD, KP_SUBTRACT and KP_MULTIPLY
will be translated to +, - and * only if the option
alternate_plus_minus is turned off.

* learn.c (learn_keys): Turn alternate_plus_minus temporarily on
to avoid translation of KP_ADD, KP_SUBTRACT and KP_MULTIPLY in
correct_key_code/make sure keypad is in application mode (makes it
possible to learn this keys).

* cmd.c (reverse_selection_cmd_panel): New function (renamed from
reverse_selection_cmd, takes a WPanel * as parameter, references to
cpanel changed to panel/the passed parameter).
reverse_selection_cmd now simply calls this function with cpanel.
This pair was missing among the *_selection_cmd* functions.

* cmd.h: Added function prototypes.
This commit is contained in:
Norbert Warmuth 1998-03-31 22:36:24 +00:00
parent 05b5ed8a99
commit 175f488cb8
8 changed files with 130 additions and 36 deletions

View File

@ -1,3 +1,39 @@
Wed Apr 1 00:15:30 1998 Norbert Warmuth <k3190@fh-sw.de>
* key.c, key.h (numeric_keypad_mode, application_keypad_mode): New
functions which encapsulate two hardcoded escape sequences from main.c.
* main.c (main): Use the two new functions from key.c
* main.c, screen.c: Moved all file selection keys from the default
keymap to the keymap for panels in listing mode.
Changed *_selection_cmd to *_selection_cmd_panel in panel_keymap
(functions in panel_keymap get a WPanel * as first parameter,
i.e. the indirection with cpanel isn't necessary).
* main.c (midnight_callback): Keys '*' and '-' were not treated
when only_leading_plus_minus==0;
Optimized the if-clauses a little bit (i.e. removed duplicate
checks). More optimation is possible but it would make the whole
stuff completly unreadable.
* key.c (correct_key_code): KP_ADD, KP_SUBTRACT and KP_MULTIPLY
will be translated to +, - and * only if the option
alternate_plus_minus is turned off.
* learn.c (learn_keys): Turn alternate_plus_minus temporarily on
to avoid translation of KP_ADD, KP_SUBTRACT and KP_MULTIPLY in
correct_key_code/make sure keypad is in application mode (makes it
possible to learn this keys).
* cmd.c (reverse_selection_cmd_panel): New function (renamed from
reverse_selection_cmd, takes a WPanel * as parameter, references to
cpanel changed to panel/the passed parameter).
reverse_selection_cmd now simply calls this function with cpanel.
This pair was missing among the *_selection_cmd* functions.
* cmd.h: Added function prototypes.
1998-03-31 Paul Sheer <psheer@obsidian.co.za>
* cmd.c (nice_cd): Forgot to invoke the history registration in

View File

@ -472,18 +472,23 @@ void do_re_sort (WPanel *panel)
panel_update_contents (panel);
}
void reverse_selection_cmd (void)
void reverse_selection_cmd_panel (WPanel *panel)
{
file_entry *file;
int i;
for (i = 0; i < cpanel->count; i++){
file = &cpanel->dir.list [i];
for (i = 0; i < panel->count; i++){
file = &panel->dir.list [i];
if (S_ISDIR (file->buf.st_mode))
continue;
do_file_mark (cpanel, i, !file->f.marked);
do_file_mark (panel, i, !file->f.marked);
}
paint_panel (cpanel);
paint_panel (panel);
}
void reverse_selection_cmd (void)
{
reverse_selection_cmd_panel (cpanel);
}
void select_cmd_panel (WPanel *panel)

View File

@ -31,7 +31,6 @@ void reread_cmd (void);
void do_re_sort (WPanel *panel);
void quick_view_cmd (void);
void tree_view_cmd (void);
void reverse_selection_cmd (void);
void ext_cmd (void);
void menu_edit_cmd (void);
void quick_chdir_cmd (void);
@ -42,6 +41,10 @@ void link_cmd (void);
void symlink_cmd (void);
void edit_symlink_cmd (void);
void other_symlink_cmd (void);
void reverse_selection_cmd_panel (WPanel *);
void unselect_cmd_panel (WPanel *);
void select_cmd_panel (WPanel *);
void reverse_selection_cmd (void);
void unselect_cmd (void);
void select_cmd (void);
void swap_cmd (void);

View File

@ -48,6 +48,8 @@
#include "key.h"
#include "main.h"
#include "file.h"
#include "win.h"
#include "cons.saver.h"
#include "../vfs/vfs.h"
#ifdef __linux__
@ -408,10 +410,11 @@ int correct_key_code (int c)
if (c == KEY_F(0))
return KEY_F(10);
if (!alternate_plus_minus)
switch (c) {
case KEY_KP_ADD: c = alternate_plus_minus ? ALT('+') : '+'; break;
case KEY_KP_SUBTRACT: c = alternate_plus_minus ? ALT('-') : '-'; break;
case KEY_KP_MULTIPLY: c = alternate_plus_minus ? ALT('*') : '*'; break;
case KEY_KP_ADD: c = '+'; break;
case KEY_KP_SUBTRACT: c = '-'; break;
case KEY_KP_MULTIPLY: c = '*'; break;
}
return c;
@ -892,6 +895,28 @@ char *learn_key (void)
*p = 0;
return strdup (buffer);
}
/* xterm and linux console only: set keypad to numeric or application
mode. Only in application keypad mode it's possible to distinguish
the '+' key and the '+' on the keypad ('*' and '-' ditto)*/
void
numeric_keypad_mode (void)
{
if (console_flag || xterm_flag) {
fprintf (stdout, "\033>");
fflush (stdout);
}
}
void
application_keypad_mode (void)
{
if (console_flag || xterm_flag) {
fprintf (stdout, "\033=");
fflush (stdout);
}
}
#endif /* !HAVE_X */
/* A function to check if we're idle.

View File

@ -79,7 +79,10 @@ typedef struct {
extern key_code_name_t key_name_conv_tab [];
extern int we_are_background;
#ifdef HAVE_GNOME
/* Set keypad mode (xterm and linux console only) */
#ifndef HAVE_X
void numeric_keypad_mode (void);
void application_keypad_mode (void);
#endif
#endif /* __KEY_H */

View File

@ -307,13 +307,27 @@ void learn_save (void)
void learn_keys (void)
{
int save_old_esc_mode = old_esc_mode;
int save_alternate_plus_minus = alternate_plus_minus;
old_esc_mode = 0; /* old_esc_mode cannot work in learn keys dialog */
alternate_plus_minus = 1; /* don't translate KP_ADD, KP_SUBTRACT and
KP_MULTIPLY to '+', '-' and '*' in
correct_key_code */
#ifndef HAVE_X
application_keypad_mode ();
#endif
init_learn ();
run_dlg (learn_dlg);
old_esc_mode = save_old_esc_mode;
alternate_plus_minus = save_alternate_plus_minus;
#ifndef HAVE_X
if (!alternate_plus_minus)
numeric_keypad_mode ();
#endif
switch (learn_dlg->ret_value) {
case B_ENTER:

View File

@ -1720,11 +1720,6 @@ static key_map default_map [] = {
{ ALT('a'), copy_current_pathname },
{ ALT('A'), copy_other_pathname },
{ ALT('+'), select_cmd },
{ ALT('\\'), unselect_cmd },
{ ALT('-'), unselect_cmd },
{ ALT('*'), reverse_selection_cmd },
{ ALT('c'), quick_cd_cmd },
/* To access the directory hotlist */
@ -1938,36 +1933,40 @@ int midnight_callback (struct Dlg_head *h, int id, int msg)
return MSG_HANDLED;
}
if (!alternate_plus_minus || !(console_flag || xterm_flag)) {
if ((!alternate_plus_minus || !(console_flag || xterm_flag)) &&
!quote && !cpanel->searching) {
if(!only_leading_plus_minus) {
/* Special treatement, since the input line will eat them */
if (id == '+' && !quote && !cpanel->searching){
if (id == '+' ) {
select_cmd ();
return MSG_HANDLED;
}
if (check_key_backslash (id) && !quote && !cpanel->searching){
if (check_key_backslash (id) || id == '-'){
unselect_cmd ();
return MSG_HANDLED;
}
} else if (command_prompt && !strlen (input_w (cmdline)->buffer)
&& !cpanel->searching) {
if (id == '*') {
reverse_selection_cmd ();
return MSG_HANDLED;
}
} else if (command_prompt && !strlen (input_w (cmdline)->buffer)) {
/* Special treatement '+', '-', '\', '*' only when this is
* first char on input line
*/
if (id == '+' && !quote && !cpanel->searching){
if (id == '+') {
select_cmd ();
return MSG_HANDLED;
}
if ((check_key_backslash (id) || id == '-') && !quote && !cpanel->searching){
if (check_key_backslash (id) || id == '-') {
unselect_cmd ();
return MSG_HANDLED;
}
if (id == '*' && !quote && !cpanel->searching){
if (id == '*') {
reverse_selection_cmd ();
return MSG_HANDLED;
}
@ -2892,9 +2891,9 @@ int main (int argc, char *argv [])
/* Also done after init_subshell, to save any shell init file messages */
if (console_flag)
handle_console (CONSOLE_SAVE);
if (alternate_plus_minus && (console_flag || xterm_flag)) {
fprintf (stdout, "\033="); fflush (stdout);
}
if (alternate_plus_minus)
application_keypad_mode ();
# endif
/* The directory hot list */
@ -2937,9 +2936,8 @@ int main (int argc, char *argv [])
if (console_flag && !(quit & SUBSHELL_EXIT))
restore_console ();
if (alternate_plus_minus && (console_flag || xterm_flag)) {
fprintf (stdout, "\033>"); fflush (stdout);
}
if (alternate_plus_minus)
numeric_keypad_mode ();
# endif
#ifndef OS2_NT

View File

@ -2097,10 +2097,20 @@ static key_map panel_keymap [] = {
{ ALT('y'), directory_history_prev },
{ ALT('u'), directory_history_next },
{ ALT('+'), select_cmd_panel },
{ KEY_KP_ADD, select_cmd_panel },
{ ALT('\\'), unselect_cmd_panel },
{ ALT('-'), unselect_cmd_panel },
{ KEY_KP_SUBTRACT, unselect_cmd_panel },
{ ALT('*'), reverse_selection_cmd_panel },
{ KEY_KP_MULTIPLY, reverse_selection_cmd_panel },
#ifdef HAVE_GNOME
{ '+', select_cmd },
{ '\\', unselect_cmd },
{ '-', unselect_cmd },
{ '+', select_cmd_panel },
{ '\\', unselect_cmd_panel },
{ '-', unselect_cmd_panel },
{ '*', reverse_selection_cmd_panel },
{ XCTRL('r'), reread_cmd },
#endif