Compare commits

..

No commits in common. "7c2ab8ab59d7b502aba747850ee4f4bcee4fd2fa" and "916f354c9b77881a50f3874e706d714ccbdc7dd0" have entirely different histories.

3 changed files with 41 additions and 58 deletions

View File

@ -1,14 +0,0 @@
BasedOnStyle: LLVM
ColumnLimit: 80
IndentWidth: 4
TabWidth: 4
UseTab: ForContinuationAndIndentation
SpaceAfterCStyleCast: true
SpaceBeforeParens: Always
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: DontAlign
AlignOperands: DontAlign
AlignConsecutiveMacros: Consecutive
BreakBeforeTernaryOperators: true
SpacesBeforeTrailingComments: 2
WhitespaceSensitiveMacros: ['XX', 'ACTIONS', 'LS']

View File

@ -16,9 +16,6 @@ sdn-navigate () {
# helpers after the terminal has been resized while running sdn # helpers after the terminal has been resized while running sdn
command true command true
# Add to history, see https://www.zsh.org/mla/workers/2020/msg00633.html
fc -R =(print -- "$helper")
/bin/sh -c "$helper" </dev/tty || break /bin/sh -c "$helper" </dev/tty || break
done done
# optionally: zle zle-line-init # optionally: zle zle-line-init

58
sdn.cpp
View File

@ -18,38 +18,38 @@
// May be required for ncursesw and we generally want it all anyway // May be required for ncursesw and we generally want it all anyway
#define _XOPEN_SOURCE_EXTENDED #define _XOPEN_SOURCE_EXTENDED
#include <string>
#include <vector>
#include <locale>
#include <iostream>
#include <algorithm> #include <algorithm>
#include <cwchar>
#include <climits> #include <climits>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <cwchar>
#include <fstream> #include <fstream>
#include <iostream>
#include <locale>
#include <map> #include <map>
#include <memory>
#include <string>
#include <tuple> #include <tuple>
#include <vector> #include <memory>
#include <unistd.h>
#include <dirent.h> #include <dirent.h>
#include <fcntl.h>
#include <grp.h>
#include <libgen.h>
#include <pwd.h>
#include <signal.h>
#include <sys/acl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/acl.h>
#include <fcntl.h>
#include <pwd.h>
#include <grp.h>
#include <libgen.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <signal.h>
#include <acl/libacl.h>
#include <ncurses.h>
#include <sys/inotify.h> #include <sys/inotify.h>
#include <sys/xattr.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/xattr.h> #include <acl/libacl.h>
#include <ncurses.h>
// To implement cbreak() with disabled ^S that gets reënabled on endwin() // To implement cbreak() with disabled ^S that gets reënabled on endwin()
#define NCURSES_INTERNALS #define NCURSES_INTERNALS
@ -609,8 +609,8 @@ fun ls_format (const entry &e, bool for_target) -> chtype {
set (LS_STICKY_OTHER_WRITABLE); set (LS_STICKY_OTHER_WRITABLE);
} else if (S_ISLNK (info.st_mode)) { } else if (S_ISLNK (info.st_mode)) {
type = LS_SYMLINK; type = LS_SYMLINK;
if (!e.target_info.st_mode && if (!e.target_info.st_mode
(ls_is_colored (LS_ORPHAN) || g.ls_symlink_as_target)) && (ls_is_colored (LS_ORPHAN) || g.ls_symlink_as_target))
type = LS_ORPHAN; type = LS_ORPHAN;
} else if (S_ISFIFO (info.st_mode)) { } else if (S_ISFIFO (info.st_mode)) {
type = LS_FIFO; type = LS_FIFO;
@ -1228,9 +1228,9 @@ fun choose (const entry &entry) {
// Move the cursor in `diff` direction and look for non-combining characters // Move the cursor in `diff` direction and look for non-combining characters
fun move_towards_spacing (int diff) -> bool { fun move_towards_spacing (int diff) -> bool {
g.editor_cursor += diff; g.editor_cursor += diff;
return g.editor_cursor <= 0 || return g.editor_cursor <= 0
g.editor_cursor >= int (g.editor_line.length ()) || || g.editor_cursor >= int (g.editor_line.length ())
wcwidth (g.editor_line.at (g.editor_cursor)); || wcwidth (g.editor_line.at (g.editor_cursor));
} }
fun handle_editor (wint_t c) { fun handle_editor (wint_t c) {
@ -1244,8 +1244,8 @@ fun handle_editor (wint_t c) {
action = i->second; action = i->second;
auto m = g_binding_contexts.find (to_mb (g.editor)); auto m = g_binding_contexts.find (to_mb (g.editor));
if (m != g_binding_contexts.end () && if (m != g_binding_contexts.end ()
(i = m->second->find (c)) != m->second->end ()) && (i = m->second->find (c)) != m->second->end ())
action = i->second; action = i->second;
} }
@ -1271,13 +1271,13 @@ fun handle_editor (wint_t c) {
g.editor_cursor = g.editor_line.length (); g.editor_cursor = g.editor_line.length ();
break; break;
case ACTION_INPUT_BACKWARD: case ACTION_INPUT_BACKWARD:
while (g.editor_cursor > 0 && while (g.editor_cursor > 0
!move_towards_spacing (-1)) && !move_towards_spacing (-1))
; ;
break; break;
case ACTION_INPUT_FORWARD: case ACTION_INPUT_FORWARD:
while (g.editor_cursor < int (g.editor_line.length ()) && while (g.editor_cursor < int (g.editor_line.length ())
!move_towards_spacing (+1)) && !move_towards_spacing (+1))
; ;
break; break;
case ACTION_INPUT_B_DELETE: case ACTION_INPUT_B_DELETE:
@ -1560,8 +1560,8 @@ fun load_ls_colors (vector<string> colors) {
if (equal == string::npos) if (equal == string::npos)
continue; continue;
auto key = pair.substr (0, equal), value = pair.substr (equal + 1); auto key = pair.substr (0, equal), value = pair.substr (equal + 1);
if (key != g_ls_colors[LS_SYMLINK] || if (key != g_ls_colors[LS_SYMLINK]
!(g.ls_symlink_as_target = value == "target")) || !(g.ls_symlink_as_target = value == "target"))
attrs[key] = decode_ansi_sgr (split (value, ";")); attrs[key] = decode_ansi_sgr (split (value, ";"));
} }
for (int i = 0; i < LS_COUNT; i++) { for (int i = 0; i < LS_COUNT; i++) {