cleanup
This commit is contained in:
+19
-15
@@ -1,7 +1,6 @@
|
|||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@@ -22,14 +21,12 @@ extern unsigned int terminal_height;
|
|||||||
extern unsigned int terminal_width;
|
extern unsigned int terminal_width;
|
||||||
|
|
||||||
extern unsigned int status;
|
extern unsigned int status;
|
||||||
extern char *start_path;
|
|
||||||
extern char *global_path;
|
extern char *global_path;
|
||||||
extern char *input;
|
extern char *input;
|
||||||
|
|
||||||
extern time_t seed;
|
extern time_t seed;
|
||||||
|
|
||||||
char search_buffer[INPUT_BUFFER_SIZE];
|
char search_buffer[INPUT_BUFFER_SIZE];
|
||||||
unsigned int input_pass;
|
|
||||||
unsigned long parsed_input_number;
|
unsigned long parsed_input_number;
|
||||||
yank yank_files = { 0 };
|
yank yank_files = { 0 };
|
||||||
|
|
||||||
@@ -52,6 +49,7 @@ void user_interactions() {
|
|||||||
char ch;
|
char ch;
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
unsigned long binding_matches = 0;
|
unsigned long binding_matches = 0;
|
||||||
|
static unsigned int input_pass;
|
||||||
|
|
||||||
|
|
||||||
ch = getch();
|
ch = getch();
|
||||||
@@ -81,6 +79,9 @@ void user_interactions() {
|
|||||||
|
|
||||||
char cmp_len = strlen(input);
|
char cmp_len = strlen(input);
|
||||||
if(strlen(input) < 1) {
|
if(strlen(input) < 1) {
|
||||||
|
/* strlen is 0 every iteration nothing is pressed
|
||||||
|
* should this be input in the strncmp, it always succeeds.
|
||||||
|
* this results in all possible bindings being printed at all times */
|
||||||
cmp_len = 1;
|
cmp_len = 1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < binding_count; i++) {
|
for (i = 0; i < binding_count; i++) {
|
||||||
@@ -125,7 +126,9 @@ int read_string(WINDOW *win, int y, int x, char *str){
|
|||||||
while(1) {
|
while(1) {
|
||||||
ch = wgetch(win);
|
ch = wgetch(win);
|
||||||
if (ch == '\n') {
|
if (ch == '\n') {
|
||||||
err = 0;
|
break;
|
||||||
|
} else if (ch == 27) { /* esc key */
|
||||||
|
err = 1;
|
||||||
break;
|
break;
|
||||||
} else if (ch == '\t') { /* tab */
|
} else if (ch == '\t') { /* tab */
|
||||||
memcpy(str + pass, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name));
|
memcpy(str + pass, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name));
|
||||||
@@ -136,9 +139,6 @@ int read_string(WINDOW *win, int y, int x, char *str){
|
|||||||
pass--;
|
pass--;
|
||||||
mvwdelch(win, y, x + pass);
|
mvwdelch(win, y, x + pass);
|
||||||
}
|
}
|
||||||
} else if (ch == 27) { /* esc key */
|
|
||||||
err = 1;
|
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
mvwaddch(win, y, x + pass, ch);
|
mvwaddch(win, y, x + pass, ch);
|
||||||
str[pass] = ch;
|
str[pass] = ch;
|
||||||
@@ -191,8 +191,8 @@ void move_left(unsigned long passes){
|
|||||||
for (i = 0; i < passes; i++) {
|
for (i = 0; i < passes; i++) {
|
||||||
change_dir("..");
|
change_dir("..");
|
||||||
}
|
}
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
|
||||||
|
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
void move_right(){
|
void move_right(){
|
||||||
|
|
||||||
@@ -264,8 +264,8 @@ void move_right(){
|
|||||||
free(cmd);
|
free(cmd);
|
||||||
free(mime);
|
free(mime);
|
||||||
}
|
}
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
|
||||||
|
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
void toggle_hidden_files(){
|
void toggle_hidden_files(){
|
||||||
file_modifiers ^= FILE_MODIFIERS_HIDDEN_FILES;
|
file_modifiers ^= FILE_MODIFIERS_HIDDEN_FILES;
|
||||||
@@ -277,6 +277,7 @@ void toggle_selection(unsigned long passes){
|
|||||||
mid_dir.current_file->status ^= FILE_STATUS_SELECTED;
|
mid_dir.current_file->status ^= FILE_STATUS_SELECTED;
|
||||||
move_down(1);
|
move_down(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND);
|
status |= (STATUS_RUN_BACKEND);
|
||||||
}
|
}
|
||||||
void jump_bottom(){
|
void jump_bottom(){
|
||||||
@@ -293,6 +294,7 @@ void open_with(){
|
|||||||
char *str = malloc(INPUT_BUFFER_SIZE);
|
char *str = malloc(INPUT_BUFFER_SIZE);
|
||||||
char *parsed_ui_text = parse_cmd(ui_open_with_text, mid_dir.current_file);
|
char *parsed_ui_text = parse_cmd(ui_open_with_text, mid_dir.current_file);
|
||||||
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
||||||
|
|
||||||
if (read_string(win_b, 0, strlen(parsed_ui_text)+1, str) == 0) {
|
if (read_string(win_b, 0, strlen(parsed_ui_text)+1, str) == 0) {
|
||||||
if (str[0] == SETTINGS_COMMAND_FORK) {
|
if (str[0] == SETTINGS_COMMAND_FORK) {
|
||||||
cmd = parse_cmd(str+1, mid_dir.current_file);
|
cmd = parse_cmd(str+1, mid_dir.current_file);
|
||||||
@@ -311,8 +313,8 @@ void open_with(){
|
|||||||
}
|
}
|
||||||
free(parsed_ui_text);
|
free(parsed_ui_text);
|
||||||
free(str);
|
free(str);
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_CLEAR);
|
|
||||||
|
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_CLEAR);
|
||||||
}
|
}
|
||||||
void rename_hovered(){
|
void rename_hovered(){
|
||||||
wclear(win_b);
|
wclear(win_b);
|
||||||
@@ -320,6 +322,7 @@ void rename_hovered(){
|
|||||||
tmp.file_name = malloc(INPUT_BUFFER_SIZE);
|
tmp.file_name = malloc(INPUT_BUFFER_SIZE);
|
||||||
char *parsed_ui_text = parse_cmd(ui_rename_text, mid_dir.current_file);
|
char *parsed_ui_text = parse_cmd(ui_rename_text, mid_dir.current_file);
|
||||||
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
||||||
|
|
||||||
if (read_string(win_b, 0, strlen(parsed_ui_text)+1, tmp.file_name) == 0) {
|
if (read_string(win_b, 0, strlen(parsed_ui_text)+1, tmp.file_name) == 0) {
|
||||||
char *cmd0 = parse_cmd(rename_cmd, mid_dir.current_file);
|
char *cmd0 = parse_cmd(rename_cmd, mid_dir.current_file);
|
||||||
char *cmd1 = parse_cmd(cmd0, &tmp);
|
char *cmd1 = parse_cmd(cmd0, &tmp);
|
||||||
@@ -329,8 +332,8 @@ void rename_hovered(){
|
|||||||
}
|
}
|
||||||
free(parsed_ui_text);
|
free(parsed_ui_text);
|
||||||
free(tmp.file_name);
|
free(tmp.file_name);
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
|
||||||
|
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
void delete(unsigned long passes){
|
void delete(unsigned long passes){
|
||||||
|
|
||||||
@@ -371,6 +374,7 @@ void makedir(){
|
|||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
free(tmp.file_name);
|
free(tmp.file_name);
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
void makefile(){
|
void makefile(){
|
||||||
@@ -384,6 +388,7 @@ void makefile(){
|
|||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
free(tmp.file_name);
|
free(tmp.file_name);
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
void enter_shell(unsigned long passes, int index){
|
void enter_shell(unsigned long passes, int index){
|
||||||
@@ -399,7 +404,6 @@ void enter_shell(unsigned long passes, int index){
|
|||||||
curs_set(0);
|
curs_set(0);
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||||
|
|
||||||
}
|
}
|
||||||
void jump_to_dir(unsigned long passes, int index){
|
void jump_to_dir(unsigned long passes, int index){
|
||||||
(void)passes;
|
(void)passes;
|
||||||
@@ -434,8 +438,8 @@ void order_by(unsigned long passes, int index){
|
|||||||
(void)passes;
|
(void)passes;
|
||||||
|
|
||||||
seed = time(NULL);
|
seed = time(NULL);
|
||||||
|
|
||||||
order_func = key_binding[index].black_magic;
|
order_func = key_binding[index].black_magic;
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
void cmd_on_selected(unsigned long passes, int index){
|
void cmd_on_selected(unsigned long passes, int index){
|
||||||
@@ -451,6 +455,7 @@ void yank_file_name(){
|
|||||||
char *cmd = parse_cmd(clipboard_cmd, mid_dir.current_file);
|
char *cmd = parse_cmd(clipboard_cmd, mid_dir.current_file);
|
||||||
system(cmd);
|
system(cmd);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND);
|
status |= (STATUS_RUN_BACKEND);
|
||||||
}
|
}
|
||||||
void yank_file_path(){
|
void yank_file_path(){
|
||||||
@@ -464,9 +469,8 @@ void yank_file_path(){
|
|||||||
free(cmd);
|
free(cmd);
|
||||||
free(tmp->file_name);
|
free(tmp->file_name);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND);
|
status |= (STATUS_RUN_BACKEND);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void copy_file(unsigned long passes, int index){
|
void copy_file(unsigned long passes, int index){
|
||||||
(void)passes;
|
(void)passes;
|
||||||
|
|||||||
Reference in New Issue
Block a user