1
1

patches by Rostislav Beneš: mc-12-menu

like buttons use menu entries hotkey_t. But menus are staticly defined, so this
change is much bigger. All menu declaration must be edited. follow standard
changes in drawing and handling hotkeys.

now basic mc's functions works in utf-8, remain correct calculation of controls
width in dialogs, replace functions like tolower, toupper,isspace, ... width
functions from strutil or g_ascii variant.
Этот коммит содержится в:
Slava Zanko 2008-12-29 00:57:59 +02:00
родитель 564c518415
Коммит 4f00496233
4 изменённых файлов: 237 добавлений и 231 удалений

Просмотреть файл

@ -297,124 +297,124 @@ menu_user_menu_cmd (void)
static menu_entry FileMenu[] =
{
{' ', N_("&Open file..."), 'O', menu_load_cmd},
{' ', N_("&New C-n"), 'N', menu_new_cmd},
{' ', "", ' ', 0},
{' ', N_("&Save F2"), 'S', menu_save_cmd},
{' ', N_("Save &as... F12"), 'A', menu_save_as_cmd},
{' ', "", ' ', 0},
{' ', N_("&Insert file... F15"), 'I', menu_insert_file_cmd},
{' ', N_("Copy to &file... C-f"), 'F', menu_cut_cmd},
{' ', "", ' ', 0},
{' ', N_("&User menu... F11"), 'U', menu_user_menu_cmd},
{' ', "", ' ', 0},
{' ', N_("A&bout... "), 'B', edit_about_cmd},
{' ', "", ' ', 0},
{' ', N_("&Quit F10"), 'Q', menu_quit_cmd}
{' ', N_("&Open file..."), NULL_HOTKEY, menu_load_cmd},
{' ', N_("&New C-n"), NULL_HOTKEY, menu_new_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Save F2"), NULL_HOTKEY, menu_save_cmd},
{' ', N_("Save &as... F12"), NULL_HOTKEY, menu_save_as_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Insert file... F15"), NULL_HOTKEY, menu_insert_file_cmd},
{' ', N_("Copy to &file... C-f"), NULL_HOTKEY, menu_cut_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&User menu... F11"), NULL_HOTKEY, menu_user_menu_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("A&bout... "), NULL_HOTKEY, edit_about_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Quit F10"), NULL_HOTKEY, menu_quit_cmd}
};
static menu_entry FileMenuEmacs[] =
{
{' ', N_("&Open file..."), 'O', menu_load_cmd},
{' ', N_("&New C-x k"), 'N', menu_new_cmd},
{' ', "", ' ', 0},
{' ', N_("&Save F2"), 'S', menu_save_cmd},
{' ', N_("Save &as... F12"), 'A', menu_save_as_cmd},
{' ', "", ' ', 0},
{' ', N_("&Insert file... F15"), 'I', menu_insert_file_cmd},
{' ', N_("Copy to &file... "), 'F', menu_cut_cmd},
{' ', "", ' ', 0},
{' ', N_("&User menu... F11"), 'U', menu_user_menu_cmd},
{' ', "", ' ', 0},
{' ', N_("A&bout... "), 'B', edit_about_cmd},
{' ', "", ' ', 0},
{' ', N_("&Quit F10"), 'Q', menu_quit_cmd}
{' ', N_("&Open file..."), NULL_HOTKEY, menu_load_cmd},
{' ', N_("&New C-x k"), NULL_HOTKEY, menu_new_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Save F2"), NULL_HOTKEY, menu_save_cmd},
{' ', N_("Save &as... F12"), NULL_HOTKEY, menu_save_as_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Insert file... F15"), NULL_HOTKEY, menu_insert_file_cmd},
{' ', N_("Copy to &file... "), NULL_HOTKEY, menu_cut_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&User menu... F11"), NULL_HOTKEY, menu_user_menu_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("A&bout... "), NULL_HOTKEY, edit_about_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Quit F10"), NULL_HOTKEY, menu_quit_cmd}
};
static menu_entry EditMenu[] =
{
{' ', N_("&Toggle Mark F3"), 'T', menu_mark_cmd},
{' ', N_("&Mark Columns S-F3"), 'T', menu_markcol_cmd},
{' ', "", ' ', 0},
{' ', N_("Toggle &ins/overw Ins"), 'I', menu_ins_cmd},
{' ', "", ' ', 0},
{' ', N_("&Copy F5"), 'C', menu_copy_cmd},
{' ', N_("&Move F6"), 'M', menu_move_cmd},
{' ', N_("&Delete F8"), 'D', menu_delete_cmd},
{' ', "", ' ', 0},
{' ', N_("&Undo C-u"), 'U', menu_undo_cmd},
{' ', "", ' ', 0},
{' ', N_("&Beginning C-PgUp"), 'B', menu_beginning_cmd},
{' ', N_("&End C-PgDn"), 'E', menu_end_cmd}
{' ', N_("&Toggle Mark F3"), NULL_HOTKEY, menu_mark_cmd},
{' ', N_("&Mark Columns S-F3"), NULL_HOTKEY, menu_markcol_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("Toggle &ins/overw Ins"), NULL_HOTKEY, menu_ins_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Copy F5"), NULL_HOTKEY, menu_copy_cmd},
{' ', N_("&Move F6"), NULL_HOTKEY, menu_move_cmd},
{' ', N_("&Delete F8"), NULL_HOTKEY, menu_delete_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Undo C-u"), NULL_HOTKEY, menu_undo_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Beginning C-PgUp"), NULL_HOTKEY, menu_beginning_cmd},
{' ', N_("&End C-PgDn"), NULL_HOTKEY, menu_end_cmd}
};
#define EditMenuEmacs EditMenu
static menu_entry SearReplMenu[] =
{
{' ', N_("&Search... F7"), 'S', menu_search_cmd},
{' ', N_("Search &again F17"), 'A', menu_search_again_cmd},
{' ', N_("&Replace... F4"), 'R', menu_replace_cmd}
{' ', N_("&Search... F7"), NULL_HOTKEY, menu_search_cmd},
{' ', N_("Search &again F17"), NULL_HOTKEY, menu_search_again_cmd},
{' ', N_("&Replace... F4"), NULL_HOTKEY, menu_replace_cmd}
};
#define SearReplMenuEmacs SearReplMenu
static menu_entry CmdMenu[] =
{
{' ', N_("&Go to line... M-l"), 'G', menu_goto_line},
{' ', N_("Go to matching &bracket M-b"), 'B', menu_goto_bracket},
{' ', "", ' ', 0},
{' ', N_("Insert &literal... C-q"), 'L', menu_lit_cmd},
{' ', "", ' ', 0},
{' ', N_("&Refresh screen C-l"), 'R', menu_refresh_cmd},
{' ', "", ' ', 0},
{' ', N_("&Start record macro C-r"), 'S', menu_begin_record_cmd},
{' ', N_("&Finish record macro... C-r"), 'F', menu_end_record_cmd},
{' ', N_("&Execute macro... C-a, KEY"), 'E', menu_exec_macro_cmd},
{' ', N_("Delete macr&o... "), 'O', menu_exec_macro_delete_cmd},
{' ', "", ' ', 0},
{' ', N_("Insert &date/time "), 'D', menu_date_cmd},
{' ', "", ' ', 0},
{' ', N_("Format p&aragraph M-p"), 'A', menu_format_paragraph},
{' ', N_("'ispell' s&pell check C-p"), 'P', menu_ispell_cmd},
{' ', N_("Sor&t... M-t"), 'T', menu_sort_cmd},
{' ', N_("Paste o&utput of... M-u"), 'U', menu_ext_cmd},
{' ', N_("E&xternal Formatter F19"), 'C', menu_c_form_cmd},
{' ', N_("&Mail... "), 'M', menu_mail_cmd}
{' ', N_("&Go to line... M-l"), NULL_HOTKEY, menu_goto_line},
{' ', N_("Go to matching &bracket M-b"), NULL_HOTKEY, menu_goto_bracket},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("Insert &literal... C-q"), NULL_HOTKEY, menu_lit_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Refresh screen C-l"), NULL_HOTKEY, menu_refresh_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Start record macro C-r"), NULL_HOTKEY, menu_begin_record_cmd},
{' ', N_("&Finish record macro... C-r"), NULL_HOTKEY, menu_end_record_cmd},
{' ', N_("&Execute macro... C-a, KEY"), NULL_HOTKEY, menu_exec_macro_cmd},
{' ', N_("Delete macr&o... "), NULL_HOTKEY, menu_exec_macro_delete_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("Insert &date/time "), NULL_HOTKEY, menu_date_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("Format p&aragraph M-p"), NULL_HOTKEY, menu_format_paragraph},
{' ', N_("'ispell' s&pell check C-p"), NULL_HOTKEY, menu_ispell_cmd},
{' ', N_("Sor&t... M-t"), NULL_HOTKEY, menu_sort_cmd},
{' ', N_("Paste o&utput of... M-u"), NULL_HOTKEY, menu_ext_cmd},
{' ', N_("E&xternal Formatter F19"), NULL_HOTKEY, menu_c_form_cmd},
{' ', N_("&Mail... "), NULL_HOTKEY, menu_mail_cmd}
};
static menu_entry CmdMenuEmacs[] =
{
{' ', N_("&Go to line... M-l"), 'G', menu_goto_line},
{' ', N_("Go to matching &bracket M-b"), 'B', menu_goto_bracket},
{' ', "", ' ', 0},
{' ', N_("Insert &literal... C-q"), 'L', menu_lit_cmd},
{' ', "", ' ', 0},
{' ', N_("&Refresh screen C-l"), 'R', menu_refresh_cmd},
{' ', "", ' ', 0},
{' ', N_("&Start record macro C-r"), 'S', menu_begin_record_cmd},
{' ', N_("&Finish record macro... C-r"), 'F', menu_end_record_cmd},
{' ', N_("&Execute macro... C-x e, KEY"), 'E', menu_exec_macro_cmd},
{' ', N_("Delete macr&o... "), 'o', menu_exec_macro_delete_cmd},
{' ', "", ' ', 0},
{' ', N_("Insert &date/time "), 'D', menu_date_cmd},
{' ', "", ' ', 0},
{' ', N_("Format p&aragraph M-p"), 'a', menu_format_paragraph},
{' ', N_("'ispell' s&pell check M-$"), 'P', menu_ispell_cmd},
{' ', N_("Sor&t... M-t"), 'T', menu_sort_cmd},
{' ', N_("Paste o&utput of... M-u"), 'U', menu_ext_cmd},
{' ', N_("E&xternal Formatter F19"), 'C', menu_c_form_cmd},
{' ', N_("&Mail... "), 'M', menu_mail_cmd}
{' ', N_("&Go to line... M-l"), NULL_HOTKEY, menu_goto_line},
{' ', N_("Go to matching &bracket M-b"), NULL_HOTKEY, menu_goto_bracket},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("Insert &literal... C-q"), NULL_HOTKEY, menu_lit_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Refresh screen C-l"), NULL_HOTKEY, menu_refresh_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Start record macro C-r"), NULL_HOTKEY, menu_begin_record_cmd},
{' ', N_("&Finish record macro... C-r"), NULL_HOTKEY, menu_end_record_cmd},
{' ', N_("&Execute macro... C-x e, KEY"), NULL_HOTKEY, menu_exec_macro_cmd},
{' ', N_("Delete macr&o... "), NULL_HOTKEY, menu_exec_macro_delete_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("Insert &date/time "), NULL_HOTKEY, menu_date_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("Format p&aragraph M-p"), NULL_HOTKEY, menu_format_paragraph},
{' ', N_("'ispell' s&pell check M-$"), NULL_HOTKEY, menu_ispell_cmd},
{' ', N_("Sor&t... M-t"), NULL_HOTKEY, menu_sort_cmd},
{' ', N_("Paste o&utput of... M-u"), NULL_HOTKEY, menu_ext_cmd},
{' ', N_("E&xternal Formatter F19"), NULL_HOTKEY, menu_c_form_cmd},
{' ', N_("&Mail... "), NULL_HOTKEY, menu_mail_cmd}
};
static menu_entry OptMenu[] =
{
{' ', N_("&General... "), 'G', menu_options},
{' ', N_("&Save mode..."), 'S', menu_save_mode_cmd},
{' ', N_("Learn &Keys..."), 'K', learn_keys},
{' ', N_("Syntax &Highlighting..."), 'H', menu_syntax},
{' ', "", ' ', 0},
{' ', N_("Save setu&p..."), 'p', save_setup_cmd}
{' ', N_("&General... "), NULL_HOTKEY, menu_options},
{' ', N_("&Save mode..."), NULL_HOTKEY, menu_save_mode_cmd},
{' ', N_("Learn &Keys..."), NULL_HOTKEY, learn_keys},
{' ', N_("Syntax &Highlighting..."), NULL_HOTKEY, menu_syntax},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("Save setu&p..."), NULL_HOTKEY, save_setup_cmd}
};
#define OptMenuEmacs OptMenu

Просмотреть файл

@ -802,76 +802,76 @@ listmode_cmd (void)
/* NOTICE: hotkeys specified here are overriden in menubar_paint_idx (alex) */
static menu_entry LeftMenu[] = {
{' ', N_("&Listing mode..."), 'L', listing_cmd},
{' ', N_("&Quick view C-x q"), 'Q', quick_view_cmd},
{' ', N_("&Info C-x i"), 'I', info_cmd},
{' ', N_("&Tree"), 'T', tree_cmd},
{' ', "", ' ', 0},
{' ', N_("&Sort order..."), 'S', sort_cmd},
{' ', "", ' ', 0},
{' ', N_("&Filter..."), 'F', filter_cmd},
{' ', N_("&Listing mode..."), NULL_HOTKEY, listing_cmd},
{' ', N_("&Quick view C-x q"), NULL_HOTKEY, quick_view_cmd},
{' ', N_("&Info C-x i"), NULL_HOTKEY, info_cmd},
{' ', N_("&Tree"), NULL_HOTKEY, tree_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Sort order..."), NULL_HOTKEY, sort_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Filter..."), NULL_HOTKEY, filter_cmd},
#ifdef USE_NETCODE
{' ', "", ' ', 0},
{' ', "", NULL_HOTKEY, 0},
#ifdef WITH_MCFS
{' ', N_("&Network link..."), 'N', netlink_cmd},
{' ', N_("&Network link..."), NULL_HOTKEY, netlink_cmd},
#endif
{' ', N_("FT&P link..."), 'P', ftplink_cmd},
{' ', N_("S&hell link..."), 'H', fishlink_cmd},
{' ', N_("FT&P link..."), NULL_HOTKEY, ftplink_cmd},
{' ', N_("S&hell link..."), NULL_HOTKEY, fishlink_cmd},
#ifdef WITH_SMBFS
{' ', N_("SM&B link..."), 'B', smblink_cmd},
{' ', N_("SM&B link..."), NULL_HOTKEY, smblink_cmd},
#endif
#endif
{' ', "", ' ', 0},
{' ', N_("&Rescan C-r"), 'R', reread_cmd}
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Rescan C-r"), NULL_HOTKEY, reread_cmd}
};
static menu_entry RightMenu[] = {
{' ', N_("&Listing mode..."), 'L', listing_cmd},
{' ', N_("&Quick view C-x q"), 'Q', quick_view_cmd},
{' ', N_("&Info C-x i"), 'I', info_cmd},
{' ', N_("&Tree"), 'T', tree_cmd},
{' ', "", ' ', 0},
{' ', N_("&Sort order..."), 'S', sort_cmd},
{' ', "", ' ', 0},
{' ', N_("&Filter..."), 'F', filter_cmd},
{' ', N_("&Listing mode..."), NULL_HOTKEY, listing_cmd},
{' ', N_("&Quick view C-x q"), NULL_HOTKEY, quick_view_cmd},
{' ', N_("&Info C-x i"), NULL_HOTKEY, info_cmd},
{' ', N_("&Tree"), NULL_HOTKEY, tree_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Sort order..."), NULL_HOTKEY, sort_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Filter..."), NULL_HOTKEY, filter_cmd},
#ifdef USE_NETCODE
{' ', "", ' ', 0},
{' ', "", NULL_HOTKEY, 0},
#ifdef WITH_MCFS
{' ', N_("&Network link..."), 'N', netlink_cmd},
{' ', N_("&Network link..."), NULL_HOTKEY, netlink_cmd},
#endif
{' ', N_("FT&P link..."), 'P', ftplink_cmd},
{' ', N_("S&hell link..."), 'H', fishlink_cmd},
{' ', N_("FT&P link..."), NULL_HOTKEY, ftplink_cmd},
{' ', N_("S&hell link..."), NULL_HOTKEY, fishlink_cmd},
#ifdef WITH_SMBFS
{' ', N_("SM&B link..."), 'B', smblink_cmd},
{' ', N_("SM&B link..."), NULL_HOTKEY, smblink_cmd},
#endif
#endif
{' ', "", ' ', 0},
{' ', N_("&Rescan C-r"), 'R', reread_cmd}
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Rescan C-r"), NULL_HOTKEY, reread_cmd}
};
static menu_entry FileMenu[] = {
{' ', N_("&User menu F2"), 'U', user_file_menu_cmd},
{' ', N_("&View F3"), 'V', view_cmd},
{' ', N_("Vie&w file... "), 'W', view_file_cmd},
{' ', N_("&Filtered view M-!"), 'F', filtered_view_cmd},
{' ', N_("&Edit F4"), 'E', edit_cmd},
{' ', N_("&Copy F5"), 'C', copy_cmd},
{' ', N_("c&Hmod C-x c"), 'H', chmod_cmd},
{' ', N_("&Link C-x l"), 'L', link_cmd},
{' ', N_("&SymLink C-x s"), 'S', symlink_cmd},
{' ', N_("edit s&Ymlink C-x C-s"), 'Y', edit_symlink_cmd},
{' ', N_("ch&Own C-x o"), 'O', chown_cmd},
{' ', N_("&Advanced chown "), 'A', chown_advanced_cmd},
{' ', N_("&Rename/Move F6"), 'R', ren_cmd},
{' ', N_("&Mkdir F7"), 'M', mkdir_cmd},
{' ', N_("&Delete F8"), 'D', delete_cmd},
{' ', N_("&Quick cd M-c"), 'Q', quick_cd_cmd},
{' ', "", ' ', 0},
{' ', N_("select &Group M-+"), 'G', select_cmd},
{' ', N_("u&Nselect group M-\\"), 'N', unselect_cmd},
{' ', N_("reverse selec&Tion M-*"), 'T', reverse_selection_cmd},
{' ', "", ' ', 0},
{' ', N_("e&Xit F10"), 'X', quit_cmd}
{' ', N_("&User menu F2"), NULL_HOTKEY, user_file_menu_cmd},
{' ', N_("&View F3"), NULL_HOTKEY, view_cmd},
{' ', N_("Vie&w file... "), NULL_HOTKEY, view_file_cmd},
{' ', N_("&Filtered view M-!"), NULL_HOTKEY, filtered_view_cmd},
{' ', N_("&Edit F4"), NULL_HOTKEY, edit_cmd},
{' ', N_("&Copy F5"), NULL_HOTKEY, copy_cmd},
{' ', N_("c&Hmod C-x c"), NULL_HOTKEY, chmod_cmd},
{' ', N_("&Link C-x l"), NULL_HOTKEY, link_cmd},
{' ', N_("&SymLink C-x s"), NULL_HOTKEY, symlink_cmd},
{' ', N_("edit s&Ymlink C-x C-s"), NULL_HOTKEY, edit_symlink_cmd},
{' ', N_("ch&Own C-x o"), NULL_HOTKEY, chown_cmd},
{' ', N_("&Advanced chown "), NULL_HOTKEY, chown_advanced_cmd},
{' ', N_("&Rename/Move F6"), NULL_HOTKEY, ren_cmd},
{' ', N_("&Mkdir F7"), NULL_HOTKEY, mkdir_cmd},
{' ', N_("&Delete F8"), NULL_HOTKEY, delete_cmd},
{' ', N_("&Quick cd M-c"), NULL_HOTKEY, quick_cd_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("select &Group M-+"), NULL_HOTKEY, select_cmd},
{' ', N_("u&Nselect group M-\\"), NULL_HOTKEY, unselect_cmd},
{' ', N_("reverse selec&Tion M-*"), NULL_HOTKEY, reverse_selection_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("e&Xit F10"), NULL_HOTKEY, quit_cmd}
};
static menu_entry CmdMenu[] = {
@ -879,52 +879,52 @@ static menu_entry CmdMenu[] = {
* as a panel still has some problems, I have not yet finished
* the WTree widget port, sorry.
*/
{' ', N_("&Directory tree"), 'D', treebox_cmd},
{' ', N_("&Find file M-?"), 'F', find_cmd},
{' ', N_("s&Wap panels C-u"), 'W', swap_cmd},
{' ', N_("switch &Panels on/off C-o"), 'P', view_other_cmd},
{' ', N_("&Compare directories C-x d"), 'C', compare_dirs_cmd},
{' ', N_("e&Xternal panelize C-x !"), 'X', external_panelize},
{' ', N_("show directory s&Izes"), 'I', dirsizes_cmd},
{' ', "", ' ', 0},
{' ', N_("command &History"), 'H', history_cmd},
{' ', N_("di&Rectory hotlist C-\\"), 'R', quick_chdir_cmd},
{' ', N_("&Directory tree"), NULL_HOTKEY, treebox_cmd},
{' ', N_("&Find file M-?"), NULL_HOTKEY, find_cmd},
{' ', N_("s&Wap panels C-u"), NULL_HOTKEY, swap_cmd},
{' ', N_("switch &Panels on/off C-o"), NULL_HOTKEY, view_other_cmd},
{' ', N_("&Compare directories C-x d"), NULL_HOTKEY, compare_dirs_cmd},
{' ', N_("e&Xternal panelize C-x !"), NULL_HOTKEY, external_panelize},
{' ', N_("show directory s&Izes"), NULL_HOTKEY, dirsizes_cmd},
{' ', "", NULL_HOTKEY, 0},
{' ', N_("command &History"), NULL_HOTKEY, history_cmd},
{' ', N_("di&Rectory hotlist C-\\"), NULL_HOTKEY, quick_chdir_cmd},
#ifdef USE_VFS
{' ', N_("&Active VFS list C-x a"), 'A', reselect_vfs},
{' ', N_("&Active VFS list C-x a"), NULL_HOTKEY, reselect_vfs},
#endif
#ifdef WITH_BACKGROUND
{' ', N_("&Background jobs C-x j"), 'B', jobs_cmd},
{' ', N_("&Background jobs C-x j"), NULL_HOTKEY, jobs_cmd},
#endif
{' ', "", ' ', 0},
{' ', "", NULL_HOTKEY, 0},
#ifdef USE_EXT2FSLIB
{' ', N_("&Undelete files (ext2fs only)"), 'U', undelete_cmd},
{' ', N_("&Undelete files (ext2fs only)"), NULL_HOTKEY, undelete_cmd},
#endif
#ifdef LISTMODE_EDITOR
{' ', N_("&Listing format edit"), 'L', listmode_cmd},
{' ', N_("&Listing format edit"), NULL_HOTKEY, listmode_cmd},
#endif
#if defined (USE_EXT2FSLIB) || defined (LISTMODE_EDITOR)
{' ', "", ' ', 0},
{' ', "", NULL_HOTKEY, 0},
#endif
{' ', N_("Edit &extension file"), 'E', ext_cmd},
{' ', N_("Edit &menu file"), 'M', edit_mc_menu_cmd},
{' ', N_("Edit &extension file"), NULL_HOTKEY, ext_cmd},
{' ', N_("Edit &menu file"), NULL_HOTKEY, edit_mc_menu_cmd},
#ifdef USE_INTERNAL_EDIT
{' ', N_("Edit edi&tor menu file"), 'T', edit_user_menu_cmd},
{' ', N_("Edit &syntax file"), 'S', edit_syntax_cmd}
{' ', N_("Edit edi&tor menu file"), NULL_HOTKEY, edit_user_menu_cmd},
{' ', N_("Edit &syntax file"), NULL_HOTKEY, edit_syntax_cmd}
#endif /* USE_INTERNAL_EDIT */
};
/* Must keep in sync with the constants in menu_cmd */
static menu_entry OptMenu[] = {
{' ', N_("&Configuration..."), 'C', configure_box},
{' ', N_("&Layout..."), 'L', layout_cmd},
{' ', N_("c&Onfirmation..."), 'O', confirm_box},
{' ', N_("&Display bits..."), 'D', display_bits_box},
{' ', N_("learn &Keys..."), 'K', learn_keys},
{' ', N_("&Configuration..."), NULL_HOTKEY, configure_box},
{' ', N_("&Layout..."), NULL_HOTKEY, layout_cmd},
{' ', N_("c&Onfirmation..."), NULL_HOTKEY, confirm_box},
{' ', N_("&Display bits..."), NULL_HOTKEY, display_bits_box},
{' ', N_("learn &Keys..."), NULL_HOTKEY, learn_keys},
#ifdef USE_VFS
{' ', N_("&Virtual FS..."), 'V', configure_vfs},
{' ', N_("&Virtual FS..."), NULL_HOTKEY, configure_vfs},
#endif /* !USE_VFS */
{' ', "", ' ', 0},
{' ', N_("&Save setup"), 'S', save_setup_cmd}
{' ', "", NULL_HOTKEY, 0},
{' ', N_("&Save setup"), NULL_HOTKEY, save_setup_cmd}
};
#define menu_entries(x) sizeof(x)/sizeof(menu_entry)

Просмотреть файл

@ -34,55 +34,35 @@
#include "mouse.h"
#include "win.h"
#include "key.h" /* For mi_getch() */
#include "strutil.h"
int menubar_visible = 1; /* This is the new default */
static void
menu_scan_hotkey (Menu *menu)
{
char *cp = strchr (menu->name, '&');
if (cp != NULL && cp[1] != '\0') {
g_strlcpy (cp, cp + 1, strlen (cp));
menu->hotkey = tolower ((unsigned char) *cp);
} else
menu->hotkey = 0;
}
Menu *
create_menu (const char *name, menu_entry *entries, int count, const char *help_node)
{
Menu *menu;
const char *cp;
menu = (Menu *) g_malloc (sizeof (*menu));
menu = g_new (Menu, 1);
menu->count = count;
menu->max_entry_len = 20;
menu->entries = entries;
menu->text = parse_hotkey (name);
if (entries != (menu_entry*) NULL) {
int len;
register menu_entry* mp;
for (mp = entries; count--; mp++) {
if (mp->text[0] != '\0') {
#ifdef ENABLE_NLS
mp->text = _(mp->text);
#endif /* ENABLE_NLS */
cp = strchr (mp->text,'&');
if (mp->label[0] != '\0') {
mp->label = _(mp->label);
mp->text = parse_hotkey (mp->label);
len = hotkey_width (mp->text);
if (cp != NULL && *(cp+1) != '\0') {
mp->hot_key = tolower ((unsigned char) *(cp+1));
menu->max_entry_len = max ((int) (strlen (mp->text) - 1),
menu->max_entry_len);
} else {
menu->max_entry_len = max ((int) strlen (mp->text),
menu->max_entry_len);
}
menu->max_entry_len = max (len, menu->max_entry_len);
}
}
}
menu->name = g_strdup (name);
menu_scan_hotkey(menu);
menu->start_x = 0;
menu->help_node = g_strdup (help_node);
return menu;
@ -97,32 +77,33 @@ static void menubar_paint_idx (WMenu *menubar, int idx, int color)
{
const Menu *menu = menubar->menu[menubar->selected];
const int y = 2 + idx;
int x = menubar-> menu[menubar->selected]->start_x;
int x = menu->start_x;
const menu_entry *entry = &menu->entries[idx];
if (x + menubar->max_entry_len + 3 > menubar->widget.cols)
x = menubar->widget.cols - menubar->max_entry_len - 3;
widget_move (&menubar->widget, y, x);
attrset (color);
hline (' ', menubar->max_entry_len + 2);
if (!*menu->entries [idx].text) {
if (entry->text.start == NULL) {
attrset (SELECTED_COLOR);
widget_move (&menubar->widget, y, x + 1);
hline (slow_terminal ? ' ' : ACS_HLINE, menubar->max_entry_len);
} else {
const char *text;
addch ((unsigned char)entry->first_letter);
addch((unsigned char)menu->entries [idx].first_letter);
for (text = menu->entries [idx].text; *text; text++)
{
if (*text != '&')
addch(*text);
else {
addstr (str_term_form (entry->text.start));
if (entry->text.hotkey != NULL) {
attrset (color == MENU_SELECTED_COLOR ?
MENU_HOTSEL_COLOR : MENU_HOT_COLOR);
addch(*(++text));
addstr (str_term_form (entry->text.hotkey));
attrset(color);
}
if (entry->text.end != NULL) {
addstr (str_term_form (entry->text.end));
}
}
widget_move (&menubar->widget, y, x + 1);
@ -166,10 +147,22 @@ static void menubar_draw (WMenu *menubar)
attrset (SELECTED_COLOR);
/* Now each one of the entries */
for (i = 0; i < items; i++){
if (menubar->active)
attrset(i == menubar->selected?MENU_SELECTED_COLOR:SELECTED_COLOR);
attrset ((menubar->active && i == menubar->selected) ?
MENU_SELECTED_COLOR : SELECTED_COLOR);
widget_move (&menubar->widget, 0, menubar->menu [i]->start_x);
tty_printf ("%s", menubar->menu [i]->name);
addstr (str_term_form (menubar->menu[i]->text.start));
if (menubar->menu[i]->text.hotkey != NULL) {
attrset ((menubar->active && i == menubar->selected) ?
MENU_HOTSEL_COLOR : COLOR_HOT_FOCUS);
addstr (str_term_form (menubar->menu[i]->text.hotkey));
attrset ((menubar->active && i == menubar->selected) ?
MENU_SELECTED_COLOR : SELECTED_COLOR);
}
if (menubar->menu[i]->text.end != NULL) {
addstr (str_term_form (menubar->menu[i]->text.end));
}
}
if (menubar->dropped)
@ -177,6 +170,7 @@ static void menubar_draw (WMenu *menubar)
else
widget_move (&menubar->widget, 0,
menubar-> menu[menubar->selected]->start_x);
}
static inline void menubar_remove (WMenu *menubar)
@ -264,8 +258,7 @@ static int menubar_handle_key (WMenu *menubar, int key)
int i;
/* Lowercase */
if (key < 256 && isalpha (key)) /* Linux libc.so.5.x.x bug fix */
key = tolower (key);
if (isascii (key)) key = g_ascii_tolower (key);
if (is_abort_char (key)){
menubar_finish (menubar);
@ -296,13 +289,16 @@ static int menubar_handle_key (WMenu *menubar, int key)
for (i = 0; i < items; i++) {
const Menu *menu = menubar->menu [i];
if (menu->hotkey == key){
if (menu->text.hotkey != NULL) {
if (g_ascii_tolower(menu->text.hotkey[0]) == key) {
menubar_drop (menubar, i);
return 1;
}
}
if (key == KEY_ENTER || key == XCTRL ('n') || key == KEY_DOWN
|| key == '\n'){
}
if (key == KEY_ENTER || key == XCTRL ('n')
|| key == KEY_DOWN || key == '\n') {
menubar_drop (menubar, menubar->selected);
return 1;
}
@ -316,12 +312,14 @@ static int menubar_handle_key (WMenu *menubar, int key)
if (!menu->entries [i].call_back)
continue;
if (key != menu->entries [i].hot_key)
if (menu->entries[i].text.hotkey != NULL) {
if (key != g_ascii_tolower (menu->entries[i].text.hotkey[0]))
continue;
menubar_execute (menubar, i);
return 1;
}
}
if (key == KEY_ENTER || key == '\n') {
menubar_execute (menubar, menubar->subsel);
@ -494,7 +492,7 @@ menubar_arrange(WMenu* menubar)
for (i = 0; i < items; i++)
{
int len = strlen(menubar->menu[i]->name);
int len = hotkey_width (menubar->menu[i]->text);
menubar->menu[i]->start_x = start_x;
start_x += len + gap;
}
@ -507,7 +505,7 @@ menubar_arrange(WMenu* menubar)
for (i = 0; i < items; i++)
{
/* preserve length here, to be used below */
gap -= (menubar->menu[i]->start_x = strlen(menubar->menu[i]->name));
gap -= (menubar->menu[i]->start_x = hotkey_width (menubar->menu[i]->text));
}
gap /= (items - 1);
@ -531,7 +529,16 @@ menubar_arrange(WMenu* menubar)
void
destroy_menu (Menu *menu)
{
g_free (menu->name);
release_hotkey (menu->text);
if (menu->entries != NULL) {
int me;
for (me = 0; me < menu->count; me++) {
if (menu->entries[me].label[0] != '\0') {
release_hotkey (menu->entries[me].text);
}
}
}
g_free (menu->help_node);
g_free (menu);
}

Просмотреть файл

@ -7,17 +7,16 @@ typedef void (*callfn) (void);
typedef struct {
char first_letter;
const char *text;
int hot_key;
const char *label;
struct hotkey_t text;
callfn call_back;
} menu_entry;
typedef struct Menu {
char *name;
struct hotkey_t text;
int count;
int max_entry_len;
int selected;
int hotkey;
menu_entry *entries;
int start_x; /* position relative to menubar start */
char *help_node;