Compare commits

..

No commits in common. "5451eba2a317600111cd47104101bbec34fc9e54" and "c07f557c1613c7b962c51206415db911090bdd0d" have entirely different histories.

2 changed files with 9 additions and 29 deletions

View File

@ -55,7 +55,7 @@ To start using this navigator, put the following in your '.zshrc':
---- ----
sdn-navigate () { sdn-navigate () {
# ... possibly zle-line-init # ... possibly zle-line-init
while eval "`sdn "$BUFFER" "$CURSOR"`"; do while eval "`sdn`"; do
[ -z "$cd" ] || cd "$cd" [ -z "$cd" ] || cd "$cd"
[ -z "$insert" ] || LBUFFER="$LBUFFER$insert " [ -z "$insert" ] || LBUFFER="$LBUFFER$insert "
[ -z "$helper" ] && break [ -z "$helper" ] && break
@ -74,9 +74,7 @@ To start using this navigator, put the following in your 'config.fish':
---- ----
function sdn-navigate function sdn-navigate
set --local IFS set --local IFS
set --local buffer (commandline) while eval (sdn | string replace -ar '^(.*?)=' 'set --$1 ')
set --local cursor (commandline --cursor)
while eval (sdn $buffer $cursor | string replace -ar '^(.*?)=' 'set --$1 ')
test -z "$cd" || cd "$cd" test -z "$cd" || cd "$cd"
test -z "$insert" || commandline --insert "$insert " test -z "$insert" || commandline --insert "$insert "
test -z "$helper" && break test -z "$helper" && break
@ -98,7 +96,7 @@ sdn-navigate () {
SDN_L=$READLINE_LINE SDN_P=$READLINE_POINT SDN_L=$READLINE_LINE SDN_P=$READLINE_POINT
READLINE_LINE= READLINE_LINE=
while eval "`sdn "$SDN_L" "$SDN_P"`"; do while eval "`sdn`"; do
[[ -z "$cd" ]] || cd "$cd" [[ -z "$cd" ]] || cd "$cd"
[[ -z "$insert" ]] || { [[ -z "$insert" ]] || {
SDN_L="${SDN_L:0:$SDN_P}$insert ${SDN_L:$SDN_P}" SDN_L="${SDN_L:0:$SDN_P}$insert ${SDN_L:$SDN_P}"
@ -131,7 +129,6 @@ cursor 231 202
bar 16 255 ul bar 16 255 ul
cwd bold cwd bold
input input
cmdline 145
.... ....
Filename colours are taken from the `LS_COLORS` environment variable. Filename colours are taken from the `LS_COLORS` environment variable.

29
sdn.cpp
View File

@ -495,7 +495,6 @@ struct level {
}; };
static struct { static struct {
ncstring cmdline; ///< Outer command line
string cwd; ///< Current working directory string cwd; ///< Current working directory
string start_dir; ///< Starting directory string start_dir; ///< Starting directory
vector<entry> entries; ///< Current directory entries vector<entry> entries; ///< Current directory entries
@ -526,10 +525,9 @@ static struct {
void (*editor_on_change) (); ///< Callback on editor change void (*editor_on_change) (); ///< Callback on editor change
void (*editor_on_confirm) (); ///< Callback on editor confirmation void (*editor_on_confirm) (); ///< Callback on editor confirmation
enum { AT_CURSOR, AT_BAR, AT_CWD, AT_INPUT, AT_CMDLINE, AT_COUNT }; enum { AT_CURSOR, AT_BAR, AT_CWD, AT_INPUT, AT_COUNT };
chtype attrs[AT_COUNT] = {A_REVERSE, 0, A_BOLD, 0, 0}; chtype attrs[AT_COUNT] = {A_REVERSE, 0, A_BOLD, 0};
const char *attr_names[AT_COUNT] = const char *attr_names[AT_COUNT] = {"cursor", "bar", "cwd", "input"};
{"cursor", "bar", "cwd", "input", "cmdline"};
map<int, chtype> ls_colors; ///< LS_COLORS decoded map<int, chtype> ls_colors; ///< LS_COLORS decoded
map<string, chtype> ls_exts; ///< LS_COLORS file extensions map<string, chtype> ls_exts; ///< LS_COLORS file extensions
@ -748,9 +746,6 @@ fun update () {
} else if (!g.message.empty ()) { } else if (!g.message.empty ()) {
move (LINES - 1, 0); move (LINES - 1, 0);
print (apply_attrs (g.message, 0), COLS); print (apply_attrs (g.message, 0), COLS);
} else if (!g.cmdline.empty ()) {
move (LINES - 1, 0);
print (g.cmdline, COLS);
} }
refresh (); refresh ();
@ -1357,20 +1352,6 @@ fun inotify_check () {
update (); update ();
} }
fun load_cmdline (int argc, char *argv[]) {
if (argc < 3)
return;
wstring line = to_wide (argv[1]); int cursor = atoi (argv[2]);
if (line.empty () || cursor < 0 || cursor > (int) line.length ())
return;
std::replace_if (begin (line), end (line), iswspace, L' ');
g.cmdline = apply_attrs (line += L' ', g.attrs[g.AT_CMDLINE]);
// It is tempting to touch the cchar_t directly, though let's rather not
g.cmdline[cursor] = cchar (g.attrs[g.AT_CMDLINE] ^ A_REVERSE, line[cursor]);
}
fun decode_ansi_sgr (const vector<string> &v) -> chtype { fun decode_ansi_sgr (const vector<string> &v) -> chtype {
vector<int> args; vector<int> args;
for (const auto &arg : v) { for (const auto &arg : v) {
@ -1646,6 +1627,9 @@ fun save_config () {
} }
int main (int argc, char *argv[]) { int main (int argc, char *argv[]) {
(void) argc;
(void) argv;
// That bitch zle closes stdin before exec without redirection // That bitch zle closes stdin before exec without redirection
(void) close (STDIN_FILENO); (void) close (STDIN_FILENO);
if (open ("/dev/tty", O_RDWR)) { if (open ("/dev/tty", O_RDWR)) {
@ -1675,7 +1659,6 @@ int main (int argc, char *argv[]) {
} }
load_colors (); load_colors ();
load_cmdline (argc, argv);
g.start_dir = g.cwd = initial_cwd (); g.start_dir = g.cwd = initial_cwd ();
reload (false); reload (false);
pop_levels (g.cwd); pop_levels (g.cwd);