aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-05-09 04:11:29 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-05-22 08:44:19 +0530
commit30aaa12e6fe535518e1d0b71e5fc8b6bc66bf3b4 (patch)
treee8a81469798c5566e3dc82ea7b197e3cb90c71b2
parentb093d98a6e778aab99a52447bd7a011e14cc7d25 (diff)
downloadnnn-30aaa12e6fe535518e1d0b71e5fc8b6bc66bf3b4.tar.gz
Fix #257
-rw-r--r--src/nnn.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/nnn.c b/src/nnn.c
index f580159..70fe67c 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3135,14 +3135,16 @@ nochange:
goto begin;
case SEL_CLICK:
if (getmouse(&event) != OK)
- break;
+ goto nochange;
// Handle clicking on a context at the top:
if (event.y == 0) {
// Get context from: "[1 2 3 4]..."
r = event.x/2;
- if (event.x != 1 + 2*r)
- break; // The character after the context number
+
+ if (event.x != 1 + (r << 1))
+ goto nochange; // The character after the context number
+
if (0 <= r && r < CTX_MAX && r != cfg.curctx) {
savecurctx(&cfg, path, dents[cur].name, r);
@@ -3154,25 +3156,26 @@ nochange:
setdirwatch();
goto begin;
}
- break;
+ goto nochange;
}
// Handle clicking on a file:
- if (2 <= event.y && event.y < LINES - 2) {
- r = 0;
- if (cur-(LINES-4)/2 > 0)
- r = cur-(LINES-4)/2;
- if (ndents >= LINES-4 && ndents - (LINES-4) < r)
- r = ndents - (LINES-4);
- r += event.y - 2;
+ if (2 <= event.y && event.y < xlines - 2) {
+ r = event.y - 2;
+
if (r >= ndents)
- break;
- cur = r;
+ goto nochange;
+
+ if (ndents > (xlines - 4) && cur >= ((xlines - 4) >> 1))
+ cur -= ((xlines - 4) >> 1) - r;
+ else
+ cur = r;
+
// Single click just selects, double click also opens
if (event.bstate != BUTTON1_DOUBLE_CLICKED)
- break; // fallthrough
+ break;
} else
- break;
+ goto nochange; // fallthrough
case SEL_NAV_IN: // fallthrough
case SEL_GOIN:
/* Cannot descend in empty directories */