From 39be570b2079c38609ae6cc6c6e2bf937649d481 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 4 Jun 2008 18:50:35 +0000 Subject: [PATCH] vi keys from Will Maier. --- TODO | 1 + input.c | 7 +++---- screen-display.c | 10 +++++++++- screen-write.c | 16 ++++++++++++---- tmux.h | 6 ++++-- window-copy.c | 4 +++- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index cbc92337..08a24cfd 100644 --- a/TODO +++ b/TODO @@ -81,3 +81,4 @@ - show-options - let server die when last session does - each command should have a print op as well for list keys +- fix occasion start server problems diff --git a/input.c b/input.c index 969991e1..8ca4e406 100644 --- a/input.c +++ b/input.c @@ -1,4 +1,4 @@ -/* $Id: input.c,v 1.47 2008-06-04 16:46:23 nicm Exp $ */ +/* $Id: input.c,v 1.48 2008-06-04 18:50:34 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -223,8 +223,6 @@ input_parse(struct window *w) else screen_write_start(&ictx->ctx, &w->base, NULL, NULL); - if (ictx->off != ictx->len) - w->flags |= WINDOW_ACTIVITY; while (ictx->off < ictx->len) { ch = ictx->buf[ictx->off++]; ictx->state(ch, ictx); @@ -483,7 +481,8 @@ input_handle_character(u_char ch, struct input_ctx *ictx) { log_debug2("-- ch %zu: %hhu (%c)", ictx->off, ch, ch); - screen_write_put_character(&ictx->ctx, ch); + if (screen_write_put_character(&ictx->ctx, ch)) + ictx->w->flags |= WINDOW_ACTIVITY; } void diff --git a/screen-display.c b/screen-display.c index 2d42210f..e433c883 100644 --- a/screen-display.c +++ b/screen-display.c @@ -1,4 +1,4 @@ -/* $Id: screen-display.c,v 1.14 2007-12-06 22:13:14 nicm Exp $ */ +/* $Id: screen-display.c,v 1.15 2008-06-04 18:50:34 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -22,6 +22,14 @@ #include "tmux.h" +/* Get a cell. */ +void +screen_display_get_cell(struct screen *s, + u_int px, u_int py, u_char *data, u_char *attr, u_char *colr) +{ + screen_get_cell(s, screen_x(s, px), screen_y(s, py), data, attr, colr); +} + /* Set a cell. */ void screen_display_set_cell( diff --git a/screen-write.c b/screen-write.c index f0693ec3..01b749ab 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1,4 +1,4 @@ -/* $Id: screen-write.c,v 1.5 2007-12-06 19:57:01 nicm Exp $ */ +/* $Id: screen-write.c,v 1.6 2008-06-04 18:50:34 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -98,10 +98,12 @@ screen_write_set_title(struct screen_write_ctx *ctx, char *title) } /* Put a character. */ -void +int screen_write_put_character(struct screen_write_ctx *ctx, u_char ch) { struct screen *s = ctx->s; + u_char data, attr, colr; + int n; if (s->cx == screen_size_x(s)) { s->cx = 0; @@ -110,14 +112,20 @@ screen_write_put_character(struct screen_write_ctx *ctx, u_char ch) screen_write_cursor_down_scroll(ctx); } else if (!screen_in_x(s, s->cx) || !screen_in_y(s, s->cy)) { SCREEN_DEBUG(s); - return; + return (0); } - screen_display_set_cell(s, s->cx, s->cy, ch, s->attr, s->colr); + screen_display_get_cell(s, s->cx, s->cy, &data, &attr, &colr); + if (ch != data || s->attr != attr || colr != s->colr) { + screen_display_set_cell(s, s->cx, s->cy, ch, s->attr, s->colr); + n = 1; + } else + n = 0; s->cx++; if (ctx->write != NULL) ctx->write(ctx->data, TTY_CHARACTER, ch); + return (n); } /* Put a string right-justified. */ diff --git a/tmux.h b/tmux.h index 3c0cdafe..491b385b 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.129 2008-06-04 17:54:26 nicm Exp $ */ +/* $Id: tmux.h,v 1.130 2008-06-04 18:50:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -919,6 +919,8 @@ void input_parse(struct window *); void input_key(struct window *, int); /* screen-display.c */ +void screen_display_get_cell( + struct screen *, u_int, u_int, u_char *, u_char *, u_char *); void screen_display_set_cell( struct screen *, u_int, u_int, u_char, u_char, u_char); void screen_display_make_lines(struct screen *, u_int, u_int); @@ -946,7 +948,7 @@ void screen_write_start(struct screen_write_ctx *, struct screen *, void (*)(void *, int, ...), void *); void screen_write_stop(struct screen_write_ctx *); void screen_write_set_title(struct screen_write_ctx *, char *); -void screen_write_put_character(struct screen_write_ctx *, u_char); +int screen_write_put_character(struct screen_write_ctx *, u_char); size_t printflike2 screen_write_put_string_rjust( struct screen_write_ctx *, const char *, ...); void printflike2 screen_write_put_string( diff --git a/window-copy.c b/window-copy.c index 2129f1c1..ddfa9239 100644 --- a/window-copy.c +++ b/window-copy.c @@ -1,4 +1,4 @@ -/* $Id: window-copy.c,v 1.16 2008-06-03 21:42:37 nicm Exp $ */ +/* $Id: window-copy.c,v 1.17 2008-06-04 18:50:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -184,9 +184,11 @@ window_copy_key(struct window *w, int key) window_copy_copy_selection(w); window_reset_mode(w); break; + case '0': case '\001': /* C-a */ window_copy_cursor_start_of_line(w); break; + case '$': case '\005': /* C-e */ window_copy_cursor_end_of_line(w); break;