From 8fba540a1c4f2f9e52858b79c0ab985697bc0696 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 14 Dec 2014 17:24:30 -0500 Subject: [PATCH] Mostly fixed up the horizontal scrolling implementation in doselect(). --- wintable/new/select.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wintable/new/select.h b/wintable/new/select.h index c6f1c1d..58cd1f5 100644 --- a/wintable/new/select.h +++ b/wintable/new/select.h @@ -43,15 +43,16 @@ static void doselect(struct table *t, intptr_t row, intptr_t column) xpos += columnWidth(t, i); if (xpos < t->hscrollpos) hscrollto(t, xpos); - else while(1){break; + else { // if the full cell is not visible, scroll to the right just enough to make it fully visible (or as visible as possible) width = columnWidth(t, t->selectedColumn); clientWidth = client.right - client.left; - if (xpos + width < t->hscrollpos + clientWidth) + if (xpos + width > t->hscrollpos + clientWidth) // > because both sides deal with the first pixel outside // if the column is too wide, then just make it occupy the whole visible area (left-aligned) if (width > clientWidth) hscrollto(t, xpos); else + // TODO this formula is wrong hscrollby(t, clientWidth - width); }