Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nccf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
702
Provoz
nccf
Commits
f448e8ea
Commit
f448e8ea
authored
3 years ago
by
Yorhel
Browse files
Options
Downloads
Patches
Plain Diff
Add dark-bg color scheme + enable colors by default if !NO_COLOR
Same thing as commit
376aad0d
in the C version.
parent
1de70064
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ncdu.pod
+6
-3
6 additions, 3 deletions
ncdu.pod
src/main.zig
+4
-2
4 additions, 2 deletions
src/main.zig
src/ui.zig
+70
-51
70 additions, 51 deletions
src/ui.zig
with
80 additions
and
56 deletions
ncdu.pod
+
6
−
3
View file @
f448e8ea
...
...
@@ -139,9 +139,12 @@ accidentally press 'q' during or after a very long scan.
=item --color I<SCHEME>
Select a color scheme. Currently only two schemes are recognized: I<off> to
disable colors (the default) and I<dark> for a color scheme intended for dark
backgrounds.
Select a color scheme. The following schemes are recognized: I<off> to disable
colors, I<dark> for a color scheme intended for dark backgrounds and I<dark-bg>
for a variation of the I<dark> color scheme that also works in terminals with a
light background.
The default is I<dark-bg> unless the C<NO_COLOR> environment variable is set.
=back
...
...
This diff is collapsed.
Click to expand it.
src/main.zig
+
4
−
2
View file @
f448e8ea
...
...
@@ -52,7 +52,7 @@ pub const config = struct {
pub
var
scan_ui
:
enum
{
none
,
line
,
full
}
=
.
full
;
pub
var
si
:
bool
=
false
;
pub
var
nc_tty
:
bool
=
false
;
pub
var
ui_color
:
enum
{
off
,
dark
}
=
.
off
;
pub
var
ui_color
:
enum
{
off
,
dark
,
darkbg
}
=
.
off
;
pub
var
thousands_sep
:
[]
const
u8
=
","
;
pub
var
show_hidden
:
bool
=
true
;
...
...
@@ -175,7 +175,7 @@ fn help() noreturn {
++
" --exclude-caches Exclude directories containing CACHEDIR.TAG
\n
"
++
" --exclude-kernfs Exclude Linux pseudo filesystems (procfs,sysfs,cgroup,...)
\n
"
++
" --confirm-quit Confirm quitting ncdu
\n
"
++
" --color SCHEME Set color scheme (off/dark)
\n
"
++
" --color SCHEME Set color scheme (off/dark
/dark-bg
)
\n
"
)
catch
{};
std
.
process
.
exit
(
0
);
}
...
...
@@ -259,6 +259,7 @@ pub fn main() void {
config
.
thousands_sep
=
span
;
}
}
if
(
std
.
os
.
getenvZ
(
"NO_COLOR"
)
==
null
)
config
.
ui_color
=
.
darkbg
;
var
args
=
Args
(
std
.
process
.
ArgIteratorPosix
).
init
(
std
.
process
.
ArgIteratorPosix
.
init
());
var
scan_dir
:
?
[]
const
u8
=
null
;
...
...
@@ -300,6 +301,7 @@ pub fn main() void {
const
val
=
args
.
arg
();
if
(
std
.
mem
.
eql
(
u8
,
val
,
"off"
))
config
.
ui_color
=
.
off
else
if
(
std
.
mem
.
eql
(
u8
,
val
,
"dark"
))
config
.
ui_color
=
.
dark
else
if
(
std
.
mem
.
eql
(
u8
,
val
,
"dark-bg"
))
config
.
ui_color
=
.
darkbg
else
ui
.
die
(
"Unknown --color option: {s}.
\n
"
,
.
{
val
});
}
else
ui
.
die
(
"Unrecognized option '{s}'.
\n
"
,
.
{
opt
.
val
});
}
...
...
This diff is collapsed.
Click to expand it.
src/ui.zig
+
70
−
51
View file @
f448e8ea
...
...
@@ -201,66 +201,85 @@ const StyleDef = struct {
name
:
[]
const
u8
,
off
:
StyleAttr
,
dark
:
StyleAttr
,
darkbg
:
StyleAttr
,
fn
style
(
self
:
*
const
@This
())
StyleAttr
{
return
switch
(
main
.
config
.
ui_color
)
{
.
off
=>
self
.
off
,
.
dark
=>
self
.
dark
,
.
darkbg
=>
self
.
darkbg
,
};
}
};
const
styles
=
[
_
]
StyleDef
{
.
{
.
name
=
"default"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
},
.
dark
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
}
},
.
{
.
name
=
"bold"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
},
.
dark
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"bold_hd"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
|
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_BLACK
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"box_title"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_BLUE
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"hd"
,
// header + footer
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_BLACK
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
0
}
},
.
{
.
name
=
"sel"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_WHITE
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"num"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"num_hd"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"num_sel"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"key"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"key_hd"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
|
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"dir"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_BLUE
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"dir_sel"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_BLUE
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"flag"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_RED
,
.
bg
=
-
1
,
.
attr
=
0
}
},
.
{
.
name
=
"flag_sel"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_RED
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
0
}
},
.
{
.
name
=
"graph"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_MAGENTA
,
.
bg
=
-
1
,
.
attr
=
0
}
},
.
{
.
name
=
"graph_sel"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_MAGENTA
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
0
}
},
.
{
.
name
=
"default"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
},
.
dark
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_WHITE
,
.
bg
=
c
.
COLOR_BLACK
,
.
attr
=
0
}
},
.
{
.
name
=
"bold"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
},
.
dark
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_WHITE
,
.
bg
=
c
.
COLOR_BLACK
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"bold_hd"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
|
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_BLACK
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
c
.
A_BOLD
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_BLACK
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"box_title"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_BLUE
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_BLUE
,
.
bg
=
c
.
COLOR_BLACK
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"hd"
,
// header + footer
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_BLACK
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
0
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_BLACK
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
0
}
},
.
{
.
name
=
"sel"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_WHITE
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
c
.
A_BOLD
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_WHITE
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"num"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
c
.
COLOR_BLACK
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"num_hd"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
c
.
A_BOLD
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"num_sel"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
c
.
A_BOLD
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"key"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
c
.
COLOR_BLACK
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"key_hd"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
|
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
c
.
A_BOLD
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_YELLOW
,
.
bg
=
c
.
COLOR_CYAN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"dir"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_BLUE
,
.
bg
=
-
1
,
.
attr
=
c
.
A_BOLD
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_BLUE
,
.
bg
=
c
.
COLOR_BLACK
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"dir_sel"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_BLUE
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
c
.
A_BOLD
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_BLUE
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
c
.
A_BOLD
}
},
.
{
.
name
=
"flag"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_RED
,
.
bg
=
-
1
,
.
attr
=
0
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_RED
,
.
bg
=
c
.
COLOR_BLACK
,
.
attr
=
0
}
},
.
{
.
name
=
"flag_sel"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_RED
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
0
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_RED
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
0
}
},
.
{
.
name
=
"graph"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
0
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_MAGENTA
,
.
bg
=
-
1
,
.
attr
=
0
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_MAGENTA
,
.
bg
=
c
.
COLOR_BLACK
,
.
attr
=
0
}
},
.
{
.
name
=
"graph_sel"
,
.
off
=
.
{
.
fg
=
-
1
,
.
bg
=
-
1
,
.
attr
=
c
.
A_REVERSE
},
.
dark
=
.
{
.
fg
=
c
.
COLOR_MAGENTA
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
0
},
.
darkbg
=
.
{
.
fg
=
c
.
COLOR_MAGENTA
,
.
bg
=
c
.
COLOR_GREEN
,
.
attr
=
0
}
},
};
pub
const
Style
=
lbl
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment