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