mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Compile option O_NOMOUSE to disable mouse support
This commit is contained in:
parent
a0339adf84
commit
e664b2d29f
4
Makefile
4
Makefile
|
@ -47,6 +47,10 @@ ifeq ($(O_NOLOC),1)
|
||||||
CPPFLAGS += -DNOLOCALE
|
CPPFLAGS += -DNOLOCALE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(O_NOMOUSE),1)
|
||||||
|
CPPFLAGS += -DNOMOUSE
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
|
ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
|
||||||
CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
|
CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
|
||||||
LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
|
LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
|
||||||
|
|
33
src/nnn.c
33
src/nnn.c
|
@ -1377,6 +1377,10 @@ static bool initcurses(mmask_t *oldmask)
|
||||||
short i;
|
short i;
|
||||||
char *colors = xgetenv(env_cfg[NNN_COLORS], "4444");
|
char *colors = xgetenv(env_cfg[NNN_COLORS], "4444");
|
||||||
|
|
||||||
|
#ifdef NOMOUSE
|
||||||
|
(void) oldmask;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (cfg.picker) {
|
if (cfg.picker) {
|
||||||
if (!newterm(NULL, stderr, stdin)) {
|
if (!newterm(NULL, stderr, stdin)) {
|
||||||
fprintf(stderr, "newterm!\n");
|
fprintf(stderr, "newterm!\n");
|
||||||
|
@ -1393,12 +1397,14 @@ static bool initcurses(mmask_t *oldmask)
|
||||||
nonl();
|
nonl();
|
||||||
//intrflush(stdscr, FALSE);
|
//intrflush(stdscr, FALSE);
|
||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
|
#ifndef NOMOUSE
|
||||||
#if NCURSES_MOUSE_VERSION <= 1
|
#if NCURSES_MOUSE_VERSION <= 1
|
||||||
mousemask(BUTTON1_PRESSED | BUTTON1_DOUBLE_CLICKED, oldmask);
|
mousemask(BUTTON1_PRESSED | BUTTON1_DOUBLE_CLICKED, oldmask);
|
||||||
#else
|
#else
|
||||||
mousemask(BUTTON1_PRESSED | BUTTON4_PRESSED | BUTTON5_PRESSED, oldmask);
|
mousemask(BUTTON1_PRESSED | BUTTON4_PRESSED | BUTTON5_PRESSED, oldmask);
|
||||||
#endif
|
#endif
|
||||||
mouseinterval(0);
|
mouseinterval(0);
|
||||||
|
#endif
|
||||||
curs_set(FALSE); /* Hide cursor */
|
curs_set(FALSE); /* Hide cursor */
|
||||||
start_color();
|
start_color();
|
||||||
use_default_colors();
|
use_default_colors();
|
||||||
|
@ -2427,7 +2433,9 @@ static int filterentries(char *path, char *lastname)
|
||||||
|
|
||||||
showfilter(ln);
|
showfilter(ln);
|
||||||
continue;
|
continue;
|
||||||
|
#ifndef NOMOUSE
|
||||||
case KEY_MOUSE: // fallthrough
|
case KEY_MOUSE: // fallthrough
|
||||||
|
#endif
|
||||||
case 27: /* Exit filter mode on Escape */
|
case 27: /* Exit filter mode on Escape */
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -4836,11 +4844,16 @@ static bool browse(char *ipath, const char *session)
|
||||||
char *path, *lastdir, *lastname, *dir, *tmp, *mark = NULL;
|
char *path, *lastdir, *lastname, *dir, *tmp, *mark = NULL;
|
||||||
enum action sel;
|
enum action sel;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
MEVENT event;
|
|
||||||
struct timespec mousetimings[2] = {{.tv_sec = 0, .tv_nsec = 0}, {.tv_sec = 0, .tv_nsec = 0} };
|
|
||||||
int r = -1, fd, presel, selstartid = 0, selendid = 0;
|
int r = -1, fd, presel, selstartid = 0, selendid = 0;
|
||||||
const uchar opener_flags = (cfg.cliopener ? F_CLI : (F_NOTRACE | F_NOWAIT));
|
const uchar opener_flags = (cfg.cliopener ? F_CLI : (F_NOTRACE | F_NOWAIT));
|
||||||
bool currentmouse = 1, dir_changed = FALSE;
|
bool dir_changed = FALSE;
|
||||||
|
|
||||||
|
#ifndef NOMOUSE
|
||||||
|
MEVENT event;
|
||||||
|
struct timespec mousetimings[2] = {{.tv_sec = 0, .tv_nsec = 0}, {.tv_sec = 0, .tv_nsec = 0} };
|
||||||
|
bool currentmouse = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef DIR_LIMITED_SELECTION
|
#ifndef DIR_LIMITED_SELECTION
|
||||||
ino_t inode = 0;
|
ino_t inode = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -4962,6 +4975,7 @@ nochange:
|
||||||
presel = 0;
|
presel = 0;
|
||||||
|
|
||||||
switch (sel) {
|
switch (sel) {
|
||||||
|
#ifndef NOMOUSE
|
||||||
case SEL_CLICK:
|
case SEL_CLICK:
|
||||||
if (getmouse(&event) != OK)
|
if (getmouse(&event) != OK)
|
||||||
goto nochange;
|
goto nochange;
|
||||||
|
@ -4988,9 +5002,13 @@ nochange:
|
||||||
setdirwatch();
|
setdirwatch();
|
||||||
goto begin;
|
goto begin;
|
||||||
}
|
}
|
||||||
} // fallthrough
|
}
|
||||||
|
#endif
|
||||||
|
// fallthrough
|
||||||
case SEL_BACK:
|
case SEL_BACK:
|
||||||
|
#ifndef NOMOUSE
|
||||||
if (sel == SEL_BACK) {
|
if (sel == SEL_BACK) {
|
||||||
|
#endif
|
||||||
dir = visit_parent(path, newpath, &presel);
|
dir = visit_parent(path, newpath, &presel);
|
||||||
if (!dir)
|
if (!dir)
|
||||||
goto nochange;
|
goto nochange;
|
||||||
|
@ -5006,8 +5024,11 @@ nochange:
|
||||||
|
|
||||||
setdirwatch();
|
setdirwatch();
|
||||||
goto begin;
|
goto begin;
|
||||||
|
#ifndef NOMOUSE
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NOMOUSE
|
||||||
#if NCURSES_MOUSE_VERSION > 1
|
#if NCURSES_MOUSE_VERSION > 1
|
||||||
/* Scroll up */
|
/* Scroll up */
|
||||||
if (event.bstate == BUTTON4_PRESSED && ndents && (cfg.rollover || cur)) {
|
if (event.bstate == BUTTON4_PRESSED && ndents && (cfg.rollover || cur)) {
|
||||||
|
@ -5066,6 +5087,7 @@ nochange:
|
||||||
presel = FILTER;
|
presel = FILTER;
|
||||||
goto nochange; // fallthrough
|
goto nochange; // fallthrough
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
case SEL_NAV_IN: // fallthrough
|
case SEL_NAV_IN: // fallthrough
|
||||||
case SEL_GOIN:
|
case SEL_GOIN:
|
||||||
/* Cannot descend in empty directories */
|
/* Cannot descend in empty directories */
|
||||||
|
@ -6721,7 +6743,10 @@ int main(int argc, char *argv[])
|
||||||
return _FAILURE;
|
return _FAILURE;
|
||||||
|
|
||||||
opt = browse(initpath, session);
|
opt = browse(initpath, session);
|
||||||
|
|
||||||
|
#ifndef NOMOUSE
|
||||||
mousemask(mask, NULL);
|
mousemask(mask, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (g_listpath)
|
if (g_listpath)
|
||||||
spawn("rm -rf", initpath, NULL, NULL, F_SILENT);
|
spawn("rm -rf", initpath, NULL, NULL, F_SILENT);
|
||||||
|
|
|
@ -96,7 +96,9 @@ enum action {
|
||||||
SEL_QUITCD,
|
SEL_QUITCD,
|
||||||
SEL_QUIT,
|
SEL_QUIT,
|
||||||
SEL_QUITFAIL,
|
SEL_QUITFAIL,
|
||||||
|
#ifndef NOMOUSE
|
||||||
SEL_CLICK,
|
SEL_CLICK,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Associate a pressed key to an action */
|
/* Associate a pressed key to an action */
|
||||||
|
@ -245,5 +247,7 @@ static struct key bindings[] = {
|
||||||
{ CONTROL('Q'), SEL_QUIT },
|
{ CONTROL('Q'), SEL_QUIT },
|
||||||
/* Quit with an error code */
|
/* Quit with an error code */
|
||||||
{ 'Q', SEL_QUITFAIL },
|
{ 'Q', SEL_QUITFAIL },
|
||||||
|
#ifndef NOMOUSE
|
||||||
{ KEY_MOUSE, SEL_CLICK },
|
{ KEY_MOUSE, SEL_CLICK },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue