]> Sergey Matveev's repositories - nnn.git/commitdiff
Compile option O_NOMOUSE to disable mouse support
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 14 Feb 2020 02:51:30 +0000 (08:21 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 14 Feb 2020 02:51:30 +0000 (08:21 +0530)
Makefile
src/nnn.c
src/nnn.h

index 6190823b306fc18f00eb9e1ebf4002e8842cf610..e4ed94ac00328e04107a6977af3881bd94abe09f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -47,6 +47,10 @@ ifeq ($(O_NOLOC),1)
        CPPFLAGS += -DNOLOCALE
 endif
 
+ifeq ($(O_NOMOUSE),1)
+       CPPFLAGS += -DNOMOUSE
+endif
+
 ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
        CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
        LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs   ncursesw)
index 431b0aba1d265aaeb115a55c05d4039752af31a0..1a858952b9057fca9a4c860769b9c2299ece657e 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1377,6 +1377,10 @@ static bool initcurses(mmask_t *oldmask)
        short i;
        char *colors = xgetenv(env_cfg[NNN_COLORS], "4444");
 
+#ifdef NOMOUSE
+       (void) oldmask;
+#endif
+
        if (cfg.picker) {
                if (!newterm(NULL, stderr, stdin)) {
                        fprintf(stderr, "newterm!\n");
@@ -1393,12 +1397,14 @@ static bool initcurses(mmask_t *oldmask)
        nonl();
        //intrflush(stdscr, FALSE);
        keypad(stdscr, TRUE);
+#ifndef NOMOUSE
 #if NCURSES_MOUSE_VERSION <= 1
        mousemask(BUTTON1_PRESSED | BUTTON1_DOUBLE_CLICKED, oldmask);
 #else
        mousemask(BUTTON1_PRESSED | BUTTON4_PRESSED | BUTTON5_PRESSED, oldmask);
 #endif
        mouseinterval(0);
+#endif
        curs_set(FALSE); /* Hide cursor */
        start_color();
        use_default_colors();
@@ -2427,7 +2433,9 @@ static int filterentries(char *path, char *lastname)
 
                        showfilter(ln);
                        continue;
+#ifndef NOMOUSE
                case KEY_MOUSE: // fallthrough
+#endif
                case 27: /* Exit filter mode on Escape */
                        goto end;
                }
@@ -4836,11 +4844,16 @@ static bool browse(char *ipath, const char *session)
        char *path, *lastdir, *lastname, *dir, *tmp, *mark = NULL;
        enum action sel;
        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;
        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
        ino_t inode = 0;
 #endif
@@ -4962,6 +4975,7 @@ nochange:
                        presel = 0;
 
                switch (sel) {
+#ifndef NOMOUSE
                case SEL_CLICK:
                        if (getmouse(&event) != OK)
                                goto nochange;
@@ -4988,9 +5002,13 @@ nochange:
                                        setdirwatch();
                                        goto begin;
                                }
-                       } // fallthrough
+                       }
+#endif
+                       // fallthrough
                case SEL_BACK:
+#ifndef NOMOUSE
                        if (sel == SEL_BACK) {
+#endif
                                dir = visit_parent(path, newpath, &presel);
                                if (!dir)
                                        goto nochange;
@@ -5006,8 +5024,11 @@ nochange:
 
                                setdirwatch();
                                goto begin;
+#ifndef NOMOUSE
                        }
+#endif
 
+#ifndef NOMOUSE
 #if NCURSES_MOUSE_VERSION > 1
                        /* Scroll up */
                        if (event.bstate == BUTTON4_PRESSED && ndents && (cfg.rollover || cur)) {
@@ -5066,6 +5087,7 @@ nochange:
                                        presel = FILTER;
                                goto nochange; // fallthrough
                        }
+#endif
                case SEL_NAV_IN: // fallthrough
                case SEL_GOIN:
                        /* Cannot descend in empty directories */
@@ -6721,7 +6743,10 @@ int main(int argc, char *argv[])
                return _FAILURE;
 
        opt = browse(initpath, session);
+
+#ifndef NOMOUSE
        mousemask(mask, NULL);
+#endif
 
        if (g_listpath)
                spawn("rm -rf", initpath, NULL, NULL, F_SILENT);
index 168b43badf1980fa22ae360b83e46ef59ea5897e..3763883605a52337cab4de12bbad2551dc8b8505 100644 (file)
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -96,7 +96,9 @@ enum action {
        SEL_QUITCD,
        SEL_QUIT,
        SEL_QUITFAIL,
+#ifndef NOMOUSE
        SEL_CLICK,
+#endif
 };
 
 /* Associate a pressed key to an action */
@@ -245,5 +247,7 @@ static struct key bindings[] = {
        { CONTROL('Q'),   SEL_QUIT },
        /* Quit with an error code */
        { 'Q',            SEL_QUITFAIL },
+#ifndef NOMOUSE
        { KEY_MOUSE,      SEL_CLICK },
+#endif
 };