summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES9
-rw-r--r--Makefile5
-rw-r--r--TODO4
-rw-r--r--cmd-kill-session.c4
-rw-r--r--cmd-list-windows.c7
-rw-r--r--cmd-scroll-mode.c55
-rw-r--r--cmd-send-prefix.c5
-rw-r--r--cmd.c3
-rw-r--r--input-keys.c4
-rw-r--r--input.c120
-rw-r--r--key-bindings.c5
-rw-r--r--resize.c7
-rw-r--r--screen-display.c46
-rw-r--r--screen.c171
-rw-r--r--server-fn.c14
-rw-r--r--server-msg.c14
-rw-r--r--server.c4
-rw-r--r--status.c4
-rw-r--r--tmux.h45
-rw-r--r--window-scroll.c122
-rw-r--r--window.c30
21 files changed, 491 insertions, 187 deletions
diff --git a/CHANGES b/CHANGES
index a4001560..9eaeba19 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+21 November 2007
+
+* Initial support for scroll history. = to enter scrolling mode, and then
+ vi keys or up/down/pgup/pgdown to navigate. Q to exit. No horizontal history
+ yet (need per-line sizes) and a few kinks to be worked out (resizing while in
+ history mode will probably cause trouble).
+
20 November 2007
* Fix format string error with "must specify a client" message. Also
@@ -233,4 +240,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.75 2007-11-20 18:11:37 nicm Exp $
+$Id: CHANGES,v 1.76 2007-11-21 13:11:41 nicm Exp $
diff --git a/Makefile b/Makefile
index 8bbc2ed6..9d6e04e4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.44 2007-11-20 21:42:28 nicm Exp $
+# $Id: Makefile,v 1.45 2007-11-21 13:11:41 nicm Exp $
.SUFFIXES: .c .o .y .h
.PHONY: clean update-index.html upload-index.html
@@ -26,7 +26,8 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-refresh-client.c cmd-kill-window.c cmd-list-clients.c \
cmd-link-window.c cmd-unlink-window.c cmd-next-window.c \
cmd-swap-window.c cmd-rename-session.c cmd-kill-session.c \
- cmd-switch-client.c cmd-has-session.c
+ cmd-switch-client.c cmd-has-session.c cmd-scroll-mode.c \
+ window-scroll.c
CC?= cc
INCDIRS+= -I. -I- -I/usr/local/include
diff --git a/TODO b/TODO
index 7ecb806c..a6522116 100644
--- a/TODO
+++ b/TODO
@@ -65,10 +65,14 @@
- session specification is all over the place. some things use -s before cmd,
some -s after, some no -s, there are various uses of -n. the differences are
sort of logical, but confusing. needs rethought
+- XXX should -i for win idx be before cmd too??
- bind non prefix keys (useful for shift-pageup for scrollback, when we
have scrollback)
+- for scrollback (?) or copy/paste, modal key/display handling (key/draw
+ through function pointers in screen). also move ? etc to that too
- stuff like rename would be nice to be able to do in-client like screen, if
it could be implemented in a non-icky way
+- there is to much redrawing. use flags? (there was a problem with this idea..?)
-- For 0.2 --------------------------------------------------------------------
- copy and paste
diff --git a/cmd-kill-session.c b/cmd-kill-session.c
index b7853810..e4addc87 100644
--- a/cmd-kill-session.c
+++ b/cmd-kill-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-kill-session.c,v 1.3 2007-11-16 21:12:31 nicm Exp $ */
+/* $Id: cmd-kill-session.c,v 1.4 2007-11-21 13:11:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -58,6 +58,6 @@ cmd_kill_session_exec(unused void *ptr, struct cmd_ctx *ctx)
session_destroy(ctx->session);
- if (!(ctx->flags & CMD_KEY))
+ if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
diff --git a/cmd-list-windows.c b/cmd-list-windows.c
index c7bd1716..c2a5e09a 100644
--- a/cmd-list-windows.c
+++ b/cmd-list-windows.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list-windows.c,v 1.9 2007-11-20 21:42:29 nicm Exp $ */
+/* $Id: cmd-list-windows.c,v 1.10 2007-11-21 13:11:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -47,9 +47,10 @@ cmd_list_windows_exec(unused void *ptr, struct cmd_ctx *ctx)
RB_FOREACH(wl, winlinks, &ctx->session->windows) {
w = wl->window;
- ctx->print(ctx, "%d: %s \"%s\" (%s) [%ux%u]",
+ ctx->print(ctx, "%d: %s \"%s\" (%s) [%ux%u] [history %u]",
wl->idx, w->name, w->screen.title, ttyname(w->fd),
- screen_size_x(&w->screen), screen_size_y(&w->screen));
+ screen_size_x(&w->screen), screen_size_y(&w->screen),
+ w->screen.hsize);
}
if (ctx->cmdclient != NULL)
diff --git a/cmd-scroll-mode.c b/cmd-scroll-mode.c
new file mode 100644
index 00000000..3bc98825
--- /dev/null
+++ b/cmd-scroll-mode.c
@@ -0,0 +1,55 @@
+/* $Id: cmd-scroll-mode.c,v 1.1 2007-11-21 13:11:41 nicm Exp $ */
+
+/*
+ * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+
+#include <getopt.h>
+#include <stdlib.h>
+
+#include "tmux.h"
+
+/*
+ * Enter scroll mode. Only valid when bound to a key.
+ */
+
+void cmd_scroll_mode_exec(void *, struct cmd_ctx *);
+
+const struct cmd_entry cmd_scroll_mode_entry = {
+ "scroll-mode", "scroll", "",
+ CMD_NOCLIENT,
+ NULL,
+ cmd_scroll_mode_exec,
+ NULL,
+ NULL,
+ NULL
+};
+
+void
+cmd_scroll_mode_exec(unused void *ptr, struct cmd_ctx *ctx)
+{
+ struct window *w = ctx->session->curw->window;
+
+ if (ctx->flags & CMD_KEY) {
+ w->mode = &window_scroll_mode;
+ w->mode->init(w);
+ server_redraw_window_all(w);
+ }
+
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
+}
diff --git a/cmd-send-prefix.c b/cmd-send-prefix.c
index 1dc9ae02..3d556675 100644
--- a/cmd-send-prefix.c
+++ b/cmd-send-prefix.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-send-prefix.c,v 1.5 2007-11-16 21:12:31 nicm Exp $ */
+/* $Id: cmd-send-prefix.c,v 1.6 2007-11-21 13:11:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -42,8 +42,7 @@ const struct cmd_entry cmd_send_prefix_entry = {
void
cmd_send_prefix_exec(unused void *ptr, struct cmd_ctx *ctx)
{
- input_translate_key(
- ctx->client->session->curw->window->out, prefix_key);
+ window_key(ctx->client->session->curw->window, prefix_key);
if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
diff --git a/cmd.c b/cmd.c
index 0be6aebb..91c41103 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1,4 +1,4 @@
-/* $Id: cmd.c,v 1.29 2007-11-16 21:31:03 nicm Exp $ */
+/* $Id: cmd.c,v 1.30 2007-11-21 13:11:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -43,6 +43,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_refresh_client_entry,
&cmd_rename_session_entry,
&cmd_rename_window_entry,
+ &cmd_scroll_mode_entry,
&cmd_select_window_entry,
&cmd_send_prefix_entry,
&cmd_set_option_entry,
diff --git a/input-keys.c b/input-keys.c
index d143494b..1d11893f 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -1,4 +1,4 @@
-/* $Id: input-keys.c,v 1.2 2007-10-19 11:10:35 nicm Exp $ */
+/* $Id: input-keys.c,v 1.3 2007-11-21 13:11:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -55,7 +55,7 @@ struct {
/* Translate a key code from client into an output key sequence. */
void
-input_translate_key(struct buffer *b, int key)
+input_key(struct buffer *b, int key)
{
u_int i;
diff --git a/input.c b/input.c
index f9061aab..4b8ec5f0 100644
--- a/input.c
+++ b/input.c
@@ -1,4 +1,4 @@
-/* $Id: input.c,v 1.33 2007-11-20 21:42:29 nicm Exp $ */
+/* $Id: input.c,v 1.34 2007-11-21 13:11:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -308,12 +308,12 @@ input_state_sequence_first(u_char ch, struct input_ctx *ictx)
ARRAY_CLEAR(&ictx->args);
if (INPUT_PARAMETER(ch)) {
+ input_new_argument(ictx); /* XXX extraneous arg if priv */
if (ch >= 0x3c && ch <= 0x3f) {
/* Private control sequence. */
ictx->private = ch;
return (input_state_sequence_next);
}
- input_new_argument(ictx);
}
/* Pass character on directly. */
@@ -373,8 +373,10 @@ input_handle_character(u_char ch, struct input_ctx *ictx)
log_debug2("-- ch %zu: %hhu (%c)", ictx->off, ch, ch);
if (s->cx == screen_size_x(s)) {
- input_store8(ictx->b, '\r');
- input_store8(ictx->b, '\n');
+ if (!screen_hidden(s)) {
+ input_store8(ictx->b, '\r');
+ input_store8(ictx->b, '\n');
+ }
s->cx = 0;
screen_display_cursor_down(s);
@@ -382,7 +384,8 @@ input_handle_character(u_char ch, struct input_ctx *ictx)
return;
screen_display_cursor_set(s, ch);
- input_store8(ictx->b, ch);
+ if (!screen_hidden(s))
+ input_store8(ictx->b, ch);
s->cx++;
}
@@ -416,14 +419,17 @@ input_handle_c0_control(u_char ch, struct input_ctx *ictx)
s->cx = 0;
screen_display_cursor_down(s);
}
- input_store_two(
- ictx->b, CODE_CURSORMOVE, s->cy + 1, s->cx + 1);
+ if (!screen_hidden(s)) {
+ input_store_two(
+ ictx->b, CODE_CURSORMOVE, s->cy + 1, s->cx + 1);
+ }
return;
default:
log_debug("unknown c0: %hhu", ch);
return;
}
- input_store8(ictx->b, ch);
+ if (!screen_hidden(s))
+ input_store8(ictx->b, ch);
}
void
@@ -436,7 +442,8 @@ input_handle_c1_control(u_char ch, struct input_ctx *ictx)
switch (ch) {
case 'M': /* RI */
screen_display_cursor_up(s);
- input_store_zero(ictx->b, CODE_REVERSEINDEX);
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_REVERSEINDEX);
break;
default:
log_debug("unknown c1: %hhu", ch);
@@ -453,10 +460,12 @@ input_handle_private_two(u_char ch, struct input_ctx *ictx)
switch (ch) {
case '=': /* DECKPAM */
- input_store_zero(ictx->b, CODE_KKEYPADON);
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_KKEYPADON);
break;
case '>': /* DECKPNM*/
- input_store_zero(ictx->b, CODE_KKEYPADOFF);
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_KKEYPADOFF);
break;
case '7': /* DECSC */
s->saved_cx = s->cx;
@@ -472,12 +481,14 @@ input_handle_private_two(u_char ch, struct input_ctx *ictx)
s->cy = s->saved_cy;
s->attr = s->saved_attr;
s->colr = s->saved_colr;
- input_store_two(
- ictx->b, CODE_ATTRIBUTES, s->attr, s->colr);
- input_store_two(ictx->b, CODE_SCROLLREGION,
- s->rupper + 1, s->rlower + 1);
- input_store_two(
- ictx->b, CODE_CURSORMOVE, s->cy + 1, s->cx + 1);
+ if (!screen_hidden(s)) {
+ input_store_two(
+ ictx->b, CODE_ATTRIBUTES, s->attr, s->colr);
+ input_store_two(ictx->b, CODE_SCROLLREGION,
+ s->rupper + 1, s->rlower + 1);
+ input_store_two(
+ ictx->b, CODE_CURSORMOVE, s->cy + 1, s->cx + 1);
+ }
break;
default:
log_debug("unknown p2: %hhu", ch);
@@ -564,7 +575,8 @@ input_handle_sequence_cuu(struct input_ctx *ictx)
}
s->cy -= n;
- input_store_one(ictx->b, CODE_CURSORUP, n);
+ if (!screen_hidden(s))
+ input_store_one(ictx->b, CODE_CURSORUP, n);
}
void
@@ -586,7 +598,8 @@ input_handle_sequence_cud(struct input_ctx *ictx)
input_limit(n, 1, screen_last_y(s) - s->cy);
s->cy += n;
- input_store_one(ictx->b, CODE_CURSORDOWN, n);
+ if (!screen_hidden(s))
+ input_store_one(ictx->b, CODE_CURSORDOWN, n);
}
void
@@ -608,7 +621,8 @@ input_handle_sequence_cuf(struct input_ctx *ictx)
input_limit(n, 1, screen_last_x(s) - s->cx);
s->cx += n;
- input_store_one(ictx->b, CODE_CURSORRIGHT, n);
+ if (!screen_hidden(s))
+ input_store_one(ictx->b, CODE_CURSORRIGHT, n);
}
void
@@ -631,7 +645,8 @@ input_handle_sequence_cub(struct input_ctx *ictx)
}
s->cx -= n;
- input_store_one(ictx->b, CODE_CURSORLEFT, n);
+ if (!screen_hidden(s))
+ input_store_one(ictx->b, CODE_CURSORLEFT, n);
}
void
@@ -653,7 +668,8 @@ input_handle_sequence_dch(struct input_ctx *ictx)
input_limit(n, 1, screen_last_x(s) - s->cx);
screen_display_delete_characters(s, s->cx, s->cy, n);
- input_store_one(ictx->b, CODE_DELETECHARACTER, n);
+ if (!screen_hidden(s))
+ input_store_one(ictx->b, CODE_DELETECHARACTER, n);
}
void
@@ -678,7 +694,8 @@ input_handle_sequence_dl(struct input_ctx *ictx)
screen_display_delete_lines(s, s->cy, n);
else
screen_display_delete_lines_region(s, s->cy, n);
- input_store_one(ictx->b, CODE_DELETELINE, n);
+ if (!screen_hidden(s))
+ input_store_one(ictx->b, CODE_DELETELINE, n);
}
void
@@ -700,7 +717,8 @@ input_handle_sequence_ich(struct input_ctx *ictx)
input_limit(n, 1, screen_last_x(s) - s->cx);
screen_display_insert_characters(s, s->cx, s->cy, n);
- input_store_one(ictx->b, CODE_INSERTCHARACTER, n);
+ if (!screen_hidden(s))
+ input_store_one(ictx->b, CODE_INSERTCHARACTER, n);
}
void
@@ -725,7 +743,8 @@ input_handle_sequence_il(struct input_ctx *ictx)
screen_display_insert_lines(s, s->cy, n);
else
screen_display_insert_lines_region(s, s->cy, n);
- input_store_one(ictx->b, CODE_INSERTLINE, n);
+ if (!screen_hidden(s))
+ input_store_one(ictx->b, CODE_INSERTLINE, n);
}
void
@@ -747,7 +766,8 @@ input_handle_sequence_vpa(struct input_ctx *ictx)
input_limit(n, 1, screen_size_y(s));
s->cy = n - 1;
- input_store_two(ictx->b, CODE_CURSORMOVE, n, s->cx + 1);
+ if (!screen_hidden(s))
+ input_store_two(ictx->b, CODE_CURSORMOVE, n, s->cx + 1);
}
void
@@ -769,7 +789,8 @@ input_handle_sequence_hpa(struct input_ctx *ictx)
input_limit(n, 1, screen_size_x(s));
s->cx = n - 1;
- input_store_two(ictx->b, CODE_CURSORMOVE, s->cy + 1, n);
+ if (!screen_hidden(s))
+ input_store_two(ictx->b, CODE_CURSORMOVE, s->cy + 1, n);
}
void
@@ -793,7 +814,8 @@ input_handle_sequence_cup(struct input_ctx *ictx)
s->cx = m - 1;
s->cy = n - 1;
- input_store_two(ictx->b, CODE_CURSORMOVE, n, m);
+ if (!screen_hidden(s))
+ input_store_two(ictx->b, CODE_CURSORMOVE, n, m);
}
void
@@ -819,6 +841,8 @@ input_handle_sequence_ed(struct input_ctx *ictx)
screen_display_fill_cursor_eos(
s, SCREEN_DEFDATA, s->attr, s->colr);
+ if (!screen_hidden(s))
+ break;
input_store_zero(ictx->b, CODE_CLEARLINE);
for (i = s->cy + 1; i < screen_size_y(s); i++) {
input_store_two(ictx->b, CODE_CURSORMOVE, i + 1, 1);
@@ -830,7 +854,9 @@ input_handle_sequence_ed(struct input_ctx *ictx)
case 2:
screen_display_fill_lines(
s, 0, screen_size_y(s), SCREEN_DEFDATA, s->attr, s->colr);
-
+
+ if (!screen_hidden(s))
+ break;
for (i = 0; i < screen_size_y(s); i++) {
input_store_two(ictx->b, CODE_CURSORMOVE, i + 1, 1);
input_store_zero(ictx->b, CODE_CLEARLINE);
@@ -862,17 +888,23 @@ input_handle_sequence_el(struct input_ctx *ictx)
case 0:
screen_display_fill_cursor_eol(
s, SCREEN_DEFDATA, s->attr, s->colr);
- input_store_zero(ictx->b, CODE_CLEARENDOFLINE);
+
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_CLEARENDOFLINE);
break;
case 1:
screen_display_fill_cursor_bol(
s, SCREEN_DEFDATA, s->attr, s->colr);
- input_store_zero(ictx->b, CODE_CLEARSTARTOFLINE);
+
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_CLEARSTARTOFLINE);
break;
case 2:
screen_display_fill_line(
s, s->cy, SCREEN_DEFDATA, s->attr, s->colr);
- input_store_zero(ictx->b, CODE_CLEARLINE);
+
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_CLEARLINE);
break;
}
}
@@ -892,11 +924,13 @@ input_handle_sequence_sm(struct input_ctx *ictx)
switch (n) {
case 1: /* GATM */
s->mode |= MODE_KCURSOR;
- input_store_zero(ictx->b, CODE_KCURSORON);
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_KCURSORON);
break;
case 25: /* TCEM */
s->mode |= MODE_CURSOR;
- input_store_zero(ictx->b, CODE_CURSORON);
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_CURSORON);
break;
default:
log_debug("unknown SM [%hhu]: %u", ictx->private, n);
@@ -906,7 +940,8 @@ input_handle_sequence_sm(struct input_ctx *ictx)
switch (n) {
case 4: /* IRM */
s->mode |= MODE_INSERT;
- input_store_zero(ictx->b, CODE_INSERTON);
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_INSERTON);
break;
case 34:
/* Cursor high visibility not supported. */
@@ -933,11 +968,13 @@ input_handle_sequence_rm(struct input_ctx *ictx)
switch (n) {
case 1: /* GATM */
s->mode &= ~MODE_KCURSOR;
- input_store_zero(ictx->b, CODE_KCURSOROFF);
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_KCURSOROFF);
break;
case 25: /* TCEM */
s->mode &= ~MODE_CURSOR;
- input_store_zero(ictx->b, CODE_CURSOROFF);
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_CURSOROFF);
break;
default:
log_debug("unknown RM [%hhu]: %u", ictx->private, n);
@@ -947,7 +984,8 @@ input_handle_sequence_rm(struct input_ctx *ictx)
switch (n) {
case 4: /* IRM */
s->mode &= ~MODE_INSERT;
- input_store_zero(ictx->b, CODE_INSERTOFF);
+ if (!screen_hidden(s))
+ input_store_zero(ictx->b, CODE_INSERTOFF);
break;
case 34:
/* Cursor high visibility not supported. */
@@ -1021,7 +1059,8 @@ input_handle_sequence_decstbm(struct input_ctx *ictx)
s->rupper = n - 1;
s->rlower = m - 1;
- input_store_two(ictx->b, CODE_SCROLLREGION, n, m);
+ if (!screen_hidden(s))
+ input_store_two(ictx->b, CODE_SCROLLREGION, n, m);
}
void
@@ -1105,7 +1144,8 @@ input_handle_sequence_sgr(struct input_ctx *ictx)
}
}
}
- input_store_two(ictx->b, CODE_ATTRIBUTES, s->attr, s->colr);
+ if (!screen_hidden(s))
+ input_store_two(ictx->b, CODE_ATTRIBUTES, s->attr, s->colr);
}
void
diff --git a/key-bindings.c b/key-bindings.c
index 0af94f8d..f17f5c86 100644
--- a/key-bindings.c
+++ b/key-bindings.c
@@ -1,4 +1,4 @@
-/* $Id: key-bindings.c,v 1.17 2007-11-20 21:42:29 nicm Exp $ */
+/* $Id: key-bindings.c,v 1.18 2007-11-21 13:11:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -108,6 +108,7 @@ key_bindings_init(void)
{ 'R', &cmd_refresh_client_entry, NULL },
{ 'r', &cmd_refresh_client_entry, NULL },
{ '&', &cmd_kill_window_entry, NULL },
+ { '=', &cmd_scroll_mode_entry, NULL },
{ META, &cmd_send_prefix_entry, NULL },
};
u_int i;
@@ -176,7 +177,7 @@ key_bindings_print(struct cmd_ctx *ctx, const char *fmt, ...)
size = BUFFER_USED(c->out);
if (line == 2 * sy || !(c->flags & CLIENT_HOLD)) {
- input_store_zero(c->out, CODE_CURSOROFF);
+ input_store_zero(c->out, CODE_CURSOROFF);
for (i = 0; i < sy; i++) {
input_store_two(c->out, CODE_CURSORMOVE, i + 1, 1);
input_store_zero(c->out, CODE_CLEARLINE);
diff --git a/resize.c b/resize.c
index 2e9380c3..a48f5c0a 100644
--- a/resize.c
+++ b/resize.c
@@ -1,4 +1,4 @@
-/* $Id: resize.c,v 1.5 2007-11-20 21:42:29 nicm Exp $ */
+/* $Id: resize.c,v 1.6 2007-11-21 13:11:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -104,8 +104,11 @@ recalculate_sizes(void)
ssy = s->sy;
}
}
- if (ssx == UINT_MAX || ssy == UINT_MAX)
+ if (ssx == UINT_MAX || ssy == UINT_MAX) {
+ w->screen.mode |= MODE_HIDDEN;
continue;
+ }
+ w->screen.mode &= ~MODE_HIDDEN;
if (screen_size_x(&w->screen) == ssx &&
screen_size_y(&w->screen) == ssy)
diff --git a/screen-display.c b/screen-display.c
index 5f2790aa..e11c6aaa 100644
--- a/screen-display.c
+++ b/screen-display.c
@@ -1,4 +1,4 @@
-/* $Id: screen-display.c,v 1.1 2007-11-20 21:42:29 nicm Exp $ */
+/* $Id: screen-display.c,v 1.2 2007-11-21 13:11:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -168,6 +168,36 @@ screen_display_cursor_down(struct screen *s)
void
screen_display_scroll_region_up(struct screen *s)
{
+ u_int sy;
+
+ /*
+ * If the region is the entire screen, this is easy-peasy. Allocate
+ * a new line and adjust the history size.
+ * XXX1 should this be done somewhere else?
+ */
+ if (s->rupper == 0 && s->rlower == screen_last_y(s)) {
+ sy = screen_size_y(s) + s->hsize;
+
+ if (s->hsize == s->hlimit) {
+ /*
+ * If the limit is hit, shift the whole thing up.
+ * XXX this is inefficient, is there a better way?
+ */
+ screen_move_lines(s, 0, 1, sy - 1);
+ } else {
+ s->hsize++;
+
+ s->grid_data = xrealloc(
+ s->grid_data, sy + 1, sizeof *s->grid_data);
+ s->grid_attr = xrealloc(
+ s->grid_attr, sy + 1, sizeof *s->grid_attr);
+ s->grid_colr = xrealloc(
+ s->grid_colr, sy + 1, sizeof *s->grid_colr);
+ }
+ screen_display_make_lines(s, screen_last_y(s), 1);
+ return;
+ }
+
/*
* Scroll scrolling region up:
* - delete rupper
@@ -189,8 +219,6 @@ screen_display_scroll_region_up(struct screen *s)
}
screen_display_make_lines(s, s->rlower, 1);
- screen_display_fill_lines(
- s, s->rlower, 1, SCREEN_DEFDATA, SCREEN_DEFATTR, SCREEN_DEFCOLR);
}
/* Scroll region down. */
@@ -218,8 +246,6 @@ screen_display_scroll_region_down(struct screen *s)
}
screen_display_make_lines(s, s->rupper, 1);
- screen_display_fill_lines(
- s, s->rupper, 1, SCREEN_DEFDATA, SCREEN_DEFATTR, SCREEN_DEFCOLR);
}
/* Insert lines. */
@@ -368,15 +394,14 @@ screen_display_insert_characters(struct screen *s, u_int px, u_int py, u_int nx)
{
u_int mx;
- px = screen_x(s, px);
- py = screen_y(s, py);
-
if (!screen_in_x(s, px) || !screen_in_y(s, py))
fatalx("bad value");
if (px + nx > screen_last_x(s))
nx = screen_last_x(s) - px;
+ py = screen_y(s, py);
+
/*
* Inserting a range of nx at px.
*
@@ -401,15 +426,14 @@ screen_display_delete_characters(struct screen *s, u_int px, u_int py, u_int nx)
{
u_int mx;
- px = screen_x(s, px);
- py = screen_y(s, py);
-
if (!screen_in_x(s, px) || !screen_in_y(s, py))
fatalx("bad value");
if (px + nx > screen_last_x(s))
nx = screen_last_x(s) - px;
+ py = screen_y(s, py);
+
/*
* Deleting the range from px to px + nx.
*
diff --git a/screen.c b/screen.c
index 06f3b99b..34051da0 100644
--- a/screen.c
+++ b/screen.c
@@ -1,4 +1,4 @@
-/* $Id: screen.c,v 1.27 2007-11-20 21:45:53 nicm Exp $ */
+/* $Id: screen.c,v 1.28 2007-11-21 13:11:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -23,9 +23,7 @@
#include "tmux.h"
/*
- * Virtual screen and basic terminal emulator.
- *
- * XXX Much of this file sucks.
+ * Virtual screen.
*/
/* Colour to string. */
@@ -92,8 +90,8 @@ screen_create(struct screen *s, u_int dx, u_int dy)
s->rupper = 0;
s->rlower = s->dy - 1;
- s->ysize = dy;
- s->ylimit = SHRT_MAX;
+ s->hsize = 0;
+ s->hlimit = SHRT_MAX;
s->attr = SCREEN_DEFATTR;
s->colr = SCREEN_DEFCOLR;
@@ -111,10 +109,7 @@ screen_create(struct screen *s, u_int dx, u_int dy)
void
screen_resize(struct screen *s, u_int sx, u_int sy)
{
- u_int i, ox, oy, ny;
-
- if (sx == s->dx && sy == s->dy)
- return;
+ u_int i, ox, oy, ny, my;
if (sx < 1)
sx = 1;
@@ -123,83 +118,79 @@ screen_resize(struct screen *s, u_int sx, u_int sy)
ox = s->dx;
oy = s->dy;
+ if (sx == ox && sy == oy)
+ return;
- log_debug("resizing screen (%u, %u) -> (%u, %u)", ox, oy, sx, sy);
-
- s->dx = sx;
- s->dy = sy;
-
- s->rupper = 0;
- s->rlower = s->dy - 1;
-
- s->ysize = sy;
-
- if (sy < oy) {
- ny = oy - sy;
- if (ny > s->cy)
- ny = s->cy;
-
- if (ny != 0) {
- log_debug("removing %u lines from top", ny);
- for (i = 0; i < ny; i++) {
- log_debug("freeing line %u", i);
- xfree(s->grid_data[i]);
- xfree(s->grid_attr[i]);
- xfree(s->grid_colr[i]);
- }
- memmove(s->grid_data, s->grid_data + ny,
- (oy - ny) * (sizeof *s->grid_data));
- memmove(s->grid_attr, s->grid_attr + ny,
- (oy - ny) * (sizeof *s->grid_attr));
- memmove(s->grid_colr, s->grid_colr + ny,
- (oy - ny) * (sizeof *s->grid_colr));
- s->cy -= ny;
- }
- if (ny < oy - sy) {
- log_debug(
- "removing %u lines from bottom", oy - sy - ny);
- for (i = sy; i < oy - ny; i++) {
- log_debug("freeing line %u", i);
- xfree(s->grid_data[i]);
- xfree(s->grid_attr[i]);
- xfree(s->grid_colr[i]);
- }
- if (s->cy >= sy)
- s->cy = sy - 1;
- }
- }
- if (sy != oy) {
- s->grid_data = xrealloc(s->grid_data, sy, sizeof *s->grid_data);
- s->grid_attr = xrealloc(s->grid_attr, sy, sizeof *s->grid_attr);
- s->grid_colr = xrealloc(s->grid_colr, sy, sizeof *s->grid_colr);
- }
- if (sy > oy) {
- for (i = oy; i < sy; i++) {
- log_debug("allocating line %u", i);
- s->grid_data[i] = xmalloc(sx);
- s->grid_attr[i] = xmalloc(sx);
- s->grid_colr[i] = xmalloc(sx);
- screen_display_fill_line(s, i,
- SCREEN_DEFDATA, SCREEN_DEFATTR, SCREEN_DEFCOLR);
- }
- sy = oy;
- }
-
+ /*
+ * X dimension.
+ */
if (sx != ox) {
- for (i = 0; i < sy; i++) {
- log_debug("adjusting line %u to %u", i, sx);
+ /* Resize all lines including history. */
+ /* XXX need per-line sizes! */
+ for (i = 0; i < s->hsize + oy; i++) {
s->grid_data[i] = xrealloc(s->grid_data[i], sx, 1);
s->grid_attr[i] = xrealloc(s->grid_attr[i], sx, 1);
s->grid_colr[i] = xrealloc(s->grid_colr[i], sx, 1);
if (sx > ox) {
- screen_display_fill_cells(s, ox, i, s->dx - ox,
+ screen_fill_cells(s, ox, i, sx - ox,
SCREEN_DEFDATA, SCREEN_DEFATTR,
SCREEN_DEFCOLR);
}
}
if (s->cx >= sx)
s->cx = sx - 1;
+ s->dx = sx;
}
+
+ /*
+ * Y dimension.
+ */
+ if (sy == oy)
+ return;
+
+ /* Size decreasing. */
+ if (sy < oy) {
+ ny = oy - sy;
+ if (s->cy != 0) {
+ /*
+ * The cursor is not at the start. Try to remove as
+ * many lines as possible from the top.
+ */
+ my = s->cy;
+ if (my > ny)
+ my = ny;
+
+ screen_display_free_lines(s, 0, my);
+ screen_display_move_lines(s, 0, my, oy - my);
+
+ s->cy -= my;
+ oy -= my;
+ }
+
+ ny = oy - sy;
+ if (ny > 0) {
+ /*
+ * Remove any remaining lines from the bottom.
+ */
+ screen_display_free_lines(s, oy, ny);
+ if (s->cy >= sy)
+ s->cy = sy - 1;
+ }
+ }
+
+ /* Resize line arrays. */
+ ny = s->hsize + sy;
+ s->grid_data = xrealloc(s->grid_data, ny, sizeof *s->grid_data);
+ s->grid_attr = xrealloc(s->grid_attr, ny, sizeof *s->grid_attr);
+ s->grid_colr = xrealloc(s->grid_colr, ny, sizeof *s->grid_colr);
+ s->dy = sy;
+
+ /* Size increasing. */
+ if (sy > oy)
+ screen_display_make_lines(s, oy, sy - oy);
+
+ s->rupper = 0;
+ s->rlower = s->dy - 1;
}
/* Destroy a screen. */
@@ -214,13 +205,10 @@ screen_destroy(struct screen *s)
/* Draw a set of lines on the screen. */
void
-screen_draw(struct screen *s, struct buffer *b, u_int uy, u_int ly)
+screen_draw(struct screen *s, struct buffer *b, u_int py, u_int ny, u_int off)
{
- u_char attr, colr;
- u_int i, j;
-
- if (uy > s->dy - 1 || ly > s->dy - 1 || ly < uy)
- fatalx("bad range");
+ u_char attr, colr;
+ u_int i, j, base;
/* XXX. This is naive and rough right now. */
attr = 0;
@@ -231,20 +219,27 @@ screen_draw(struct screen *s, struct buffer *b, u_int uy, u_int ly)
input_store_zero(b, CODE_CURSOROFF);
input_store_two(b, CODE_ATTRIBUTES, attr, colr);
- for (j = uy; j <= ly; j++) {
+ base = screen_y(s, 0);
+ if (off > base)
+ base = 0;
+ else
+ base -= off;
+
+ for (j = py; j < py + ny; j++) {
input_store_two(b, CODE_CURSORMOVE, j + 1, 1);
for (i = 0; i <= screen_last_x(s); i++) {
- if (s->grid_attr[j][i] != attr ||
- s->grid_colr[j][i] != colr) {
+ if (s->grid_attr[base + j][i] != attr ||
+ s->grid_colr[base + j][i] != colr) {
input_store_two(b, CODE_ATTRIBUTES,
- s->grid_attr[j][i], s->grid_colr[j][i]);
- attr = s->grid_attr[j][i];
- colr = s->grid_colr[j][i];
+ s->grid_attr[base + j][i],
+ s->grid_colr[base + j][i]);
+ attr = s->grid_attr[base + j][i];
+ colr = s->grid_colr[base + j][i];
}
- input_store8(b, s->grid_data[j][i]);
+ input_store8(b, s->grid_data[base + j][i]);
}
- }
+ }
input_store_two(b, CODE_CURSORMOVE, s->cy + 1, s->cx + 1);
input_store_two(b, CODE_ATTRIBUTES, s->attr, s->colr);
diff --git a/server-fn.c b/server-fn.c
index 40a35400..af651a81 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -1,4 +1,4 @@
-/* $Id: server-fn.c,v 1.26 2007-11-20 21:42:29 nicm Exp $ */
+/* $Id: server-fn.c,v 1.27 2007-11-21 13:11:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -192,7 +192,7 @@ server_clear_client(struct client *c)
void
server_redraw_client(struct client *c)
{