Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
d3bd855c
Commit
d3bd855c
authored
8 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: rename a function, and move the sorting there too
parent
bd3f1560
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/browser.c
+10
-11
src/browser.c
src/proto.h
+1
-1
src/proto.h
with
11 additions
and
12 deletions
+11
-12
src/browser.c
View file @
d3bd855c
...
...
@@ -83,15 +83,10 @@ char *do_browser(char *path)
assert
(
path
!=
NULL
&&
path
[
strlen
(
path
)
-
1
]
==
'/'
);
/* Get the file list, and set longest and width in the process. */
browser_ini
t
(
path
,
dir
);
read_the_lis
t
(
path
,
dir
);
closedir
(
dir
);
assert
(
filelist
!=
NULL
);
/* Sort the file list. */
qsort
(
filelist
,
filelist_len
,
sizeof
(
char
*
),
diralphasort
);
/* If given, reselect the present_name and then discard it. */
if
(
present_name
!=
NULL
)
{
browser_select_dirname
(
present_name
);
...
...
@@ -419,10 +414,8 @@ char *do_browse_from(const char *inpath)
* set filelist_len to the number of files in that list, set longest to
* the width in columns of the longest filename in that list (between 15
* and COLS), and set width to the number of files that we can display
* per line. longest needs to be at least 15 columns in order to
* display ".. (parent dir)", as Pico does. Assume path exists and is a
* directory. */
void
browser_init
(
const
char
*
path
,
DIR
*
dir
)
* per line. And sort the list too. */
void
read_the_list
(
const
char
*
path
,
DIR
*
dir
)
{
const
struct
dirent
*
nextdir
;
size_t
i
=
0
,
path_len
=
strlen
(
path
);
...
...
@@ -445,9 +438,10 @@ void browser_init(const char *path, DIR *dir)
* in the list whenever possible, as Pico does. */
longest
+=
10
;
/*
Make sure longest is between 15 and COLS
. */
/*
If needed, make room for ".. (parent dir)"
. */
if
(
longest
<
15
)
longest
=
15
;
/* Make sure we're not wider than the window. */
if
(
longest
>
COLS
)
longest
=
COLS
;
...
...
@@ -477,6 +471,11 @@ void browser_init(const char *path, DIR *dir)
* filelist, so record it. */
filelist_len
=
i
;
assert
(
filelist
!=
NULL
);
/* Sort the list of names. */
qsort
(
filelist
,
filelist_len
,
sizeof
(
char
*
),
diralphasort
);
/* Calculate how many files fit on a line -- feigning room for two
* spaces beyond the right edge, and adding two spaces of padding
* between columns. */
...
...
This diff is collapsed.
Click to expand it.
src/proto.h
View file @
d3bd855c
...
...
@@ -152,7 +152,7 @@ typedef void (*functionptrtype)(void);
#ifndef DISABLE_BROWSER
char
*
do_browser
(
char
*
path
);
char
*
do_browse_from
(
const
char
*
inpath
);
void
browser_ini
t
(
const
char
*
path
,
DIR
*
dir
);
void
read_the_lis
t
(
const
char
*
path
,
DIR
*
dir
);
functionptrtype
parse_browser_input
(
int
*
kbinput
);
void
browser_refresh
(
void
);
void
browser_select_dirname
(
const
char
*
needle
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment