From bc3ab273645602f7d39a021fff5d625b0d7583b2 Mon Sep 17 00:00:00 2001 From: kojima Date: Tue, 6 May 2003 03:36:21 +0000 Subject: [PATCH] patch from Vitaly Ovtchinnikov for double/triple-click selection in textfield --- WINGs/ChangeLog | 3 ++- WINGs/wtextfield.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/WINGs/ChangeLog b/WINGs/ChangeLog index 7f8d54d1..2263ecf8 100644 --- a/WINGs/ChangeLog +++ b/WINGs/ChangeLog @@ -58,7 +58,8 @@ Changes since wmaker 0.80.1: - Fixed small memory leak in the font panel code. - Fixed call to qsort in WMSortArray. - Fixed a memleak in the file panel. - +- Double/triple-click selection in text widgets (Vitaly Ovtchinnikov + ) Changes since wmaker 0.80.0: ............................ diff --git a/WINGs/wtextfield.c b/WINGs/wtextfield.c index 08fb61de..cd279959 100644 --- a/WINGs/wtextfield.c +++ b/WINGs/wtextfield.c @@ -1396,6 +1396,7 @@ handleTextFieldActionEvents(XEvent *event, void *data) TextField *tPtr = (TextField*)data; static int move = 0; static Time lastButtonReleasedEvent = 0; + static Time lastButtonReleasedEvent2 = 0; Display *dpy = event->xany.display; CHECK_CLASS(data, WC_TextField); @@ -1554,8 +1555,30 @@ handleTextFieldActionEvents(XEvent *event, void *data) if (!tPtr->flags.secure && event->xbutton.time - lastButtonReleasedEvent <= WINGsConfiguration.doubleClickDelay) { - tPtr->selection.position = 0; - tPtr->selection.count = tPtr->textLen; + + if (event->xbutton.time - lastButtonReleasedEvent2 <= 2*WINGsConfiguration.doubleClickDelay) { + tPtr->selection.position = 0; + tPtr->selection.count = tPtr->textLen; + } else { + int pos, cnt; + char *txt; + pos = tPtr->selection.position; + cnt = tPtr->selection.count; + txt = tPtr->text; + while(pos >= 0) { + if (txt[pos] == ' ' || txt[pos] == '\t') break; + pos--; + } + pos++; + + while(pos + cnt < tPtr->textLen) { + if (txt[pos + cnt] == ' ' || txt[pos + cnt] == '\t') + break; + cnt++; + } + tPtr->selection.position = pos; + tPtr->selection.count = cnt; + } paintTextField(tPtr); if (!tPtr->flags.ownsSelection) { @@ -1574,6 +1597,7 @@ handleTextFieldActionEvents(XEvent *event, void *data) &selectionHandler, NULL); } + lastButtonReleasedEvent2 = lastButtonReleasedEvent; lastButtonReleasedEvent = event->xbutton.time; break; -- 2.11.4.GIT