dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit 68949cd1c8eb669563231180b6d96607f962387f
parent ab5777d8cf0f7362266d63271f3d5de41f96a70c
Author: Marc Andre Tanner <mat@brain-dump.org>
Date:   Mon,  7 Jan 2013 22:24:01 +0100

vt: handle search of multibyte characters

Signed-off-by: Marc Andre Tanner <mat@brain-dump.org>

Diffstat:
vt.c | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/vt.c b/vt.c @@ -1694,7 +1694,6 @@ static void copymode_search(Vt *t, int direction) Row *row = start_row, *matched_row = NULL; int matched_col = 0; - int end_col = direction > 0 ? b->cols - 1 : 0; int s_start = direction > 0 ? 0 : t->searchbuf_curs - 1; int s_end = direction > 0 ? t->searchbuf_curs - 1 : 0; int s = s_start; @@ -1703,7 +1702,7 @@ static void copymode_search(Vt *t, int direction) int col = direction > 0 ? 0 : b->cols - 1; if (row == start_row) col = start_col; - for (;;) { + for (; col >= 0 && col < b->cols; col += direction) { if (t->searchbuf[s] == row->cells[col].text) { if (s == s_start) { matched_row = row; @@ -1716,12 +1715,14 @@ static void copymode_search(Vt *t, int direction) return; } s += direction; + int width = wcwidth(t->searchbuf[s]); + if (width < 0) + width = 0; + else if (width >= 1) + width--; + col += direction > 0 ? width : -width; } else s = s_start; - - if (col == end_col) - break; - col += direction; } if ((row = buffer_next_row(b, row, direction)) == start_row)