summaryrefslogtreecommitdiff
path: root/src/actions.c
diff options
context:
space:
mode:
authorrcyeske <rcyeske>2000-10-31 04:35:51 +0000
committerrcyeske <rcyeske>2000-10-31 04:35:51 +0000
commit4919815a954b76addb8527ea398475462d929770 (patch)
treeec3aa52a367cd8a3e32a839c283e2c1ca7adcd49 /src/actions.c
parent7894d7c0f48880154f0be554b1945dd64999a5a0 (diff)
downloadratpoison-4919815a954b76addb8527ea398475462d929770.zip
* actions.c (rename_current_window): added test to skip renaming if user entered an empty string
(execute_command): added command (key_actions): execute_command is called by pressing ':'
Diffstat (limited to 'src/actions.c')
-rw-r--r--src/actions.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/actions.c b/src/actions.c
index 6bdcfe3..e9e0867 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -11,6 +11,7 @@ rp_action key_actions[] = { {'c', -1, "xterm", spawn},
{'e', -1, "emacs", spawn},
{'p', -1, 0, prev_window},
{'n', -1, 0, next_window},
+ {';', ShiftMask, 0, execute_command},
{KEY_PREFIX, -1, 0, last_window},
{'w', -1, 0, toggle_bar},
{'k', ShiftMask, 0, kill_window},
@@ -91,18 +92,21 @@ rename_current_window (void *data)
get_input (rp_current_window->scr, "Name: ", winname, 100);
PRINT_DEBUG ("user entered: %s\n", winname);
- free (rp_current_window->name);
- rp_current_window->name = malloc (sizeof (char) * strlen (winname) + 1);
- if (rp_current_window->name == NULL)
+ if (*winname)
{
- PRINT_ERROR ("Out of memory\n");
- exit (EXIT_FAILURE);
- }
- strcpy (rp_current_window->name, winname);
- rp_current_window->named = 1;
+ free (rp_current_window->name);
+ rp_current_window->name = malloc (sizeof (char) * strlen (winname) + 1);
+ if (rp_current_window->name == NULL)
+ {
+ PRINT_ERROR ("Out of memory\n");
+ exit (EXIT_FAILURE);
+ }
+ strcpy (rp_current_window->name, winname);
+ rp_current_window->named = 1;
- /* Update the program bar. */
- update_window_names (rp_current_window->scr);
+ /* Update the program bar. */
+ update_window_names (rp_current_window->scr);
+ }
}
@@ -134,6 +138,17 @@ kill_window (void *data)
}
void
+execute_command (void *data)
+{
+ char cmd[100];
+
+ get_input (rp_current_window->scr, "Command: ", cmd, 100);
+ PRINT_DEBUG ("user entered: %s\n", cmd);
+
+ spawn (cmd);
+}
+
+void
spawn(void *data)
{
char *prog = data;