commit f6ad753f7936921954258e3eafc64f4416a67ffc
Author: Raniconduh <clagv.randomgames@gmail.com>
Date: Sun Dec 05 22:05:21 2021 +0000
diff --git a/README.md b/README.md
index 736c739..8edb1ef 100644
--- a/README.md
+++ b/README.md
@@ -268 +269 @@ Files that are executable but have another identifier will keep the identifier b
### Options
-* `-p`: Print the path cscroll ends in. Useful for commands like `cd $(cscroll -p)` to cd into the last directory.
-* `-nc`: Turn off coloring.
+* `-p`: Print the path cscroll ends in. Useful for commands like `cd $(cscroll -p)` to cd into the last directory
+* `-nc`: Turn off coloring
+* `-h`, `--help`: Show the help screen
### Commands
@@ -507 +517 @@ Files that are executable but have another identifier will keep the identifier b
#### Options Prompt
-An options prompt will pop up in the center of the screen with text at the top of the popup and one or more options at the bottom. To move the cursor to the left, any of the left or up keys will work. To move it to the right, any of the down or right keys (except for enter) will work. To select the current option, press either the space bar or the enter key.The `q` key will quit the prompt without selecting an option.
+An options prompt will pop up in the center of the screen with text at the top of the pop-up and one or more options at the bottom. To move the cursor to the left, any of the left or up keys will work. To move it to the right, any of the down or right keys (except for enter) will work. To select the current option, press either the space bar or the enter key. The `q` key will quit the prompt without selecting an option.
#### Command Prompt
@@ -6217 +6321 @@ The command prompt will show up upon pressing `:` and the prompt itself is prefi
#### Renaming
-The `r` command will show a prompt (similar to a command prompt but without a prefix) where the new file name is to be expected. A file may only be renamed within the same directory. E.g. if the directory cscroll is in is `/home/user/downloads` and the file `image.png` is renamed to `/home/user/image.png`, it will fail. The file can only be renamed to something like `my_image.png`. (Attempting to move a file across directories is not possible with the rename function.) Mass renaming is not possible.
+The `r` command will show a prompt (similar to a command prompt but without a prefix) where the new file name is to be expected. A file may only be renamed within the same directory.
+
+E.g. if the directory cscroll is in is `/home/user/downloads` and the file `image.png` is renamed to `/home/user/image.png`, it will fail. The file can only be renamed to something like `my_image.png`. (Attempting to move a file across directories is not possible with the rename function.) Mass renaming is not possible.
#### Shell Commands
-Pressing `!` will open a prompt prefixed with `!` which will run the shell command entered into it. Entering %f will format the command entered with the name of the file the cursor is currently on. To escape this format (i.e. to not have it be replaced with the file name), enter `%%f`. The output will be literally `%f`. E.g. `vim %f` will format to `vim FILE` where `FILE` is the name of the file the cursor is on. `echo %%f`, however, will format to `echo %f` and the output of the command will literally be `%f`.
+Pressing `!` will open a prompt prefixed with `!` which will run the shell command entered into it. Entering `%f` will format the command entered with the name of the file the cursor is currently on. To escape this format (i.e. to not have it be replaced with the file name), enter `%%f`. The output will be literally `%f`.
+
+E.g. `vim %f` will format to `vim FILE` where `FILE` is the name of the file the cursor is on. `echo %%f`, however, will format to `echo %f` and the output of the command will literally be `%f`.
## Installation
-The cscroll binary has one dependency to run: ncurses. To compile cscroll you must install `libncurses`. However, compilation through the makefile requires `pkg-config` as well.
+To run, cscroll requires libncurses and libterminfo. Compilation, however, also requires pkg-config.
-On Debian and Ubuntu based system this should be titled `libncurses-dev` and may be installed with `sudo apt install libncurses-dev`.
+On Debian and Ubuntu based system, libncurses this may be titled `libncurses-dev` or simply `libncurses` and can be installed with `sudo apt install libncurses-dev`.
-Then run `make` to compile. The program will then be accessible by running `./cscroll`.
+To compile, simply run `make`. The program will then be accessible by running `./cscroll`. Installation is also possible with `make install`.
diff --git a/include/commands.h b/include/commands.h
index 3ffd386..2db52ba 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -86 +87 @@ void free_cuts(void);
void paste_cuts(char *);
void run_cmd(char *);
+
extern bool cutting;
extern char * cut_start_dir;
extern char ** cuts;
diff --git a/include/dir.h b/include/dir.h
index b5074af..643c17a 100644
--- a/include/dir.h
+++ b/include/dir.h
@@ -36 +37 @@
#include <stdbool.h>
+
int list_dir(char *);
void free_dir_entries(void);
void cd_back(void);
diff --git a/include/io.h b/include/io.h
index ae3ff4f..278e907 100644
--- a/include/io.h
+++ b/include/io.h
@@ -66 +67 @@
#define NO_IDENT 0
+
enum colors {
BLUE = 1,
CYAN = 2,
@@ -276 +287 @@ enum keys {
CTRL_F
};
+
void curses_init(void);
void terminate_curses(void);
void curses_write_file(struct dir_entry_t *, bool);
@@ -366 +387 @@ char * curses_getline(char *);
void unmark_all(void);
void mark_all(void);
+
extern bool print_path;
extern int stdout_back;
extern size_t n_marked_files;
diff --git a/include/main.h b/include/main.h
index 900331c..0be26b8 100644
--- a/include/main.h
+++ b/include/main.h
@@ -34 +37 @@
#define LAST_F (n_dir_entries > ((unsigned)LINES - 6) ? ((unsigned)LINES - 6) : n_dir_entries)
+
+void help(void);
+
#endif /* MAIN_H */
diff --git a/include/type.h b/include/type.h
index 0323b1d..e9fd420 100644
--- a/include/type.h
+++ b/include/type.h
@@ -510 +511 @@ char * get_ext(char *);
int scmp(const void *, const void *);
void lowers(char *);
+
#define n_media_exts 68
#define n_archive_exts 55
extern char * media_exts[n_media_exts];
extern char * archive_exts[n_archive_exts];
-#endif
+#endif /* TYPE_H */
diff --git a/src/commands.c b/src/commands.c
index ff3c10b..1abc157 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -910 +912 @@
#include "dir.h"
#include "commands.h"
+
bool cutting = false;
char * cut_start_dir = NULL;
char ** cuts = NULL;
+
void ext_open(char * file) {
clear();
refresh();
@@ -1056 +1077 @@ void free_cuts(void) {
cut_start_dir = NULL;
}
+
void paste_cuts(char * path) {
cutting = false;
for (char ** p = cuts; *p; p++) {
@@ -1277 +1307 @@ void run_cmd(char * cmd) {
}
wait(NULL);
- addstr("\nPress enter to contine\n");
+ addstr("\nPress enter to continue\n");
refresh();
while (getch() != '\n');
diff --git a/src/dir.c b/src/dir.c
index e479c94..f7f7c02 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -116 +117 @@
#include "dir.h"
#include "io.h"
+
char * cwd = NULL;
size_t n_dir_entries = 0;
@@ -196 +207 @@ struct dir_entry_t ** dir_entries = NULL;
bool show_dot_files = false;
bool permission_denied = false;
+
int list_dir(char * dir_path) {
struct dirent * d_entry;
DIR * dir = opendir(dir_path);
diff --git a/src/io.c b/src/io.c
index feaec4d..bffea31 100644
--- a/src/io.c
+++ b/src/io.c
@@ -911 +913 @@
#include "dir.h"
#include "io.h"
+
bool print_path = false;
int stdout_back = 0;
size_t n_marked_files = false;
bool color = true;
+
void curses_init(void) {
if (print_path) {
stdout_back = dup(STDOUT_FILENO);
diff --git a/src/main.c b/src/main.c
index a04f327..f4dc345 100644
--- a/src/main.c
+++ b/src/main.c
@@ -106 +107 @@
#include "dir.h"
#include "io.h"
+
int main(int argc, char ** argv) {
if (argc > 1) {
for (int i = 1; i < argc; i++) {
@@ -176 +188 @@ int main(int argc, char ** argv) {
print_path = true;
} else if (!strcmp(argv[i], "-nc")) {
color = false;
+ } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
+ help();
} else {
cwd = realpath(argv[i], NULL);
chdir(cwd);
@@ -3463 +34922 @@ done:
return 0;
}
+
+
+void help(void) {
+ puts(
+ "cscroll\n"
+ "A small and efficient file manager\n"
+ "\n"
+ "Usage:\n"
+ " cscroll [OPTION]... [DIR]\n"
+ "\n"
+ "Options:\n"
+ " -h, --help Show this screen and exit\n"
+ " -nc Turn off colors\n"
+ " -p Print the path cscroll is in when it exits\n"
+ "\n"
+ "See https://github.com/Raniconduh/cscroll for documentation\n"
+ );
+ exit(0);
+}
diff --git a/src/type.c b/src/type.c
index e5ee850..e671b91 100644
--- a/src/type.c
+++ b/src/type.c
@@ -26 +27 @@
#include "type.h"
+
char * media_exts[] = {
"3g2", "3gp", "aac", "ac3", "ai",
"aif", "amv", "asf", "avi", "bmp",
@@ -4010 +4112 @@ char * get_ext(char * s) {
return ns + 1;
}
+
int scmp(const void * a, const void * b) {
return strcmp(*(const char**)a, *(const char**)b);
}
+
void lowers(char * s) {
for (char * p = s; *p; p++)
// A to Z