mirror of
https://gittea.dev/nova/th.git
synced 2025-10-22 10:50:15 -04:00
Compare commits
3 Commits
7b563894f7
...
37d82bebf8
Author | SHA1 | Date | |
---|---|---|---|
![]() |
37d82bebf8 | ||
![]() |
8b02e8e4e6 | ||
![]() |
7526a9e6e5 |
5
config.h
5
config.h
@@ -38,6 +38,7 @@ static const binding key_binding[] = {
|
|||||||
{ "q", quit_program, NULL, "quit" },
|
{ "q", quit_program, NULL, "quit" },
|
||||||
{ " ", toggle_selection, NULL, "toggle file selection" }, /* on hovered file/directory */
|
{ " ", toggle_selection, NULL, "toggle file selection" }, /* on hovered file/directory */
|
||||||
{ "e", update, NULL, "rerun all backend" }, /* executes the entire backend and redrawing of the screen */
|
{ "e", update, NULL, "rerun all backend" }, /* executes the entire backend and redrawing of the screen */
|
||||||
|
{ "B", enter_shell, "$SHELL", "enter $SHELL shell" },
|
||||||
{ "/", not_implemented, NULL, "search" },
|
{ "/", not_implemented, NULL, "search" },
|
||||||
|
|
||||||
{ "h", move_left, NULL, "move left" }, /* moves one dir up */
|
{ "h", move_left, NULL, "move left" }, /* moves one dir up */
|
||||||
@@ -54,6 +55,7 @@ static const binding key_binding[] = {
|
|||||||
{ "gg", jump_top, NULL, "jump to first file in dir" },
|
{ "gg", jump_top, NULL, "jump to first file in dir" },
|
||||||
{ "gh", jump_to_dir, "$HOME", "jump to $HOME" },
|
{ "gh", jump_to_dir, "$HOME", "jump to $HOME" },
|
||||||
{ "gs", jump_to_dir, "$START_PATH", "jump to $START_PATH" },
|
{ "gs", jump_to_dir, "$START_PATH", "jump to $START_PATH" },
|
||||||
|
{ "gD", jump_to_dir, "$HOME/Downloads", "jump to $HOME/Downloads" },
|
||||||
{ "gd", jump_to_dir, "/dev", "jump to /dev" },
|
{ "gd", jump_to_dir, "/dev", "jump to /dev" },
|
||||||
{ "ge", jump_to_dir, "/etc", "jump to /etc" },
|
{ "ge", jump_to_dir, "/etc", "jump to /etc" },
|
||||||
{ "gm", jump_to_dir, "/mnt", "jump to /mnt" },
|
{ "gm", jump_to_dir, "/mnt", "jump to /mnt" },
|
||||||
@@ -80,8 +82,9 @@ static const binding key_binding[] = {
|
|||||||
{ "mf", makefile, NULL, "create file" },
|
{ "mf", makefile, NULL, "create file" },
|
||||||
|
|
||||||
{ "a", toggle_hidden_files, NULL, "toggle hidden files" },
|
{ "a", toggle_hidden_files, NULL, "toggle hidden files" },
|
||||||
{ "\x7F", toggle_hidden_files, NULL, "toggle hidden files" }, /* backspace/delete key */
|
{ "\x7F", toggle_hidden_files, NULL, "toggle hidden files" }, /* backspace key */
|
||||||
};
|
};
|
||||||
static const unsigned long binding_count = sizeof(key_binding) / sizeof(binding);
|
static const unsigned long binding_count = sizeof(key_binding) / sizeof(binding);
|
||||||
static const unsigned long mimetype_default_count = sizeof(mimetype_default_cmd) / sizeof(mimetype);
|
static const unsigned long mimetype_default_count = sizeof(mimetype_default_cmd) / sizeof(mimetype);
|
||||||
static const unsigned long file_extension_default_count = sizeof(file_extension_default_cmd) / sizeof(extension);
|
static const unsigned long file_extension_default_count = sizeof(file_extension_default_cmd) / sizeof(extension);
|
||||||
|
|
||||||
|
@@ -77,7 +77,6 @@ void user_interactions() {
|
|||||||
memset(input, 0, 255);
|
memset(input, 0, 255);
|
||||||
input_pass = 0;
|
input_pass = 0;
|
||||||
timeout(100); /* blocking timeout of getch() */
|
timeout(100); /* blocking timeout of getch() */
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
|
||||||
}
|
}
|
||||||
binding_pass = 0;
|
binding_pass = 0;
|
||||||
status |= STATUS_UPDATE_SCREEN_0;
|
status |= STATUS_UPDATE_SCREEN_0;
|
||||||
@@ -86,7 +85,7 @@ void user_interactions() {
|
|||||||
|
|
||||||
|
|
||||||
void (*func_ptr)(int, int);
|
void (*func_ptr)(int, int);
|
||||||
int number_length = 0;
|
unsigned long number_length = 0;
|
||||||
|
|
||||||
if (!binding_pass) {
|
if (!binding_pass) {
|
||||||
parsed_input_number = 0;
|
parsed_input_number = 0;
|
||||||
@@ -94,7 +93,6 @@ void user_interactions() {
|
|||||||
parsed_input_number = (parsed_input_number * 10) + (*input - '0');
|
parsed_input_number = (parsed_input_number * 10) + (*input - '0');
|
||||||
input++;
|
input++;
|
||||||
number_length++;
|
number_length++;
|
||||||
mvaddch(terminal_height-5, 5, number_length+48);
|
|
||||||
}
|
}
|
||||||
input -= number_length;
|
input -= number_length;
|
||||||
binding_pass = 1;
|
binding_pass = 1;
|
||||||
@@ -121,7 +119,7 @@ void user_interactions() {
|
|||||||
mvaddstr(terminal_height-binding_matches-2, 0, "input\tcommand\t\t");
|
mvaddstr(terminal_height-binding_matches-2, 0, "input\tcommand\t\t");
|
||||||
attroff(A_UNDERLINE);
|
attroff(A_UNDERLINE);
|
||||||
status &= ~STATUS_INPUT_MATCH;
|
status &= ~STATUS_INPUT_MATCH;
|
||||||
} else {
|
} else if (number_length != strlen(input)) {
|
||||||
memset(input, 0, 255);
|
memset(input, 0, 255);
|
||||||
input_pass = 0;
|
input_pass = 0;
|
||||||
binding_pass = 0;
|
binding_pass = 0;
|
||||||
@@ -249,6 +247,7 @@ void move_right(){
|
|||||||
if (system(cmd) == -1) {
|
if (system(cmd) == -1) {
|
||||||
/*do nothing*/
|
/*do nothing*/
|
||||||
}
|
}
|
||||||
|
curs_set(1); /*for some reason, 1 here turns it invisible once again */
|
||||||
match = 1;
|
match = 1;
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
break;
|
break;
|
||||||
@@ -269,6 +268,7 @@ void move_right(){
|
|||||||
if (system(cmd) == -1) {
|
if (system(cmd) == -1) {
|
||||||
/*do nothing*/
|
/*do nothing*/
|
||||||
}
|
}
|
||||||
|
curs_set(1); /*for some reason, 1 here turns it invisible once again */
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -519,10 +519,55 @@ void not_implemented(int passes, int index){
|
|||||||
mvaddstr(terminal_height-1, strlen(key_binding[index].comment) + strlen("\t"), "is not yet implemented");
|
mvaddstr(terminal_height-1, strlen(key_binding[index].comment) + strlen("\t"), "is not yet implemented");
|
||||||
}
|
}
|
||||||
void jump_to_dir(int passes, int index){
|
void jump_to_dir(int passes, int index){
|
||||||
if ((char*)key_binding[index].black_magic) {
|
char *ch = (char*)key_binding[index].black_magic;
|
||||||
if (chdir(getenv((char*)key_binding[index].black_magic+1)) != 0) {
|
char slash = 0;
|
||||||
|
unsigned int env_len = 0;
|
||||||
|
while (*ch != '\0') {
|
||||||
|
if (*ch == '/') {
|
||||||
|
slash = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
env_len++;
|
||||||
|
ch++;
|
||||||
|
}
|
||||||
|
char *env_str = NULL;
|
||||||
|
char *env_parsed = NULL;
|
||||||
|
char *path = NULL;
|
||||||
|
ch = (char*)key_binding[index].black_magic;
|
||||||
|
if (*ch == '/') {
|
||||||
|
path = malloc(strlen((char*)key_binding[index].black_magic));
|
||||||
|
strcpy(path, (char*)key_binding[index].black_magic);
|
||||||
|
} else if (slash) {
|
||||||
|
env_str = malloc(env_len * sizeof(char));
|
||||||
|
memcpy(env_str, (char*)key_binding[index].black_magic +1, env_len);
|
||||||
|
env_str[env_len-1] = '\0';
|
||||||
|
env_parsed = getenv(env_str);
|
||||||
|
if (env_parsed) {
|
||||||
|
path = concat(env_parsed, (char*)key_binding[index].black_magic + env_len);
|
||||||
|
} else {
|
||||||
|
path = malloc(strlen((char*)key_binding[index].black_magic));
|
||||||
|
strcpy(path, (char*)key_binding[index].black_magic);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
env_parsed = getenv((char*)key_binding[index].black_magic +1);
|
||||||
|
if (env_parsed) {
|
||||||
|
path = malloc(strlen(env_parsed)+1);
|
||||||
|
strcpy(path, env_parsed);
|
||||||
|
} else {
|
||||||
|
path = malloc(strlen((char*)key_binding[index].black_magic));
|
||||||
|
strcpy(path, (char*)key_binding[index].black_magic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chdir(path) != 0) {
|
||||||
FAIL("jump_to_dir", "jumping to black_magic in config.h failed");
|
FAIL("jump_to_dir", "jumping to black_magic in config.h failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*env_parsed shall not be modified (read: free'd) - the man page*/
|
||||||
|
if (env_str) {
|
||||||
|
free(env_str);
|
||||||
|
}
|
||||||
|
if(path) {
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user