2 /* 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 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
;
70 char *repeat_last_function
= NULL
;
71 char *repeat_last_complex_function
= NULL
;
72 char *repeat_last_builtin_function
= NULL
;
73 char *repeat_last_module
= NULL
;
74 char *repeat_last_top_function
= NULL
;
75 char *repeat_last_menu
= NULL
;
76 FvwmWindow
*repeat_last_fvwm_window
= NULL
;
79 /* Stores the contents of the data pointer internally for the repeat command.
80 * The type of data is determined by the 'type' parameter. If this function is
81 * called to set a string value representing an fvwm builtin function the
82 * 'builtin' can be set to the F_... value in the function table in
83 * functions.c. If this value is set certain functions are not recorded.
84 * The 'depth' parameter indicates the recursion depth of the current data
85 * pointer (i.e. the first function call has a depth of one, functions called
86 * from within this function have depth 2 and higher, this may be applicable
87 * to future enhancements like menus).
89 * TODO: [finish and update description]
91 Bool
set_repeat_data(void *data
, repeat_t type
, const func_t
*builtin
)
93 /* No history recording during startup. */
102 if (last
.command_line
== (char *)data
)
104 /* Already stored, no need to free the data pointer. */
107 if (data
== NULL
|| repeat_depth
!= 0)
109 /* Ignoring the data, must free it outside of this
113 if (builtin
&& (builtin
->flags
& FUNC_DONT_REPEAT
))
115 /* Dont' record functions that have the
116 * FUNC_DONT_REPEAT flag set. */
119 if (last
.command_line
)
121 free(last
.command_line
);
123 /* Store a backup. */
124 last
.command_line
= (char *)data
;
125 /* Since we stored the pointer the caller must not free it. */
131 free(last
.menu_name
);
133 last
.menu_name
= (char *)data
;
134 /* Since we stored the pointer the caller must not free it. */
138 case REPEAT_DESK_AND_PAGE
:
140 case REPEAT_FVWM_WINDOW
:
148 void CMD_Repeat(F_CMD_ARGS
)
157 /* Replay the backup, we don't want the repeat command recorded. */
158 GetNextTokenIndex(action
, optlist
, 0, &index
);
161 case 0: /* command */
163 action
= last
.command_line
;
165 cond_rc
, exc
, action
, FUNC_DONT_EXPAND_COMMAND
);