Compare commits
4 Commits
98c8dc5b7d
...
e60ffeeb20
Author | SHA1 | Date | |
---|---|---|---|
e60ffeeb20 | |||
9a2f6ab5cf | |||
0a66ae4d26 | |||
121d7850fe |
22
README.adoc
22
README.adoc
@ -89,10 +89,10 @@ bind -x '"\201": sdn-restore'
|
|||||||
bind '"\eo":"\200\C-m\201"'
|
bind '"\eo":"\200\C-m\201"'
|
||||||
....
|
....
|
||||||
|
|
||||||
Colors
|
Colours
|
||||||
------
|
-------
|
||||||
Here is an example of a '~/.config/sdn/look' file; the format is similar to
|
Here is an example of a '~/.config/sdn/look' file; the format is similar to
|
||||||
that of git, only named colors aren't supported:
|
that of git, only named colours aren't supported:
|
||||||
|
|
||||||
....
|
....
|
||||||
cursor 231 202
|
cursor 231 202
|
||||||
@ -101,7 +101,7 @@ cwd bold
|
|||||||
input
|
input
|
||||||
....
|
....
|
||||||
|
|
||||||
Filename colors are taken from the `LS_COLORS` environment variable.
|
Filename colours are taken from the `LS_COLORS` environment variable.
|
||||||
Run `dircolors` to get some defaults.
|
Run `dircolors` to get some defaults.
|
||||||
|
|
||||||
Bindings
|
Bindings
|
||||||
@ -115,6 +115,20 @@ normal l choose
|
|||||||
normal ? help
|
normal ? help
|
||||||
....
|
....
|
||||||
|
|
||||||
|
Helper programs
|
||||||
|
---------------
|
||||||
|
The F3 and F4 keys are normally bound to actions 'view' and 'edit', similarly to
|
||||||
|
Norton Commander and other orthodox file managers. The helper programs used
|
||||||
|
here may be changed by setting the PAGER and VISUAL (or EDITOR) environment
|
||||||
|
variables.
|
||||||
|
|
||||||
|
While it is mostly possible to get 'mcview' working using an invocation like
|
||||||
|
`PAGER='mcview -u' sdn`, beware that this helper cannot read files from its
|
||||||
|
standard input, nor does it enable overstrike processing by default (F9, could
|
||||||
|
be hacked around in 'mc.ext' by turning on the `nroff` switch for a custom file
|
||||||
|
extension, just without actually invoking 'nroff'), and thus it can't show the
|
||||||
|
program help. 'sdn' is currently optimised for 'less' as the pager.
|
||||||
|
|
||||||
Similar software
|
Similar software
|
||||||
----------------
|
----------------
|
||||||
* https://elvish.io/ is an entire shell with an integrated ranger-like file
|
* https://elvish.io/ is an entire shell with an integrated ranger-like file
|
||||||
|
15
sdn.cpp
15
sdn.cpp
@ -243,7 +243,8 @@ fun capitalize (const string &s) -> string {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Underlining for teletypes, also imitated in more(1) and less(1)
|
/// Underlining for teletypes (also called overstriking),
|
||||||
|
/// also imitated in more(1) and less(1)
|
||||||
fun underline (const string& s) -> string {
|
fun underline (const string& s) -> string {
|
||||||
string result;
|
string result;
|
||||||
for (auto c : s)
|
for (auto c : s)
|
||||||
@ -865,6 +866,12 @@ fun run_program (initializer_list<const char*> list, const string &filename) {
|
|||||||
if (WSTOPSIG (status) == SIGTSTP)
|
if (WSTOPSIG (status) == SIGTSTP)
|
||||||
kill (child, SIGCONT);
|
kill (child, SIGCONT);
|
||||||
tcsetpgrp (STDOUT_FILENO, getpgid (0));
|
tcsetpgrp (STDOUT_FILENO, getpgid (0));
|
||||||
|
|
||||||
|
if (WIFEXITED (status) && WEXITSTATUS (status)) {
|
||||||
|
printf ("Helper returned non-zero exit status %d. "
|
||||||
|
"Press Enter to continue.\n", WEXITSTATUS (status));
|
||||||
|
string dummy; getline (cin, dummy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh ();
|
refresh ();
|
||||||
@ -872,7 +879,9 @@ fun run_program (initializer_list<const char*> list, const string &filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun view (const string &filename) {
|
fun view (const string &filename) {
|
||||||
run_program ({(const char *) getenv ("PAGER"), "pager", "cat"}, filename);
|
// XXX: we cannot realistically detect that the pager hasn't made a pause
|
||||||
|
// at the end of the file, so we can't ensure all contents have been seen
|
||||||
|
run_program ({(const char *) getenv ("PAGER"), "less", "cat"}, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
fun edit (const string &filename) {
|
fun edit (const string &filename) {
|
||||||
@ -896,7 +905,7 @@ fun run_pager (FILE *contents) {
|
|||||||
dup2 (fileno (contents), STDIN_FILENO);
|
dup2 (fileno (contents), STDIN_FILENO);
|
||||||
|
|
||||||
// Behaviour copies man-db's man(1), similar to POSIX man(1)
|
// Behaviour copies man-db's man(1), similar to POSIX man(1)
|
||||||
for (auto pager : {(const char *) getenv ("PAGER"), "pager", "cat"})
|
for (auto pager : {(const char *) getenv ("PAGER"), "less", "cat"})
|
||||||
if (pager) execl ("/bin/sh", "/bin/sh", "-c", pager, NULL);
|
if (pager) execl ("/bin/sh", "/bin/sh", "-c", pager, NULL);
|
||||||
_exit (EXIT_FAILURE);
|
_exit (EXIT_FAILURE);
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user