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
fdd86924
Commit
fdd86924
authored
12 years ago
by
Chris West (Faux)
Browse files
Options
Downloads
Patches
Plain Diff
'C' sorts by items
parent
cfcac262
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/browser.c
+4
-0
4 additions, 0 deletions
src/browser.c
src/dirlist.c
+15
-6
15 additions, 6 deletions
src/dirlist.c
src/dirlist.h
+1
-0
1 addition, 0 deletions
src/dirlist.h
src/help.c
+2
-1
2 additions, 1 deletion
src/help.c
with
22 additions
and
7 deletions
src/browser.c
+
4
−
0
View file @
fdd86924
...
...
@@ -341,6 +341,10 @@ int browse_key(int ch) {
dirlist_set_sort
(
i
,
dirlist_sort_col
==
i
?
!
dirlist_sort_desc
:
1
,
DL_NOCHANGE
);
info_show
=
0
;
break
;
case
'C'
:
dirlist_set_sort
(
DL_COL_ITEMS
,
dirlist_sort_col
==
DL_COL_ITEMS
?
!
dirlist_sort_desc
:
1
,
DL_NOCHANGE
);
info_show
=
0
;
break
;
case
'e'
:
dirlist_set_hidden
(
!
dirlist_hidden
);
info_show
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/dirlist.c
+
15
−
6
View file @
fdd86924
...
...
@@ -62,25 +62,34 @@ static int dirlist_cmp(struct dir *x, struct dir *y) {
}
/* sort columns:
* 1 -> 2 -> 3
* NAME: name -> size -> asize
* SIZE: size -> asize -> name
* ASIZE: asize -> size -> name
* 1 -> 2 -> 3 -> 4
* NAME: name -> size -> asize -> items
* SIZE: size -> asize -> name -> items
* ASIZE: asize -> size -> name -> items
* ITEMS: items -> size -> asize -> name
*
* Note that the method used below is supposed to be fast, not readable :-)
*/
#define CMP_NAME strcmp(x->name, y->name)
#define CMP_SIZE (x->size > y->size ? 1 : (x->size == y->size ? 0 : -1))
#define CMP_ASIZE (x->asize > y->asize ? 1 : (x->asize == y->asize ? 0 : -1))
#define CMP_ITEMS (x->items > y->items ? 1 : (x->items == y->items ? 0 : -1))
/* try 1 */
r
=
dirlist_sort_col
==
DL_COL_NAME
?
CMP_NAME
:
dirlist_sort_col
==
DL_COL_SIZE
?
CMP_SIZE
:
CMP_ASIZE
;
r
=
dirlist_sort_col
==
DL_COL_NAME
?
CMP_NAME
:
dirlist_sort_col
==
DL_COL_SIZE
?
CMP_SIZE
:
dirlist_sort_col
==
DL_COL_ASIZE
?
CMP_ASIZE
:
CMP_ITEMS
;
/* try 2 */
if
(
!
r
)
r
=
dirlist_sort_col
==
DL_COL_SIZE
?
CMP_ASIZE
:
CMP_SIZE
;
/* try 3 */
if
(
!
r
)
r
=
dirlist_sort_col
==
DL_COL_NAME
?
CMP_ASIZE
:
CMP_NAME
;
r
=
(
dirlist_sort_col
==
DL_COL_NAME
||
dirlist_sort_col
==
DL_COL_ITEMS
)
?
CMP_ASIZE
:
CMP_NAME
;
/* try 4 */
if
(
!
r
)
r
=
dirlist_sort_col
==
DL_COL_ITEMS
?
CMP_NAME
:
CMP_ITEMS
;
/* reverse when sorting in descending order */
if
(
dirlist_sort_desc
&&
r
!=
0
)
...
...
This diff is collapsed.
Click to expand it.
src/dirlist.h
+
1
−
0
View file @
fdd86924
...
...
@@ -36,6 +36,7 @@
#define DL_COL_NAME 0
#define DL_COL_SIZE 1
#define DL_COL_ASIZE 2
#define DL_COL_ITEMS 3
void
dirlist_open
(
struct
dir
*
);
...
...
This diff is collapsed.
Click to expand it.
src/help.c
+
2
−
1
View file @
fdd86924
...
...
@@ -32,7 +32,7 @@
int
page
,
start
;
#define KEYS 1
5
#define KEYS 1
6
char
*
keys
[
KEYS
*
2
]
=
{
/*|----key----| |----------------description----------------|*/
"up, k"
,
"Move cursor up"
,
...
...
@@ -41,6 +41,7 @@ char *keys[KEYS*2] = {
"left, <, h"
,
"Open parent directory"
,
"n"
,
"Sort by name (ascending/descending)"
,
"s"
,
"Sort by size (ascending/descending)"
,
"C"
,
"Sort by items (ascending/descending)"
,
"d"
,
"Delete selected file or directory"
,
"t"
,
"Toggle dirs before files when sorting"
,
"g"
,
"Show percentage and/or 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