Swap in new paste buffer code and add a couple more commands.

This commit is contained in:
Nicholas Marriott 2008-06-20 17:31:48 +00:00
parent 9798dcd4df
commit 4e4f71febb
18 changed files with 239 additions and 63 deletions

13
CHANGES
View File

@ -1,5 +1,16 @@
20 June 2008 20 June 2008
* Initial buffer improvements. Each session has a stack of buffers and each
buffer command takes a -b option to manipulate items on the stack. If -b
is omitted, the top entry is used. The following commands are currently
available:
set-buffer [-b index] [-t target-session] string
paste-buffer [-d] [-b index] [-t target-window]
delete-buffer [-b index] [-t target-session]
show-buffers [-t target-session]
-d to paste-buffer deletes the buffer after pasting it.
* New option, display-time, sets the time status line messages stay on screen * New option, display-time, sets the time status line messages stay on screen
(unless a key is pressed). Set in milliseconds, default is 750 (0.75 seconds). (unless a key is pressed). Set in milliseconds, default is 750 (0.75 seconds).
The timer is only checked every 100 ms or so. The timer is only checked every 100 ms or so.
@ -517,4 +528,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other (including mutt, emacs). No status bar yet and no key remapping or other
customisation. customisation.
$Id: CHANGES,v 1.130 2008-06-19 23:24:40 nicm Exp $ $Id: CHANGES,v 1.131 2008-06-20 17:31:48 nicm Exp $

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.64 2008-06-20 08:36:20 nicm Exp $ # $Id: Makefile,v 1.65 2008-06-20 17:31:48 nicm Exp $
.SUFFIXES: .c .o .y .h .SUFFIXES: .c .o .y .h
.PHONY: clean update-index.html upload-index.html .PHONY: clean update-index.html upload-index.html
@ -31,7 +31,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-paste-buffer.c cmd-new-session.c cmd-start-server.c \ cmd-paste-buffer.c cmd-new-session.c cmd-start-server.c \
cmd-kill-server.c cmd-set-window-option.c cmd-show-options.c \ cmd-kill-server.c cmd-set-window-option.c cmd-show-options.c \
cmd-show-window-options.c cmd-command-prompt.c cmd-set-buffer.c \ cmd-show-window-options.c cmd-command-prompt.c cmd-set-buffer.c \
cmd-show-buffer.c \ cmd-show-buffer.c cmd-list-buffers.c cmd-delete-buffer.c \
window-scroll.c window-more.c window-copy.c options.c paste.c \ window-scroll.c window-more.c window-copy.c options.c paste.c \
tty.c tty-keys.c tty-write.c screen-write.c screen-redraw.c tty.c tty-keys.c tty-write.c screen-write.c screen-redraw.c

10
TODO
View File

@ -77,13 +77,15 @@
- list-keys should be sorted - list-keys should be sorted
--- ---
buffer stack. buffer numbered 0 is top and ascending buffer stack. buffer numbered 0 is top and ascending
where -b number == top if missing: where -b number == top if missing:
paste-buffer -b number ---
delete-buffer -b number
set-buffer -b number string
save-buffer -b number filename save-buffer -b number filename
load-buffer -b number filename load-buffer -b number filename
copy-buffer (from other session) copy-buffer (from other session)
---
set-buffer -b number string
show-buffer -n number
paste-buffer -b number
delete-buffer -b number
show-buffers show-buffers
--- ---

63
cmd-delete-buffer.c Normal file
View File

@ -0,0 +1,63 @@
/* $Id: cmd-delete-buffer.c,v 1.1 2008-06-20 17:31:48 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"
/*
* Delete a paste buffer.
*/
void cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_delete_buffer_entry = {
"delete-buffer", "deleteb",
CMD_BUFFER_SESSION_USAGE,
0,
cmd_buffer_init,
cmd_buffer_parse,
cmd_delete_buffer_exec,
cmd_buffer_send,
cmd_buffer_recv,
cmd_buffer_free,
cmd_buffer_print
};
void
cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_buffer_data *data = self->data;
struct session *s;
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return;
if (data->buffer == -1)
paste_free_top(&s->buffers);
else {
if (paste_free_index(&s->buffers, data->buffer) != 0)
ctx->error(ctx, "no buffer %d", data->buffer);
}
if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}

80
cmd-list-buffers.c Normal file
View File

@ -0,0 +1,80 @@
/* $Id: cmd-list-buffers.c,v 1.1 2008-06-20 17:31:48 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 <string.h>
#include "tmux.h"
/*
* List paste buffers.
*/
void cmd_list_buffers_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_list_buffers_entry = {
"list-buffers", "lsb",
CMD_TARGET_SESSION_USAGE,
0,
cmd_target_init,
cmd_target_parse,
cmd_list_buffers_exec,
cmd_target_send,
cmd_target_recv,
cmd_target_free,
cmd_target_print
};
void
cmd_list_buffers_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_target_data *data = self->data;
struct session *s;
struct paste_buffer *pb;
u_int idx;
char tmp[16], *tim;
size_t in, out;
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return;
idx = 0;
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) {
in = out = 0;
while (out < (sizeof tmp) - 1 && pb->data[in] != '\0') {
if (pb->data[in] > 31 && pb->data[in] != 127)
tmp[out++] = pb->data[in];
in++;
}
tmp[out] = '\0';
if (out == (sizeof tmp) - 1) {
tmp[out - 1] = '.';
tmp[out - 2] = '.';
}
tim = ctime(&pb->ts.tv_sec);
*strchr(tim, '\n') = '\0';
ctx->print(ctx, "%d: %zu bytes "
"(created %s): \"%s\"", idx, strlen(pb->data), tim, tmp);
}
if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}

View File

@ -1,4 +1,4 @@
/* $Id: cmd-paste-buffer.c,v 1.8 2008-06-05 21:25:00 nicm Exp $ */ /* $Id: cmd-paste-buffer.c,v 1.9 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -29,30 +29,45 @@
void cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *); void cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_paste_buffer_entry = { const struct cmd_entry cmd_paste_buffer_entry = {
"paste-buffer", "paste", "paste-buffer", "pasteb",
CMD_TARGET_WINDOW_USAGE, CMD_BUFFER_WINDOW_USAGE,
0, CMD_DFLAG,
cmd_target_init, cmd_buffer_init,
cmd_target_parse, cmd_buffer_parse,
cmd_paste_buffer_exec, cmd_paste_buffer_exec,
cmd_target_send, cmd_buffer_send,
cmd_target_recv, cmd_buffer_recv,
cmd_target_free, cmd_buffer_free,
cmd_target_print cmd_buffer_print
}; };
void void
cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
{ {
struct cmd_target_data *data = self->data; struct cmd_buffer_data *data = self->data;
struct winlink *wl; struct winlink *wl;
struct session *s;
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) struct paste_buffer *pb;
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
return; return;
if (paste_buffer != NULL && *paste_buffer != '\0') { if (data->buffer == -1)
buffer_write( pb = paste_get_top(&s->buffers);
wl->window->out, paste_buffer, strlen(paste_buffer)); else {
if ((pb = paste_get_top(&s->buffers)) == NULL)
ctx->error(ctx, "no buffer %d", data->buffer);
}
if (pb != NULL)
buffer_write(wl->window->out, pb->data, strlen(pb->data));
/* Delete the buffer if -d. */
if (ctx->flags & CMD_DFLAG) {
if (data->buffer == -1)
paste_free_top(&s->buffers);
else
paste_free_index(&s->buffers, data->buffer);
} }
if (ctx->cmdclient != NULL) if (ctx->cmdclient != NULL)

View File

@ -1,4 +1,4 @@
/* $Id: cmd-send-keys.c,v 1.12 2008-06-10 20:28:42 nicm Exp $ */ /* $Id: cmd-send-keys.c,v 1.13 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -121,7 +121,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
return; return;
for (i = 0; i < data->nkeys; i++) for (i = 0; i < data->nkeys; i++)
window_key(wl->window, data->keys[i]); window_key(wl->window, ctx->curclient, data->keys[i]);
if (ctx->cmdclient != NULL) if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-send-prefix.c,v 1.16 2008-06-19 22:04:02 nicm Exp $ */ /* $Id: cmd-send-prefix.c,v 1.17 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -49,7 +49,8 @@ cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL) if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
return; return;
window_key(wl->window, options_get_key(&s->options, "prefix")); window_key(
wl->window, ctx->curclient, options_get_key(&s->options, "prefix"));
if (ctx->cmdclient != NULL) if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);

4
cmd.c
View File

@ -1,4 +1,4 @@
/* $Id: cmd.c,v 1.51 2008-06-20 08:36:20 nicm Exp $ */ /* $Id: cmd.c,v 1.52 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -31,6 +31,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_bind_key_entry, &cmd_bind_key_entry,
&cmd_command_prompt_entry, &cmd_command_prompt_entry,
&cmd_copy_mode_entry, &cmd_copy_mode_entry,
&cmd_delete_buffer_entry,
&cmd_detach_client_entry, &cmd_detach_client_entry,
&cmd_has_session_entry, &cmd_has_session_entry,
&cmd_kill_server_entry, &cmd_kill_server_entry,
@ -38,6 +39,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_kill_window_entry, &cmd_kill_window_entry,
&cmd_last_window_entry, &cmd_last_window_entry,
&cmd_link_window_entry, &cmd_link_window_entry,
&cmd_list_buffers_entry,
&cmd_list_clients_entry, &cmd_list_clients_entry,
&cmd_list_keys_entry, &cmd_list_keys_entry,
&cmd_list_sessions_entry, &cmd_list_sessions_entry,

View File

@ -1,4 +1,4 @@
/* $Id: key-bindings.c,v 1.33 2008-06-19 21:28:41 nicm Exp $ */ /* $Id: key-bindings.c,v 1.34 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -108,8 +108,9 @@ key_bindings_init(void)
{ '=', &cmd_scroll_mode_entry }, { '=', &cmd_scroll_mode_entry },
{ '[', &cmd_copy_mode_entry }, { '[', &cmd_copy_mode_entry },
{ ']', &cmd_paste_buffer_entry }, { ']', &cmd_paste_buffer_entry },
{ '#', &cmd_list_buffers_entry },
{ '-', &cmd_delete_buffer_entry },
{ ':', &cmd_command_prompt_entry }, { ':', &cmd_command_prompt_entry },
{ ';', &cmd_command_prompt_entry },
{ META, &cmd_send_prefix_entry }, { META, &cmd_send_prefix_entry },
}; };
u_int i; u_int i;

View File

@ -1,4 +1,4 @@
/* $Id: paste.c,v 1.1 2008-06-20 08:36:20 nicm Exp $ */ /* $Id: paste.c,v 1.2 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -105,7 +105,7 @@ paste_add(struct paste_stack *ps, const char *data)
ARRAY_INSERT(ps, 0, pb); ARRAY_INSERT(ps, 0, pb);
pb->data = xstrdup(data); pb->data = xstrdup(data);
if (clock_gettime(CLOCK_REALTIME, &pb->created) != 0) if (clock_gettime(CLOCK_REALTIME, &pb->ts) != 0)
fatal("clock_gettime"); fatal("clock_gettime");
} }
@ -121,7 +121,7 @@ paste_replace(struct paste_stack *ps, u_int idx, const char *data)
xfree(pb->data); xfree(pb->data);
pb->data = xstrdup(data); pb->data = xstrdup(data);
if (clock_gettime(CLOCK_REALTIME, &pb->created) != 0) if (clock_gettime(CLOCK_REALTIME, &pb->ts) != 0)
fatal("clock_gettime"); fatal("clock_gettime");
return (0); return (0);

View File

@ -1,4 +1,4 @@
/* $Id: server.c,v 1.73 2008-06-20 06:36:01 nicm Exp $ */ /* $Id: server.c,v 1.74 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -542,7 +542,7 @@ server_handle_client(struct client *c)
} else if (key == prefix) } else if (key == prefix)
c->flags |= CLIENT_PREFIX; c->flags |= CLIENT_PREFIX;
else else
window_key(w, key); window_key(w, c, key);
} }
} }

5
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.64 2008-06-19 23:20:45 nicm Exp $ */ /* $Id: tmux.c,v 1.65 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -48,7 +48,6 @@ volatile sig_atomic_t sigterm;
char *cfg_file; char *cfg_file;
struct options global_options; struct options global_options;
char *paste_buffer;
int debug_level; int debug_level;
int be_quiet; int be_quiet;
@ -222,8 +221,6 @@ main(int argc, char **argv)
options_set_number(&global_options, "status-interval", 15); options_set_number(&global_options, "status-interval", 15);
options_set_number(&global_options, "set-titles", 1); options_set_number(&global_options, "set-titles", 1);
paste_buffer = NULL;
if (cfg_file == NULL) { if (cfg_file == NULL) {
home = getenv("HOME"); home = getenv("HOME");
if (home == NULL || *home == '\0') { if (home == NULL || *home == '\0') {

12
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.157 2008-06-20 08:36:20 nicm Exp $ */ /* $Id: tmux.h,v 1.158 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -519,11 +519,12 @@ struct input_ctx {
* Window mode. Windows can be in several modes and this is used to call the * Window mode. Windows can be in several modes and this is used to call the
* right function to handle input and output. * right function to handle input and output.
*/ */
struct client;
struct window_mode { struct window_mode {
struct screen *(*init)(struct window *); struct screen *(*init)(struct window *);
void (*free)(struct window *); void (*free)(struct window *);
void (*resize)(struct window *, u_int, u_int); void (*resize)(struct window *, u_int, u_int);
void (*key)(struct window *, int); void (*key)(struct window *, struct client *, int);
}; };
/* Window structure. */ /* Window structure. */
@ -593,7 +594,7 @@ struct options {
/* Paste buffer. */ /* Paste buffer. */
struct paste_buffer { struct paste_buffer {
char *data; char *data;
struct timespec created; struct timespec ts;
}; };
ARRAY_DECL(paste_stack, struct paste_buffer *); ARRAY_DECL(paste_stack, struct paste_buffer *);
@ -819,7 +820,6 @@ extern volatile sig_atomic_t sigwinch;
extern volatile sig_atomic_t sigterm; extern volatile sig_atomic_t sigterm;
extern struct options global_options; extern struct options global_options;
extern char *cfg_file; extern char *cfg_file;
extern char *paste_buffer;
extern int debug_level; extern int debug_level;
extern int be_quiet; extern int be_quiet;
void logfile(const char *); void logfile(const char *);
@ -900,6 +900,7 @@ extern const struct cmd_entry cmd_attach_session_entry;
extern const struct cmd_entry cmd_bind_key_entry; extern const struct cmd_entry cmd_bind_key_entry;
extern const struct cmd_entry cmd_command_prompt_entry; extern const struct cmd_entry cmd_command_prompt_entry;
extern const struct cmd_entry cmd_copy_mode_entry; extern const struct cmd_entry cmd_copy_mode_entry;
extern const struct cmd_entry cmd_delete_buffer_entry;
extern const struct cmd_entry cmd_detach_client_entry; extern const struct cmd_entry cmd_detach_client_entry;
extern const struct cmd_entry cmd_has_session_entry; extern const struct cmd_entry cmd_has_session_entry;
extern const struct cmd_entry cmd_kill_server_entry; extern const struct cmd_entry cmd_kill_server_entry;
@ -907,6 +908,7 @@ extern const struct cmd_entry cmd_kill_session_entry;
extern const struct cmd_entry cmd_kill_window_entry; extern const struct cmd_entry cmd_kill_window_entry;
extern const struct cmd_entry cmd_last_window_entry; extern const struct cmd_entry cmd_last_window_entry;
extern const struct cmd_entry cmd_link_window_entry; extern const struct cmd_entry cmd_link_window_entry;
extern const struct cmd_entry cmd_list_buffers_entry;
extern const struct cmd_entry cmd_list_clients_entry; extern const struct cmd_entry cmd_list_clients_entry;
extern const struct cmd_entry cmd_list_keys_entry; extern const struct cmd_entry cmd_list_keys_entry;
extern const struct cmd_entry cmd_list_sessions_entry; extern const struct cmd_entry cmd_list_sessions_entry;
@ -1158,7 +1160,7 @@ int window_resize(struct window *, u_int, u_int);
int window_set_mode(struct window *, const struct window_mode *); int window_set_mode(struct window *, const struct window_mode *);
void window_reset_mode(struct window *); void window_reset_mode(struct window *);
void window_parse(struct window *); void window_parse(struct window *);
void window_key(struct window *, int); void window_key(struct window *, struct client *, int);
/* window-copy.c */ /* window-copy.c */
extern const struct window_mode window_copy_mode; extern const struct window_mode window_copy_mode;

View File

@ -1,4 +1,4 @@
/* $Id: window-copy.c,v 1.19 2008-06-19 19:40:35 nicm Exp $ */ /* $Id: window-copy.c,v 1.20 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -25,7 +25,7 @@
struct screen *window_copy_init(struct window *); struct screen *window_copy_init(struct window *);
void window_copy_free(struct window *); void window_copy_free(struct window *);
void window_copy_resize(struct window *, u_int, u_int); void window_copy_resize(struct window *, u_int, u_int);
void window_copy_key(struct window *, int); void window_copy_key(struct window *, struct client *, int);
void window_copy_redraw_lines(struct window *, u_int, u_int); void window_copy_redraw_lines(struct window *, u_int, u_int);
void window_copy_redraw_screen(struct window *); void window_copy_redraw_screen(struct window *);
@ -41,7 +41,7 @@ void window_copy_write_columns(
void window_copy_update_cursor(struct window *); void window_copy_update_cursor(struct window *);
void window_copy_start_selection(struct window *); void window_copy_start_selection(struct window *);
int window_copy_update_selection(struct window *); int window_copy_update_selection(struct window *);
void window_copy_copy_selection(struct window *); void window_copy_copy_selection(struct window *, struct client *);
void window_copy_copy_line( void window_copy_copy_line(
struct window *, char **, size_t *, size_t *, u_int, u_int, u_int); struct window *, char **, size_t *, size_t *, u_int, u_int, u_int);
u_int window_copy_find_length(struct window *, u_int); u_int window_copy_find_length(struct window *, u_int);
@ -126,7 +126,7 @@ window_copy_resize(struct window *w, u_int sx, u_int sy)
} }
void void
window_copy_key(struct window *w, int key) window_copy_key(struct window *w, struct client *c, int key)
{ {
struct window_copy_mode_data *data = w->modedata; struct window_copy_mode_data *data = w->modedata;
struct screen *s = &data->screen; struct screen *s = &data->screen;
@ -181,8 +181,10 @@ window_copy_key(struct window *w, int key)
break; break;
case '\027': /* C-w */ case '\027': /* C-w */
case '\r': /* enter */ case '\r': /* enter */
window_copy_copy_selection(w); if (c != NULL && c->session != NULL) {
window_reset_mode(w); window_copy_copy_selection(w, c);
window_reset_mode(w);
}
break; break;
case '0': case '0':
case '\001': /* C-a */ case '\001': /* C-a */
@ -354,7 +356,7 @@ window_copy_update_selection(struct window *w)
} }
void void
window_copy_copy_selection(struct window *w) window_copy_copy_selection(struct window *w, struct client *c)
{ {
struct window_copy_mode_data *data = w->modedata; struct window_copy_mode_data *data = w->modedata;
struct screen *s = &data->screen; struct screen *s = &data->screen;
@ -412,9 +414,9 @@ window_copy_copy_selection(struct window *w)
if (off != 0) if (off != 0)
buf[off - 1] = '\0'; buf[off - 1] = '\0';
if (paste_buffer != NULL) /* Add the buffer to the stack. */
xfree(paste_buffer); paste_add(&c->session->buffers, buf);
paste_buffer = buf; xfree(buf);
} }
void void

View File

@ -1,4 +1,4 @@
/* $Id: window-more.c,v 1.12 2008-06-18 22:21:51 nicm Exp $ */ /* $Id: window-more.c,v 1.13 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -25,7 +25,7 @@
struct screen *window_more_init(struct window *); struct screen *window_more_init(struct window *);
void window_more_free(struct window *); void window_more_free(struct window *);
void window_more_resize(struct window *, u_int, u_int); void window_more_resize(struct window *, u_int, u_int);
void window_more_key(struct window *, int); void window_more_key(struct window *, struct client *, int);
void window_more_redraw_screen(struct window *); void window_more_redraw_screen(struct window *);
void window_more_write_line( void window_more_write_line(
@ -123,7 +123,7 @@ window_more_resize(struct window *w, u_int sx, u_int sy)
} }
void void
window_more_key(struct window *w, int key) window_more_key(struct window *w, unused struct client *c, int key)
{ {
struct window_more_mode_data *data = w->modedata; struct window_more_mode_data *data = w->modedata;
struct screen *s = &data->screen; struct screen *s = &data->screen;

View File

@ -1,4 +1,4 @@
/* $Id: window-scroll.c,v 1.18 2008-06-03 21:42:37 nicm Exp $ */ /* $Id: window-scroll.c,v 1.19 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -25,7 +25,7 @@
struct screen *window_scroll_init(struct window *); struct screen *window_scroll_init(struct window *);
void window_scroll_free(struct window *); void window_scroll_free(struct window *);
void window_scroll_resize(struct window *, u_int, u_int); void window_scroll_resize(struct window *, u_int, u_int);
void window_scroll_key(struct window *, int); void window_scroll_key(struct window *, struct client *, int);
void window_scroll_redraw_screen(struct window *); void window_scroll_redraw_screen(struct window *);
void window_scroll_write_line( void window_scroll_write_line(
@ -97,7 +97,7 @@ window_scroll_resize(struct window *w, u_int sx, u_int sy)
} }
void void
window_scroll_key(struct window *w, int key) window_scroll_key(struct window *w, unused struct client *c, int key)
{ {
struct window_scroll_mode_data *data = w->modedata; struct window_scroll_mode_data *data = w->modedata;
struct screen *s = &data->screen; struct screen *s = &data->screen;

View File

@ -1,4 +1,4 @@
/* $Id: window.c,v 1.44 2008-06-18 22:21:51 nicm Exp $ */ /* $Id: window.c,v 1.45 2008-06-20 17:31:48 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -323,10 +323,10 @@ window_parse(struct window *w)
} }
void void
window_key(struct window *w, int key) window_key(struct window *w, struct client *c, int key)
{ {
if (w->mode != NULL) if (w->mode != NULL)
w->mode->key(w, key); w->mode->key(w, c, key);
else else
input_key(w, key); input_key(w, key);
} }