Browse Source

make option O_NOSSN to compile out session

master
Arun Prakash Jana 4 years ago
parent
commit
faddaa5c3a
No known key found for this signature in database GPG Key ID: A75979F35C080412
2 changed files with 26 additions and 0 deletions
  1. +5
    -0
      Makefile
  2. +21
    -0
      src/nnn.c

+ 5
- 0
Makefile View File

@@ -23,6 +23,7 @@ O_ICONS := 0 # support icons-in-terminal
O_NERD := 0 # support icons-nerdfont O_NERD := 0 # support icons-nerdfont
O_QSORT := 0 # use Alexey Tourbin's QSORT implementation O_QSORT := 0 # use Alexey Tourbin's QSORT implementation
O_BENCH := 0 # benchmark mode (stops at first user input) O_BENCH := 0 # benchmark mode (stops at first user input)
O_NOSSN := 0 # enable session support


# convert targets to flags for backwards compatibility # convert targets to flags for backwards compatibility
ifneq ($(filter debug,$(MAKECMDGOALS)),) ifneq ($(filter debug,$(MAKECMDGOALS)),)
@@ -90,6 +91,10 @@ ifeq ($(O_BENCH),1)
CPPFLAGS += -DBENCH CPPFLAGS += -DBENCH
endif endif


ifeq ($(O_NOSSN),1)
CPPFLAGS += -DNOSSN
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)


+ 21
- 0
src/nnn.c View File

@@ -124,7 +124,10 @@
/* Macro definitions */ /* Macro definitions */
#define VERSION "3.4" #define VERSION "3.4"
#define GENERAL_INFO "BSD 2-Clause\nhttps://github.com/jarun/nnn" #define GENERAL_INFO "BSD 2-Clause\nhttps://github.com/jarun/nnn"

#ifndef NOSSN
#define SESSIONS_VERSION 1 #define SESSIONS_VERSION 1
#endif


#ifndef S_BLKSIZE #ifndef S_BLKSIZE
#define S_BLKSIZE 512 /* S_BLKSIZE is missing on Android NDK (Termux) */ #define S_BLKSIZE 512 /* S_BLKSIZE is missing on Android NDK (Termux) */
@@ -335,6 +338,7 @@ typedef struct {
uint color; /* Color code for directories */ uint color; /* Color code for directories */
} context; } context;


#ifndef NOSSN
typedef struct { typedef struct {
size_t ver; size_t ver;
size_t pathln[CTX_MAX]; size_t pathln[CTX_MAX];
@@ -342,6 +346,7 @@ typedef struct {
size_t nameln[CTX_MAX]; size_t nameln[CTX_MAX];
size_t fltrln[CTX_MAX]; size_t fltrln[CTX_MAX];
} session_header_t; } session_header_t;
#endif


/* GLOBALS */ /* GLOBALS */


@@ -3835,6 +3840,7 @@ static void savecurctx(settings *curcfg, char *path, char *curname, int r /* nex
*curcfg = tmpcfg; *curcfg = tmpcfg;
} }


#ifndef NOSSN
static void save_session(bool last_session, int *presel) static void save_session(bool last_session, int *presel)
{ {
int i; int i;
@@ -3970,6 +3976,7 @@ END:


return status; return status;
} }
#endif


static uchar get_free_ctx(void) static uchar get_free_ctx(void)
{ {
@@ -5772,8 +5779,12 @@ static bool browse(char *ipath, const char *session, int pkey)
xlines = LINES; xlines = LINES;
xcols = COLS; xcols = COLS;


#ifndef NOSSN
/* setup first context */ /* setup first context */
if (!session || !load_session(session, &path, &lastdir, &lastname, FALSE)) { if (!session || !load_session(session, &path, &lastdir, &lastname, FALSE)) {
#else
(void)session;
#endif
g_ctx[0].c_last[0] = '\0'; g_ctx[0].c_last[0] = '\0';
lastdir = g_ctx[0].c_last; /* last visited directory */ lastdir = g_ctx[0].c_last; /* last visited directory */


@@ -5790,7 +5801,9 @@ static bool browse(char *ipath, const char *session, int pkey)


g_ctx[0].c_fltr[0] = g_ctx[0].c_fltr[1] = '\0'; g_ctx[0].c_fltr[0] = g_ctx[0].c_fltr[1] = '\0';
g_ctx[0].c_cfg = cfg; /* current configuration */ g_ctx[0].c_cfg = cfg; /* current configuration */
#ifndef NOSSN
} }
#endif


newpath[0] = rundir[0] = runfile[0] = '\0'; newpath[0] = rundir[0] = runfile[0] = '\0';


@@ -6919,6 +6932,7 @@ nochange:
/* Dir removed, go to next entry */ /* Dir removed, go to next entry */
copynextname(lastname); copynextname(lastname);
goto begin; goto begin;
#ifndef NOSSN
case SEL_SESSIONS: case SEL_SESSIONS:
r = get_input(messages[MSG_SSN_OPTS]); r = get_input(messages[MSG_SSN_OPTS]);


@@ -6933,6 +6947,7 @@ nochange:


statusbar(path); statusbar(path);
goto nochange; goto nochange;
#endif
case SEL_EXPORT: case SEL_EXPORT:
export_file_list(); export_file_list();
cfg.filtermode ? presel = FILTER : statusbar(path); cfg.filtermode ? presel = FILTER : statusbar(path);
@@ -6983,8 +6998,10 @@ nochange:
break; // fallthrough break; // fallthrough
} }


#ifndef NOSSN
if (session && *session == '@' && !session[1]) if (session && *session == '@' && !session[1])
save_session(TRUE, NULL); save_session(TRUE, NULL);
#endif


/* CD on Quit */ /* CD on Quit */
if (sel == SEL_QUITCD || getenv("NNN_TMPFILE")) { if (sel == SEL_QUITCD || getenv("NNN_TMPFILE")) {
@@ -7282,8 +7299,10 @@ static void usage(void)
" -Q no quit confirmation\n" " -Q no quit confirmation\n"
" -r use advcpmv patched cp, mv\n" " -r use advcpmv patched cp, mv\n"
" -R no rollover at edges\n" " -R no rollover at edges\n"
#ifndef NOSSN
" -s name load session by name\n" " -s name load session by name\n"
" -S persistent session\n" " -S persistent session\n"
#endif
" -t secs timeout to lock\n" " -t secs timeout to lock\n"
" -T key sort order [a/d/e/r/s/t/v]\n" " -T key sort order [a/d/e/r/s/t/v]\n"
" -u use selection (no prompt)\n" " -u use selection (no prompt)\n"
@@ -7533,6 +7552,7 @@ int main(int argc, char *argv[])
case 'R': case 'R':
cfg.rollover = 0; cfg.rollover = 0;
break; break;
#ifndef NOSSN
case 's': case 's':
if (env_opts_id < 0) if (env_opts_id < 0)
session = optarg; session = optarg;
@@ -7540,6 +7560,7 @@ int main(int argc, char *argv[])
case 'S': case 'S':
session = "@"; session = "@";
break; break;
#endif
case 't': case 't':
if (env_opts_id < 0) if (env_opts_id < 0)
idletimeout = atoi(optarg); idletimeout = atoi(optarg);


Loading…
Cancel
Save