O_NERD := 0 # support icons-nerdfont
O_QSORT := 0 # use Alexey Tourbin's QSORT implementation
O_BENCH := 0 # benchmark mode (stops at first user input)
+O_NOSSN := 0 # enable session support
# convert targets to flags for backwards compatibility
ifneq ($(filter debug,$(MAKECMDGOALS)),)
CPPFLAGS += -DBENCH
endif
+ifeq ($(O_NOSSN),1)
+ CPPFLAGS += -DNOSSN
+endif
+
ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
/* Macro definitions */
#define VERSION "3.4"
#define GENERAL_INFO "BSD 2-Clause\nhttps://github.com/jarun/nnn"
+
+#ifndef NOSSN
#define SESSIONS_VERSION 1
+#endif
#ifndef S_BLKSIZE
#define S_BLKSIZE 512 /* S_BLKSIZE is missing on Android NDK (Termux) */
uint color; /* Color code for directories */
} context;
+#ifndef NOSSN
typedef struct {
size_t ver;
size_t pathln[CTX_MAX];
size_t nameln[CTX_MAX];
size_t fltrln[CTX_MAX];
} session_header_t;
+#endif
/* GLOBALS */
*curcfg = tmpcfg;
}
+#ifndef NOSSN
static void save_session(bool last_session, int *presel)
{
int i;
return status;
}
+#endif
static uchar get_free_ctx(void)
{
xlines = LINES;
xcols = COLS;
+#ifndef NOSSN
/* setup first context */
if (!session || !load_session(session, &path, &lastdir, &lastname, FALSE)) {
+#else
+ (void)session;
+#endif
g_ctx[0].c_last[0] = '\0';
lastdir = g_ctx[0].c_last; /* last visited directory */
g_ctx[0].c_fltr[0] = g_ctx[0].c_fltr[1] = '\0';
g_ctx[0].c_cfg = cfg; /* current configuration */
+#ifndef NOSSN
}
+#endif
newpath[0] = rundir[0] = runfile[0] = '\0';
/* Dir removed, go to next entry */
copynextname(lastname);
goto begin;
+#ifndef NOSSN
case SEL_SESSIONS:
r = get_input(messages[MSG_SSN_OPTS]);
statusbar(path);
goto nochange;
+#endif
case SEL_EXPORT:
export_file_list();
cfg.filtermode ? presel = FILTER : statusbar(path);
break; // fallthrough
}
+#ifndef NOSSN
if (session && *session == '@' && !session[1])
save_session(TRUE, NULL);
+#endif
/* CD on Quit */
if (sel == SEL_QUITCD || getenv("NNN_TMPFILE")) {
" -Q no quit confirmation\n"
" -r use advcpmv patched cp, mv\n"
" -R no rollover at edges\n"
+#ifndef NOSSN
" -s name load session by name\n"
" -S persistent session\n"
+#endif
" -t secs timeout to lock\n"
" -T key sort order [a/d/e/r/s/t/v]\n"
" -u use selection (no prompt)\n"
case 'R':
cfg.rollover = 0;
break;
+#ifndef NOSSN
case 's':
if (env_opts_id < 0)
session = optarg;
case 'S':
session = "@";
break;
+#endif
case 't':
if (env_opts_id < 0)
idletimeout = atoi(optarg);