summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsabetts <sabetts>2006-04-21 00:14:25 +0000
committersabetts <sabetts>2006-04-21 00:14:25 +0000
commitda43881cd91e35267b094bab80873aa63ba4e109 (patch)
treee887fbe64daffdd3e71d6751841bebdd1645faf6
parentfc0a1e5e68121502a02d556e90fe1ceb570e3493 (diff)
downloadratpoison-da43881cd91e35267b094bab80873aa63ba4e109.zip
* src/actions.h: new command sfrestore
* src/actions.c (init_user_commands): new command sfrestore (cmd_sfrestore): new function
-rw-r--r--ChangeLog7
-rw-r--r--NEWS3
-rw-r--r--doc/ratpoison.texi4
-rw-r--r--src/actions.c74
-rw-r--r--src/actions.h1
5 files changed, 89 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 19ced16..161642e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-04-20 Shawn Betts <sabetts@vcn.bc.ca>
+
+ * src/actions.h: new command sfrestore
+
+ * src/actions.c (init_user_commands): new command sfrestore
+ (cmd_sfrestore): new function
+
2006-04-19 Shawn Betts <sabetts@vcn.bc.ca>
* src/events.c (property_notify): Only map the first window in the launch frame.
diff --git a/NEWS b/NEWS
index 248ed81..d9c5ae3 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,9 @@ notice and this notice are preserved.
* Changes since 1.4.0
** support for i18n fonts
+** new command sfrestore
+restores frame configurations for multiple screens.
+
* Changes since 1.4.0-beta4
** new parameters in frame dumps
:screenh and :screenw specify the size of the screen the frame was
diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi
index eb924df..619fc6f 100644
--- a/doc/ratpoison.texi
+++ b/doc/ratpoison.texi
@@ -896,6 +896,10 @@ Like fdump, but dump information about each screen instead of each frame.
Dump all the screen number and the frames on all screens.
@end deffn
+@deffn Command sfrestore
+restore a frame configuration created using @command{sfdump}.
+@end deffn
+
@node Keystrokes, Hooks, Multiple Monitors, Top
@chapter Keystrokes
diff --git a/src/actions.c b/src/actions.c
index 78736b1..8f57d7c 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -281,6 +281,8 @@ init_user_commands()
"Variable: ", arg_STRING,
"Value: ", arg_REST);
add_command ("shrink", cmd_shrink, 0, 0, 0);
+ add_command ("sfrestore", cmd_sfrestore, 1, 1, 1,
+ "Frames: ", arg_REST);
add_command ("source", cmd_source, 1, 1, 1,
"File: ", arg_REST);
add_command ("sselect", cmd_sselect, 1, 1, 1,
@@ -4933,6 +4935,78 @@ cmd_sfdump (int interactively, struct cmdarg **args)
}
cmdret *
+cmd_sfrestore (int interactively, struct cmdarg **args)
+{
+ int out_of_screen = 0;
+ int number_of_frames = 0;
+ int j;
+ long x;
+ char *dup;
+ char *token;
+ char *ptr;
+ struct sbuf *buffer[num_screens];
+
+ /* initialize frameset-buffer for each screen */
+ for (j=0; j<num_screens; j++) {
+ buffer[j] = sbuf_new(0);
+ }
+
+ /* now split the whole input to the corresponding screens */
+ dup = xstrdup (ARG_STRING(0));
+
+ token = strtok (dup, ",");
+ if (token == NULL) {
+ free (dup);
+ return cmdret_new (RET_FAILURE, "sfrestore: invalid frame format");
+ }
+
+ while (token != NULL) {
+ /* search for end of frameset */
+ ptr = token;
+ while (*ptr != ')') {
+ ptr++;
+ }
+ /* skip space */
+ ptr++;
+
+ /* convert to integer */
+ x = strtol (ptr, NULL, 10);
+
+ /* check that specified screen number is not bigger than current number of connected screens */
+ if (x < num_screens) {
+ /* append frameset to buffer[x] */
+ sbuf_concat(buffer[x], token);
+ sbuf_concat(buffer[x], ",");
+ number_of_frames++;
+ }
+ else {
+ out_of_screen++;
+ }
+
+ /* continue with next frameset */
+ token = strtok (NULL, ",");
+ }
+
+ free (dup);
+
+ /* now restore the frames for each screen */
+ for (j=0; j<num_screens; j++) {
+ push_frame_undo (&screens[j]); /* fdump to stack */
+ /* FIXME: store RET_SUCCESS || RET_FAILURE for each screen and output it later */
+ frestore (sbuf_get(buffer[j]), &screens[j]);
+ /* clear buffer */
+ sbuf_free(buffer[j]);
+ }
+
+ if (!out_of_screen) {
+ return cmdret_new (RET_SUCCESS, "Restored %i Frame(s)", number_of_frames);
+ }
+ else {
+ return cmdret_new (RET_SUCCESS, "Restored %i Frame(s), %i Frame(s) out of Screen(s)", number_of_frames, out_of_screen);
+ }
+}
+
+cmdret *
cmd_sdump (int interactive, struct cmdarg **args)
{
cmdret *ret;
diff --git a/src/actions.h b/src/actions.h
index dae4935..34bf3cc 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -201,6 +201,7 @@ RP_CMD (iprev);
RP_CMD (prompt);
RP_CMD (sdump);
RP_CMD (sfdump);
+RP_CMD (sfrestore);
RP_CMD (undo);
RP_CMD (redo);
RP_CMD (putsel);