mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +00:00
Get pager with arg
This commit is contained in:
parent
419f365e88
commit
ef361294db
26
src/nnn.c
26
src/nnn.c
|
@ -292,6 +292,7 @@ static uint idle;
|
||||||
static uint idletimeout, copybufpos, copybuflen;
|
static uint idletimeout, copybufpos, copybuflen;
|
||||||
static char *copier;
|
static char *copier;
|
||||||
static char *editor, *editor_arg;
|
static char *editor, *editor_arg;
|
||||||
|
static char *pager, *pager_arg;
|
||||||
static blkcnt_t ent_blocks;
|
static blkcnt_t ent_blocks;
|
||||||
static blkcnt_t dir_blocks;
|
static blkcnt_t dir_blocks;
|
||||||
static ulong num_files;
|
static ulong num_files;
|
||||||
|
@ -863,8 +864,11 @@ static char *xgetenv(const char *name, char *fallback)
|
||||||
return value && value[0] ? value : fallback;
|
return value && value[0] ? value : fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse a string to return program and argument */
|
/*
|
||||||
static int getprogarg(char *prog, char **arg)
|
* Parse a string to get program and argument
|
||||||
|
* NOTE: original string may be modified
|
||||||
|
*/
|
||||||
|
static void getprogarg(char *prog, char **arg)
|
||||||
{
|
{
|
||||||
char *argptr;
|
char *argptr;
|
||||||
|
|
||||||
|
@ -878,13 +882,13 @@ static int getprogarg(char *prog, char **arg)
|
||||||
|
|
||||||
/* Make sure there are no more args */
|
/* Make sure there are no more args */
|
||||||
while (*argptr) {
|
while (*argptr) {
|
||||||
if (*argptr == ' ')
|
if (*argptr == ' ') {
|
||||||
return -1;
|
fprintf(stderr, "Too many %s args\n", prog);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
++argptr;
|
++argptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if a dir exists, IS a dir and is readable */
|
/* Check if a dir exists, IS a dir and is readable */
|
||||||
|
@ -3597,11 +3601,13 @@ int main(int argc, char *argv[])
|
||||||
if (getuid() == 0 || getenv("NNN_SHOW_HIDDEN"))
|
if (getuid() == 0 || getenv("NNN_SHOW_HIDDEN"))
|
||||||
cfg.showhidden = 1;
|
cfg.showhidden = 1;
|
||||||
|
|
||||||
|
/* Get VISUAL/EDITOR */
|
||||||
editor = xgetenv("VISUAL", xgetenv("EDITOR", "vi"));
|
editor = xgetenv("VISUAL", xgetenv("EDITOR", "vi"));
|
||||||
if (getprogarg(editor, &editor_arg) < 0) {
|
getprogarg(editor, &editor_arg);
|
||||||
fprintf(stderr, "Too many editor args\n");
|
|
||||||
exit(1);
|
/* Get PAGER */
|
||||||
}
|
pager = xgetenv("PAGER", "less");
|
||||||
|
getprogarg(pager, &pager_arg);
|
||||||
|
|
||||||
/* Edit text in EDITOR, if opted */
|
/* Edit text in EDITOR, if opted */
|
||||||
if (getenv("NNN_USE_EDITOR"))
|
if (getenv("NNN_USE_EDITOR"))
|
||||||
|
|
|
@ -227,7 +227,7 @@ static struct key bindings[] = {
|
||||||
{ 'R', SEL_RUNSCRIPT, "sh", "SHELL" },
|
{ 'R', SEL_RUNSCRIPT, "sh", "SHELL" },
|
||||||
/* Run command with argument */
|
/* Run command with argument */
|
||||||
{ 'e', SEL_RUNARG, "", "VISUAL" },
|
{ 'e', SEL_RUNARG, "", "VISUAL" },
|
||||||
{ 'p', SEL_RUNARG, "less", "PAGER" },
|
{ 'p', SEL_RUNARG, "", "PAGER" },
|
||||||
/* Lock screen */
|
/* Lock screen */
|
||||||
{ 'L', SEL_LOCK, "", "" },
|
{ 'L', SEL_LOCK, "", "" },
|
||||||
/* Quit a context */
|
/* Quit a context */
|
||||||
|
|
Loading…
Reference in a new issue