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
5264be76
Commit
5264be76
authored
4 years ago
by
Yorhel
Browse files
Options
Downloads
Patches
Plain Diff
UI: Display shared/unique sizes + hide some columns when no space
parent
59ef5fd2
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
README.md
+0
-1
0 additions, 1 deletion
README.md
src/browser.zig
+31
-11
31 additions, 11 deletions
src/browser.zig
src/main.zig
+1
-0
1 addition, 0 deletions
src/main.zig
with
32 additions
and
12 deletions
README.md
+
0
−
1
View file @
5264be76
...
@@ -48,7 +48,6 @@ Already implemented:
...
@@ -48,7 +48,6 @@ Already implemented:
-
Add support for separate counting hard links that are shared with other
-
Add support for separate counting hard links that are shared with other
directories or unique within the directory (issue
directories or unique within the directory (issue
[
#36
](
https://code.blicky.net/yorhel/ncdu/issues/36
)
).
[
#36
](
https://code.blicky.net/yorhel/ncdu/issues/36
)
).
(Implemented in the data model, but not displayed in the UI yet)
-
Faster --exclude-kernfs thanks to
`statfs()`
caching.
-
Faster --exclude-kernfs thanks to
`statfs()`
caching.
-
Improved handling of Unicode and special characters.
-
Improved handling of Unicode and special characters.
-
Remembers item position when switching directories.
-
Remembers item position when switching directories.
...
...
This diff is collapsed.
Click to expand it.
src/browser.zig
+
31
−
11
View file @
5264be76
...
@@ -14,6 +14,7 @@ var dir_items = std.ArrayList(?*model.Entry).init(main.allocator);
...
@@ -14,6 +14,7 @@ var dir_items = std.ArrayList(?*model.Entry).init(main.allocator);
var
dir_max_blocks
:
u64
=
0
;
var
dir_max_blocks
:
u64
=
0
;
var
dir_max_size
:
u64
=
0
;
var
dir_max_size
:
u64
=
0
;
var
dir_has_shared
:
bool
=
false
;
// Index into dir_items that is currently selected.
// Index into dir_items that is currently selected.
var
cursor_idx
:
usize
=
0
;
var
cursor_idx
:
usize
=
0
;
...
@@ -124,6 +125,7 @@ pub fn loadDir() void {
...
@@ -124,6 +125,7 @@ pub fn loadDir() void {
dir_items
.
shrinkRetainingCapacity
(
0
);
dir_items
.
shrinkRetainingCapacity
(
0
);
dir_max_size
=
1
;
dir_max_size
=
1
;
dir_max_blocks
=
1
;
dir_max_blocks
=
1
;
dir_has_shared
=
false
;
if
(
dir_parents
.
top
()
!=
model
.
root
)
if
(
dir_parents
.
top
()
!=
model
.
root
)
dir_items
.
append
(
null
)
catch
unreachable
;
dir_items
.
append
(
null
)
catch
unreachable
;
...
@@ -131,13 +133,14 @@ pub fn loadDir() void {
...
@@ -131,13 +133,14 @@ pub fn loadDir() void {
while
(
it
)
|
e
|
{
while
(
it
)
|
e
|
{
if
(
e
.
blocks
>
dir_max_blocks
)
dir_max_blocks
=
e
.
blocks
;
if
(
e
.
blocks
>
dir_max_blocks
)
dir_max_blocks
=
e
.
blocks
;
if
(
e
.
size
>
dir_max_size
)
dir_max_size
=
e
.
size
;
if
(
e
.
size
>
dir_max_size
)
dir_max_size
=
e
.
size
;
if
(
main
.
config
.
show_hidden
)
// fast path
const
shown
=
main
.
config
.
show_hidden
or
blk
:
{
dir_items
.
append
(
e
)
catch
unreachable
else
{
const
excl
=
if
(
e
.
file
())
|
f
|
f
.
excluded
else
false
;
const
excl
=
if
(
e
.
file
())
|
f
|
f
.
excluded
else
false
;
const
name
=
e
.
name
();
const
name
=
e
.
name
();
if
(
!
excl
and
name
[
0
]
!=
'.'
and
name
[
name
.
len
-
1
]
!=
'~'
)
break
:
blk
!
excl
and
name
[
0
]
!=
'.'
and
name
[
name
.
len
-
1
]
!=
'~'
;
dir_items
.
append
(
e
)
catch
unreachable
;
};
if
(
shown
)
{
dir_items
.
append
(
e
)
catch
unreachable
;
if
(
e
.
dir
())
|
d
|
if
(
d
.
shared_blocks
>
0
or
d
.
shared_size
>
0
)
{
dir_has_shared
=
true
;
};
}
}
it
=
e
.
next
;
it
=
e
.
next
;
}
}
...
@@ -175,15 +178,26 @@ const Row = struct {
...
@@ -175,15 +178,26 @@ const Row = struct {
}
}
fn
size
(
self
:
*
Self
)
void
{
fn
size
(
self
:
*
Self
)
void
{
defer
self
.
col
+=
if
(
main
.
config
.
si
)
@as
(
u32
,
9
)
else
10
;
var
width
=
if
(
main
.
config
.
si
)
@as
(
u32
,
9
)
else
10
;
if
(
dir_has_shared
and
main
.
config
.
show_shared
!=
.
off
)
width
+=
1
+
width
;
defer
self
.
col
+=
width
;
const
item
=
self
.
item
orelse
return
;
const
item
=
self
.
item
orelse
return
;
const
siz
=
if
(
main
.
config
.
show_blocks
)
blocksToSize
(
item
.
blocks
)
else
item
.
size
;
var
shr
=
if
(
item
.
dir
())
|
d
|
(
if
(
main
.
config
.
show_blocks
)
blocksToSize
(
d
.
shared_blocks
)
else
d
.
shared_size
)
else
0
;
if
(
main
.
config
.
show_shared
==
.
unique
)
shr
=
saturateSub
(
siz
,
shr
);
ui
.
move
(
self
.
row
,
self
.
col
);
ui
.
move
(
self
.
row
,
self
.
col
);
ui
.
addsize
(
self
.
bg
,
if
(
main
.
config
.
show_blocks
)
blocksToSize
(
item
.
blocks
)
else
item
.
size
);
ui
.
addsize
(
self
.
bg
,
siz
);
// TODO: shared sizes
if
(
shr
>
0
and
main
.
config
.
show_shared
!=
.
off
)
{
self
.
bg
.
fg
(.
flag
);
ui
.
addstr
(
if
(
main
.
config
.
show_shared
==
.
unique
)
" U"
else
" S"
);
ui
.
addsize
(
self
.
bg
,
shr
);
}
}
}
fn
graph
(
self
:
*
Self
)
void
{
fn
graph
(
self
:
*
Self
)
void
{
if
(
main
.
config
.
show_graph
==
.
off
)
return
;
if
(
main
.
config
.
show_graph
==
.
off
or
self
.
col
+
20
>
ui
.
cols
)
return
;
const
bar_size
=
std
.
math
.
max
(
ui
.
cols
/
7
,
10
);
const
bar_size
=
std
.
math
.
max
(
ui
.
cols
/
7
,
10
);
defer
self
.
col
+=
switch
(
main
.
config
.
show_graph
)
{
defer
self
.
col
+=
switch
(
main
.
config
.
show_graph
)
{
...
@@ -223,7 +237,7 @@ const Row = struct {
...
@@ -223,7 +237,7 @@ const Row = struct {
}
}
fn
items
(
self
:
*
Self
)
void
{
fn
items
(
self
:
*
Self
)
void
{
if
(
!
main
.
config
.
show_items
)
return
;
if
(
!
main
.
config
.
show_items
or
self
.
col
+
10
>
ui
.
cols
)
return
;
defer
self
.
col
+=
7
;
defer
self
.
col
+=
7
;
const
n
=
(
if
(
self
.
item
)
|
d
|
d
.
dir
()
orelse
return
else
return
).
items
;
const
n
=
(
if
(
self
.
item
)
|
d
|
d
.
dir
()
orelse
return
else
return
).
items
;
ui
.
move
(
self
.
row
,
self
.
col
);
ui
.
move
(
self
.
row
,
self
.
col
);
...
@@ -254,7 +268,7 @@ const Row = struct {
...
@@ -254,7 +268,7 @@ const Row = struct {
}
}
fn
mtime
(
self
:
*
Self
)
void
{
fn
mtime
(
self
:
*
Self
)
void
{
if
(
!
main
.
config
.
show_mtime
)
return
;
if
(
!
main
.
config
.
show_mtime
or
self
.
col
+
37
>
ui
.
cols
)
return
;
defer
self
.
col
+=
27
;
defer
self
.
col
+=
27
;
ui
.
move
(
self
.
row
,
self
.
col
+
1
);
ui
.
move
(
self
.
row
,
self
.
col
+
1
);
const
ext
=
(
if
(
self
.
item
)
|
e
|
e
.
ext
()
else
@as
(
?*
model
.
Ext
,
null
))
orelse
dir_parents
.
top
().
entry
.
ext
();
const
ext
=
(
if
(
self
.
item
)
|
e
|
e
.
ext
()
else
@as
(
?*
model
.
Ext
,
null
))
orelse
dir_parents
.
top
().
entry
.
ext
();
...
@@ -469,6 +483,12 @@ pub fn keyInput(ch: i32) void {
...
@@ -469,6 +483,12 @@ pub fn keyInput(ch: i32) void {
.
percent
=>
.
both
,
.
percent
=>
.
both
,
.
both
=>
.
off
,
.
both
=>
.
off
,
},
},
// TODO: This key binding is not final! I'd rather add a menu selection thing for advanced settings rather than risk running out of more keys.
'u'
=>
main
.
config
.
show_shared
=
switch
(
main
.
config
.
show_shared
)
{
.
off
=>
.
shared
,
.
shared
=>
.
unique
,
.
unique
=>
.
off
,
},
else
=>
{}
else
=>
{}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main.zig
+
1
−
0
View file @
5264be76
...
@@ -51,6 +51,7 @@ pub const config = struct {
...
@@ -51,6 +51,7 @@ pub const config = struct {
pub
var
show_hidden
:
bool
=
true
;
pub
var
show_hidden
:
bool
=
true
;
pub
var
show_blocks
:
bool
=
true
;
pub
var
show_blocks
:
bool
=
true
;
pub
var
show_shared
:
enum
{
off
,
shared
,
unique
}
=
.
shared
;
pub
var
show_items
:
bool
=
false
;
pub
var
show_items
:
bool
=
false
;
pub
var
show_mtime
:
bool
=
false
;
pub
var
show_mtime
:
bool
=
false
;
pub
var
show_graph
:
enum
{
off
,
graph
,
percent
,
both
}
=
.
graph
;
pub
var
show_graph
:
enum
{
off
,
graph
,
percent
,
both
}
=
.
graph
;
...
...
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