From: NeilBrown Date: Fri, 25 Aug 2023 01:38:28 +0000 (+1000) Subject: lib-renderline: fix problems with finding position of 'click' location. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=623cbf4d7209d9e06f290bba187e42a8c9232758;p=edlib.git lib-renderline: fix problems with finding position of 'click' location. This broken menus and links etc. So add a test for menus in the spelling test. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 77edd718..f051ba3a 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -9,7 +9,7 @@ the file. ### Triage -- [ ] clicking on link is BROKEN +- [X] clicking on link is BROKEN - [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. YES. diff --git a/lib-renderline.c b/lib-renderline.c index 16dc0fca..5cbaa2a2 100644 --- a/lib-renderline.c +++ b/lib-renderline.c @@ -876,6 +876,7 @@ static int find_xy(struct pane *p safe, struct pane *focus safe, if (r->y <= y && r->x <= x) { ri = r; start = r->start; + splitpos = 0; } for (split = 0; split < r->split_cnt; split++) { if (r->y + (split + 1) * rd->line_height <= y && @@ -893,7 +894,7 @@ static int find_xy(struct pane *p safe, struct pane *focus safe, return start; cr = do_measure(p, ri, splitpos, -1, x - ri->x); if ((splitpos ? ri->wrap_x : ri->x ) + cr.x > x && - ri->y + rd->line_height * splitpos > y && + ri->y + rd->line_height * (1 + splitpos) > y && xyattr) *xyattr = ri->attr; if (cr.s) diff --git a/tests.d/02-spell b/tests.d/02-spell index ae414e32..701e7ea2 100644 --- a/tests.d/02-spell +++ b/tests.d/02-spell @@ -222,8 +222,18 @@ Key ":C-X" Display 80,30 9599A4BF3962C00266BB8CF8D9AB3088 59,24 Key ":C-S" Display 80,30 15D263B1D5B3FDF5F97D3428BAC8D27A 59,24 +Mouse ":Press-3" 26,19 +Display 80,30 6F5B8256777D5528183E96E329DEF02A 26,19 +Mouse ":Release-3" 28,22 +Display 80,30 27E164C7FF1F619A0449FFCBCD256DBB 59,24 +Mouse ":Press-3" 2,21 +Display 80,30 C863D1562DFABCF048E1488BC4179421 2,21 +Mouse ":Release-3" 5,22 +Display 80,30 27E164C7FF1F619A0449FFCBCD256DBB 59,24 +Display 80,30 7E7D27ABFCF26E6F9024BE8A73EE9EE9 59,24 Key ":C-X" -Display 80,30 4EEC8A848EC8816669FCC7D1F8E9717F 59,24 +Display 80,30 120A6A63790E9F0E123CFEC24BDBB033 59,24 Key ":C-C" -Display 80,30 6DC926582CA3B121E4CCEEAD1963B806 59,24 -Close 591 +Display 80,30 43E0643A1430614E6E43F15DE5008897 21,8 +Key "-q" +Close 680