summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/grid.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/grid.c')
-rw-r--r--usr.bin/tmux/grid.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c
index 451df187b77..6d070c9907e 100644
--- a/usr.bin/tmux/grid.c
+++ b/usr.bin/tmux/grid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid.c,v 1.94 2019/05/13 20:10:23 nicm Exp $ */
+/* $OpenBSD: grid.c,v 1.95 2019/05/26 17:34:45 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1350,3 +1350,22 @@ grid_unwrap_position(struct grid *gd, u_int *px, u_int *py, u_int wx, u_int wy)
*px = wx;
*py = yy;
}
+
+/* Get length of line. */
+u_int
+grid_line_length(struct grid *gd, u_int py)
+{
+ struct grid_cell gc;
+ u_int px;
+
+ px = grid_get_line(gd, py)->cellsize;
+ if (px > gd->sx)
+ px = gd->sx;
+ while (px > 0) {
+ grid_get_cell(gd, px - 1, py, &gc);
+ if (gc.data.size != 1 || *gc.data.data != ' ')
+ break;
+ px--;
+ }
+ return (px);
+}