usermenu: clarify compilation w/o internal editor.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2023-03-11 10:01:04 +03:00
parent de1edb72f8
commit 683122482b
3 changed files with 33 additions and 28 deletions

View File

@ -1785,7 +1785,7 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
edit_save_block (edit, block_file, start_mark, end_mark); edit_save_block (edit, block_file, start_mark, end_mark);
/* run shell scripts from menu */ /* run shell scripts from menu */
if (user_menu_cmd (edit, menu_file, selected_entry) if (user_menu_cmd (CONST_WIDGET (edit), menu_file, selected_entry)
&& (mc_stat (block_file_vpath, &status) == 0) && (status.st_size != 0)) && (mc_stat (block_file_vpath, &status) == 0) && (status.st_size != 0))
{ {
int rc = 0; int rc = 0;

View File

@ -44,9 +44,10 @@
#include "lib/vfs/vfs.h" #include "lib/vfs/vfs.h"
#include "lib/strutil.h" #include "lib/strutil.h"
#include "lib/util.h" #include "lib/util.h"
#include "lib/widget.h"
#include "src/editor/edit.h" /* WEdit, BLOCK_FILE */ #ifdef USE_INTERNAL_EDIT
#include "src/editor/edit.h" /* WEdit */
#endif
#include "src/viewer/mcviewer.h" /* for default_* externs */ #include "src/viewer/mcviewer.h" /* for default_* externs */
#include "src/args.h" /* mc_run_param0 */ #include "src/args.h" /* mc_run_param0 */
@ -219,10 +220,13 @@ test_type (WPanel * panel, char *arg)
p. Returns the point after condition. */ p. Returns the point after condition. */
static char * static char *
test_condition (const WEdit * edit_widget, char *p, gboolean * condition) test_condition (const Widget * edit_widget, char *p, gboolean * condition)
{ {
char arg[256]; char arg[256];
const mc_search_type_t search_type = easy_patterns ? MC_SEARCH_T_GLOB : MC_SEARCH_T_REGEX; const mc_search_type_t search_type = easy_patterns ? MC_SEARCH_T_GLOB : MC_SEARCH_T_REGEX;
#ifdef USE_INTERNAL_EDIT
const WEdit *e = (const WEdit *) edit_widget;
#endif
/* Handle one condition */ /* Handle one condition */
for (; *p != '\n' && *p != '&' && *p != '|'; p++) for (; *p != '\n' && *p != '&' && *p != '|'; p++)
@ -249,11 +253,11 @@ test_condition (const WEdit * edit_widget, char *p, gboolean * condition)
case 'f': /* file name pattern */ case 'f': /* file name pattern */
p = extract_arg (p, arg, sizeof (arg)); p = extract_arg (p, arg, sizeof (arg));
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
if (edit_widget != NULL) if (e != NULL)
{ {
const char *edit_filename; const char *edit_filename;
edit_filename = edit_get_file_name (edit_widget); edit_filename = edit_get_file_name (e);
*condition = mc_search (arg, DEFAULT_CHARSET, edit_filename, search_type); *condition = mc_search (arg, DEFAULT_CHARSET, edit_filename, search_type);
} }
else else
@ -264,11 +268,11 @@ test_condition (const WEdit * edit_widget, char *p, gboolean * condition)
break; break;
case 'y': /* syntax pattern */ case 'y': /* syntax pattern */
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
if (edit_widget != NULL) if (e != NULL)
{ {
const char *syntax_type; const char *syntax_type;
syntax_type = edit_get_syntax_type (edit_widget); syntax_type = edit_get_syntax_type (e);
if (syntax_type != NULL) if (syntax_type != NULL)
{ {
p = extract_arg (p, arg, sizeof (arg)); p = extract_arg (p, arg, sizeof (arg));
@ -360,7 +364,7 @@ debug_out (char *start, char *end, gboolean condition)
the point just before the end of line. */ the point just before the end of line. */
static char * static char *
test_line (const WEdit * edit_widget, char *p, gboolean * result) test_line (const Widget * edit_widget, char *p, gboolean * result)
{ {
char operator; char operator;
@ -426,7 +430,7 @@ test_line (const WEdit * edit_widget, char *p, gboolean * result)
/** FIXME: recode this routine on version 3.0, it could be cleaner */ /** FIXME: recode this routine on version 3.0, it could be cleaner */
static void static void
execute_menu_command (const WEdit * edit_widget, const char *commands, gboolean show_prompt) execute_menu_command (const Widget * edit_widget, const char *commands, gboolean show_prompt)
{ {
FILE *cmd_file; FILE *cmd_file;
int cmd_file_fd; int cmd_file_fd;
@ -742,7 +746,7 @@ check_format_var (const char *p, char **v)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
char * char *
expand_format (const WEdit * edit_widget, char c, gboolean do_quote) expand_format (const Widget * edit_widget, char c, gboolean do_quote)
{ {
WPanel *panel = NULL; WPanel *panel = NULL;
char *(*quote_func) (const char *, gboolean); char *(*quote_func) (const char *, gboolean);
@ -750,7 +754,9 @@ expand_format (const WEdit * edit_widget, char c, gboolean do_quote)
char *result; char *result;
char c_lc; char c_lc;
#ifndef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
const WEdit *e = (const WEdit *) edit_widget;
#else
(void) edit_widget; (void) edit_widget;
#endif #endif
@ -761,8 +767,8 @@ expand_format (const WEdit * edit_widget, char c, gboolean do_quote)
{ {
case MC_RUN_FULL: case MC_RUN_FULL:
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
if (edit_widget != NULL) if (e != NULL)
fname = edit_get_file_name (edit_widget); fname = edit_get_file_name (e);
else else
#endif #endif
{ {
@ -781,7 +787,7 @@ expand_format (const WEdit * edit_widget, char c, gboolean do_quote)
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
case MC_RUN_EDITOR: case MC_RUN_EDITOR:
fname = edit_get_file_name (edit_widget); fname = edit_get_file_name (e);
break; break;
#endif #endif
@ -828,29 +834,29 @@ expand_format (const WEdit * edit_widget, char c, gboolean do_quote)
} }
case 'c': case 'c':
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
if (edit_widget != NULL) if (e != NULL)
{ {
result = g_strdup_printf ("%u", (unsigned int) edit_get_cursor_offset (edit_widget)); result = g_strdup_printf ("%u", (unsigned int) edit_get_cursor_offset (e));
goto ret; goto ret;
} }
#endif #endif
break; break;
case 'i': /* indent equal number cursor position in line */ case 'i': /* indent equal number cursor position in line */
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
if (edit_widget != NULL) if (e != NULL)
{ {
result = g_strnfill (edit_get_curs_col (edit_widget), ' '); result = g_strnfill (edit_get_curs_col (e), ' ');
goto ret; goto ret;
} }
#endif #endif
break; break;
case 'y': /* syntax type */ case 'y': /* syntax type */
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
if (edit_widget != NULL) if (e != NULL)
{ {
const char *syntax_type; const char *syntax_type;
syntax_type = edit_get_syntax_type (edit_widget); syntax_type = edit_get_syntax_type (e);
if (syntax_type != NULL) if (syntax_type != NULL)
{ {
result = g_strdup (syntax_type); result = g_strdup (syntax_type);
@ -862,7 +868,7 @@ expand_format (const WEdit * edit_widget, char c, gboolean do_quote)
case 'k': /* block file name */ case 'k': /* block file name */
case 'b': /* block file name / strip extension */ case 'b': /* block file name / strip extension */
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
if (edit_widget != NULL) if (e != NULL)
{ {
char *file; char *file;
@ -880,7 +886,7 @@ expand_format (const WEdit * edit_widget, char c, gboolean do_quote)
break; break;
case 'n': /* strip extension in editor */ case 'n': /* strip extension in editor */
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
if (edit_widget != NULL) if (e != NULL)
{ {
result = strip_ext (quote_func (fname, FALSE)); result = strip_ext (quote_func (fname, FALSE));
goto ret; goto ret;
@ -950,7 +956,7 @@ expand_format (const WEdit * edit_widget, char c, gboolean do_quote)
*/ */
gboolean gboolean
user_menu_cmd (const WEdit * edit_widget, const char *menu_file, int selected_entry) user_menu_cmd (const Widget * edit_widget, const char *menu_file, int selected_entry)
{ {
char *p; char *p;
char *data, **entries; char *data, **entries;

View File

@ -6,8 +6,7 @@
#define MC__USERMENU_H #define MC__USERMENU_H
#include "lib/global.h" #include "lib/global.h"
#include "lib/widget.h"
#include "src/editor/edit.h" /* WEdit */
/*** typedefs(not structures) and defined constants **********************************************/ /*** typedefs(not structures) and defined constants **********************************************/
@ -19,8 +18,8 @@
/*** declarations of public functions ************************************************************/ /*** declarations of public functions ************************************************************/
gboolean user_menu_cmd (const WEdit * edit_widget, const char *menu_file, int selected_entry); gboolean user_menu_cmd (const Widget * edit_widget, const char *menu_file, int selected_entry);
char *expand_format (const WEdit * edit_widget, char c, gboolean do_quote); char *expand_format (const Widget * edit_widget, char c, gboolean do_quote);
int check_format_view (const char *p); int check_format_view (const char *p);
int check_format_var (const char *p, char **v); int check_format_var (const char *p, char **v);
int check_format_cd (const char *p); int check_format_cd (const char *p);