summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/window-copy.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-03-20 17:59:41 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-03-20 17:59:41 +0000
commit89474c2744364bd20ca48e1b54bb5e070465cd28 (patch)
tree02328ee07c3b0a43287bd2136a93df264e298e81 /usr.bin/tmux/window-copy.c
parent83f6331ddc43df7d32a1b60448e00b6e02e446b5 (diff)
Make the mouse_word and mouse_line formats work in copy mode and enable
the default pane menu in copy mode.
Diffstat (limited to 'usr.bin/tmux/window-copy.c')
-rw-r--r--usr.bin/tmux/window-copy.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 30644086949..57317a432d7 100644
--- a/usr.bin/tmux/window-copy.c
+++ b/usr.bin/tmux/window-copy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-copy.c,v 1.255 2020/03/20 13:12:04 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.256 2020/03/20 17:59:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -596,10 +596,31 @@ window_copy_next_paragraph(struct window_mode_entry *wme)
window_copy_scroll_to(wme, ox, oy);
}
+char *
+window_copy_get_word(struct window_pane *wp, u_int x, u_int y)
+{
+ struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes);
+ struct window_copy_mode_data *data = wme->data;
+ struct grid *gd = data->screen.grid;
+
+ return (format_grid_word(gd, x, gd->hsize + y));
+}
+
+char *
+window_copy_get_line(struct window_pane *wp, u_int y)
+{
+ struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes);
+ struct window_copy_mode_data *data = wme->data;
+ struct grid *gd = data->screen.grid;
+
+ return (format_grid_line(gd, gd->hsize + y));
+}
+
static void
window_copy_formats(struct window_mode_entry *wme, struct format_tree *ft)
{
struct window_copy_mode_data *data = wme->data;
+ struct grid *gd = data->screen.grid;
char *s;
format_add(ft, "scroll_position", "%d", data->oy);
@@ -619,13 +640,13 @@ window_copy_formats(struct window_mode_entry *wme, struct format_tree *ft)
} else
format_add(ft, "selection_active", "%d", 0);
- s = format_grid_word(data->screen.grid, data->cx, data->cy);
+ s = format_grid_word(gd, data->cx, gd->hsize + data->cy);
if (s != NULL) {
format_add(ft, "copy_cursor_word", "%s", s);
free(s);
}
- s = format_grid_line(data->screen.grid, data->cy);
+ s = format_grid_line(gd, gd->hsize + data->cy);
if (s != NULL) {
format_add(ft, "copy_cursor_line", "%s", s);
free(s);