diff --git a/CHANGES b/CHANGES index ac033861..999397cb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ +16 November 2008 + +* Enable default colours if op contains \033[39;49m, based on a report from + fulvio ciriaco. + +12 November 2008 + +* Keep stack of last windows rather than just most recent; based on a diff from + joshe. + 04 November 2008 * Don't try to redraw status line when showing a prompt or message; if it does, @@ -687,4 +697,4 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.165 2008-11-04 20:55:58 nicm Exp $ +$Id: CHANGES,v 1.166 2008-11-16 10:10:26 nicm Exp $ diff --git a/TODO b/TODO index a7fd4d58..b8e65fe6 100644 --- a/TODO +++ b/TODO @@ -33,7 +33,7 @@ - flags to centre screen in window - better terminal emulation (identify, insert mode, some other bits) - save stack for last window -- paste stack should be an SLIST. also key bindings? others? +- when resizing, use history -- For 0.5 -------------------------------------------------------------------- @@ -54,3 +54,4 @@ - many more info() displays for various things - document mode-keys - vi half page scroll +- document new flags diff --git a/cmd-link-window.c b/cmd-link-window.c index 8a9bb6df..a4557bc8 100644 --- a/cmd-link-window.c +++ b/cmd-link-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-link-window.c,v 1.24 2008-06-25 20:33:20 nicm Exp $ */ +/* $Id: cmd-link-window.c,v 1.25 2008-11-16 10:10:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -79,6 +79,7 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx) * if this makes it empty. */ session_alert_cancel(dst, wl_dst); + winlink_stack_remove(&dst->lastw, wl_dst); winlink_remove(&dst->windows, wl_dst); /* Force select/redraw if current. */ @@ -86,8 +87,6 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx) data->flags &= ~CMD_DFLAG; dst->curw = NULL; } - if (wl_dst == dst->lastw) - dst->lastw = NULL; } } diff --git a/cmd-move-window.c b/cmd-move-window.c index 31694443..aca44d31 100644 --- a/cmd-move-window.c +++ b/cmd-move-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-move-window.c,v 1.1 2008-06-25 20:43:13 nicm Exp $ */ +/* $Id: cmd-move-window.c,v 1.2 2008-11-16 10:10:26 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -81,6 +81,7 @@ cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx) * if this makes it empty. */ session_alert_cancel(dst, wl_dst); + winlink_stack_remove(&dst->lastw, wl_dst); winlink_remove(&dst->windows, wl_dst); /* Force select/redraw if current. */ @@ -88,8 +89,6 @@ cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx) data->flags &= ~CMD_DFLAG; dst->curw = NULL; } - if (wl_dst == dst->lastw) - dst->lastw = NULL; } } diff --git a/session.c b/session.c index 49f3ee8c..32e595d6 100644 --- a/session.c +++ b/session.c @@ -1,4 +1,4 @@ -/* $Id: session.c,v 1.44 2008-11-05 01:19:24 nicm Exp $ */ +/* $Id: session.c,v 1.45 2008-11-16 10:10:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -117,7 +117,8 @@ session_create(const char *name, const char *cmd, u_int sx, u_int sy) s = xmalloc(sizeof *s); if (gettimeofday(&s->tv, NULL) != 0) fatal("gettimeofday"); - s->curw = s->lastw = NULL; + s->curw = NULL; + SLIST_INIT(&s->lastw); RB_INIT(&s->windows); SLIST_INIT(&s->alerts); paste_init_stack(&s->buffers); @@ -168,6 +169,8 @@ session_destroy(struct session *s) options_free(&s->options); paste_free_stack(&s->buffers); + while (!SLIST_EMPTY(&s->lastw)) + winlink_stack_remove(&s->lastw, SLIST_FIRST(&s->lastw)); while (!RB_EMPTY(&s->windows)) winlink_remove(&s->windows, RB_ROOT(&s->windows)); @@ -223,10 +226,9 @@ session_detach(struct session *s, struct winlink *wl) { if (s->curw == wl && session_last(s) != 0 && session_previous(s) != 0) session_next(s); - if (s->lastw == wl) - s->lastw = NULL; session_alert_cancel(s, wl); + winlink_stack_remove(&s->lastw, wl); winlink_remove(&s->windows, wl); if (RB_EMPTY(&s->windows)) { session_destroy(s); @@ -262,7 +264,8 @@ session_next(struct session *s) wl = RB_MIN(winlinks, &s->windows); if (wl == s->curw) return (1); - s->lastw = s->curw; + winlink_stack_remove(&s->lastw, wl); + winlink_stack_push(&s->lastw, s->curw); s->curw = wl; session_alert_cancel(s, wl); return (0); @@ -282,7 +285,8 @@ session_previous(struct session *s) wl = RB_MAX(winlinks, &s->windows); if (wl == s->curw) return (1); - s->lastw = s->curw; + winlink_stack_remove(&s->lastw, wl); + winlink_stack_push(&s->lastw, s->curw); s->curw = wl; session_alert_cancel(s, wl); return (0); @@ -299,7 +303,8 @@ session_select(struct session *s, int idx) return (-1); if (wl == s->curw) return (1); - s->lastw = s->curw; + winlink_stack_remove(&s->lastw, wl); + winlink_stack_push(&s->lastw, s->curw); s->curw = wl; session_alert_cancel(s, wl); return (0); @@ -311,13 +316,14 @@ session_last(struct session *s) { struct winlink *wl; - wl = s->lastw; + wl = SLIST_FIRST(&s->lastw); if (wl == NULL) return (-1); if (wl == s->curw) return (1); - s->lastw = s->curw; + winlink_stack_remove(&s->lastw, wl); + winlink_stack_push(&s->lastw, s->curw); s->curw = wl; session_alert_cancel(s, wl); return (0); diff --git a/status.c b/status.c index bdac3135..0bc77eaf 100644 --- a/status.c +++ b/status.c @@ -1,4 +1,4 @@ -/* $Id: status.c,v 1.49 2008-09-29 17:47:12 nicm Exp $ */ +/* $Id: status.c,v 1.50 2008-11-16 10:10:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -277,7 +277,7 @@ status_print(struct session *s, struct winlink *wl, struct grid_cell *gc) char *text, flag; flag = ' '; - if (wl == s->lastw) + if (wl == SLIST_FIRST(&s->lastw)) flag = '-'; if (wl == s->curw) flag = '*'; diff --git a/tmux.h b/tmux.h index f8486776..bab5e998 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.195 2008-11-05 01:19:24 nicm Exp $ */ +/* $Id: tmux.h,v 1.196 2008-11-16 10:10:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -589,8 +589,10 @@ struct winlink { struct window *window; RB_ENTRY(winlink) entry; + SLIST_ENTRY(winlink) sentry; }; RB_HEAD(winlinks, winlink); +SLIST_HEAD(winlink_stack, winlink); /* Option data structures. */ struct options_entry { @@ -640,7 +642,7 @@ struct session { u_int sy; struct winlink *curw; - struct winlink *lastw; + struct winlink_stack lastw; struct winlinks windows; struct options options; @@ -1260,6 +1262,8 @@ struct winlink *winlink_add(struct winlinks *, struct window *, int); void winlink_remove(struct winlinks *, struct winlink *); struct winlink *winlink_next(struct winlinks *, struct winlink *); struct winlink *winlink_previous(struct winlinks *, struct winlink *); +void winlink_stack_push(struct winlink_stack *, struct winlink *); +void winlink_stack_remove(struct winlink_stack *, struct winlink *); struct window *window_create(const char *, const char *, const char **, u_int, u_int, u_int); int window_spawn(struct window *, const char *, const char **); diff --git a/tty.c b/tty.c index 1683d5e7..90c4b9d0 100644 --- a/tty.c +++ b/tty.c @@ -1,4 +1,4 @@ -/* $Id: tty.c,v 1.49 2008-11-05 01:19:24 nicm Exp $ */ +/* $Id: tty.c,v 1.50 2008-11-16 10:10:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -255,6 +255,7 @@ tty_find_term(char *name, int fd, char **cause) { struct tty_term *term; int error; + char *s; SLIST_FOREACH(term, &tty_terms, entry) { if (strcmp(term->name, name) == 0) { @@ -348,6 +349,9 @@ tty_find_term(char *name, int fd, char **cause) if (tigetflag("AX") == TRUE) term->flags |= TERM_HASDEFAULTS; + s = tigetstr("orig_pair"); + if (s != NULL && s != (char *) -1 && strcmp(s, "\033[39;49m") == 0) + term->flags |= TERM_HASDEFAULTS; /* * Try to figure out if we have 256 colours. The standard xterm diff --git a/window.c b/window.c index 14cdfc00..92d955c0 100644 --- a/window.c +++ b/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.50 2008-09-26 06:45:28 nicm Exp $ */ +/* $Id: window.c,v 1.51 2008-11-16 10:10:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -164,6 +164,32 @@ winlink_previous(unused struct winlinks *wwl, struct winlink *wl) #endif } +void +winlink_stack_push(struct winlink_stack *stack, struct winlink *wl) +{ + if (wl == NULL) + return; + + winlink_stack_remove(stack, wl); + SLIST_INSERT_HEAD(stack, wl, sentry); +} + +void +winlink_stack_remove(struct winlink_stack *stack, struct winlink *wl) +{ + struct winlink *wl2; + + if (wl == NULL) + return; + + SLIST_FOREACH(wl2, stack, sentry) { + if (wl2 == wl) { + SLIST_REMOVE(stack, wl, winlink, sentry); + return; + } + } +} + struct window * window_create(const char *name, const char *cmd, const char **envp, u_int sx, u_int sy, u_int hlimit)