mirror of
https://github.com/jarun/nnn.git
synced 2025-03-18 20:39:45 +00:00
refactor quitcd
This commit is contained in:
parent
602ec0e41b
commit
3dc1760630
1 changed files with 20 additions and 16 deletions
36
src/nnn.c
36
src/nnn.c
|
@ -1217,6 +1217,25 @@ static void archive_selection(const char *archive, const char *curpath)
|
||||||
spawn("sh", "-c", g_buf, curpath, F_NORMAL | F_SIGINT);
|
spawn("sh", "-c", g_buf, curpath, F_NORMAL | F_SIGINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool write_lastdir(const char *curpath)
|
||||||
|
{
|
||||||
|
char *tmp = getenv(env_cfg[NNN_TMPFILE]);
|
||||||
|
|
||||||
|
if (!tmp) {
|
||||||
|
printmsg("set NNN_TMPFILE");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *fp = fopen(tmp, "w");
|
||||||
|
|
||||||
|
if (fp) {
|
||||||
|
fprintf(fp, "cd \"%s\"", curpath);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns:
|
* Returns:
|
||||||
* FALSE - a message is shown
|
* FALSE - a message is shown
|
||||||
|
@ -3917,23 +3936,8 @@ nochange:
|
||||||
/* Picker mode: reset buffer or clear file */
|
/* Picker mode: reset buffer or clear file */
|
||||||
if (copybufpos)
|
if (copybufpos)
|
||||||
cfg.pickraw ? copybufpos = 0 : writecp(NULL, 0);
|
cfg.pickraw ? copybufpos = 0 : writecp(NULL, 0);
|
||||||
|
} else if (!write_lastdir(path))
|
||||||
dentfree(dents);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp = getenv(env_cfg[NNN_TMPFILE]);
|
|
||||||
if (!tmp) {
|
|
||||||
printmsg("set NNN_TMPFILE");
|
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
|
||||||
|
|
||||||
FILE *fp = fopen(tmp, "w");
|
|
||||||
|
|
||||||
if (fp) {
|
|
||||||
fprintf(fp, "cd \"%s\"", path);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
} // fallthrough
|
} // fallthrough
|
||||||
case SEL_QUITCTX:
|
case SEL_QUITCTX:
|
||||||
if (sel == SEL_QUITCTX) {
|
if (sel == SEL_QUITCTX) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue