From: NeilBrown Date: Fri, 18 Aug 2023 19:35:26 +0000 (+1000) Subject: lib-render: move tab/non-tab distinction out of find_xy() X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=0df598620f590b4f02c654504ea8dc52532537ae;p=edlib.git lib-render: move tab/non-tab distinction out of find_xy() The special handling of tabs is best kept in common code. So move more into do_measure(). Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 128dbf71..669bd549 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -10,9 +10,9 @@ the file. ### Triage -- [ ] tabs can wrap around a newline - with part of tab at end of one +- [X] tabs can wrap around a newline - with part of tab at end of one line and part at start of the next. Do I want that? do_measure() - decides. + decides. YES. - [X] in xcb, find-file draws result a pixel high, then moves done when cursor moves - [ ] favourites... I want some favourite documents that are easy to diff --git a/lib-renderline.c b/lib-renderline.c index 7dad2bdb..ef506a3e 100644 --- a/lib-renderline.c +++ b/lib-renderline.c @@ -481,6 +481,13 @@ static inline struct call_return do_measure(struct pane *p safe, cr.i >= len) /* All fits in maxwidth */ cr.ret = 2; + /* Report position in rd->line */ + if (str == tb) { + cr.s = rd->line + ri->start; + if (splitpos + cr.i >= ri->tab_cols) + cr.s += 1; + } else + cr.s = str + cr.i; return cr; } @@ -968,12 +975,8 @@ static int find_xy(struct pane *p safe, struct pane *focus safe, ri->y + rd->line_height * splitpos > y && xyattr) *xyattr = ri->attr; - if (rd->line[ri->start] == '\t') - /* do_measure reports how many spaces, we don't care */ - /* FIXME but should do_measure report that? Do I *want* - * a tab to wrap around a newline?? - */ - cr.i = 0; + if (cr.s) + return cr.s - rd->line; return start + cr.i; }