summaryrefslogtreecommitdiff
path: root/src/actions.h
blob: 3fcd3b7a68a839c6abe9fd83dabddc2603ee6593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/* Prototypes of all actions that can be performed with keystrokes.
 * Copyright (C) 2000, 2001, 2002, 2003, 2004 Shawn Betts <sabetts@vcn.bc.ca>
 *
 * This file is part of ratpoison.
 *
 * ratpoison is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * ratpoison is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307 USA
 */

#ifndef _RATPOISON_ACTIONS_H
#define _RATPOISON_ACTIONS_H 1

#define MAX_COMMAND_LENGTH 100
#define MAX_ARGS_LENGTH 100

#include <ratpoison.h>

typedef struct user_command user_command;

/* arg_REST and arg_SHELLCMD eat the rest of the input. */
enum argtype { arg_REST,
               arg_NUMBER,
               arg_STRING,
               arg_FRAME,
               arg_WINDOW,
               arg_COMMAND,
               arg_SHELLCMD,
               arg_KEYMAP,
               arg_KEY,
               arg_GRAVITY,
               arg_GROUP,
               arg_HOOK,
               arg_VARIABLE,
               arg_RAW};

union arg_union {
    rp_frame *frame;
    int number;
    float fnumber;
    rp_window *win;
    rp_keymap *keymap;
    rp_group *group;
    struct list_head *hook;
    struct set_var *variable;
    struct rp_key *key;
    int gravity;
  };

struct cmdarg
{
  int type;
  char *string;
  union arg_union arg;
  struct list_head node;
};

struct argspec
{
  int type;
  char *prompt;
};

/* The structure returned by a command. */
typedef struct cmdret cmdret;
struct cmdret
{
  char *output;
  int success;
};

struct
user_command
{
  char *name;
  cmdret * (*func)(int, struct cmdarg **);
  struct argspec *args;
  int num_args;
  /* The number of required arguments. Any arguments after that are
     optional and won't be filled in when called
     interactively. ni_required_args is used when called non-interactively,
     i_required_args when called interactively. */
  int ni_required_args, i_required_args;

  struct list_head node;
};

int spawn(char *data, int raw, rp_frame *frame);
cmdret *command (int interactive, char *data);

/* command function prototypes. */
#define RP_CMD(cmd) cmdret *cmd_ ## cmd (int interactive, struct cmdarg **args)
RP_CMD (abort);
RP_CMD (addhook);
RP_CMD (alias);
RP_CMD (banish);
RP_CMD (bind);
RP_CMD (compat);
RP_CMD (chdir);
RP_CMD (clrunmanaged);
RP_CMD (colon);
RP_CMD (curframe);
RP_CMD (delete);
RP_CMD (echo);
RP_CMD (escape);
RP_CMD (exec);
RP_CMD (execa);
RP_CMD (execf);
RP_CMD (fdump);
RP_CMD (focusdown);
RP_CMD (focuslast);
RP_CMD (focusleft);
RP_CMD (focusright);
RP_CMD (focusup);
RP_CMD (exchangeup);
RP_CMD (exchangedown);
RP_CMD (exchangeleft);
RP_CMD (exchangeright);
RP_CMD (swap);
RP_CMD (frestore);
RP_CMD (fselect);
RP_CMD (gdelete);
RP_CMD (getenv);
RP_CMD (gmerge);
RP_CMD (gmove);
RP_CMD (gnew);
RP_CMD (gnewbg);
RP_CMD (gnext);
RP_CMD (gprev);
RP_CMD (gother);
RP_CMD (gravity);
RP_CMD (grename);
RP_CMD (groups);
RP_CMD (gselect);
RP_CMD (h_split);
RP_CMD (help);
RP_CMD (info);
RP_CMD (kill);
RP_CMD (lastmsg);
RP_CMD (license);
RP_CMD (link);
RP_CMD (listhook);
RP_CMD (meta);
RP_CMD (msgwait);
RP_CMD (newwm);
RP_CMD (next);
RP_CMD (next_frame);
RP_CMD (nextscreen);
RP_CMD (number);
RP_CMD (only);
RP_CMD (other);
RP_CMD (prev);
RP_CMD (prev_frame);
RP_CMD (prevscreen);
RP_CMD (quit);
RP_CMD (redisplay);
RP_CMD (remhook);
RP_CMD (remove);
RP_CMD (rename);
RP_CMD (resize);
RP_CMD (restart);
RP_CMD (rudeness);
RP_CMD (select);
RP_CMD (setenv);
RP_CMD (shrink);
RP_CMD (source);
RP_CMD (startup_message);
RP_CMD (time);
RP_CMD (tmpwm);
RP_CMD (unalias);
RP_CMD (unbind);
RP_CMD (unimplemented);
RP_CMD (unmanage);
RP_CMD (unsetenv);
RP_CMD (v_split);
RP_CMD (verbexec);
RP_CMD (version);
RP_CMD (warp);
RP_CMD (windows);
RP_CMD (readkey);
RP_CMD (newkmap);
RP_CMD (delkmap);
RP_CMD (definekey);
RP_CMD (undefinekey);
RP_CMD (set);
RP_CMD (sselect);
RP_CMD (ratwarp);
RP_CMD (ratclick);
RP_CMD (ratrelwarp);
RP_CMD (rathold);
RP_CMD (cnext);
RP_CMD (cother);
RP_CMD (cprev);
RP_CMD (dedicate);
RP_CMD (describekey);
RP_CMD (inext);
RP_CMD (iother);
RP_CMD (iprev);
RP_CMD (prompt);
RP_CMD (sdump);
RP_CMD (sfdump);
RP_CMD (sfrestore);
RP_CMD (undo);
RP_CMD (redo);
RP_CMD (putsel);
RP_CMD (getsel);

void del_frame_undo (rp_frame_undo *u);

rp_keymap *find_keymap (char *name);
void init_user_commands(void);
void initialize_default_keybindings (void);
cmdret *cmdret_new (int success, char *fmt, ...);
void cmdret_free (cmdret *ret);
void keymap_free (rp_keymap *map);
void free_user_commands (void);
void free_aliases (void);
void free_keymaps (void);
char *wingravity_to_string (int g);
rp_action* find_keybinding (KeySym keysym, unsigned int state, rp_keymap *map);
rp_action* find_keybinding_by_action (char *action, rp_keymap *map);


#endif /* ! _RATPOISON_ACTIONS_H */