1 /* Copyright (C) 1999 Dominik Vogt
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "libs/fvwmlib.h"
26 #include "functions.h"
28 #include "libs/Parse.h"
31 /* If non-zero we are already repeating a function, so don't record the
33 static unsigned int repeat_depth
= 0;
40 } double_ended_string;
44 double_ended_string string;
45 double_ended_string old;
46 double_ended_string builtin;
47 double_ended_string function;
48 double_ended_string top_function;
49 double_ended_string module;
50 double_ended_string menu;
51 double_ended_string popup;
52 double_ended_string menu_or_popup;
56 FvwmWindow *fvwm_window;
64 } last
= { NULL
, NULL
};
67 char *repeat_last_function = NULL;
68 char *repeat_last_complex_function = NULL;
69 char *repeat_last_builtin_function = NULL;
70 char *repeat_last_module = NULL;
71 char *repeat_last_top_function = NULL;
72 char *repeat_last_menu = NULL;
73 FvwmWindow *repeat_last_fvwm_window = NULL;
76 /* Prcedure: set_repeat_data
78 * Stores the contents of the data pointer internally for the repeat command.
79 * The sype of data is determined by the 'type' parameter. If this function is
80 * called to set a string value representing a fvwm builtin function the
81 * 'func_typetion' can be set to the F_<func_type> value in the function table
82 * in functions.c. If this value is set certain functions are not recorded.
83 * The 'depth' parameter indicates the recursion depth of the current data
84 * pointer (i.e. the first function call has a depth of one, functions called
85 * from within this function have depth 2 and higher, this may be applicable
86 * to future enhancements like menus).
88 * TODO: [finish and update description]
90 Bool
set_repeat_data(void *data
, repeat_type type
, const func_type
*builtin
)
92 /* No history recording during startup. */
99 if (last
.command_line
== (char *)data
)
100 /* Already stored, no need to free the data pointer. */
102 if (data
== NULL
|| repeat_depth
!= 0)
103 /* Ignoring the data, must free it outside of this call. */
105 if (builtin
&& (builtin
->flags
& FUNC_DONT_REPEAT
))
106 /* Dont' record functions that have the FUNC_DONT_REPEAT flag set. */
108 if (last
.command_line
)
109 free(last
.command_line
);
110 /* Store a backup. */
111 last
.command_line
= (char *)data
;
112 /* Since we stored the pointer the caller must not free it. */
117 free(last
.menu_name
);
118 last
.menu_name
= (char *)data
;
119 /* Since we stored the pointer the caller must not free it. */
123 case REPEAT_DESK_AND_PAGE
:
125 case REPEAT_FVWM_WINDOW
:
133 void repeat_function(F_CMD_ARGS
)
142 /* Replay the backup, we don't want the repeat command recorded. */
143 GetNextTokenIndex(action
, optlist
, 0, &index
);
146 case 0: /* command */
149 fprintf( stderr
, "repeating 0x%lx, %s\n",
150 (unsigned long) last
.command_line
, last
.command_line
);
152 action
= last
.command_line
;
153 ExecuteFunction(F_PASS_EXEC_ARGS
, FUNC_DONT_EXPAND_COMMAND
, NULL
);