summaryrefslogtreecommitdiffstats
path: root/status.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-05-14 19:36:56 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-05-14 19:36:56 +0000
commitcba338ac138331b42f2cfd741f4137329751555c (patch)
tree2362322d8caf29ff7ac6f9aecb0e6fd96d7d608b /status.c
parent8931f0018a25010c924f326d4902cff4f935d9e8 (diff)
Keys in status line (p in vi mode, M-y in emacs) to paste the first line of the upper paste buffer. Suggested by Dan Colish.
Diffstat (limited to 'status.c')
-rw-r--r--status.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/status.c b/status.c
index 1f60256b..6d8a7838 100644
--- a/status.c
+++ b/status.c
@@ -1,4 +1,4 @@
-/* $Id: status.c,v 1.79 2009-05-13 23:29:45 nicm Exp $ */
+/* $Id: status.c,v 1.80 2009-05-14 19:36:56 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -673,9 +673,9 @@ status_prompt_redraw(struct client *c)
void
status_prompt_key(struct client *c, int key)
{
- char *s, *first, *last;
- size_t size, n, off, idx;
- char word[64];
+ struct paste_buffer *pb;
+ char *s, *first, *last, word[64];
+ size_t size, n, off, idx;
size = strlen(c->prompt_buffer);
switch (mode_key_lookup(&c->prompt_mdata, key)) {
@@ -805,6 +805,28 @@ status_prompt_key(struct client *c, int key)
c->prompt_index = strlen(c->prompt_buffer);
c->flags |= CLIENT_STATUS;
break;
+ case MODEKEYCMD_PASTE:
+ if ((pb = paste_get_top(&c->session->buffers)) == NULL)
+ break;
+ if ((last = strchr(pb->data, '\n')) == NULL)
+ last = strchr(pb->data, '\0');
+ n = last - pb->data;
+
+ c->prompt_buffer = xrealloc(c->prompt_buffer, 1, size + n + 1);
+ if (c->prompt_index == size) {
+ memcpy(c->prompt_buffer + c->prompt_index, pb->data, n);
+ c->prompt_index += n;
+ c->prompt_buffer[c->prompt_index] = '\0';
+ } else {
+ memmove(c->prompt_buffer + c->prompt_index + n,
+ c->prompt_buffer + c->prompt_index,
+ size + 1 - c->prompt_index);
+ memcpy(c->prompt_buffer + c->prompt_index, pb->data, n);
+ c->prompt_index += n;
+ }
+
+ c->flags |= CLIENT_STATUS;
+ break;
case MODEKEYCMD_CHOOSE:
if (*c->prompt_buffer != '\0') {
status_prompt_add_history(c);