Merge branch '2848_keymap_load'

* 2848_keymap_load:
  Allow define keymap file without .keymap extension
  Optimization of ini files load.
  mc.keymap.default, mc.keymap.emacs: comment out unassigned commands.
  Ticket #2848: fixup of user-defined keymap load.
This commit is contained in:
Andrew Borodin 2012-07-31 14:50:33 +04:00
commit 849fe8e4b1
18 changed files with 293 additions and 264 deletions

View File

@ -66,7 +66,7 @@ Display configure options.
Reset softkeys to their default from the termcap/terminfo
database. Only useful on HP terminals when the function keys don't work.
.TP
.I \-K file
.I \-K file, \-\-keymap=file
Specify a name of keymap file in the command line.
.TP
.I \-\-nokeymap
@ -325,7 +325,13 @@ the input lines in the query dialogs.
.\"NODE " Keys_redefine"
.SH " Redefine hotkey bindings"
Hotkey bindings may be read from external file (keymap\-file).
A keymap\-file is searched on the following algorithm (to the first one found):
Initially, Mignight Commander creates key bindings using keymap defined
in the source code. Then, two files
.B %prefix%/share/mc/mc.keymap
and
.B %sysconfdir%/mc/mc.keymap
are loaded always, sequentially reassigned key bindings defined earlier.
User\-defined keymap\-file is searched on the following algorithm (to the first one found):
.IP
.br
1) command line option
@ -345,11 +351,6 @@ of config file.
4) File
.B ~/.config/mc/mc.keymap
.br
5) File
.B %sysconfdir%/mc/mc.keymap
.br
6) File
.B %prefix%/share/mc/mc.keymap
.PP
Command line option, environment variable and parameter in config file may
contain the absolute path to the keymap\-file (with the extension \.keymap

View File

@ -79,7 +79,7 @@ UNIX\-подобных операционных системах.
termcap/terminfo. Этот ключ используется только на терминалах HP, где
функциональные клавиши не работают.
.TP
.I \-K файл
.I \-K файл, \-\-keymap=файл
Задаёт файл клавиатурных команд для переопределения привязки клавиатурных
комбинаций к действиям.
.TP
@ -320,8 +320,14 @@ S\-<символ> означает, что нужно держать в нажа
.\"NODE " Keys_redefine"
.SH " Переопределение клавиатурных команд"
Клавиатурные команды могут быть прочитаны из внешнего файла.
Поиск файла клавиатурных команд производится по следующему алгоритму
(до первого нахождения файла):
Сначала Midnight Commander создаёт карту клавиатурных команд из списка,
определённого в исходном коде. Затем всегда загружаются два файла
.B %sysconfdir%/mc/mc.keymap
и
.B %prefix%/share/mc/mc.keymap ,
последовательно переопределяя ранее загруженные команды.
Поиск файла клавиатурных команд, определённого пользователем, производится
по следующему алгоритму (до первого нахождения файла):
.IP
.br
1) параметр командной строки
@ -341,12 +347,6 @@ S\-<символ> означает, что нужно держать в нажа
4) файл
.B ~/.config/mc/mc.keymap
.br
5) файл
.B %sysconfdir%/mc/mc.keymap
.br
6) файл
.B %prefix%/share/mc/mc.keymap
.PP
Параметры в трёх первых случаях могут содержать абсолютный путь к файлу
клавиатурных команд либо просто название схемы привязки (с расширением

View File

@ -184,9 +184,9 @@ mc_fhl_read_ini_file (mc_fhl_t * fhl, const gchar * filename)
return FALSE;
if (fhl->config != NULL)
return mc_config_read_file (fhl->config, filename, FALSE);
return mc_config_read_file (fhl->config, filename, TRUE, FALSE);
fhl->config = mc_config_init (filename);
fhl->config = mc_config_init (filename, TRUE);
return (fhl->config != NULL);
}

View File

@ -29,8 +29,8 @@ extern mc_config_t *mc_panels_config;
/* mcconfig/common.c: */
mc_config_t *mc_config_init (const gchar *);
void mc_config_deinit (mc_config_t *);
mc_config_t *mc_config_init (const gchar * ini_path, gboolean read_only);
void mc_config_deinit (mc_config_t * mc_config);
gboolean mc_config_del_key (mc_config_t *, const char *, const gchar *);
gboolean mc_config_del_group (mc_config_t *, const char *);
@ -38,7 +38,7 @@ gboolean mc_config_del_group (mc_config_t *, const char *);
gboolean mc_config_has_param (const mc_config_t *, const char *, const gchar *);
gboolean mc_config_has_group (mc_config_t *, const char *);
gboolean mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path,
gboolean mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path, gboolean read_only,
gboolean remove_empty);
gboolean mc_config_save_file (mc_config_t * config, GError ** error);

View File

@ -102,7 +102,7 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path,
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
mc_config_t *
mc_config_init (const gchar * ini_path)
mc_config_init (const gchar * ini_path, gboolean read_only)
{
mc_config_t *mc_config;
struct stat st;
@ -128,8 +128,13 @@ mc_config_init (const gchar * ini_path)
vpath = vfs_path_from_str (ini_path);
if (mc_stat (vpath, &st) == 0 && st.st_size != 0)
{
GKeyFileFlags flags = G_KEY_FILE_NONE;
if (!read_only)
flags |= G_KEY_FILE_KEEP_COMMENTS;
/* file exists and not empty */
g_key_file_load_from_file (mc_config->handle, ini_path, G_KEY_FILE_KEEP_COMMENTS, NULL);
g_key_file_load_from_file (mc_config->handle, ini_path, flags, NULL);
}
vfs_path_free (vpath);
}
@ -207,7 +212,8 @@ mc_config_del_group (mc_config_t * mc_config, const char *group)
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
gboolean
mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path, gboolean remove_empty)
mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path, gboolean read_only,
gboolean remove_empty)
{
mc_config_t *tmp_config;
gchar **groups, **curr_grp;
@ -217,7 +223,7 @@ mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path, gboolean r
if (mc_config == NULL)
return FALSE;
tmp_config = mc_config_init (ini_path);
tmp_config = mc_config_init (ini_path, read_only);
if (tmp_config == NULL)
return FALSE;

View File

@ -281,7 +281,7 @@ mc_deserialize_config (const char *data, GError ** error)
{
char *current_group = NULL, *current_param = NULL, *current_value = NULL;
size_t current_position = 0;
mc_config_t *ret_data = mc_config_init (NULL);
mc_config_t *ret_data;
enum automat_status
{
WAIT_GROUP,
@ -289,6 +289,8 @@ mc_deserialize_config (const char *data, GError ** error)
WAIT_VALUE
} current_status = WAIT_GROUP;
ret_data = mc_config_init (NULL, FALSE);
while (data != NULL)
{
if ((current_status == WAIT_GROUP) && (*data == 'p') && (current_group != NULL))

View File

@ -51,7 +51,7 @@ mc_skin_ini_file_load_search_in_dir (mc_skin_t * mc_skin, const gchar * base_dir
file_name = g_build_filename (base_dir, MC_SKINS_SUBDIR, mc_skin->name, NULL);
if (exist_file (file_name))
{
mc_skin->config = mc_config_init (file_name);
mc_skin->config = mc_config_init (file_name, TRUE);
g_free (file_name);
return (mc_skin->config != NULL);
}
@ -63,7 +63,7 @@ mc_skin_ini_file_load_search_in_dir (mc_skin_t * mc_skin, const gchar * base_dir
if (exist_file (file_name))
{
mc_skin->config = mc_config_init (file_name);
mc_skin->config = mc_config_init (file_name, TRUE);
g_free (file_name);
return (mc_skin->config != NULL);
}
@ -89,7 +89,7 @@ mc_skin_ini_file_load (mc_skin_t * mc_skin)
g_free (file_name);
if (!g_path_is_absolute (mc_skin->name))
return FALSE;
mc_skin->config = mc_config_init (mc_skin->name);
mc_skin->config = mc_config_init (mc_skin->name, TRUE);
return (mc_skin->config != NULL);
}
g_free (file_name);
@ -127,7 +127,7 @@ mc_skin_ini_file_parse (mc_skin_t * mc_skin)
void
mc_skin_set_hardcoded_skin (mc_skin_t * mc_skin)
{
mc_skin->config = mc_config_init (NULL);
mc_skin->config = mc_config_init (NULL, TRUE);
mc_config_set_string (mc_skin->config, "skin", "description", "hardcoded skin");

View File

@ -1053,7 +1053,7 @@ vfs_path_element_need_cleanup_converter (const vfs_path_element_t * element)
char *
vfs_path_serialize (const vfs_path_t * vpath, GError ** error)
{
mc_config_t *cpath = mc_config_init (NULL);
mc_config_t *cpath;
ssize_t element_index;
char *ret_value;
@ -1063,6 +1063,9 @@ vfs_path_serialize (const vfs_path_t * vpath, GError ** error)
return NULL;
}
cpath = mc_config_init (NULL, FALSE);
for (element_index = 0; element_index < vfs_path_elements_count (vpath); element_index++)
{
char *groupname;
@ -1106,10 +1109,11 @@ vfs_path_serialize (const vfs_path_t * vpath, GError ** error)
vfs_path_t *
vfs_path_deserialize (const char *data, GError ** error)
{
mc_config_t *cpath = mc_deserialize_config (data, error);
mc_config_t *cpath;
size_t element_index = 0;
vfs_path_t *vpath;
cpath = mc_deserialize_config (data, error);
if (cpath == NULL)
return NULL;

View File

@ -165,7 +165,7 @@ dlg_read_history (Dlg_head * h)
return;
profile = mc_config_get_full_path (MC_HISTORY_FILE);
event_data.cfg = mc_config_init (profile);
event_data.cfg = mc_config_init (profile, TRUE);
event_data.receiver = NULL;
/* create all histories in dialog */
@ -1335,7 +1335,7 @@ dlg_save_history (Dlg_head * h)
{
ev_history_load_save_t event_data;
event_data.cfg = mc_config_init (profile);
event_data.cfg = mc_config_init (profile, FALSE);
event_data.receiver = NULL;
/* get all histories in dialog */

View File

@ -151,7 +151,7 @@ history_get (const char *input_name)
return NULL;
profile = mc_config_get_full_path (MC_HISTORY_FILE);
cfg = mc_config_init (profile);
cfg = mc_config_init (profile, TRUE);
hist = history_load (cfg, input_name);

View File

@ -2,9 +2,9 @@
Help = f1
UserMenu = f2
View = f3
ViewFile =
# ViewFile =
Edit = f4
EditForceInternal =
# EditForceInternal =
Copy = f5
Move = f6
MakeDir = f7
@ -21,9 +21,9 @@ DirSize = ctrl-space
Suspend = ctrl-z
Swap = ctrl-u
History = alt-h
PanelListing =
# PanelListing =
PanelListingSwitch = alt-t
PanelListingChange =
# PanelListingChange =
ShowHidden = alt-dot
SplitVertHoriz = alt-comma
SplitEqual = alt-equal
@ -37,20 +37,20 @@ Select = kpplus
Unselect = kpminus
SelectInvert = kpasterisk
ScreenList = alt-prime
OptionsLayout =
OptionsPanel =
OptionsConfirm =
OptionsDisplayBits =
OptionsVfs =
LearnKeys =
SaveSetup =
EditExtensionsFile =
EditFileHighlightFile =
Filter =
ConnectFish =
ConnectFtp =
ConnectSmb =
Undelete =
# OptionsLayout =
# OptionsPanel =
# OptionsConfirm =
# OptionsDisplayBits =
# OptionsVfs =
# LearnKeys =
# SaveSetup =
# EditExtensionsFile =
# EditFileHighlightFile =
# Filter =
# ConnectFish =
# ConnectFtp =
# ConnectSmb =
# Undelete =
ExtendedKeyMap = ctrl-x
[main:xmap]
@ -80,8 +80,8 @@ Search = ctrl-s; alt-s
Mark = insert; ctrl-t
MarkUp = shift-up
MarkDown = shift-down
MarkLeft =
MarkRight =
# MarkLeft =
# MarkRight =
Down = down; ctrl-n
Up = up; ctrl-p
Left = left
@ -101,8 +101,8 @@ Unselect = alt-minus
SelectInvert = alt-asterisk
CdChild = ctrl-pgdn
CdParent = ctrl-pgup
CdParentSmart =
Panelize =
# CdParentSmart =
# Panelize =
History = alt-shift-h
HistoryNext = alt-u
HistoryPrev = alt-y
@ -113,16 +113,16 @@ PanelOtherSync = alt-i
SelectCodepage = alt-e
Top = alt-lt; home; a1
Bottom = alt-gt; end; c1
Sort =
SortPrev =
SortNext =
SortReverse =
SortByName =
SortByExt =
SortBySize =
SortByMTime =
ScrollLeft =
ScrollRight =
# Sort =
# SortPrev =
# SortNext =
# SortReverse =
# SortByName =
# SortByExt =
# SortBySize =
# SortByMTime =
# ScrollLeft =
# ScrollRight =
[dialog]
Ok = enter
@ -149,18 +149,18 @@ Backspace = backspace; ctrl-h
Delete = delete; ctrl-d
DeleteToWordBegin = alt-backspace
DeleteToWordEnd = alt-d
Mark =
# Mark =
Remove = ctrl-w
Cut =
# Cut =
Store = alt-w
Paste =
# Paste =
Yank = ctrl-y
DeleteToEnd = ctrl-k
HistoryPrev = alt-p; ctrl-down
HistoryNext = alt-n; ctrl-up
History = alt-h
Complete = alt-tab
Clear =
# Clear =
MarkLeft = shift-left
MarkRight = shift-right
MarkToWordBegin = ctrl-shift-left
@ -247,26 +247,26 @@ DeleteToWordBegin = alt-backspace
DeleteToWordEnd = alt-d
DeleteLine = ctrl-y
DeleteToEnd = ctrl-k
DeleteToHome =
ParagraphUp =
ParagraphDown =
# DeleteToHome =
# ParagraphUp =
# ParagraphDown =
Save = f2
EditFile =
# EditFile =
EditNew = ctrl-n
SaveAs = f12; ctrl-f2
Close =
# Close =
Mark = f3
Copy = f5
Move = f6
Remove = f8
MarkLine =
MarkWord =
MarkAll =
Unmark =
# MarkLine =
# MarkWord =
# MarkAll =
# Unmark =
Search = f7
SearchContinue = f17
BlockShiftLeft =
BlockShiftRight =
# BlockShiftLeft =
# BlockShiftRight =
MarkPageUp = shift-pgup
MarkPageDown = shift-pgdn
MarkLeft = shift-left
@ -283,18 +283,18 @@ MarkToPageBegin = ctrl-shift-pgup
MarkToPageEnd = ctrl-shift-pgdn
MarkScrollUp = ctrl-shift-up
MarkScrollDown = ctrl-shift-down
MarkParagraphUp =
MarkParagraphDown =
# MarkParagraphUp =
# MarkParagraphDown =
MarkColumnPageUp = alt-pgup
MarkColumnPageDown = alt-pgdn
MarkColumnLeft = alt-left
MarkColumnRight = alt-right
MarkColumnUp = alt-up
MarkColumnDown = alt-down
MarkColumnScrollUp =
MarkColumnScrollDown =
MarkColumnParagraphUp =
MarkColumnParagraphDown =
# MarkColumnScrollUp =
# MarkColumnScrollDown =
# MarkColumnParagraphUp =
# MarkColumnParagraphDown =
BlockSave = ctrl-f
MarkColumn = f13
Replace = f4
@ -304,7 +304,7 @@ InsertFile = f15
Quit = f10; esc
InsertOverwrite = insert
Help = f1
Date =
# Date =
Refresh = ctrl-l
Goto = alt-l
Sort = alt-t
@ -318,36 +318,36 @@ Bookmark = alt-k
BookmarkFlush = alt-o
BookmarkNext = alt-j
BookmarkPrev = alt-i
History =
# History =
Shell = ctrl-o
InsertLiteral = ctrl-q
MacroStartRecord =
MacroStopRecord =
# MacroStartRecord =
# MacroStopRecord =
MacroStartStopRecord = ctrl-r
MacroDelete =
# MacroDelete =
ShowNumbers = alt-n
ShowTabTws = alt-underline
SyntaxOnOff = ctrl-s
SyntaxChoose =
ShowMargin =
# SyntaxChoose =
# ShowMargin =
Find = alt-enter
FilePrev = alt-minus
FileNext = alt-plus
RepeatStartStopRecord =
# RepeatStartStopRecord =
SelectCodepage = alt-e
Options =
OptionsSaveMode =
SpellCheck =
# Options =
# OptionsSaveMode =
# SpellCheck =
SpellCheckCurrentWord = ctrl-p
SpellCheckSelectLang =
LearnKeys =
WindowMove =
WindowResize =
WindowFullscreen =
WindowList =
WindowNext =
WindowPrev =
ExtendedKeyMap =
# SpellCheckSelectLang =
# LearnKeys =
# WindowMove =
# WindowResize =
# WindowFullscreen =
# WindowList =
# WindowNext =
# WindowPrev =
# ExtendedKeyMap =
[viewer]
Help = f1

View File

@ -2,9 +2,9 @@
Help = f1
UserMenu = f2
View = f3
ViewFile =
# ViewFile =
Edit = f4
EditForceInternal =
# EditForceInternal =
Copy = f5
Move = f6
MakeDir = f7
@ -21,9 +21,9 @@ DirSize = ctrl-space
Suspend = ctrl-z
Swap = ctrl-u
History = alt-h
PanelListing =
# PanelListing =
PanelListingSwitch = alt-t
PanelListingChange =
# PanelListingChange =
ShowHidden = alt-dot
SplitVertHoriz = alt-comma
SplitEqual = alt-equal
@ -37,21 +37,20 @@ Select = kpplus
Unselect = kpminus
SelectInvert = kpasterisk
ScreenList = alt-prime
Options =
OptionsLayout =
OptionsPanel =
OptionsConfirm =
OptionsDisplayBits =
OptionsVfs =
LearnKeys =
SaveSetup =
EditExtensionsFile =
EditFileHighlightFile =
Filter =
ConnectFish =
ConnectFtp =
ConnectSmb =
Undelete =
# OptionsLayout =
# OptionsPanel =
# OptionsConfirm =
# OptionsDisplayBits =
# OptionsVfs =
# LearnKeys =
# SaveSetup =
# EditExtensionsFile =
# EditFileHighlightFile =
# Filter =
# ConnectFish =
# ConnectFtp =
# ConnectSmb =
# Undelete =
ExtendedKeyMap = ctrl-x
[main:xmap]
@ -81,8 +80,8 @@ Search = ctrl-s; alt-s
Mark = insert; ctrl-t
MarkUp = shift-up
MarkDown = shift-down
MarkLeft =
MarkRight =
# MarkLeft =
# MarkRight =
Down = down; ctrl-n
Up = up; ctrl-p
Left = left
@ -102,8 +101,8 @@ Unselect = alt-minus
SelectInvert = alt-asterisk
CdChild = ctrl-pgdn
CdParent = ctrl-pgup
Panelize =
CdParentSmart =
# CdParentSmart =
# Panelize =
History = alt-shift-h
HistoryNext = alt-u
HistoryPrev = alt-y
@ -114,16 +113,16 @@ PanelOtherSync = alt-i
SelectCodepage = alt-e
Top = alt-lt; home; a1
Bottom = alt-gt; end; c1
Sort =
SortPrev =
SortNext =
SortReverse =
SortByName =
SortByExt =
SortBySize =
SortByMTime =
ScrollLeft =
ScrollRight =
# Sort =
# SortPrev =
# SortNext =
# SortReverse =
# SortByName =
# SortByExt =
# SortBySize =
# SortByMTime =
# ScrollLeft =
# ScrollRight =
[dialog]
Ok = enter
@ -150,24 +149,24 @@ Backspace = backspace
Delete = delete
DeleteToWordBegin = alt-backspace
DeleteToWordEnd = alt-d
Mark =
# Mark =
Remove = ctrl-w
Cut =
# Cut =
Store = alt-w
Paste =
# Paste =
Yank = ctrl-y
DeleteToEnd = ctrl-k
HistoryPrev = alt-p; ctrl-down
HistoryNext = alt-n; ctrl-up
History = alt-h
Complete = alt-tab
Clear =
MarkLeft =
MarkRight =
MarkToWordBegin =
MarkToWordEnd =
MarkToHome =
MarkToEnd =
# Clear =
# MarkLeft =
# MarkRight =
# MarkToWordBegin =
# MarkToWordEnd =
# MarkToHome =
# MarkToEnd =
[listbox]
Up = up; ctrl-p
@ -237,7 +236,7 @@ Home = home; ctrl-a
End = end; ctrl-e
Tab = tab
Undo = ctrl-u
Redo =
# Redo =
Top = ctrl-home; alt-lt
Bottom = ctrl-end; alt-gt
ScrollUp = ctrl-up
@ -248,25 +247,25 @@ DeleteToWordBegin = alt-backspace
DeleteToWordEnd = alt-d
DeleteLine = ctrl-y
DeleteToEnd = ctrl-k
DeleteToHome =
ParagraphUp =
ParagraphDown =
# DeleteToHome =
# ParagraphUp =
# ParagraphDown =
Save = f2
EditFile =
# EditFile =
SaveAs = f12; ctrl-f2
Close =
# Close =
Mark = f3; ctrl-at
Copy = f5
Move = f6
Remove = f8
MarkLine =
MarkWord =
MarkAll =
Unmark =
# MarkLine =
# MarkWord =
# MarkAll =
# Unmark =
Search = f7; ctrl-s
SearchContinue = f17
BlockShiftLeft =
BlockShiftRight =
# BlockShiftLeft =
# BlockShiftRight =
MarkPageUp = shift-pgup
MarkPageDown = shift-pgdn
MarkLeft = shift-left
@ -283,19 +282,19 @@ MarkToPageBegin = ctrl-shift-pgup
MarkToPageEnd = ctrl-shift-pgdn
MarkScrollUp = ctrl-shift-up
MarkScrollDown = ctrl-shift-down
MarkParagraphUp =
MarkParagraphDown =
# MarkParagraphUp =
# MarkParagraphDown =
MarkColumnPageUp = alt-pgup
MarkColumnPageDown = alt-pgdn
MarkColumnLeft = alt-left
MarkColumnRight = alt-right
MarkColumnUp = alt-up
MarkColumnDown = alt-down
MarkColumnScrollUp =
MarkColumnScrollDown =
MarkColumnParagraphUp =
MarkColumnParagraphDown =
BlockSave =
# MarkColumnScrollUp =
# MarkColumnScrollDown =
# MarkColumnParagraphUp =
# MarkColumnParagraphDown =
# BlockSave =
MarkColumn = f13
Replace = f4
ReplaceContinue = f14
@ -304,49 +303,49 @@ InsertFile = f15
Quit = f10; esc
InsertOverwrite = insert
Help = f1
Date =
# Date =
Refresh = ctrl-l
Goto = alt-l
Sort = alt-t
Mail =
# Mail =
ParagraphFormat = alt-p
MatchBracket =
# MatchBracket =
ExternalCommand = alt-u
UserMenu = f11
Menu = f9
Bookmark =
BookmarkFlush =
BookmarkNext =
BookmarkPrev =
History =
# Bookmark =
# BookmarkFlush =
# BookmarkNext =
# BookmarkPrev =
# History =
Shell = ctrl-o
InsertLiteral = ctrl-q
MacroStartRecord =
MacroStopRecord =
# MacroStartRecord =
# MacroStopRecord =
MacroStartStopRecord = ctrl-r
MacroDelete =
# MacroDelete =
ShowNumbers = alt-n
ShowTabTws = alt-underline
SyntaxOnOff = ctrl-s
SyntaxChoose =
ShowMargin =
# SyntaxChoose =
# ShowMargin =
Find = alt-enter
FilePrev = alt-minus
FileNext = alt-plus
RepeatStartStopRecord =
# RepeatStartStopRecord =
SelectCodepage = alt-e
Options =
OptionsSaveMode =
SpellCheck =
SpellCheckCurrentWord =
SpellCheckSelectLang =
LearnKeys =
WindowMove =
WindowResize =
WindowFullscreen =
WindowList =
WindowNext =
WindowPrev =
# Options =
# OptionsSaveMode =
# SpellCheck =
# SpellCheckCurrentWord =
# SpellCheckSelectLang =
# LearnKeys =
# WindowMove =
# WindowResize =
# WindowFullscreen =
# WindowList =
# WindowNext =
# WindowPrev =
ExtendedKeyMap = ctrl-x
[editor:xmap]

View File

@ -1416,7 +1416,7 @@ edit_delete_macro (WEdit * edit, int hotkey)
}
macros_fname = mc_config_get_full_path (MC_MACRO_FILE);
macros_config = mc_config_init (macros_fname);
macros_config = mc_config_init (macros_fname, FALSE);
g_free (macros_fname);
if (macros_config == NULL)
@ -1835,7 +1835,7 @@ edit_store_macro_cmd (WEdit * edit)
edit_delete_macro (edit, hotkey);
macros_fname = mc_config_get_full_path (MC_MACRO_FILE);
macros_config = mc_config_init (macros_fname);
macros_config = mc_config_init (macros_fname, FALSE);
g_free (macros_fname);
if (macros_config == NULL)
@ -1939,7 +1939,7 @@ edit_load_macro_cmd (WEdit * edit)
(void) edit;
macros_fname = mc_config_get_full_path (MC_MACRO_FILE);
macros_config = mc_config_init (macros_fname);
macros_config = mc_config_init (macros_fname, TRUE);
g_free (macros_fname);
if (macros_config == NULL)

View File

@ -565,7 +565,7 @@ process_special_dirs (GList ** special_dirs, char *file)
mc_config_t *cfg;
gsize buffers_len;
cfg = mc_config_init (file);
cfg = mc_config_init (file, TRUE);
if (cfg == NULL)
return;

View File

@ -578,7 +578,7 @@ create_default_keymap (void)
{
mc_config_t *keymap;
keymap = mc_config_init (NULL);
keymap = mc_config_init (NULL, TRUE);
create_default_keymap_section (keymap, KEYMAP_SECTION_MAIN, default_main_keymap);
create_default_keymap_section (keymap, KEYMAP_SECTION_MAIN_EXT, default_main_x_keymap);

View File

@ -371,33 +371,36 @@ static const struct
/**
Get name of config file.
\param subdir
if not NULL, then config also search into specified subdir.
\param config_file_name
If specified filename is relative, then will search in standart patches.
\return
Newly allocated path to config name or NULL if file not found.
If config_file_name is a relative path, then search config in stantart paths.
@param subdir If not NULL, config is also searched in specified subdir.
@param config_file_name If relative, file if searched in standard paths.
@returns Newly allocated string with config name or NULL if file is not found.
*/
static char *
load_setup_get_full_config_name (const char *subdir, const char *config_file_name)
{
/*
TODO: IMHO, in future this function must be placed into mc_config module.
TODO: IMHO, in future, this function shall be placed in mcconfig module.
*/
char *lc_basename, *ret;
char *file_name;
if (config_file_name == NULL)
return NULL;
if (g_path_is_absolute (config_file_name))
return g_strdup (config_file_name);
/* check for .keymap suffix */
if (g_str_has_suffix (config_file_name, ".keymap"))
file_name = g_strdup (config_file_name);
else
file_name = g_strconcat (config_file_name, ".keymap", (char *) NULL);
canonicalize_pathname (file_name);
if (g_path_is_absolute (file_name))
return file_name;
lc_basename = g_path_get_basename (file_name);
g_free (file_name);
lc_basename = g_path_get_basename (config_file_name);
if (lc_basename == NULL)
return NULL;
@ -409,6 +412,7 @@ load_setup_get_full_config_name (const char *subdir, const char *config_file_nam
if (exist_file (ret))
{
g_free (lc_basename);
canonicalize_pathname (ret);
return ret;
}
g_free (ret);
@ -421,6 +425,7 @@ load_setup_get_full_config_name (const char *subdir, const char *config_file_nam
if (exist_file (ret))
{
g_free (lc_basename);
canonicalize_pathname (ret);
return ret;
}
g_free (ret);
@ -433,11 +438,13 @@ load_setup_get_full_config_name (const char *subdir, const char *config_file_nam
g_free (lc_basename);
if (exist_file (ret))
{
canonicalize_pathname (ret);
return ret;
}
g_free (ret);
return NULL;
}
/* --------------------------------------------------------------------------------------------- */
@ -464,7 +471,7 @@ setup__move_panels_config_into_separate_file (const char *profile)
if (!exist_file (profile))
return;
tmp_cfg = mc_config_init (profile);
tmp_cfg = mc_config_init (profile, FALSE);
if (!tmp_cfg)
return;
@ -485,7 +492,7 @@ setup__move_panels_config_into_separate_file (const char *profile)
mc_config_save_to_file (tmp_cfg, panels_profile_name, NULL);
mc_config_deinit (tmp_cfg);
tmp_cfg = mc_config_init (profile);
tmp_cfg = mc_config_init (profile, FALSE);
if (!tmp_cfg)
{
g_strfreev (groups);
@ -516,17 +523,17 @@ setup__move_panels_config_into_separate_file (const char *profile)
*/
static void
load_setup_init_config_from_file (mc_config_t ** config, const char *fname)
load_setup_init_config_from_file (mc_config_t ** config, const char *fname, gboolean read_only)
{
/*
TODO: IMHO, in future this function must be placed into mc_config module.
TODO: IMHO, in future, this function shall be placed in mcconfig module.
*/
if (exist_file (fname))
{
if (*config != NULL)
mc_config_read_file (*config, fname, TRUE);
mc_config_read_file (*config, fname, read_only, TRUE);
else
*config = mc_config_init (fname);
*config = mc_config_init (fname, read_only);
}
}
@ -676,9 +683,10 @@ static mc_config_t *
load_setup_get_keymap_profile_config (gboolean load_from_file)
{
/*
TODO: IMHO, in future this function must be placed into mc_config module.
TODO: IMHO, in future, this function shall be placed in mcconfig module.
*/
mc_config_t *keymap_config;
char *share_keymap, *sysconfig_keymap;
char *fname, *fname2;
/* 0) Create default keymap */
@ -686,47 +694,56 @@ load_setup_get_keymap_profile_config (gboolean load_from_file)
if (!load_from_file)
return keymap_config;
/* load and merge global keymaps */
/* 1) /usr/share/mc (mc_global.share_data_dir) */
fname = g_build_filename (mc_global.share_data_dir, GLOBAL_KEYMAP_FILE, NULL);
load_setup_init_config_from_file (&keymap_config, fname);
g_free (fname);
share_keymap = g_build_filename (mc_global.share_data_dir, GLOBAL_KEYMAP_FILE, NULL);
load_setup_init_config_from_file (&keymap_config, share_keymap, TRUE);
/* 2) /etc/mc (mc_global.sysconfig_dir) */
fname = g_build_filename (mc_global.sysconfig_dir, GLOBAL_KEYMAP_FILE, NULL);
load_setup_init_config_from_file (&keymap_config, fname);
g_free (fname);
sysconfig_keymap = g_build_filename (mc_global.sysconfig_dir, GLOBAL_KEYMAP_FILE, NULL);
load_setup_init_config_from_file (&keymap_config, sysconfig_keymap, TRUE);
/* 3) ${XDG_CONFIG_HOME}/mc */
fname = mc_config_get_full_path (GLOBAL_KEYMAP_FILE);
load_setup_init_config_from_file (&keymap_config, fname);
g_free (fname);
/* then load and merge one of user-defined keymap */
/* 4) main config; [Midnight Commander] -> keymap */
fname2 =
mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, "keymap", GLOBAL_KEYMAP_FILE);
fname = load_setup_get_full_config_name (NULL, fname2);
if (fname != NULL)
{
load_setup_init_config_from_file (&keymap_config, fname);
g_free (fname);
}
g_free (fname2);
/* 5) getenv("MC_KEYMAP") */
fname = load_setup_get_full_config_name (NULL, g_getenv ("MC_KEYMAP"));
if (fname != NULL)
{
load_setup_init_config_from_file (&keymap_config, fname);
g_free (fname);
}
/* 6) --keymap=<keymap> */
/* 3) --keymap=<keymap> */
fname = load_setup_get_full_config_name (NULL, mc_args__keymap_file);
if (fname != NULL)
if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0)
{
load_setup_init_config_from_file (&keymap_config, fname);
g_free (fname);
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
goto done;
}
g_free (fname);
/* 4) getenv("MC_KEYMAP") */
fname = load_setup_get_full_config_name (NULL, g_getenv ("MC_KEYMAP"));
if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0)
{
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
goto done;
}
g_free (fname);
/* 5) main config; [Midnight Commander] -> keymap */
fname2 = mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, "keymap", NULL);
if (fname2 != NULL && *fname2 != '\0')
fname = load_setup_get_full_config_name (NULL, fname2);
g_free (fname2);
if (fname != NULL && strcmp (fname, sysconfig_keymap) != 0 && strcmp (fname, share_keymap) != 0)
{
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
goto done;
}
g_free (fname);
/* 6) ${XDG_CONFIG_HOME}/mc/mc.keymap */
fname = mc_config_get_full_path (GLOBAL_KEYMAP_FILE);
load_setup_init_config_from_file (&keymap_config, fname, TRUE);
done:
g_free (fname);
g_free (sysconfig_keymap);
g_free (share_keymap);
return keymap_config;
}
@ -880,12 +897,12 @@ load_setup (void)
panels_profile_name = mc_config_get_full_path (MC_PANELS_FILE);
mc_main_config = mc_config_init (profile);
mc_main_config = mc_config_init (profile, FALSE);
if (!exist_file (panels_profile_name))
setup__move_panels_config_into_separate_file (profile);
mc_panels_config = mc_config_init (panels_profile_name);
mc_panels_config = mc_config_init (panels_profile_name, FALSE);
/* Load integer boolean options */
for (i = 0; int_options[i].opt_name != NULL; i++)
@ -1144,7 +1161,7 @@ load_key_defs (void)
*/
mc_config_t *mc_global_config;
mc_global_config = mc_config_init (global_profile_name);
mc_global_config = mc_config_init (global_profile_name, FALSE);
if (mc_global_config != NULL)
{
load_keys_from_section ("general", mc_global_config);

View File

@ -69,7 +69,7 @@ START_TEST (create_ini_file)
ini_filename = g_build_filename(WORKDIR, "test-create_ini_file.ini",NULL);
unlink(ini_filename);
mc_config = mc_config_init (ini_filename);
mc_config = mc_config_init (ini_filename, FALSE);
if (mc_config == NULL)
{
fail("unable to create mc_congif_t object!");
@ -91,7 +91,7 @@ START_TEST (create_ini_file)
}
mc_config_deinit (mc_config);
mc_config = mc_config_init (ini_filename);
mc_config = mc_config_init (ini_filename, FALSE);
actual_value = mc_config_get_string(mc_config, "group-not-exists", "param-not_exists", NULL);
fail_unless(actual_value == NULL, "return value for nonexistent ini-parameters isn't NULL (default value)!");
@ -139,7 +139,7 @@ START_TEST (emulate__learn_save)
ini_filename = g_build_filename(WORKDIR, "test-emulate__learn_save.ini",NULL);
unlink(ini_filename);
mc_config = mc_config_init (ini_filename);
mc_config = mc_config_init (ini_filename, FALSE);
if (mc_config == NULL)
{
fail("unable to create mc_congif_t object!");
@ -157,7 +157,7 @@ START_TEST (emulate__learn_save)
}
mc_config_deinit (mc_config);
mc_config = mc_config_init (ini_filename);
mc_config = mc_config_init (ini_filename, FALSE);
actual_value = mc_config_get_string_raw( mc_config, "test-group1", "test-param1", "not-exists");
fail_unless_strcmp("T\\;E\\X\\;T-FOR-\\T\\;E\\;S\\TI\\;N'G");

View File

@ -117,7 +117,7 @@ START_TEST (test_serialize_config)
GError *error = NULL;
char *actual;
test_data = mc_config_init (NULL);
test_data = mc_config_init (NULL, FALSE);
mc_config_set_string_raw (test_data, "group1", "param1", "some value");
mc_config_set_string (test_data, "group1", "param2", "some value ");