mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Merge branch '4413_user_syntax'
* 4413_user_syntax: Ticket #4413: mcedit: syntax definitions in user location don't work.
This commit is contained in:
commit
2df6771645
@ -237,12 +237,12 @@ where equal is symbol "=" goes to next function in navigation list
|
|||||||
supports syntax highlighting. This means that keywords and contexts
|
supports syntax highlighting. This means that keywords and contexts
|
||||||
(like C comments, string constants, etc) are highlighted in different
|
(like C comments, string constants, etc) are highlighted in different
|
||||||
colors. The following section explains the format of the file
|
colors. The following section explains the format of the file
|
||||||
.BR ~/.config/mc/mcedit/Syntax .
|
.BR ~/.local/share/mc/syntax/Syntax .
|
||||||
If this file is missing, system\-wide
|
If this file is missing, system\-wide
|
||||||
.B %pkgdatadir%/syntax/Syntax
|
.B %pkgdatadir%/syntax/Syntax
|
||||||
is used.
|
is used.
|
||||||
The file
|
The file
|
||||||
.B ~/.config/mc/mcedit/Syntax
|
.B ~/.local/share/mc/syntax/Syntax
|
||||||
is rescanned on opening of every new editor file. The file contains
|
is rescanned on opening of every new editor file. The file contains
|
||||||
rules for highlighting, each of which is given on a separate line, and
|
rules for highlighting, each of which is given on a separate line, and
|
||||||
define which keywords will be highlighted with what color.
|
define which keywords will be highlighted with what color.
|
||||||
@ -631,7 +631,9 @@ affect all users, whether they have ~/.config/mc/ini or not.
|
|||||||
.I %pkgdatadir%/syntax/*
|
.I %pkgdatadir%/syntax/*
|
||||||
.IP
|
.IP
|
||||||
The default system\-wide syntax files for mcedit, used only if
|
The default system\-wide syntax files for mcedit, used only if
|
||||||
the corresponding user's own ~/.local/share/mc/mcedit/ file is missing.
|
the corresponding user's own file in
|
||||||
|
.B ~/.local/share/mc/syntax/
|
||||||
|
is missing.
|
||||||
.PP
|
.PP
|
||||||
.I ~/.config/mc/ini
|
.I ~/.config/mc/ini
|
||||||
.IP
|
.IP
|
||||||
|
@ -72,10 +72,11 @@
|
|||||||
|
|
||||||
/* file names */
|
/* file names */
|
||||||
#define EDIT_HOME_MACRO_FILE EDIT_HOME_DIR PATH_SEP_STR "macros.d" PATH_SEP_STR "macro"
|
#define EDIT_HOME_MACRO_FILE EDIT_HOME_DIR PATH_SEP_STR "macros.d" PATH_SEP_STR "macro"
|
||||||
#define EDIT_HOME_SYNTAX_FILE EDIT_HOME_DIR PATH_SEP_STR "Syntax"
|
|
||||||
#define EDIT_HOME_CLIP_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.clip"
|
#define EDIT_HOME_CLIP_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.clip"
|
||||||
#define EDIT_HOME_BLOCK_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.block"
|
#define EDIT_HOME_BLOCK_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.block"
|
||||||
#define EDIT_HOME_TEMP_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.temp"
|
#define EDIT_HOME_TEMP_FILE EDIT_HOME_DIR PATH_SEP_STR "mcedit.temp"
|
||||||
|
#define EDIT_SYNTAX_DIR "syntax"
|
||||||
|
#define EDIT_SYNTAX_FILE EDIT_SYNTAX_DIR PATH_SEP_STR "Syntax"
|
||||||
|
|
||||||
#define EDIT_GLOBAL_MENU "mcedit.menu"
|
#define EDIT_GLOBAL_MENU "mcedit.menu"
|
||||||
#define EDIT_LOCAL_MENU ".cedit.menu"
|
#define EDIT_LOCAL_MENU ".cedit.menu"
|
||||||
|
@ -64,7 +64,6 @@ static const struct
|
|||||||
{ &mc_config_str, MC_HOTLIST_FILE },
|
{ &mc_config_str, MC_HOTLIST_FILE },
|
||||||
{ &mc_config_str, GLOBAL_KEYMAP_FILE },
|
{ &mc_config_str, GLOBAL_KEYMAP_FILE },
|
||||||
{ &mc_config_str, MC_USERMENU_FILE },
|
{ &mc_config_str, MC_USERMENU_FILE },
|
||||||
{ &mc_config_str, EDIT_HOME_SYNTAX_FILE },
|
|
||||||
{ &mc_config_str, EDIT_HOME_MENU },
|
{ &mc_config_str, EDIT_HOME_MENU },
|
||||||
{ &mc_config_str, MC_PANELS_FILE },
|
{ &mc_config_str, MC_PANELS_FILE },
|
||||||
|
|
||||||
@ -82,6 +81,7 @@ static const struct
|
|||||||
{ &mc_data_str, MC_EXTFS_DIR },
|
{ &mc_data_str, MC_EXTFS_DIR },
|
||||||
{ &mc_data_str, MC_HISTORY_FILE },
|
{ &mc_data_str, MC_HISTORY_FILE },
|
||||||
{ &mc_data_str, MC_FILEPOS_FILE },
|
{ &mc_data_str, MC_FILEPOS_FILE },
|
||||||
|
{ &mc_data_str, EDIT_SYNTAX_FILE },
|
||||||
{ &mc_data_str, EDIT_HOME_CLIP_FILE },
|
{ &mc_data_str, EDIT_HOME_CLIP_FILE },
|
||||||
{ &mc_data_str, MC_MACRO_FILE },
|
{ &mc_data_str, MC_MACRO_FILE },
|
||||||
|
|
||||||
|
@ -1128,19 +1128,19 @@ edit_load_syntax_file (WDialog * h)
|
|||||||
_("&User"), _("&System wide"));
|
_("&User"), _("&System wide"));
|
||||||
|
|
||||||
extdir_vpath =
|
extdir_vpath =
|
||||||
vfs_path_build_filename (mc_global.sysconfig_dir, "syntax", "Syntax", (char *) NULL);
|
vfs_path_build_filename (mc_global.sysconfig_dir, EDIT_SYNTAX_FILE, (char *) NULL);
|
||||||
if (!exist_file (vfs_path_get_last_path_str (extdir_vpath)))
|
if (!exist_file (vfs_path_get_last_path_str (extdir_vpath)))
|
||||||
{
|
{
|
||||||
vfs_path_free (extdir_vpath, TRUE);
|
vfs_path_free (extdir_vpath, TRUE);
|
||||||
extdir_vpath =
|
extdir_vpath =
|
||||||
vfs_path_build_filename (mc_global.share_data_dir, "syntax", "Syntax", (char *) NULL);
|
vfs_path_build_filename (mc_global.share_data_dir, EDIT_SYNTAX_FILE, (char *) NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dir == 0)
|
if (dir == 0)
|
||||||
{
|
{
|
||||||
vfs_path_t *user_syntax_file_vpath;
|
vfs_path_t *user_syntax_file_vpath;
|
||||||
|
|
||||||
user_syntax_file_vpath = mc_config_get_full_vpath (EDIT_HOME_SYNTAX_FILE);
|
user_syntax_file_vpath = mc_config_get_full_vpath (EDIT_SYNTAX_FILE);
|
||||||
check_for_default (extdir_vpath, user_syntax_file_vpath);
|
check_for_default (extdir_vpath, user_syntax_file_vpath);
|
||||||
ret = edit_load_file_from_filename (h, user_syntax_file_vpath, 0);
|
ret = edit_load_file_from_filename (h, user_syntax_file_vpath, 0);
|
||||||
vfs_path_free (user_syntax_file_vpath, TRUE);
|
vfs_path_free (user_syntax_file_vpath, TRUE);
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
#include "lib/global.h"
|
#include "lib/global.h"
|
||||||
#include "lib/search.h" /* search engine */
|
#include "lib/search.h" /* search engine */
|
||||||
#include "lib/skin.h"
|
#include "lib/skin.h"
|
||||||
#include "lib/fileloc.h" /* EDIT_HOME_DIR, EDIT_HOME_SYNTAX_FILE */
|
#include "lib/fileloc.h" /* EDIT_SYNTAX_DIR, EDIT_SYNTAX_FILE */
|
||||||
#include "lib/strutil.h" /* utf string functions */
|
#include "lib/strutil.h" /* utf string functions */
|
||||||
#include "lib/util.h"
|
#include "lib/util.h"
|
||||||
#include "lib/widget.h" /* Listbox, message() */
|
#include "lib/widget.h" /* Listbox, message() */
|
||||||
@ -887,20 +887,14 @@ open_include_file (const char *filename)
|
|||||||
|
|
||||||
g_free (error_file_name);
|
g_free (error_file_name);
|
||||||
error_file_name =
|
error_file_name =
|
||||||
g_build_filename (mc_config_get_data_path (), EDIT_HOME_DIR, filename, (char *) NULL);
|
g_build_filename (mc_config_get_data_path (), EDIT_SYNTAX_DIR, filename, (char *) NULL);
|
||||||
f = fopen (error_file_name, "r");
|
|
||||||
if (f != NULL)
|
|
||||||
return f;
|
|
||||||
|
|
||||||
g_free (error_file_name);
|
|
||||||
error_file_name = g_build_filename (mc_global.sysconfig_dir, "syntax", filename, (char *) NULL);
|
|
||||||
f = fopen (error_file_name, "r");
|
f = fopen (error_file_name, "r");
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
return f;
|
return f;
|
||||||
|
|
||||||
g_free (error_file_name);
|
g_free (error_file_name);
|
||||||
error_file_name =
|
error_file_name =
|
||||||
g_build_filename (mc_global.share_data_dir, "syntax", filename, (char *) NULL);
|
g_build_filename (mc_global.share_data_dir, EDIT_SYNTAX_DIR, filename, (char *) NULL);
|
||||||
|
|
||||||
return fopen (error_file_name, "r");
|
return fopen (error_file_name, "r");
|
||||||
}
|
}
|
||||||
@ -1270,7 +1264,7 @@ edit_read_syntax_file (WEdit * edit, GPtrArray * pnames, const char *syntax_file
|
|||||||
f = fopen (syntax_file, "r");
|
f = fopen (syntax_file, "r");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
{
|
{
|
||||||
lib_file = g_build_filename (mc_global.share_data_dir, "syntax", "Syntax", (char *) NULL);
|
lib_file = g_build_filename (mc_global.share_data_dir, EDIT_SYNTAX_FILE, (char *) NULL);
|
||||||
f = fopen (lib_file, "r");
|
f = fopen (lib_file, "r");
|
||||||
g_free (lib_file);
|
g_free (lib_file);
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
@ -1521,7 +1515,7 @@ edit_load_syntax (WEdit * edit, GPtrArray * pnames, const char *type)
|
|||||||
if (edit != NULL && edit->filename_vpath == NULL)
|
if (edit != NULL && edit->filename_vpath == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
f = mc_config_get_full_path (EDIT_HOME_SYNTAX_FILE);
|
f = mc_config_get_full_path (EDIT_SYNTAX_FILE);
|
||||||
if (edit != NULL)
|
if (edit != NULL)
|
||||||
r = edit_read_syntax_file (edit, pnames, f, vfs_path_as_str (edit->filename_vpath),
|
r = edit_read_syntax_file (edit, pnames, f, vfs_path_as_str (edit->filename_vpath),
|
||||||
get_first_editor_line (edit),
|
get_first_editor_line (edit),
|
||||||
|
@ -97,8 +97,8 @@ static const struct test_user_config_paths_ds
|
|||||||
MC_USERMENU_FILE
|
MC_USERMENU_FILE
|
||||||
},
|
},
|
||||||
{ /* 5. */
|
{ /* 5. */
|
||||||
CONF_MAIN,
|
CONF_DATA,
|
||||||
EDIT_HOME_SYNTAX_FILE
|
EDIT_SYNTAX_FILE
|
||||||
},
|
},
|
||||||
{ /* 6. */
|
{ /* 6. */
|
||||||
CONF_MAIN,
|
CONF_MAIN,
|
||||||
|
Loading…
Reference in New Issue
Block a user