From 5b014877c27f67a5f644cee545cfd6624ef77187 Mon Sep 17 00:00:00 2001 From: sabetts Date: Mon, 10 Feb 2003 11:43:35 +0000 Subject: * src/actions.c (cmd_bind): more informative error messages (cmd_unbind): likewise (cmd_source): likewise (cmd_select): likewise (cmd_number): likewise (cmd_escape): likewise (cmd_h_split): likewise (cmd_v_split): likewise (cmd_rudeness): likewise (cmd_gravity): likewise (cmd_defwingravity): likewise (cmd_deftransgravity): likewise (cmd_defmaxsizegravity): likewise (cmd_msgwait): likewise (cmd_defbargravity): likewise (cmd_defbargravity): likewise (cmd_defborder): likewise (cmd_defbarborder): likewise (cmd_definputwidth): likewise (cmd_definputwidth): only accept input widths >=0 (cmd_chdir): add error message if HOME environment variable is not set. (cmd_chdir): add error message if chdir fails. (cmd_rudeness): only accept rudeness numbers between 0 and 15 (cmd_msgwait): only accept waiting times >=0 --- ChangeLog | 28 +++++++ doc/ratpoison.texi | 35 +++++++++ src/actions.c | 211 +++++++++++++++++++++++++++++------------------------ 3 files changed, 178 insertions(+), 96 deletions(-) diff --git a/ChangeLog b/ChangeLog index b56cd6d..b182fb8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2003-01-30 Shawn Betts + + * src/actions.c (cmd_bind): more informative error messages + (cmd_unbind): likewise + (cmd_source): likewise + (cmd_select): likewise + (cmd_number): likewise + (cmd_escape): likewise + (cmd_h_split): likewise + (cmd_v_split): likewise + (cmd_rudeness): likewise + (cmd_gravity): likewise + (cmd_defwingravity): likewise + (cmd_deftransgravity): likewise + (cmd_defmaxsizegravity): likewise + (cmd_msgwait): likewise + (cmd_defbargravity): likewise + (cmd_defbargravity): likewise + (cmd_defborder): likewise + (cmd_defbarborder): likewise + (cmd_definputwidth): likewise + (cmd_definputwidth): only accept input widths >=0 + (cmd_chdir): add error message if HOME environment variable is not + set. + (cmd_chdir): add error message if chdir fails. + (cmd_rudeness): only accept rudeness numbers between 0 and 15 + (cmd_msgwait): only accept waiting times >=0 + 2003-01-25 Shawn Betts * src/actions.c (cmd_help): Print key binding when called diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi index f5618d3..4fc52f3 100644 --- a/doc/ratpoison.texi +++ b/doc/ratpoison.texi @@ -408,6 +408,9 @@ Indicate which frame is the current frame. @item defbarborder @var{n} Set the border width for the bar window. +@item defbarborder @var{n} +Set the border width for the bar window. + @item defbargravity @var{g} Set the default alignment for the message bar. See the @command{gravity} command. @@ -504,6 +507,13 @@ Set the default gravity for normal windows. See the When called non-interactively with no arguments, the current setting is returned. +@item defwingravity @var{g} +Set the default gravity for normal windows. See the +@command{gravity} command. + +When called non-interactively with no arguments, the current setting is +returned. + @item defwinname @var{name} There are three resources ratpoison can get a window's name from: the WMNAME hint, the res_name from the WMCLASS hint, or the res_class from @@ -563,6 +573,9 @@ standard compass 1 and 2 letter abbreviations (i.e. @samp{nw}, When called non-interactively with no arguments, the current setting is returned. +When called non-interactively with no arguments, the current setting is +returned. + @item help Display a help screen that lists all bound keystrokes. @@ -581,6 +594,9 @@ Display the last message. @item license Display ratpoison's license. By default, this is bound to @kbd{C-t V}. +@item license +Display ratpoison's license. By default, this is bound to @kbd{C-t V}. + @item link @var{key} Call the command that @var{key} is bound to. For instance @command{link C-t} would call the command @command{other} and switch @@ -599,6 +615,10 @@ returned. This is a bad-bad command. It kills ratpoison and revives that ugly rodent! Yuck! Avoid! +@item newwm @var{window-manager} +This is a bad-bad command. It kills ratpoison and revives that +ugly rodent! Yuck! Avoid! + @item next This jumps you to the next window in the window list. This one is bound to three keystrokes, namely @kbd{C-t n}, @kbd{C-t space}, @@ -682,6 +702,9 @@ request with a message like @samp{Raise request from window 1 When called non-interactively with no arguments, the current setting is returned. +When called non-interactively with no arguments, the current setting is +returned. + @item select @var{n} This jumps you to window @var{n} where @var{n} is the window number as shown in the Program Bar. You can do the same trick with @@ -720,6 +743,9 @@ Turn on or off the startup_message. This is most useful in your When called non-interactively with no arguments, the current setting is returned. +When called non-interactively with no arguments, the current setting is +returned. + @item time Show current time. Disappears after 5 seconds, like all other info bars. In the default setup, the @kbd{C-t a} keystroke is bound to this command. @@ -732,6 +758,9 @@ the @kbd{C-t A} keystroke is bound to this command. @item unalias @var{name} Remove @var{name} from the list of defined aliases. +@item unalias @var{name} +Remove @var{name} from the list of defined aliases. + @item unbind @var{key} Unbind a keystroke. @@ -762,6 +791,12 @@ rat when leaving a window and when the user returns to the window the rat's position is restored. This can be counter-intuitive, so you can toggle it with this command. @var{state} can be @code{on} or @code{off}. +@item warp @var{state} +Toggle rat warping. By default ratpoison saves the position of the +rat when leaving a window and when the user returns to the window the +rat's position is restored. This can be counter-intuitive, so you can +toggle it with this command. @var{state} can be @code{on} or @code{off}. + @item windows @var{fmt} This displays the Program Bar which displays the windows you currently have running. The number before each window name is used to jump to diff --git a/src/actions.c b/src/actions.c index 18d6c4b..623ca40 100644 --- a/src/actions.c +++ b/src/actions.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "ratpoison.h" @@ -486,7 +487,7 @@ cmd_bind (int interactive, void *data) add_keybinding (key->sym, key->state, cmd); } else - message (" bind: could not parse key description "); + marked_message_printf (0, 0, " bind: unknown key '%s' ", keydesc); } } @@ -514,11 +515,11 @@ cmd_unbind (int interactive, void *data) if (key) { if (!remove_keybinding (key->sym, key->state)) - marked_message_printf (0, 0, " %s unbound key ", keydesc); + marked_message_printf (0, 0, " unbind: unbound key '%s' ", keydesc); } else { - marked_message_printf (0, 0, " %s unknown key ", keydesc); + marked_message_printf (0, 0, " unbind: unknown key '%s' ", keydesc); } free (keydesc); @@ -539,7 +540,7 @@ cmd_source (int interactive, void *data) FILE *fileptr; if ((fileptr = fopen ((char*) data, "r")) == NULL) - message (" source: error opening file "); + marked_message_printf (0, 0, " source: %s : %s ", (char *)data, strerror(errno)); else { read_rc_file (fileptr); @@ -758,8 +759,7 @@ cmd_select (int interactive, void *data) if ((w = find_window_name (str))) goto_window (w); else - /* we need to format a string that includes the str */ - message (" no window by that name "); + marked_message_printf (0, 0, " select: unknown window '%s' ", str); } } @@ -1084,7 +1084,7 @@ cmd_number (int interactive, void *data) new_number = string_to_window_number (tmp); if (new_number < 0) { - message (" number: Bad argument "); + message (" number: invalid argument "); free (str); return NULL; } @@ -1109,7 +1109,7 @@ cmd_number (int interactive, void *data) win_number = string_to_window_number (tmp); if (win_number < 0) { - message (" number: Bad argument "); + message (" number: invalid argument "); free (str); return NULL; } @@ -1249,7 +1249,7 @@ cmd_escape (int interactive, void *data) } else { - message (" escape: could not parse key description "); + marked_message_printf (0, 0, " escape: unknown key '%s' ", (char *)data); } return NULL; @@ -1306,6 +1306,8 @@ cmd_h_split (int interactive, void *data) if (pixels > 0) h_split_frame (current_screen()->rp_current_frame, pixels); + else + message (" hsplit: invalid argument "); return NULL; } @@ -1323,6 +1325,8 @@ cmd_v_split (int interactive, void *data) if (pixels > 0) v_split_frame (current_screen()->rp_current_frame, pixels); + else + message (" vsplit: invalid argument "); return NULL; } @@ -1608,13 +1612,13 @@ cmd_rudeness (int interactive, void *data) if (data == NULL) { - message (" Rudeness level required "); + message (" rudeness: one argument required "); return NULL; } - if (sscanf ((char *)data, "%d", &num) < 1) + if (sscanf ((char *)data, "%d", &num) < 1 || num < 0 || num > 15) { - marked_message_printf (0, 0, " Bad rudeness level: %s ", (char *)data); + marked_message_printf (0, 0, " rudeness: invalid level '%s' ", (char *)data); return NULL; } @@ -1694,11 +1698,14 @@ cmd_gravity (int interactive, void *data) if (data == NULL && !interactive) return xstrdup (wingravity_to_string (win->gravity)); - if (data == NULL - || (gravity = parse_wingravity (data)) < 0) + if (data == NULL) { - message (" gravity: Unknown gravity "); + message (" gravity: one argument required "); + return NULL; } + + if ((gravity = parse_wingravity (data)) < 0) + message (" gravity: unknown gravity "); else { win->gravity = gravity; @@ -1716,15 +1723,16 @@ cmd_defwingravity (int interactive, void *data) if (data == NULL && !interactive) return xstrdup (wingravity_to_string (defaults.win_gravity)); - if (data == NULL - || (gravity = parse_wingravity (data)) < 0) + if (data == NULL) { - message (" defwingravity: Unknown gravity "); + message (" defwingravity: one argument required "); + return NULL; } + + if ((gravity = parse_wingravity (data)) < 0) + message (" defwingravity: unknown gravity "); else - { - defaults.win_gravity = gravity; - } + defaults.win_gravity = gravity; return NULL; } @@ -1736,16 +1744,17 @@ cmd_deftransgravity (int interactive, void *data) if (data == NULL && !interactive) return xstrdup (wingravity_to_string (defaults.trans_gravity)); - - if (data == NULL - || (gravity = parse_wingravity (data)) < 0) + + if (data == NULL) { - message (" gravity: Unknown gravity "); + message (" deftransgravity: one argument required "); + return NULL; } + + if ((gravity = parse_wingravity (data)) < 0) + message (" deftransgravity: unknown gravity "); else - { - defaults.trans_gravity = gravity; - } + defaults.trans_gravity = gravity; return NULL; } @@ -1758,15 +1767,16 @@ cmd_defmaxsizegravity (int interactive, void *data) if (data == NULL && !interactive) return xstrdup (wingravity_to_string (defaults.maxsize_gravity)); - if (data == NULL - || (gravity = parse_wingravity (data)) < 0) + if (data == NULL) { - message (" defmaxsizegravity: Unknown gravity "); + message (" defmaxsizegravity: one argument required "); + return NULL; } + + if ((gravity = parse_wingravity (data)) < 0) + message (" defmaxsizegravity: unknown gravity "); else - { - defaults.maxsize_gravity = gravity; - } + defaults.maxsize_gravity = gravity; return NULL; } @@ -1779,16 +1789,16 @@ cmd_msgwait (int interactive, void *data) if (data == NULL && !interactive) return xsprintf ("%d", defaults.bar_timeout); - if (data == NULL - || sscanf (data, "%d", &tmp) < 1) + if (data == NULL) { - message (" msgwait: One argument required "); + message (" msgwait: one argument required "); + return NULL; } - if (tmp >= 0) - defaults.bar_timeout = tmp; + if (sscanf (data, "%d", &tmp) < 1 || tmp < 0) + message (" msgwait: invalid argument "); else - message (" msgwait: Bad argument "); + defaults.bar_timeout = tmp; return NULL; } @@ -1803,19 +1813,14 @@ cmd_defbargravity (int interactive, void *data) if (data == NULL) { - message (" defbargravity: One argument required "); + message (" defbargravity: one argument required "); return NULL; } if ((gravity = parse_wingravity (data)) < 0) - { - message (" defbargravity: Bad location "); - return NULL; - } + message (" defbargravity: unknown gravity "); else - { - defaults.bar_location = gravity; - } + defaults.bar_location = gravity; return NULL; } @@ -1860,7 +1865,7 @@ cmd_deffont (int interactive, void *data) font = XLoadQueryFont (dpy, (char *)data); if (font == NULL) { - message (" deffont: Unknown font "); + message (" deffont: unknown font "); return NULL; } @@ -1888,7 +1893,7 @@ cmd_defpadding (int interactive, void *data) if (data == NULL || sscanf (data, "%d %d %d %d", &l, &t, &r, &b) < 4) { - message (" defpadding: Four arguments required "); + message (" defpadding: four arguments required "); return NULL; } @@ -1946,21 +1951,20 @@ cmd_defborder (int interactive, void *data) if (data == NULL && !interactive) return xsprintf ("%d", defaults.window_border_width); - if (data == NULL - || sscanf (data, "%d", &tmp) < 1) + if (data == NULL) { - message (" defborder: One argument required "); + message (" defborder: one argument required "); return NULL; } - if (tmp >= 0) - defaults.window_border_width = tmp; - else + if (sscanf (data, "%d", &tmp) < 1 || tmp < 0) { - message (" defborder: Bad argument "); - return NULL; + message (" defborder: invalid argument "); + return NULL; } + defaults.window_border_width = tmp; + /* Update all the visible windows. */ for (win = rp_mapped_window_sentinel->next; win != rp_mapped_window_sentinel; @@ -1982,21 +1986,20 @@ cmd_defbarborder (int interactive, void *data) if (data == NULL && !interactive) return xsprintf ("%d", defaults.bar_border_width); - if (data == NULL - || sscanf (data, "%d", &tmp) < 1) + if (data == NULL) { - message (" defbarborder: One argument required "); + message (" defbarborder: one argument required "); return NULL; } - if (tmp >= 0) - defaults.bar_border_width = tmp; - else + if (sscanf (data, "%d", &tmp) < 1 || tmp < 0) { - message (" defbarborder: Bad argument "); + message (" defbarborder: invalid argument "); return NULL; } + defaults.bar_border_width = tmp; + /* Update the frame and bar windows. */ for (i=0; i