diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2021-04-13 06:25:59 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2021-04-13 06:25:59 +0100 |
commit | c2048c5c65aea99f2b79290b87635cb1d90863a6 (patch) | |
tree | 8aafdf588893ccdd65c8db53f5188f83f020675b /grid-reader.c | |
parent | 46cbbe3d4566885b8ad4235598389936f63c2c01 (diff) | |
parent | bedf2bd4372c60a525c22e6309f329cfd0bd07bc (diff) | |
download | rtmux-c2048c5c65aea99f2b79290b87635cb1d90863a6.tar.gz rtmux-c2048c5c65aea99f2b79290b87635cb1d90863a6.tar.bz2 rtmux-c2048c5c65aea99f2b79290b87635cb1d90863a6.zip |
Merge branch 'master' into 3.2-rc
Diffstat (limited to 'grid-reader.c')
-rw-r--r-- | grid-reader.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/grid-reader.c b/grid-reader.c index ae2f4d2b..89fe90fb 100644 --- a/grid-reader.c +++ b/grid-reader.c @@ -71,7 +71,7 @@ grid_reader_cursor_right(struct grid_reader *gr, int wrap, int all) /* Move cursor back one position. */ void -grid_reader_cursor_left(struct grid_reader *gr) +grid_reader_cursor_left(struct grid_reader *gr, int wrap) { struct grid_cell gc; @@ -81,7 +81,9 @@ grid_reader_cursor_left(struct grid_reader *gr) break; gr->cx--; } - if (gr->cx == 0 && gr->cy > 0) { + if (gr->cx == 0 && gr->cy > 0 && + (wrap || + grid_get_line(gr->gd, gr->cy - 1)->flags & GRID_LINE_WRAPPED)) { grid_reader_cursor_up(gr); grid_reader_cursor_end_of_line(gr, 0, 0); } else if (gr->cx > 0) @@ -363,3 +365,25 @@ grid_reader_cursor_jump_back(struct grid_reader *gr, const struct utf8_data *jc) } return 0; } + +/* Jump back to the first non-blank character of the line. */ +void +grid_reader_cursor_back_to_indentation(struct grid_reader *gr) +{ + struct grid_cell gc; + u_int px, py, xx, yy; + + yy = gr->gd->hsize + gr->gd->sy - 1; + grid_reader_cursor_start_of_line(gr, 1); + + for (py = gr->cy; py <= yy; py++) { + xx = grid_line_length(gr->gd, py); + for (px = 0; px < xx; px++) { + grid_get_cell(gr->gd, px, py, &gc); + if (gc.data.size != 1 || *gc.data.data != ' ') + break; + } + if (~grid_get_line(gr->gd, py)->flags & GRID_LINE_WRAPPED) + break; + } +} |