From 25157592df99f779712f89c2678e6520c5c34128 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sat, 17 Apr 2021 13:08:34 +0530 Subject: [PATCH] make option NOX11: disable notis, sel to clipboard sync, xterm title --- Makefile | 5 +++++ misc/haiku/Makefile | 5 +++++ src/nnn.c | 16 ++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/Makefile b/Makefile index 49b4b0a9..cd3fe9f6 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ O_BENCH := 0 # benchmark mode (stops at first user input) O_NOSSN := 0 # enable session support O_NOUG := 0 # disable user, group name in status bar O_CKBOARD := 0 # use checker board (stipple) in detail mode +O_NOX11 := 0 # disable X11 integration # convert targets to flags for backwards compatibility ifneq ($(filter debug,$(MAKECMDGOALS)),) @@ -105,6 +106,10 @@ ifeq ($(strip $(O_CKBOARD)),1) CPPFLAGS += -DCKBOARD endif +ifeq ($(strip $(O_NOX11)),1) + CPPFLAGS += -DNOX11 +endif + ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1) CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw) LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw) diff --git a/misc/haiku/Makefile b/misc/haiku/Makefile index b9b0dbf4..4d3adc48 100644 --- a/misc/haiku/Makefile +++ b/misc/haiku/Makefile @@ -24,6 +24,7 @@ O_BENCH := 0 # benchmark mode (stops at first user input) O_NOSSN := 0 # enable session support O_NOUG := 0 # disable user, group name in status bar O_CKBOARD := 0 # use checker board (stipple) in detail mode +O_NOX11 := 0 # disable X11 integration # convert targets to flags for backwards compatibility ifneq ($(filter debug,$(MAKECMDGOALS)),) @@ -104,6 +105,10 @@ ifeq ($(strip $(O_CKBOARD)),1) CPPFLAGS += -DCKBOARD endif +ifeq ($(strip $(O_NOX11)),1) + CPPFLAGS += -DNOX11 +endif + ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1) CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw) LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw) diff --git a/src/nnn.c b/src/nnn.c index 16258ccc..250661f4 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -5914,6 +5914,7 @@ begin: setdirwatch(); } +#ifndef NOX11 if (cfg.x11) { /* Set terminal window title */ r = set_tilde_in_path(path); @@ -5924,6 +5925,7 @@ begin: if (r) reset_tilde_in_path(path); } +#endif if (g_state.selmode && lastdir[0]) lastappendpos = selbufpos; @@ -6579,8 +6581,10 @@ nochange: writesel(NULL, 0); } +#ifndef NOX11 if (cfg.x11) plugscript(utils[UTIL_CBCP], F_NOWAIT | F_NOTRACE); +#endif if (!nselected) unlink(selpath); @@ -6673,8 +6677,10 @@ nochange: writesel(pselbuf, selbufpos - 1); /* Truncate NULL from end */ } +#ifndef NOX11 if (cfg.x11) plugscript(utils[UTIL_CBCP], F_NOWAIT | F_NOTRACE); +#endif continue; case SEL_SELEDIT: r = editselection(); @@ -6682,8 +6688,10 @@ nochange: r = !r ? MSG_0_SELECTED : MSG_FAILED; printwait(messages[r], &presel); } else { +#ifndef NOX11 if (cfg.x11) plugscript(utils[UTIL_CBCP], F_NOWAIT | F_NOTRACE); +#endif cfg.filtermode ? presel = FILTER : statusbar(path); } goto nochange; @@ -6730,9 +6738,11 @@ nochange: presel = FILTER; clearfilter(); +#ifndef NOX11 /* Show notification on operation complete */ if (cfg.x11) plugscript(utils[UTIL_NTFY], F_NOWAIT | F_NOTRACE); +#endif if (newpath[0] && !access(newpath, F_OK)) xstrsncpy(lastname, xbasename(newpath), NAME_MAX+1); @@ -7405,7 +7415,9 @@ static void usage(void) #endif " -V show version\n" " -w place HW cursor on hovered\n" +#ifndef NOX11 " -x notis, sel to clipboard, xterm title\n" +#endif " -h show help\n\n" "v%s\n%s\n", __func__, VERSION, GENERAL_INFO); } @@ -7512,10 +7524,12 @@ static bool set_tmp_path(void) static void cleanup(void) { +#ifndef NOX11 if (cfg.x11) { printf("\033[23;0t"); /* reset terminal window title */ fflush(stdout); } +#endif free(selpath); free(plgpath); free(cfgpath); @@ -7931,11 +7945,13 @@ int main(int argc, char *argv[]) } #endif +#ifndef NOX11 if (cfg.x11) { /* Save terminal window title */ printf("\033[22;0t"); fflush(stdout); } +#endif #ifndef NOMOUSE if (!initcurses(&mask))