Skip to content

Commit

Permalink
More explicit multi-click handling
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Mar 31, 2024
1 parent cfbd1d0 commit f24a190
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Quake/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static void Con_ApplyMouseSelection (void)
// and the current selection hasn't advanced towards the actual content (either left or right),
// then we nudge the starting point by one character so that the word adjacent to the initial click
// is always selected.
if (con_mouseclicks & 2)
if (con_mouseclicks == 2)
{
int boundary = IntSign (Con_TestWordBoundary (con_selection.begin.col, line, len));
int dir = IntSign (Con_OfsCompare (&con_selection.end, &con_selection.begin));
Expand All @@ -518,17 +518,16 @@ static void Con_ApplyMouseSelection (void)
if (len == 0 && Con_OfsCompare (&con_selection.begin, &con_selection.end) == 0)
return;

// For click counts >= 2, we alternate between selecting whole words and whole lines
// Odd number of clicks: select whole lines
if (con_mouseclicks & 1)
// Triple click: select whole lines
if (con_mouseclicks >= 3)
{
con_selection.begin.col = 0;
con_selection.end.col = 0;
con_selection.end.line = q_min (con_selection.end.line, con_current) + 1;
return;
}

// Even number of clicks: select whole words
// Double click: select whole words

// Move begin marker to the first word boundary to its left
while (!Con_TestWordBoundary (con_selection.begin.col, line, len))
Expand Down Expand Up @@ -564,6 +563,9 @@ static void Con_SetMouseState (conmouse_t state)
con_mouseclicks = 1;
else
con_mouseclicks++;
// For click counts >= 2, we alternate between selecting whole words (2) and whole lines (3)
if (con_mouseclicks == 4)
con_mouseclicks = 2;
con_mouseclickdelay = 0.0;
con_mouseselection.begin = con_mouseselection.end = pos;
Con_ApplyMouseSelection ();
Expand Down

0 comments on commit f24a190

Please sign in to comment.