diff options
author | Marco Peereboom <marco@conformal.com> | 2011-01-11 20:11:41 +0000 |
---|---|---|
committer | Marco Peereboom <marco@conformal.com> | 2011-01-11 20:11:41 +0000 |
commit | 805908e257aa281a72fe9e3d41db765f884d10b4 (patch) | |
tree | 830085e481044b364bb1a358cc3a9bd6560d0639 | |
parent | 627ce4c9e600e92ea59c6b5b41037873c5e7a252 (diff) | |
download | xombrero-805908e257aa281a72fe9e3d41db765f884d10b4.tar.gz |
add session save <filename>
-rw-r--r-- | xxxterm.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/xxxterm.c b/xxxterm.c index 7de17e0..139bd60 100644 --- a/xxxterm.c +++ b/xxxterm.c @@ -1583,7 +1583,7 @@ save_tabs(struct tab *t, struct karg *a) return (1); snprintf(file, sizeof file, "%s/%s", sessions_dir, a->s); - +warnx("save_tabs %s", file); if ((f = fopen(file, "w")) == NULL) { show_oops(t, "Can't open save_tabs file: %s", strerror(errno)); return (1); @@ -3711,9 +3711,32 @@ set(struct tab *t, struct karg *args) } int +session_save(struct tab *t, char *filename, char **ret) +{ + struct karg a; + char *f = filename; + int rv = 1; + + f += strlen("save"); + while (*f == ' ' && *f != '\0') + f++; + if (strlen(f) == 0) + goto done; + + a.s = f; + save_tabs(t, &a); + + *ret = f; + rv = 0; +done: + return (rv); +} + +int session_cmd(struct tab *t, struct karg *args) { char *action = NULL; + char *filename = NULL; if (t == NULL) return (1); @@ -3723,6 +3746,18 @@ session_cmd(struct tab *t, struct karg *args) else action = "show"; + if (!strcmp(action, "show")) + show_oops(t, "Current session: %s", named_session[0] == '\0' ? + XT_SAVED_TABS_FILE : named_session); + else if (g_str_has_prefix(action, "save ")) { + if (session_save(t, action, &filename)) { + show_oops(t, "Can't save session: %s", + filename ? filename : "INVALID"); + goto done; + } + } else + show_oops(t, "Invalid command: %s", action); +done: return (XT_CB_PASSTHROUGH); } |