summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2019-03-19 19:01:50 +0000
committernicm <nicm>2019-03-19 19:01:50 +0000
commit161b57869e12a0fd8a95965e98b4866f6055f860 (patch)
treea153c5f9e1864f2cbb8802544606eb7cc2e3bf2f
parentb24c9e34a9581773de7bc67da81ac25da97dcd1a (diff)
Add a cursor_character format.
-rw-r--r--format.c17
-rw-r--r--tmux.11
2 files changed, 18 insertions, 0 deletions
diff --git a/format.c b/format.c
index 30391da1..8fe0b55b 100644
--- a/format.c
+++ b/format.c
@@ -685,6 +685,21 @@ format_cb_pane_in_mode(struct format_tree *ft, struct format_entry *fe)
xasprintf(&fe->value, "%u", n);
}
+/* Callback for cursor_character. */
+static void
+format_cb_cursor_character(struct format_tree *ft, struct format_entry *fe)
+{
+ struct window_pane *wp = ft->wp;
+ struct grid_cell gc;
+
+ if (wp == NULL)
+ return;
+
+ grid_view_get_cell(wp->base.grid, wp->base.cx, wp->base.cy, &gc);
+ if (~gc.flags & GRID_FLAG_PADDING)
+ xasprintf(&fe->value, "%.*s", (int)gc.data.size, gc.data.data);
+}
+
/* Merge a format tree. */
static void
format_merge(struct format_tree *ft, struct format_tree *from)
@@ -2031,6 +2046,8 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
format_add(ft, "cursor_x", "%u", wp->base.cx);
format_add(ft, "cursor_y", "%u", wp->base.cy);
+ format_add_cb(ft, "cursor_character", format_cb_cursor_character);
+
format_add(ft, "scroll_region_upper", "%u", wp->base.rupper);
format_add(ft, "scroll_region_lower", "%u", wp->base.rlower);
diff --git a/tmux.1 b/tmux.1
index 1ff00bba..8d8c3c00 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3744,6 +3744,7 @@ The following variables are available, where appropriate:
.It Li "command_list_alias" Ta "" Ta "Command alias if listing commands"
.It Li "command_list_usage" Ta "" Ta "Command usage if listing commands"
.It Li "cursor_flag" Ta "" Ta "Pane cursor flag"
+.It Li "cursor_character" Ta "Character at cursor in pane"
.It Li "cursor_x" Ta "" Ta "Cursor X position in pane"
.It Li "cursor_y" Ta "" Ta "Cursor Y position in pane"
.It Li "history_bytes" Ta "" Ta "Number of bytes in window history"