+
Skip to content

Rewrite function parser and remove the Repeat command #643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions doc/fvwm3_manpage_source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3655,15 +3655,6 @@ _infostore_ which prints information on all entries in the infostore,
listing the key and its value. _verbose_ has no effect with this
option.

*Repeat*::
When the *Repeat* command is invoked, the last command that was
executed by fvwm is executed again. This happens regardless of whether
it was triggered by user interaction, a module or by an X event.
Commands that are executed from a function defined with the *Function*
command, from the *Read* or *PipeRead* commands or by a menu are not
repeated. Instead, the function, menu or the *Read* or *PipeRead*
command is executed again.

*Schedule* [Periodic] _delay_ms_ [_command_id_] _command_::
The _command_ is executed after about _delay_ms_ milliseconds. This
may be useful in some tricky setups. The _command_ is executed in the
Expand Down
8 changes: 5 additions & 3 deletions fvwm/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ fvwm3_SOURCES = \
icccm2.h icons.h menubindings.h menudim.h menugeometry.h \
menuitem.h menuroot.h menuparameters.h menus.h menustyle.h misc.h \
modconf.h module_interface.h module_list.h move_resize.h \
placement.h read.h repeat.h execcontext.h schedule.h screen.h \
placement.h read.h execcontext.h schedule.h screen.h \
session.h stack.h style.h update.h virtual.h window_flags.h frame.h \
infostore.h \
cmdparser.h cmdparser_hooks.h cmdparser_old.h functable_complex.h \
\
menus.c style.c borders.c events.c move_resize.c builtins.c \
add_window.c icons.c fvwm3.c frame.c placement.c virtual.c \
Expand All @@ -27,8 +28,9 @@ fvwm3_SOURCES = \
windowlist.c functable.c menuitem.c expand.c module_interface.c \
menubindings.c decorations.c ewmh_icons.c update.c bindings.c misc.c \
cursor.c colormaps.c modconf.c ewmh_conf.c read.c schedule.c \
menucmd.c ewmh_names.c icccm2.c windowshade.c focus_policy.c repeat.c \
execcontext.c menugeometry.c menudim.c condrc.c infostore.c
menucmd.c ewmh_names.c icccm2.c windowshade.c focus_policy.c \
execcontext.c menugeometry.c menudim.c condrc.c infostore.c \
cmdparser_old.c functable_complex.c

fvwm3_DEPENDENCIES = $(top_builddir)/libs/libfvwm3.a

Expand Down
9 changes: 5 additions & 4 deletions fvwm/add_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -2495,7 +2495,7 @@ FvwmWindow *AddWindow(
char *cmd;

xasprintf(&cmd, "GotoDesk %s 0 %d", tm->si->name, fw->Desk);
execute_function_override_window(NULL, NULL, cmd, 0, fw);
execute_function_override_window(NULL, NULL, cmd, NULL, 0, fw);
free(cmd);

/* read the requested absolute geometry */
Expand Down Expand Up @@ -2695,7 +2695,8 @@ FvwmWindow *AddWindow(
SET_STICKY_ACROSS_PAGES(fw, 0);
SET_STICKY_ACROSS_DESKS(fw, 0);
handle_stick(
NULL, exc2, "", stick_page, stick_desk, 1, 0);
NULL, exc2, "", NULL, stick_page, stick_desk,
1, 0);
exc_destroy_context(exc2);
}
}
Expand Down Expand Up @@ -2727,7 +2728,7 @@ FvwmWindow *AddWindow(
ecc.w.wcontext = C_WINDOW;
exc2 = exc_clone_context(
exc, &ecc, ECC_ETRIGGER | ECC_FW | ECC_WCONTEXT);
CMD_Resize(NULL, exc2, "");
CMD_Resize(NULL, exc2, "", NULL);
exc_destroy_context(exc2);
}

Expand Down Expand Up @@ -2796,7 +2797,7 @@ FvwmWindow *AddWindow(
EWMH_STATE_HAS_HINT) ? 100 : 0;
sprintf(cmd,"Maximize on %i %i", h, v);
execute_function_override_window(
NULL, NULL, cmd, 0, fw);
NULL, NULL, cmd, NULL, 0, fw);
}
}
if (HAS_EWMH_INIT_FULLSCREEN_STATE(fw) == EWMH_STATE_HAS_HINT)
Expand Down
4 changes: 2 additions & 2 deletions fvwm/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ static void __remove_window_decors(F_CMD_ARGS, FvwmDecor *d)
exc2 = exc_clone_context(
exc, &ecc, ECC_FW | ECC_WCONTEXT);
execute_function(
cond_rc, exc2, "ChangeDecor Default", 0);
cond_rc, exc2, "ChangeDecor Default", pc, 0);
exc_destroy_context(exc2);
}
}
Expand Down Expand Up @@ -2166,7 +2166,7 @@ void AddToDecor(F_CMD_ARGS, FvwmDecor *decor)
return;
}
Scr.cur_decor = decor;
execute_function(cond_rc, exc, action, 0);
execute_function(F_PASS_ARGS, 0);
Scr.cur_decor = NULL;

return;
Expand Down
65 changes: 65 additions & 0 deletions fvwm/cmdparser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* -*-c-*- */

#ifndef FVWM_CMDPARSER_H
#define FVWM_CMDPARSER_H

/* ---------------------------- included header files ---------------------- */

/* ---------------------------- global definitions ------------------------- */

/* $0 through to $9 */
#define CMDPARSER_NUM_POS_ARGS 10

/* ---------------------------- global macros ------------------------------ */

/* ---------------------------- type definitions --------------------------- */

/* Enum for all the possible prefixes. */
typedef enum
{
CP_PREFIX_NONE = 0,
CP_PREFIX_MINUS = 0x1,
CP_PREFIX_SILENT = 0x2,
CP_PREFIX_KEEPRC = 0x4
} cmdparser_prefix_flags_t;

/* Enum for types of things to execute. */
typedef enum
{
CP_EXECTYPE_UNKNOWN = 0,
CP_EXECTYPE_BUILTIN_FUNCTION,
CP_EXECTYPE_COMPLEX_FUNCTION,
CP_EXECTYPE_COMPLEX_FUNCTION_DOES_NOT_EXIST,
CP_EXECTYPE_MODULECONFIG
} cmdparser_execute_type_t;

/* move this to the implementation file and use void* instead??? */

typedef struct
{
/* !!!note: need to define which bits in here may be accessed by the
* user and which are internal */
unsigned char is_created : 1;
/* the original command line */
char *line;
/* the current command line */
char *cline;
/* the expanded command line */
char *expline;
unsigned char do_free_expline : 1;
/* the command name */
char *command;
/* name of the complex function if present */
char *complex_function_name;
/* current function nesting depth */
int call_depth;
/* A string with all positional arguments of a complex function. May
* be NULL if not in the context of a complex function. */
char *all_pos_args_string;
/* An array of the first CMDPARSER_NUM_POS_ARGS positional arguments up
* to and excluding the first NULL pointer. Must (not) all be NULL if
* all_pos_args_string is (not) NULL. */
char *pos_arg_tokens[CMDPARSER_NUM_POS_ARGS];
} cmdparser_context_t;

#endif /* FVWM_CMDPARSER_H */
74 changes: 74 additions & 0 deletions fvwm/cmdparser_hooks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* -*-c-*- */

#ifndef FVWM_CMDPARSER_HOOKS_H
#define FVWM_CMDPARSER_HOOKS_H

/* ---------------------------- included header files ---------------------- */

/* ---------------------------- global definitions ------------------------- */

/* ---------------------------- global macros ------------------------------ */

/* ---------------------------- type definitions --------------------------- */

typedef struct
{
/* in general, functions in this structure that return int return
* 0: success
* > 0: unsuccessful but not an error condition
* < 0: unsuccessful, error
*/
int (*create_context)(
/* context structure to initialise */
cmdparser_context_t *dest_context,
/* context structure of the caller or NULL */
cmdparser_context_t *caller_context,
/* input command line */
char *line,
/* A string with all positional arguments of a complex
* function. May be NULL if not in the context of a complex
* function. */
char *all_pos_args_string,
/* An array of the first CMDPARSER_NUM_POS_ARGS positional
* arguments up to and excluding the first NULL pointer. Must
* (not) all be NULL if all_pos_args_string is (not) NULL. */
char *pos_arg_tokens[]
);
int (*handle_line_start)(cmdparser_context_t *context);
/* Returns a set of or'ed flags of which prefixes are present on the
* command line. The prefixes are stripped. */
cmdparser_prefix_flags_t (*handle_line_prefix)(
cmdparser_context_t *context);
/* parses and returns the command name or returns a NULL pointer if not
* possible */
const char *(*parse_command_name)(
cmdparser_context_t *context, void *func_rc, const void *exc);
/* returns 1 if the stored command is a module configuration command
* and 0 otherwise */
int (*is_module_config)(cmdparser_context_t *context);
/* expands the command line */
void (*expand_command_line)(
cmdparser_context_t *context, int is_addto, void *func_rc,
const void *exc);
/* Release the expline field from the context structure and return it.
* It is then the responsibility of the caller to free() it. */
void (*release_expanded_line)(cmdparser_context_t *context);
/* Tries to find a builtin function, a complex function or a module
* config line to execute and returns the type found or
* CP_EXECTYPE_UNKNOWN if none of the above were identified. For a
* builtin or a complex function, the pointer to the description is
* returned in *ret_builtin or *ret_complex_function. Consumes the
* the "Module" or the "Function" command from the input. Does not
* consider builtin functions if *ret_builtin is != NULL when the
* function is called. */
cmdparser_execute_type_t (*find_something_to_execute)(
cmdparser_context_t *context,
const func_t **ret_builtin,
FvwmFunction **ret_complex_function);
/* Release the context initialised with create_context(). */
void (*destroy_context)(cmdparser_context_t *context);
/* Print the contents of the context. */
void (*debug)(cmdparser_context_t *context, const char *msg);
} cmdparser_hooks_t;

#endif /* FVWM_CMDPARSER_HOOKS_H */
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载