Browse Source

Fix #257: fix the logic for determining which file was clicked.

master
Bruce Hill Arun Prakash Jana 6 years ago
parent
commit
2297373306
No known key found for this signature in database GPG Key ID: A75979F35C080412
1 changed files with 8 additions and 5 deletions
  1. +8
    -5
      src/nnn.c

+ 8
- 5
src/nnn.c View File

@@ -109,6 +109,8 @@
#define LEN(x) (sizeof(x) / sizeof(*(x)))
#undef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#undef MAX
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ISODD(x) ((x) & 1)
#define ISBLANK(x) ((x) == ' ' || (x) == '\t')
#define TOUPPER(ch) \
@@ -3155,19 +3157,20 @@ nochange:

// Handle clicking on a file:
if (2 <= event.y && event.y < xlines - 2) {
r = event.y - 2;
// Get index of the first file listed on-screen:
r = MAX(0, MIN(cur-((xlines-4)>>1), ndents-(xlines-4)));
// Add the mouse click position to get the clicked file:
r += event.y - 2;

if (r >= ndents)
goto nochange;

if (ndents > (xlines - 4) && cur >= ((xlines - 4) >> 1))
cur -= ((xlines - 4) >> 1) - r;
else
cur = r;
cur = r;

// Single click just selects, double click also opens
if (event.bstate != BUTTON1_DOUBLE_CLICKED)
break;
// fallthrough to select the file
} else
goto nochange; // fallthrough
case SEL_NAV_IN: // fallthrough


||||||
x
 
000:0
Loading…
Cancel
Save