Type accuracy and code clean up.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2009-11-06 14:41:54 +03:00
parent 9760092c17
commit da33e767e9
27 changed files with 148 additions and 156 deletions

View File

@ -153,7 +153,7 @@ int edit_drop_hotkey_menu (WEdit *e, int key);
void edit_menu_cmd (WEdit *e);
void edit_init_menu (struct WMenuBar *menubar);
cb_ret_t edit_command_execute (struct Widget *sender, struct Widget *receiver,
int command, const void *data);
unsigned long command, const void *data);
void menu_save_mode_cmd (void);
int edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch);
int edit_get_byte (WEdit * edit, long byte_index);
@ -229,7 +229,7 @@ void edit_date_cmd (WEdit * edit);
void edit_goto_cmd (WEdit * edit);
int eval_marks (WEdit * edit, long *start_mark, long *end_mark);
void edit_status (WEdit * edit);
void edit_execute_key_command (WEdit *edit, int command,
void edit_execute_key_command (WEdit *edit, unsigned long command,
int char_for_insertion);
void edit_update_screen (WEdit * edit);
int edit_print_string (WEdit * e, const char *s);

View File

@ -47,11 +47,11 @@
#include "../src/cmddef.h"
#include "../src/tty/color.h" /* EDITOR_NORMAL_COLOR */
#include "../src/tty/tty.h" /* attrset() */
#include "../src/tty/key.h" /* is_idle() */
#include "../src/skin/skin.h" /* mc_skin_color_get */
#include "../src/tty/tty.h" /* attrset() */
#include "../src/tty/key.h" /* is_idle() */
#include "../src/skin/skin.h" /* mc_skin_color_get */
#include "../src/widget.h" /* buttonbar_redraw() */
#include "../src/widget.h"
#include "../src/cmd.h" /* view_other_cmd() */
#include "../src/user.h" /* user_menu_cmd() */
#include "../src/wtools.h" /* query_dialog() */
@ -2527,7 +2527,8 @@ static void edit_goto_matching_bracket (WEdit *edit)
* passed as -1. Commands are executed, and char_for_insertion is
* inserted at the cursor.
*/
void edit_execute_key_command (WEdit *edit, int command, int char_for_insertion)
void
edit_execute_key_command (WEdit *edit, unsigned long command, int char_for_insertion)
{
if (command == CK_Begin_Record_Macro) {
edit->macro_i = 0;

View File

@ -2595,16 +2595,13 @@ edit_execute_macro_cmd (WEdit *edit)
}
void
edit_begin_end_macro_cmd(WEdit *edit)
edit_begin_end_macro_cmd (WEdit *edit)
{
int command;
/* edit is a pointer to the widget */
if (edit) {
command =
edit->macro_i <
0 ? CK_Begin_Record_Macro : CK_End_Record_Macro;
edit_execute_key_command (edit, command, -1);
unsigned long command = edit->macro_i < 0
? CK_Begin_Record_Macro : CK_End_Record_Macro;
edit_execute_key_command (edit, command, -1);
}
}

View File

@ -60,9 +60,9 @@
int
edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
{
int command = CK_Insert_Char;
unsigned long command = (unsigned long) CK_Insert_Char;
int char_for_insertion = -1;
int i = 0;
size_t i = 0;
int c;
/* an ordinary insertable character */
@ -161,8 +161,8 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
}
}
fin:
*cmd = command;
*cmd = (int) command; /* FIXME */
*ch = char_for_insertion;
return (command == CK_Insert_Char && char_for_insertion == -1) ? 0 : 1;
return (command == (unsigned long) CK_Insert_Char && char_for_insertion == -1) ? 0 : 1;
}

View File

@ -53,7 +53,8 @@
#include "edit-widget.h"
cb_ret_t
edit_command_execute (Widget *sender, Widget *receiver, int command, const void *data)
edit_command_execute (Widget *sender, Widget *receiver,
unsigned long command, const void *data)
{
(void) sender;
(void) receiver;

View File

@ -47,7 +47,7 @@
#include "edit-impl.h"
#include "edit-widget.h"
#include "../src/widget.h" /* buttonbar_redraw() */
#include "../src/widget.h" /* ButtonBar */
#include "../src/menu.h" /* menubar_new() */
#include "../src/cmddef.h"
@ -59,7 +59,7 @@ int column_highlighting = 0;
static cb_ret_t edit_callback (Widget *, widget_msg_t msg, int parm);
static char *
edit_get_shortcut (int command)
edit_get_shortcut (unsigned long command)
{
const char *ext_map;
const char *shortcut = NULL;
@ -201,7 +201,7 @@ edit_dialog_callback (Dlg_head *h, dlg_msg_t msg, int parm)
int
edit_file (const char *_file, int line)
{
static int made_directory = 0;
static gboolean made_directory = FALSE;
Dlg_head *edit_dlg;
if (!made_directory) {
@ -233,7 +233,7 @@ edit_file (const char *_file, int line)
add_widget (edit_dlg, wedit);
add_widget (edit_dlg, buttonbar_new (1));
add_widget (edit_dlg, buttonbar_new (TRUE));
run_dlg (edit_dlg);

View File

@ -302,7 +302,7 @@ InputBackwardDelete = backspace
InputDeleteChar = delete
InputKillWord = alt-d
InputBackwardKillWord = alt-backspace
InputSetMark =
InputSetMark =
InputKillRegion = ctrl-w
InputXStore = alt-w
InputXPaste =

View File

@ -670,7 +670,7 @@ tree_box (const char *current_dir)
mytree = tree_new (0, 2, 2, dlg->lines - 6, dlg->cols - 5);
add_widget (dlg, mytree);
bar = buttonbar_new(1);
bar = buttonbar_new (TRUE);
add_widget (dlg, bar);
/* restore ButtonBar coordinates after add_widget() */
((Widget *) bar)->x = 0;

View File

@ -70,6 +70,7 @@
#define CK_Replace_Again 304
#define CK_Complete_Word 305
#if 0
/* debugger commands */
#define CK_Debug_Start 350
#define CK_Debug_Stop 351
@ -81,6 +82,7 @@
#define CK_Debug_Continue 357
#define CK_Debug_Enter_Command 358
#define CK_Debug_Until_Curser 359
#endif
/* misc */
#define CK_Insert_File 401

View File

@ -335,11 +335,6 @@ add_widget (Dlg_head *h, void *w)
return add_widget_autopos (h, w, WPOS_KEEP_LEFT | WPOS_KEEP_TOP);
}
enum {
REFRESH_COVERS_PART, /* If the refresh fn convers only a part */
REFRESH_COVERS_ALL /* If the refresh fn convers all the screen */
};
static void
do_complete_refresh (Dlg_head *dlg)
{
@ -438,7 +433,7 @@ int dlg_overlap (Widget *a, Widget *b)
/* Find the widget with the given callback in the dialog h */
Widget *
find_widget_type (Dlg_head *h, callback_fn callback)
find_widget_type (const Dlg_head *h, callback_fn callback)
{
Widget *w = NULL;
@ -459,7 +454,7 @@ find_widget_type (Dlg_head *h, callback_fn callback)
/* Find the widget with the given dialog id in the dialog h and select it */
void
dlg_select_by_id (Dlg_head *h, int id)
dlg_select_by_id (const Dlg_head *h, int id)
{
Widget *w, *w_found;

View File

@ -95,11 +95,11 @@ typedef cb_ret_t (*dlg_cb_fn)(struct Dlg_head *h, dlg_msg_t msg, int parm);
should be NULL if sender is menu or buttonbar
*/
typedef cb_ret_t (*dlg_exec_fn) (Widget *sender, Widget *receiver,
int command, const void *data);
unsigned long command, const void *data);
/* get string representation of shortcut assigned with command */
/* as menu is a widget of dialog, ask dialog about shortcut string */
typedef char * (*dlg_shortcut_str) (int command);
typedef char * (*dlg_shortcut_str) (unsigned long command);
/* Dialog color constants */
#define DLG_COLOR_NUM 4
@ -265,8 +265,8 @@ void dlg_select_widget (void *widget);
void dlg_one_up (Dlg_head *h);
void dlg_one_down (Dlg_head *h);
int dlg_focus (Dlg_head *h);
Widget *find_widget_type (Dlg_head *h, callback_fn callback);
void dlg_select_by_id (Dlg_head *h, int id);
Widget *find_widget_type (const Dlg_head *h, callback_fn callback);
void dlg_select_by_id (const Dlg_head *h, int id);
/* Redraw all dialogs */
void do_refresh (void);

View File

@ -875,7 +875,7 @@ interactive_display (const char *filename, const char *node)
history[history_ptr].link = selected_item;
}
help_bar = buttonbar_new (1);
help_bar = buttonbar_new (TRUE);
help_bar->widget.y -= whelp->y;
help_bar->widget.x -= whelp->x;

View File

@ -91,6 +91,7 @@ static name_keymap_t command_names[] = {
{ "EditReplace", CK_Replace },
{ "EditReplaceAgain", CK_Replace_Again },
{ "EditCompleteWord", CK_Complete_Word },
#if 0
{ "EditDebugStart", CK_Debug_Start },
{ "EditDebugStop", CK_Debug_Stop },
{ "EditDebugToggleBreak", CK_Debug_Toggle_Break },
@ -101,6 +102,7 @@ static name_keymap_t command_names[] = {
{ "EditDebugContinue", CK_Debug_Continue },
{ "EditDebugEnterCommand", CK_Debug_Enter_Command },
{ "EditDebugUntilCurser", CK_Debug_Until_Curser },
#endif
{ "EditInsertFile", CK_Insert_File },
{ "EditQuit", CK_Quit },
{ "EditToggleInsert", CK_Toggle_Insert },
@ -633,7 +635,7 @@ const global_keymap_t default_editor_x_keymap[] = {
{ 'e', CK_Execute_Macro, "e"},
{ 0, CK_Ignore_Key, "" }
};
#endif
#endif /* USE_INTERNAL_EDIT */
/* tree */
const global_keymap_t default_tree_keymap[] = {
@ -845,7 +847,31 @@ sort_command_names (void)
}
}
int
static void
keymap_add (GArray *keymap, long key, unsigned long cmd, const char *caption)
{
if (key != 0 && cmd != CK_Ignore_Key) {
global_keymap_t new_bind;
new_bind.key = key;
new_bind.command = cmd;
g_snprintf (new_bind.caption, sizeof (new_bind.caption), "%s", caption);
g_array_append_val (keymap, new_bind);
}
}
void
keybind_cmd_bind (GArray *keymap, const char *keybind, unsigned long action)
{
char *caption = NULL;
long key;
key = lookup_key (keybind, &caption);
keymap_add (keymap, key, action, caption);
g_free (caption);
}
unsigned long
lookup_action (const char *keyname)
{
const name_keymap_t key = { keyname, 0 };
@ -859,34 +885,10 @@ lookup_action (const char *keyname)
return (res != NULL) ? res->val : CK_Ignore_Key;
}
static void
keymap_add (GArray *keymap, int key, int cmd, const char *caption)
{
if (key != 0 && cmd != 0) {
global_keymap_t new_bind;
new_bind.key = key;
new_bind.command = cmd;
g_snprintf (new_bind.caption, sizeof (new_bind.caption), "%s", caption);
g_array_append_val (keymap, new_bind);
}
}
void
keybind_cmd_bind (GArray *keymap, const char *keybind, int action)
{
char *caption = NULL;
int key;
key = lookup_key (keybind, &caption);
keymap_add (keymap, key, action, caption);
g_free (caption);
}
const char *
lookup_keymap_shortcut (const global_keymap_t *keymap, int action)
lookup_keymap_shortcut (const global_keymap_t *keymap, unsigned long action)
{
unsigned int i;
size_t i;
for (i = 0; keymap[i].key != 0; i++)
if (keymap[i].command == action)

View File

@ -6,7 +6,7 @@
typedef struct name_keymap_t {
const char *name;
int val;
unsigned long val;
} name_keymap_t;
typedef struct key_config_t {
@ -20,13 +20,13 @@ typedef struct key_config_t {
#define KEYMAP_SHORTCUT_LENGTH 32 /* FIXME: is 32 bytes enough for shortcut? */
typedef struct global_keymap_t {
long key;
long command;
unsigned long command;
char caption[KEYMAP_SHORTCUT_LENGTH];
} global_keymap_t;
int lookup_action (const char *keyname);
void keybind_cmd_bind (GArray *keymap, const char *keybind, int action);
const char *lookup_keymap_shortcut (const global_keymap_t *keymap, int action);
void keybind_cmd_bind (GArray *keymap, const char *keybind, unsigned long action);
unsigned long lookup_action (const char *keyname);
const char *lookup_keymap_shortcut (const global_keymap_t *keymap, unsigned long action);
/* viewer/actions_cmd.c */
extern const global_keymap_t default_viewer_keymap[];
@ -38,9 +38,6 @@ extern const global_keymap_t default_editor_keymap[];
extern const global_keymap_t default_editor_x_keymap[];
#endif
/* tree.c */
extern const global_keymap_t default_tree_keymap[];
/* screen.c */
extern const global_keymap_t default_panel_keymap[];
@ -51,4 +48,7 @@ extern const global_keymap_t default_input_keymap[];
extern const global_keymap_t default_main_map[];
extern const global_keymap_t default_main_x_map[];
/* tree.c */
extern const global_keymap_t default_tree_keymap[];
#endif /* MC_KEYBIND_H */

View File

@ -56,7 +56,6 @@
#include "dialog.h"
#include "menu.h"
#include "panel.h"
#include "main.h"
#include "option.h"
#include "tree.h"
#include "treestore.h"
@ -73,12 +72,12 @@
#include "execute.h"
#include "ext.h" /* For flush_extension_file() */
#include "strutil.h"
/* Listbox for the command history feature */
#include "widget.h"
#include "command.h"
#include "wtools.h"
#include "cmddef.h" /* CK_ cmd name const */
#include "fileloc.h" /* MC_USERCONF_DIR */
#include "user.h" /* user_file_menu_cmd() */
#include "../vfs/vfs.h" /* vfs_translate_url() */
@ -86,6 +85,8 @@
#include "chown.h"
#include "achown.h"
#include "main.h"
#ifdef WITH_SMBFS
#include "../vfs/smbfs.h" /* smbfs_set_debug() */
#endif
@ -843,7 +844,7 @@ menu_cmd (void)
}
static char *
midnight_get_shortcut (int command)
midnight_get_shortcut (unsigned long command)
{
const char *ext_map;
const char *shortcut = NULL;
@ -1118,17 +1119,17 @@ init_labels (void)
buttonbar_set_label (midnight_dlg, 10, Q_("ButtonBar|Quit"), quit_cmd);
}
static int ctl_x_map_enabled = 0;
static gboolean ctl_x_map_enabled = FALSE;
static void
ctl_x_cmd (void)
{
ctl_x_map_enabled = 1;
ctl_x_map_enabled = TRUE;
}
static cb_ret_t
midnight_execute_cmd (Widget *sender, Widget *receiver,
int command, const void *data)
unsigned long command, const void *data)
{
cb_ret_t res = MSG_HANDLED;
@ -1587,7 +1588,7 @@ midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
case DLG_KEY:
if (ctl_x_map_enabled) {
ctl_x_map_enabled = 0;
ctl_x_map_enabled = FALSE;
for (i = 0; main_x_map[i].key; i++)
if (parm == main_x_map[i].key)
return midnight_execute_cmd (NULL, NULL, main_x_map[i].command, NULL);
@ -1607,7 +1608,8 @@ midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
if (parm == '\n') {
for (i = 0; cmdline->buffer[i] && (cmdline->buffer[i] == ' ' ||
cmdline->buffer[i] == '\t'); i++);
cmdline->buffer[i] == '\t'); i++)
;
if (cmdline->buffer[i]) {
send_message ((Widget *) cmdline, WIDGET_KEY, parm);
return MSG_HANDLED;
@ -1687,7 +1689,7 @@ midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
return MSG_HANDLED;
}
if (ctl_x_map_enabled) {
ctl_x_map_enabled = 0;
ctl_x_map_enabled = FALSE;
for (i = 0; main_x_map[i].key; i++)
if (parm == main_x_map[i].key)
return midnight_execute_cmd (NULL, NULL, main_x_map[i].command, NULL);
@ -1907,11 +1909,12 @@ do_nc (void)
midnight_shutdown = 1;
/* destroy_dlg destroys even current_panel->cwd, so we have to save a copy :) */
if (mc_args__last_wd_file && vfs_current_is_local ()) {
if (mc_args__last_wd_file && vfs_current_is_local ())
last_wd_string = g_strdup (current_panel->cwd);
}
done_mc ();
}
destroy_dlg (midnight_dlg);
panel_deinit ();
current_panel = 0;
@ -1954,7 +1957,6 @@ OS_Setup (void)
if (!home_dir)
home_dir = mc_home;
}
static void
@ -2023,7 +2025,7 @@ init_sigchld (void)
}
static void
mc_main__setup_by_args(int argc, char *argv[])
mc_main__setup_by_args (int argc, char *argv[])
{
const char *base;
char *tmp;
@ -2032,8 +2034,7 @@ mc_main__setup_by_args(int argc, char *argv[])
use_mouse_p = MOUSE_DISABLED;
#ifdef USE_NETCODE
if (mc_args__netfs_logfile != NULL)
{
if (mc_args__netfs_logfile != NULL) {
mc_setctl ("/#ftp:", VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
#ifdef WITH_SMBFS
smbfs_set_debugf (mc_args__netfs_logfile);
@ -2042,16 +2043,12 @@ mc_main__setup_by_args(int argc, char *argv[])
#ifdef WITH_SMBFS
if (mc_args__debug_level != 0)
{
smbfs_set_debug (mc_args__debug_level);
}
#endif /* WITH_SMBFS */
#endif /* USE_NETCODE */
base = x_basename (argv[0]);
tmp = (argc > 0)? argv[1] : NULL;
tmp = (argc > 0) ? argv[1] : NULL;
if (!STRNCOMP (base, "mce", 3) || !STRCOMP (base, "vi")) {
edit_one_file = "";
@ -2112,8 +2109,6 @@ mc_main__setup_by_args(int argc, char *argv[])
other_dir = g_strdup (tmp);
}
}
}
int
@ -2148,8 +2143,8 @@ main (int argc, char *argv[])
if ( !mc_args_handle (&argc, &argv, "mc"))
return 1;
mc_main__setup_by_args(argc,argv);
mc_main__setup_by_args (argc,argv);
/* NOTE: This has to be called before tty_init or whatever routine
calls any define_sequence */

View File

@ -6,6 +6,7 @@
#ifndef MC_MAIN_H
#define MC_MAIN_H
#include "global.h"
#include "keybind.h"
/* Toggling functions */
@ -83,9 +84,9 @@ extern GArray *viewer_keymap;
extern GArray *viewer_hex_keymap;
extern GArray *main_keymap;
extern GArray *main_x_keymap;
extern GArray *tree_keymap;
extern GArray *panel_keymap;
extern GArray *input_keymap;
extern GArray *tree_keymap;
extern const global_keymap_t *panel_map;
extern const global_keymap_t *input_map;
@ -131,7 +132,7 @@ char *remove_encoding_from_path (const char *);
struct WPanel;
void directory_history_add (struct WPanel *panel, const char *dir);
int do_panel_cd (struct WPanel *panel, const char *new_dir, enum cd_enum cd_type);
void directory_history_add (struct WPanel *panel, const char *dir);
int do_panel_cd (struct WPanel *panel, const char *new_dir, enum cd_enum cd_type);
#endif
#endif /* MC_MAIN_H */

View File

@ -33,19 +33,20 @@
#include "../src/tty/mouse.h"
#include "../src/tty/key.h" /* key macros */
#include "menu.h"
#include "cmddef.h" /* CK_Ignore_Key */
#include "help.h"
#include "dialog.h"
#include "widget.h"
#include "main.h" /* is_right */
#include "strutil.h"
#include "menu.h"
int menubar_visible = 1; /* This is the new default */
static cb_ret_t menubar_callback (Widget *w, widget_msg_t msg, int parm);
menu_entry_t *
menu_entry_create (const char *name, int command)
menu_entry_create (const char *name, unsigned long command)
{
menu_entry_t *entry;
@ -310,7 +311,7 @@ menubar_execute (WMenuBar *menubar)
const Menu *menu = g_list_nth_data (menubar->menu, menubar->selected);
const menu_entry_t *entry = g_list_nth_data (menu->entries, menu->selected);
if ((entry != NULL) && (entry->command != 0)) {
if ((entry != NULL) && (entry->command != CK_Ignore_Key)) {
is_right = (menubar->selected != 0);
menubar_finish (menubar);
menubar->widget.parent->execute (
@ -332,7 +333,7 @@ menubar_down (WMenuBar *menubar)
do {
menu->selected = (menu->selected + 1) % len;
entry = (menu_entry_t *) g_list_nth_data (menu->entries, menu->selected);
} while ((entry == NULL) || (entry->command == 0));
} while ((entry == NULL) || (entry->command == CK_Ignore_Key));
menubar_paint_idx (menubar, menu->selected, MENU_SELECTED_COLOR);
}
@ -352,7 +353,7 @@ menubar_up (WMenuBar *menubar)
else
menu->selected--;
entry = (menu_entry_t *) g_list_nth_data (menu->entries, menu->selected);
} while ((entry == NULL) || (entry->command == 0));
} while ((entry == NULL) || (entry->command == CK_Ignore_Key));
menubar_paint_idx (menubar, menu->selected, MENU_SELECTED_COLOR);
}
@ -373,7 +374,7 @@ menubar_first (WMenuBar *menubar)
while (TRUE) {
entry = (menu_entry_t *) g_list_nth_data (menu->entries, menu->selected);
if ((entry == NULL) || (entry->command == 0))
if ((entry == NULL) || (entry->command == CK_Ignore_Key))
menu->selected++;
else
break;
@ -399,7 +400,7 @@ menubar_last (WMenuBar *menubar)
do {
menu->selected--;
entry = (menu_entry_t *) g_list_nth_data (menu->entries, menu->selected);
} while ((entry == NULL) || (entry->command == 0));
} while ((entry == NULL) || (entry->command == CK_Ignore_Key));
menubar_paint_idx (menubar, menu->selected, MENU_SELECTED_COLOR);
}
@ -469,7 +470,7 @@ menubar_handle_key (WMenuBar *menubar, int key)
for (i = menu->entries; i != NULL; i = g_list_next (i)) {
const menu_entry_t *entry = i->data;
if ((entry != NULL) && (entry->command != 0)
if ((entry != NULL) && (entry->command != CK_Ignore_Key)
&& (entry->text.hotkey != NULL)
&& (key == g_ascii_tolower (entry->text.hotkey[0]))) {
menu->selected = g_list_position (menu->entries, i);
@ -670,7 +671,7 @@ menubar_event (Gpm_Event *event, void *data)
if ((pos < 0) || (pos >= bottom_y - 3))
return MOU_NORMAL;
if ((entry != NULL) && (entry->command != 0)) {
if ((entry != NULL) && (entry->command != CK_Ignore_Key)) {
menubar_paint_idx (menubar, menu->selected, MENU_ENTRY_COLOR);
menu->selected = pos;
menubar_paint_idx (menubar, menu->selected, MENU_SELECTED_COLOR);

View File

@ -32,11 +32,11 @@ extern int menubar_visible;
typedef struct menu_entry_t {
unsigned char first_letter;
struct hotkey_t text;
int command;
unsigned long command;
char *shortcut;
} menu_entry_t;
menu_entry_t *menu_entry_create (const char *name, int command);
menu_entry_t *menu_entry_create (const char *name, unsigned long command);
void menu_entry_free (menu_entry_t *me);
#define menu_separator_create() NULL
@ -71,4 +71,4 @@ void menubar_set_menu (WMenuBar *menubar, GList *menu);
void menubar_add_menu (WMenuBar *menubar, Menu *menu);
void menubar_arrange (WMenuBar *menubar);
#endif /* MC_MENU_H */
#endif /* MC_MENU_H */

View File

@ -2633,7 +2633,7 @@ static void cmd_unselect(WPanel *wp) { (void) wp; unselect_cmd(); }
static void cmd_reverse_selection(WPanel *wp) { (void) wp; reverse_selection_cmd(); }
static cb_ret_t
panel_execute_cmd (WPanel *panel, int command)
panel_execute_cmd (WPanel *panel, unsigned long command)
{
int res = MSG_HANDLED;
@ -2763,10 +2763,10 @@ panel_execute_cmd (WPanel *panel, int command)
static cb_ret_t
panel_key (WPanel *panel, int key)
{
int i;
int res, command;
size_t i;
unsigned long res, command;
for (i = 0; panel_map[i].key; i++) {
for (i = 0; panel_map[i].key != 0; i++) {
if (key == panel_map[i].key) {
int old_searching = panel->searching;

View File

@ -869,7 +869,7 @@ load_keys_from_section (const char *terminal, mc_config_t *cfg)
gchar **profile_keys, **keys;
gchar **values, **curr_values;
char *valcopy, *value;
int key_code;
long key_code;
gsize len, values_len;
if (!terminal)
@ -891,7 +891,7 @@ load_keys_from_section (const char *terminal, mc_config_t *cfg)
curr_values = values = mc_config_get_string_list (cfg, section_name, *profile_keys, &values_len);
key_code = lookup_key (*profile_keys, NULL);
if (key_code){
if (key_code != 0) {
if (curr_values){
while (*curr_values){
valcopy = convert_controls (*curr_values);
@ -953,8 +953,8 @@ load_keymap_from_section (const char *section_name, GArray *keymap, mc_config_t
curr_values = values = mc_config_get_string_list (cfg, section_name, *profile_keys, &values_len);
action = lookup_action (*profile_keys);
if (action>0) {
if (curr_values){
while (*curr_values){
if (curr_values) {
while (*curr_values) {
valcopy = convert_controls (*curr_values);
keybind_cmd_bind (keymap, valcopy, action);
g_free (valcopy);
@ -963,9 +963,9 @@ load_keymap_from_section (const char *section_name, GArray *keymap, mc_config_t
} else {
value = mc_config_get_string (cfg, section_name, *profile_keys, "");
valcopy = convert_controls (value);
//define_sequence (key_code, valcopy, MCKEY_NOACTION);
/* define_sequence (key_code, valcopy, MCKEY_NOACTION); */
g_free (valcopy);
g_free(value);
g_free (value);
}
}
profile_keys++;

View File

@ -37,6 +37,7 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "global.h"
@ -866,7 +867,7 @@ tree_start_search (WTree *tree)
}
static cb_ret_t
tree_execute_cmd (WTree *tree, int command)
tree_execute_cmd (WTree *tree, unsigned long command)
{
cb_ret_t res = MSG_HANDLED;
@ -929,25 +930,25 @@ tree_execute_cmd (WTree *tree, int command)
}
/* temporary wrappers */
void
static void
tree_help (void *data)
{
tree_execute_cmd ((WTree *) data, CK_TreeHelp);
}
void
static void
tree_toggle_f4 (void *data)
{
tree_execute_cmd ((WTree *) data, CK_TreeToggleNav);
}
void
static void
tree_copy_cmd (void *data)
{
tree_execute_cmd ((WTree *) data, CK_TreeCopy);
}
void
static void
tree_move_cmd (void *data)
{
tree_execute_cmd ((WTree *) data, CK_TreeMove);
@ -956,7 +957,7 @@ tree_move_cmd (void *data)
static cb_ret_t
tree_key (WTree *tree, int key)
{
int i;
size_t i;
for (i = 0; tree_map [i].key != 0; i++)
if (key == tree_map [i].key)

View File

@ -1293,7 +1293,7 @@ lookup_keyname (const char *keyname, int *lc_index)
}
/* Return the code associated with the symbolic name keyname */
int
long
lookup_key (const char *keyname, char **label)
{
char **lc_keys, **p;
@ -1393,7 +1393,7 @@ lookup_key (const char *keyname, char **label)
if (use_meta != -1)
k = ALT (k);
return k;
return (long) k;
}
/*

View File

@ -21,7 +21,7 @@ void done_key (void);
typedef void (*move_fn) (void *data, int param);
cb_ret_t check_movement_keys (int key, int page_size, void *data,
move_fn backfn, move_fn forfn, move_fn topfn, move_fn bottomfn);
int lookup_key (const char *keyname, char **label);
long lookup_key (const char *keyname, char **label);
typedef struct {
int code;

View File

@ -285,7 +285,7 @@ mcview_handle_editkey (mcview_t * view, int key)
static cb_ret_t
mcview_execute_cmd (Widget *sender, Widget *receiver,
int command, const void *data)
unsigned long command, const void *data)
{
mcview_t *view = (mcview_t *) receiver;
int res = MSG_HANDLED;

View File

@ -273,7 +273,7 @@ mcview_viewer (const char *command, const char *file, int *move_dir_p, int start
lc_mcview = mcview_new (0, 0, COLS, LINES - 1, 0);
add_widget (view_dlg, lc_mcview);
add_widget (view_dlg, buttonbar_new (1));
add_widget (view_dlg, buttonbar_new (TRUE));
succeeded = mcview_load (lc_mcview, command, file, start_line);
if (succeeded) {

View File

@ -1771,7 +1771,7 @@ port_region_marked_for_delete (WInput *in)
}
static cb_ret_t
input_execute_cmd (WInput *in, int command)
input_execute_cmd (WInput *in, unsigned long command)
{
cb_ret_t res = MSG_HANDLED;
@ -1864,16 +1864,12 @@ input_execute_cmd (WInput *in, int command)
int
is_in_input_map (WInput *in, int key)
{
int i;
for (i = 0; input_map[i].key; i++) {
size_t i;
for (i = 0; input_map[i].key != 0; i++)
if (key == input_map[i].key) {
input_execute_cmd (in, input_map[i].command);
if (input_map[i].command == CK_InputComplete)
return 2;
else
return 1;
return (input_map[i].command == CK_InputComplete) ? 2 : 1;
}
}
return 0;
}
@ -2692,7 +2688,7 @@ buttonbar_call (WButtonBar *bb, int i)
/* calculate width of one button, width is never lesser than 7 */
static int
buttonbat_get_button_width ()
buttonbat_get_button_width (void)
{
int result = COLS / BUTTONBAR_LABELS_NUM;
return (result >= 7) ? result : 7;
@ -2725,7 +2721,7 @@ buttonbar_callback (Widget *w, widget_msg_t msg, int parm)
tty_setcolor (DEFAULT_COLOR);
bb->btn_width = buttonbat_get_button_width ();
tty_printf ("%-*s", bb->widget.cols, "");
count_free_positions = COLS - bb->btn_width*BUTTONBAR_LABELS_NUM;
count_free_positions = COLS - bb->btn_width * BUTTONBAR_LABELS_NUM;
for (i = 0; i < COLS / bb->btn_width && i < BUTTONBAR_LABELS_NUM; i++) {
widget_move (&bb->widget, 0, (i * bb->btn_width) + offset);
@ -2764,14 +2760,14 @@ buttonbar_event (Gpm_Event *event, void *data)
return MOU_NORMAL;
if (event->y == 2)
return MOU_NORMAL;
button = (event->x - 1) * BUTTONBAR_LABELS_NUM / (COLS);
button = (event->x - 1) * BUTTONBAR_LABELS_NUM / COLS;
if (button < BUTTONBAR_LABELS_NUM)
buttonbar_call (bb, button);
return MOU_NORMAL;
}
WButtonBar *
buttonbar_new (int visible)
buttonbar_new (gboolean visible)
{
WButtonBar *bb;
int i;
@ -2797,13 +2793,12 @@ static void
set_label_text (WButtonBar * bb, int lc_index, const char *text)
{
g_free (bb->labels[lc_index - 1].text);
bb->labels[lc_index - 1].text = g_strdup (text);
}
/* Find ButtonBar widget in the dialog */
WButtonBar *
find_buttonbar (Dlg_head *h)
find_buttonbar (const Dlg_head *h)
{
WButtonBar *bb;
@ -2832,7 +2827,7 @@ buttonbar_set_label_data (Dlg_head *h, int idx, const char *text,
if (!bb)
return;
assert (cback != (buttonbarfn) 0);
assert (cback != (buttonbarfn) NULL);
set_label_text (bb, idx, text);
bb->labels[idx - 1].tag = BBFUNC_PTR;
bb->labels[idx - 1].u.fn_ptr = cback;
@ -2847,7 +2842,7 @@ buttonbar_set_label (Dlg_head *h, int idx, const char *text, voidfn cback)
if (!bb)
return;
assert (cback != (voidfn) 0);
assert (cback != (voidfn) NULL);
set_label_text (bb, idx, text);
bb->labels[idx - 1].tag = BBFUNC_VOID;
bb->labels[idx - 1].u.fn_void = cback;

View File

@ -6,6 +6,7 @@
#ifndef MC_WIDGET_H
#define MC_WIDGET_H
#include "global.h"
#include "dialog.h" /* Widget */
/* Completion stuff */
@ -166,7 +167,7 @@ typedef void (*buttonbarfn)(void *);
typedef struct WButtonBar {
Widget widget;
int visible; /* Is it visible? */
gboolean visible; /* Is it visible? */
int btn_width; /* width of one button */
struct {
char *text;
@ -197,7 +198,7 @@ WInput *input_new (int y, int x, int color, int len, const char *text, const
WLabel *label_new (int y, int x, const char *text);
WGauge *gauge_new (int y, int x, int shown, int max, int current);
WListbox *listbox_new (int y, int x, int height, int width, lcback callback);
WButtonBar *buttonbar_new (int visible);
WButtonBar *buttonbar_new (gboolean visible);
WGroupbox *groupbox_new (int y, int x, int height, int width, const char *title);
/* Input lines */
@ -253,15 +254,15 @@ char *listbox_add_item (WListbox *l, enum append_pos pos, int
hotkey, const char *text, void *data);
WButtonBar *find_buttonbar (Dlg_head *h);
WButtonBar *find_buttonbar (const Dlg_head *h);
void buttonbar_clear_label (Dlg_head *, int idx);
void buttonbar_set_label (Dlg_head *, int index, const char *text, voidfn);
void buttonbar_set_label_data (Dlg_head *h, int idx, const char *text,
buttonbarfn cback, void *data);
void buttonbar_set_visible (WButtonBar *, gboolean);
void buttonbar_set_visible (WButtonBar *bb, gboolean visible);
void buttonbar_redraw (Dlg_head *h);
void free_completions (WInput *);
void complete (WInput *);
void free_completions (WInput *in);
void complete (WInput *in);
#endif
#endif /* MC_WIDGET_H */