mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Some minor optimization.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
4b48da136d
commit
100a8d02ae
32
src/main.c
32
src/main.c
@ -1202,9 +1202,11 @@ nothing (void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
static cb_ret_t
|
||||
midnight_execute_cmd(int command)
|
||||
{
|
||||
cb_ret_t res = MSG_HANDLED;
|
||||
|
||||
switch (command) {
|
||||
case CK_MenuLastSelectedCmd:
|
||||
menu_last_selected_cmd ();
|
||||
@ -1301,7 +1303,11 @@ midnight_execute_cmd(int command)
|
||||
case CK_StartExtMap1:
|
||||
ctl_x_cmd ();
|
||||
break;
|
||||
default:
|
||||
res = MSG_NOT_HANDLED;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1523,10 +1529,8 @@ midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
|
||||
if (ctl_x_map_enabled) {
|
||||
ctl_x_map_enabled = 0;
|
||||
for (i = 0; main_x_map[i].key; i++)
|
||||
if (parm == main_x_map[i].key) {
|
||||
midnight_execute_cmd (main_x_map[i].command);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
if (parm == main_x_map[i].key)
|
||||
return midnight_execute_cmd (main_x_map[i].command);
|
||||
}
|
||||
|
||||
/* FIXME: should handle all menu shortcuts before this point */
|
||||
@ -1616,25 +1620,21 @@ midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
|
||||
|
||||
case DLG_UNHANDLED_KEY:
|
||||
if (command_prompt) {
|
||||
int v;
|
||||
cb_ret_t v;
|
||||
|
||||
v = send_message ((Widget *) cmdline, WIDGET_KEY, parm);
|
||||
if (v)
|
||||
return v;
|
||||
if (v == MSG_HANDLED)
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
if (ctl_x_map_enabled) {
|
||||
ctl_x_map_enabled = 0;
|
||||
for (i = 0; main_x_map[i].key; i++)
|
||||
if (parm == main_x_map[i].key) {
|
||||
midnight_execute_cmd (main_x_map[i].command);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
if (parm == main_x_map[i].key)
|
||||
return midnight_execute_cmd (main_x_map[i].command);
|
||||
} else {
|
||||
for (i = 0; main_map[i].key; i++) {
|
||||
if (parm == main_map[i].key) {
|
||||
midnight_execute_cmd (main_map[i].command);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
if (parm == main_map[i].key)
|
||||
return midnight_execute_cmd (main_map[i].command);
|
||||
}
|
||||
}
|
||||
return MSG_NOT_HANDLED;
|
||||
|
18
src/screen.c
18
src/screen.c
@ -1780,9 +1780,8 @@ move_selection (WPanel *panel, int lines)
|
||||
}
|
||||
|
||||
static cb_ret_t
|
||||
move_left (WPanel *panel, int c_code)
|
||||
move_left (WPanel *panel)
|
||||
{
|
||||
(void) c_code;
|
||||
if (panel->split) {
|
||||
move_selection (panel, -llines (panel));
|
||||
return MSG_HANDLED;
|
||||
@ -1791,9 +1790,8 @@ move_left (WPanel *panel, int c_code)
|
||||
}
|
||||
|
||||
static int
|
||||
move_right (WPanel *panel, int c_code)
|
||||
move_right (WPanel *panel)
|
||||
{
|
||||
(void) c_code;
|
||||
if (panel->split) {
|
||||
move_selection (panel, llines (panel));
|
||||
return MSG_HANDLED;
|
||||
@ -2289,7 +2287,7 @@ static void cmd_unselect(WPanel *wp) { (void) wp;unselect_cmd(); }
|
||||
static void cmd_reverse_selection(WPanel *wp) { (void) wp;reverse_selection_cmd(); }
|
||||
|
||||
void
|
||||
panel_execute_cmd (WPanel *panel, int command, int key)
|
||||
panel_execute_cmd (WPanel *panel, int command)
|
||||
{
|
||||
switch (command) {
|
||||
case CK_PanelChdirOtherPanel:
|
||||
@ -2365,10 +2363,10 @@ panel_execute_cmd (WPanel *panel, int command, int key)
|
||||
move_down (panel);
|
||||
break;
|
||||
case CK_PanelMoveLeft:
|
||||
move_left (panel, key);
|
||||
move_left (panel);
|
||||
break;
|
||||
case CK_PanelMoveRight:
|
||||
move_right (panel, key);
|
||||
move_right (panel);
|
||||
break;
|
||||
case CK_PanelMoveEnd:
|
||||
move_end (panel);
|
||||
@ -2400,7 +2398,7 @@ panel_key (WPanel *panel, int key)
|
||||
if (panel_map[i].command != CK_PanelStartSearch)
|
||||
panel->searching = 0;
|
||||
|
||||
panel_execute_cmd (panel, panel_map[i].command, key);
|
||||
panel_execute_cmd (panel, panel_map[i].command);
|
||||
|
||||
if (panel->searching != old_searching)
|
||||
display_mini_info (panel);
|
||||
@ -2417,10 +2415,10 @@ panel_key (WPanel *panel, int key)
|
||||
/* The command line widget may do something more useful */
|
||||
/*
|
||||
if (key == KEY_LEFT)
|
||||
return move_left (panel, key);
|
||||
return move_left (panel);
|
||||
|
||||
if (key == KEY_RIGHT)
|
||||
return move_right (panel, key);
|
||||
return move_right (panel);
|
||||
*/
|
||||
if (is_abort_char (key)) {
|
||||
panel->searching = 0;
|
||||
|
@ -50,13 +50,16 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "../src/tty/tty.h"
|
||||
#include "../src/tty/key.h"
|
||||
|
||||
#include "../src/dialog.h" /* cb_ret_t */
|
||||
#include "../src/panel.h"
|
||||
#include "../src/layout.h"
|
||||
#include "../src/wtools.h"
|
||||
#include "../src/history.h"
|
||||
#include "../src/charsets.h"
|
||||
#include "../src/tty/tty.h"
|
||||
#include "../src/tty/key.h"
|
||||
#include "../src/cmd.h"
|
||||
#include "../src/execute.h"
|
||||
#include "../src/help.h"
|
||||
@ -282,7 +285,7 @@ mcview_hook (void *v)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
static cb_ret_t
|
||||
mcview_execute_cmd (mcview_t * view, int command, int key)
|
||||
{
|
||||
int res = MSG_HANDLED;
|
||||
@ -399,27 +402,20 @@ mcview_handle_key (mcview_t * view, int key)
|
||||
{
|
||||
key = convert_from_input_c (key);
|
||||
|
||||
int res = 0;
|
||||
int i;
|
||||
|
||||
if (view->hex_mode) {
|
||||
for (i = 0; view->hex_map[i].key; i++) {
|
||||
if (key == view->hex_map[i].key) {
|
||||
res = mcview_execute_cmd (view, view->hex_map[i].command, key);
|
||||
if (res == MSG_HANDLED) {
|
||||
for (i = 0; view->hex_map[i].key != 0; i++)
|
||||
if ((key == view->hex_map[i].key)
|
||||
&& (mcview_execute_cmd (view, view->hex_map[i].command,
|
||||
key) == MSG_HANDLED))
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; view->plain_map[i].key; i++) {
|
||||
if (key == view->plain_map[i].key) {
|
||||
res = mcview_execute_cmd (view, view->plain_map[i].command, key);
|
||||
if (res == MSG_HANDLED) {
|
||||
for (i = 0; view->plain_map[i].key != 0; i++)
|
||||
if ((key == view->plain_map[i].key)
|
||||
&& (mcview_execute_cmd (view, view->plain_map[i].command,
|
||||
key) == MSG_HANDLED))
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mcview_check_left_right_keys (view, key))
|
||||
return MSG_HANDLED;
|
||||
|
@ -1729,6 +1729,8 @@ port_region_marked_for_delete (WInput *in)
|
||||
static void
|
||||
input_execute_cmd (WInput *in, int command, int key)
|
||||
{
|
||||
(void) key;
|
||||
|
||||
switch (command) {
|
||||
case CK_InputBol:
|
||||
beginning_of_line (in);
|
||||
|
Loading…
Reference in New Issue
Block a user