mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +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.
|
||||
|
||||
| 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 double | Select context or open file/directory |
|
||||
| Middle single | Visit parent directory |
|
||||
|
||||
##### Leader key
|
||||
|
||||
|
|
77
src/nnn.c
77
src/nnn.c
|
@ -912,10 +912,9 @@ static bool initcurses(void)
|
|||
//intrflush(stdscr, FALSE);
|
||||
keypad(stdscr, TRUE);
|
||||
#if NCURSES_MOUSE_VERSION <= 1
|
||||
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON2_CLICKED, NULL);
|
||||
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED, NULL);
|
||||
#else
|
||||
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON2_CLICKED
|
||||
| BUTTON4_PRESSED | BUTTON5_PRESSED, NULL);
|
||||
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON4_PRESSED | BUTTON5_PRESSED, NULL);
|
||||
#endif
|
||||
mouseinterval(400);
|
||||
curs_set(FALSE); /* Hide cursor */
|
||||
|
@ -3341,9 +3340,28 @@ nochange:
|
|||
if (getmouse(&event) != OK)
|
||||
goto nochange; // fallthrough
|
||||
case SEL_BACK:
|
||||
// Handle right click to go to parent
|
||||
if ((sel == SEL_BACK)
|
||||
|| (sel == SEL_CLICK && event.bstate == BUTTON2_CLICKED)) {
|
||||
/* Handle clicking on a context at the top */
|
||||
if (sel == SEL_CLICK && event.bstate == BUTTON1_CLICKED && event.y == 0) {
|
||||
/* 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);
|
||||
if (!dir)
|
||||
goto nochange;
|
||||
|
@ -3361,45 +3379,20 @@ nochange:
|
|||
}
|
||||
|
||||
#if NCURSES_MOUSE_VERSION > 1
|
||||
if (event.bstate == BUTTON4_PRESSED || event.bstate == BUTTON5_PRESSED)
|
||||
{
|
||||
/* Scroll up */
|
||||
if (event.bstate == BUTTON4_PRESSED && ndents) {
|
||||
move_cursor((cur + ndents - 1) % ndents, 0);
|
||||
break;
|
||||
}
|
||||
/* Scroll up */
|
||||
if (event.bstate == BUTTON4_PRESSED && ndents) {
|
||||
move_cursor((cur + ndents - 1) % ndents, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Scroll down */
|
||||
if (event.bstate == BUTTON5_PRESSED && ndents) {
|
||||
move_cursor((cur + 1) % ndents, 0);
|
||||
break;
|
||||
}
|
||||
/* Scroll down */
|
||||
if (event.bstate == BUTTON5_PRESSED && ndents) {
|
||||
move_cursor((cur + 1) % ndents, 0);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Handle clicking on a context at the top:
|
||||
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:
|
||||
/* Handle clicking on a file */
|
||||
if (2 <= event.y && event.y < xlines - 2) {
|
||||
r = curscroll + (event.y - 2);
|
||||
|
||||
|
@ -3408,7 +3401,7 @@ nochange:
|
|||
|
||||
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)
|
||||
break;
|
||||
} else
|
||||
|
|
Loading…
Reference in a new issue