mirror of
https://github.com/jarun/nnn.git
synced 2024-12-01 02:49:44 +00:00
Termux improvement: remap visit parent click
Visit parent is now left single click outside context nums on top row.
This commit is contained in:
parent
9b0cf4a2b9
commit
051a8b27c2
|
@ -264,10 +264,11 @@ Press <kbd>?</kbd> in `nnn` to see the list anytime.
|
||||||
Note: Help & settings, file details, media info and archive listing are shown in the PAGER. Use the PAGER-specific keys in these screens.
|
Note: Help & settings, file details, media info and archive listing are shown in the PAGER. Use the PAGER-specific keys in these screens.
|
||||||
|
|
||||||
| Mouse click | Function |
|
| Mouse click | Function |
|
||||||
|:---:| --- |
|
|---| --- |
|
||||||
|
| Left single on context number | Visit context |
|
||||||
|
| Left single on top row after context numbers | Visit parent |
|
||||||
| Left single | Select context or entry |
|
| Left single | Select context or entry |
|
||||||
| Left double | Select context or open file/directory |
|
| Left double | Select context or open file/directory |
|
||||||
| Middle single | Visit parent directory |
|
|
||||||
|
|
||||||
##### Leader key
|
##### Leader key
|
||||||
|
|
||||||
|
|
59
src/nnn.c
59
src/nnn.c
|
@ -912,10 +912,9 @@ static bool initcurses(void)
|
||||||
//intrflush(stdscr, FALSE);
|
//intrflush(stdscr, FALSE);
|
||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
#if NCURSES_MOUSE_VERSION <= 1
|
#if NCURSES_MOUSE_VERSION <= 1
|
||||||
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON2_CLICKED, NULL);
|
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED, NULL);
|
||||||
#else
|
#else
|
||||||
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON2_CLICKED
|
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON4_PRESSED | BUTTON5_PRESSED, NULL);
|
||||||
| BUTTON4_PRESSED | BUTTON5_PRESSED, NULL);
|
|
||||||
#endif
|
#endif
|
||||||
mouseinterval(400);
|
mouseinterval(400);
|
||||||
curs_set(FALSE); /* Hide cursor */
|
curs_set(FALSE); /* Hide cursor */
|
||||||
|
@ -3341,9 +3340,28 @@ nochange:
|
||||||
if (getmouse(&event) != OK)
|
if (getmouse(&event) != OK)
|
||||||
goto nochange; // fallthrough
|
goto nochange; // fallthrough
|
||||||
case SEL_BACK:
|
case SEL_BACK:
|
||||||
// Handle right click to go to parent
|
/* Handle clicking on a context at the top */
|
||||||
if ((sel == SEL_BACK)
|
if (sel == SEL_CLICK && event.bstate == BUTTON1_CLICKED && event.y == 0) {
|
||||||
|| (sel == SEL_CLICK && event.bstate == BUTTON2_CLICKED)) {
|
/* Get context from: "[1 2 3 4]..." */
|
||||||
|
r = event.x >> 1;
|
||||||
|
|
||||||
|
/* If clicked after contexts, go to parent */
|
||||||
|
if (r >= CTX_MAX)
|
||||||
|
sel = SEL_BACK;
|
||||||
|
else if (0 <= r && r < CTX_MAX && r != cfg.curctx) {
|
||||||
|
savecurctx(&cfg, path, dents[cur].name, r);
|
||||||
|
|
||||||
|
/* Reset the pointers */
|
||||||
|
path = g_ctx[r].c_path;
|
||||||
|
lastdir = g_ctx[r].c_last;
|
||||||
|
lastname = g_ctx[r].c_name;
|
||||||
|
|
||||||
|
setdirwatch();
|
||||||
|
goto begin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sel == SEL_BACK) {
|
||||||
dir = visit_parent(path, newpath, &presel);
|
dir = visit_parent(path, newpath, &presel);
|
||||||
if (!dir)
|
if (!dir)
|
||||||
goto nochange;
|
goto nochange;
|
||||||
|
@ -3361,8 +3379,6 @@ nochange:
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NCURSES_MOUSE_VERSION > 1
|
#if NCURSES_MOUSE_VERSION > 1
|
||||||
if (event.bstate == BUTTON4_PRESSED || event.bstate == BUTTON5_PRESSED)
|
|
||||||
{
|
|
||||||
/* Scroll up */
|
/* Scroll up */
|
||||||
if (event.bstate == BUTTON4_PRESSED && ndents) {
|
if (event.bstate == BUTTON4_PRESSED && ndents) {
|
||||||
move_cursor((cur + ndents - 1) % ndents, 0);
|
move_cursor((cur + ndents - 1) % ndents, 0);
|
||||||
|
@ -3374,32 +3390,9 @@ nochange:
|
||||||
move_cursor((cur + 1) % ndents, 0);
|
move_cursor((cur + 1) % ndents, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Handle clicking on a context at the top:
|
/* Handle clicking on a file */
|
||||||
if (event.y == 0) {
|
|
||||||
// Get context from: "[1 2 3 4]..."
|
|
||||||
r = event.x >> 1;
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
/* Reset the pointers */
|
|
||||||
path = g_ctx[r].c_path;
|
|
||||||
lastdir = g_ctx[r].c_last;
|
|
||||||
lastname = g_ctx[r].c_name;
|
|
||||||
|
|
||||||
setdirwatch();
|
|
||||||
goto begin;
|
|
||||||
}
|
|
||||||
goto nochange;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle clicking on a file:
|
|
||||||
if (2 <= event.y && event.y < xlines - 2) {
|
if (2 <= event.y && event.y < xlines - 2) {
|
||||||
r = curscroll + (event.y - 2);
|
r = curscroll + (event.y - 2);
|
||||||
|
|
||||||
|
@ -3408,7 +3401,7 @@ nochange:
|
||||||
|
|
||||||
move_cursor(r, 1);
|
move_cursor(r, 1);
|
||||||
|
|
||||||
// Single click just selects, double click also opens
|
/*Single click just selects, double click also opens */
|
||||||
if (event.bstate != BUTTON1_DOUBLE_CLICKED)
|
if (event.bstate != BUTTON1_DOUBLE_CLICKED)
|
||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in a new issue