Permalink
Browse files

Added :set termprog and :terminal.

The TERM_PROG compile-time option no longer exists. You now change the terminal
setting with the new :set option.
  • Loading branch information...
1 parent c35bf7d commit 5268a5c58542b0fe532b864e676516cf965e8a4b @christiank committed Apr 13, 2011
Showing with 46 additions and 11 deletions.
  1. +5 −2 README.cfkbranch
  2. +0 −4 configure.in
  3. +38 −4 src/actions.c
  4. +1 −0 src/actions.h
  5. +1 −0 src/data.h
  6. +1 −0 src/main.c
  7. +0 −1 src/messages.h
View
@@ -16,6 +16,11 @@ The big differences:
of Ratpoison.
* You can change the format of the :time command, with :set timefmt.
+
+ * The default terminal for C-c is not a compile-time option, it is instead set
+ with :set termprog.
+
+ * To launch a terminal, run :terminal, not :exec [termprogram].
* The ``def'' commands (the setter functions for what are now :set options)
are totally gone.
@@ -43,8 +48,6 @@ The not so big differences:
Stuff I want to do:
- * Make TERM_PROG a :set option instead of a compile-time option.
-
* Document pretty much everything.
* Fix every single FIXME and do every TODO.
View
@@ -37,10 +37,6 @@ AC_ARG_ENABLE(debug,AC_HELP_STRING([--enable-debug],[build with extra debugging
AC_MSG_RESULT(no)
fi],[AC_MSG_RESULT(no)])
-AC_ARG_WITH(xterm,AC_HELP_STRING([--with-xterm=PROG],[set the x terminal emulator used by ratpoison]),
-term_prog=$withval, term_prog="xterm")
-AC_DEFINE_UNQUOTED(TERM_PROG, "$term_prog", X terminal emulator to use)
-
dnl We need Xft. Right now we look for it without letting anyone know.
dnl TODO: Add a "checking for Xft.... yes" bit.
CFLAGS="$CFLAGS `pkg-config --cflags xft`"
View
@@ -58,6 +58,7 @@ static cmdret * set_maxsizegravity (struct cmdarg **args);
static cmdret * set_bargravity (struct cmdarg **args);
static cmdret * set_font (struct cmdarg **args);
static cmdret * set_timefmt (struct cmdarg **args);
+static cmdret * set_termprog (struct cmdarg **args);
static cmdret * set_padding (struct cmdarg **args);
static cmdret * set_border (struct cmdarg **args);
static cmdret * set_barborder (struct cmdarg **args);
@@ -130,6 +131,7 @@ init_set_vars(void)
add_set_var("bargravity", set_bargravity, 1, "", arg_GRAVITY);
add_set_var("font", set_font, 1, "", arg_STRING);
add_set_var("timefmt", set_timefmt, 1, "", arg_STRING);
+ add_set_var("termprog", set_termprog, 1, "", arg_STRING);
add_set_var("padding", set_padding, 4,
"", arg_NUMBER, "", arg_NUMBER, "", arg_NUMBER, "", arg_NUMBER);
add_set_var("border", set_border, 1, "", arg_NUMBER);
@@ -315,7 +317,7 @@ init_user_commands(void)
add_command ("other", cmd_other, 0, 0, 0);
add_command ("prev", cmd_prev, 0, 0, 0);
add_command ("prevscreen", cmd_prevscreen, 0, 0, 0);
- add_command ("quit", cmd_quit, 0, 0, 0);
+ add_command ("quit", cmd_quit, 2, 0, 0);
add_command ("ratinfo", cmd_ratinfo, 0, 0, 0);
add_command ("ratrelinfo", cmd_ratrelinfo, 0, 0, 0);
add_command ("banishrel", cmd_banishrel, 0, 0, 0);
@@ -360,6 +362,7 @@ init_user_commands(void)
"Screen: ", arg_NUMBER);
add_command ("startup_message", cmd_startup_message, 1, 1, 1,
"Startup message: ", arg_STRING);
+ add_command ("terminal", cmd_terminal, 0, 0, 0);
add_command ("time", cmd_time, 0, 0, 0);
add_command ("title", cmd_rename, 1, 1, 1,
"Set window's title to: ", arg_REST);
@@ -778,11 +781,18 @@ initialize_default_keybindings (void)
add_keybinding (XK_a, RP_CONTROL_MASK, "time", map);
add_keybinding (XK_b, 0, "banish", map);
add_keybinding (XK_b, RP_CONTROL_MASK, "banish", map);
- add_keybinding (XK_c, 0, "exec " TERM_PROG, map);
- add_keybinding (XK_c, RP_CONTROL_MASK, "exec " TERM_PROG, map);
+ add_keybinding (XK_c, 0, "terminal", map);
+ add_keybinding (XK_c, RP_CONTROL_MASK, "terminal", map);
add_keybinding (XK_colon, 0, "colon", map);
add_keybinding (XK_exclam, 0, "exec", map);
- add_keybinding (XK_exclam, RP_CONTROL_MASK, "colon exec " TERM_PROG " -e ", map);
+
+ /* We're constructing the string "colon exec [termprog] -e ". */
+ struct sbuf *t = sbuf_new(0);
+ sbuf_concat(t, "colon exec ");
+ sbuf_concat(t, defaults.termprog_string);
+ sbuf_concat(t, " -e ");
+ add_keybinding (XK_exclam, RP_CONTROL_MASK, sbuf_free_struct(t), map);
+
add_keybinding (XK_i, 0, "info", map);
add_keybinding (XK_i, RP_CONTROL_MASK, "info", map);
add_keybinding (XK_k, 0, "delete", map);
@@ -2793,6 +2803,18 @@ cmd_quit(int interactive UNUSED, struct cmdarg **args UNUSED)
}
+/*
+ * Spawns a new terminal in the current frame, according to the "termprog"
+ * setting. It is equivalent to running ":exec [termprog]."
+ */
+cmdret *
+cmd_terminal (int interactive UNUSED, struct cmdarg **args UNUSED)
+{
+ spawn(defaults.termprog_string, 0, current_frame());
+ return cmdret_new(RET_SUCCESS, NULL);
+}
+
+
/* Show the current time on the bar. Thanks to Martin Samuelsson
* <cosis@lysator.liu.se> for the patch. Thanks to Jonathan Walther
* <krooger@debian.org> for making it pretty.
@@ -3937,6 +3959,18 @@ set_timefmt (struct cmdarg **args)
static cmdret *
+set_termprog (struct cmdarg **args)
+{
+ if (args[0] == NULL) {
+ return cmdret_new(RET_SUCCESS, "%s", defaults.termprog_string);
+ }
+
+ defaults.termprog_string = xstrdup(ARG_STRING(0));
+ return cmdret_new(RET_SUCCESS, NULL);
+}
+
+
+static cmdret *
set_padding (struct cmdarg **args)
{
rp_frame *frame;
View
@@ -179,6 +179,7 @@ RP_CMD (setenv);
RP_CMD (shrink);
RP_CMD (source);
RP_CMD (startup_message);
+RP_CMD (terminal);
RP_CMD (time);
RP_CMD (tmpwm);
RP_CMD (unalias);
View
@@ -224,6 +224,7 @@ struct rp_defaults {
char *font_string;
char *timefmt_string;
+ char *termprog_string;
char *fgcolor_string;
char *bgcolor_string;
View
@@ -564,6 +564,7 @@ init_defaults (void)
defaults.font_string = xstrdup (DEFAULT_XFT_FONT);
defaults.timefmt_string = xstrdup ("%a %b %d %k:%M:%S %Y");
+ defaults.termprog_string = xstrdup ("xterm");
defaults.fgcolor_string = xstrdup ("black");
defaults.bgcolor_string = xstrdup ("white");
View
@@ -44,7 +44,6 @@
#define MESSAGE_PROMPT_SHELL_COMMAND "/bin/sh -c "
#define MESSAGE_PROMPT_COMMAND ":"
#define MESSAGE_PROMPT_SWITCH_WM "Switch to wm: "
-#define MESSAGE_PROMPT_XTERM_COMMAND MESSAGE_PROMPT_SHELL_COMMAND TERM_PROG " -e "
#define MESSAGE_PROMPT_SWITCH_TO_GROUP "Switch to group: "
#define MESSAGE_PROMPT_SELECT_VAR "Variable: "
#define MESSAGE_PROMPT_VAR_VALUE "Value: "

0 comments on commit 5268a5c

Please sign in to comment.