Compare commits
2
Commits
f88b86c1f5
...
ef4e49e022
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef4e49e022 | ||
|
|
eafb13d3e2 |
@@ -9,7 +9,6 @@
|
||||
unsigned int color_count;
|
||||
color *colors;
|
||||
|
||||
extern unsigned int settings;
|
||||
extern unsigned int status;
|
||||
|
||||
void parse_colors(char *line, short *fg, short *bg){
|
||||
@@ -31,7 +30,6 @@ void parse_colors(char *line, short *fg, short *bg){
|
||||
|
||||
void colors_init() {
|
||||
if (has_colors()) {
|
||||
settings |= SETTINGS_HAS_COLOR;
|
||||
start_color();
|
||||
color_count = 0;
|
||||
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
#define STATUS_QUIT_PROGRAM 1
|
||||
#define STATUS_RUN_BACKEND 2
|
||||
#define STATUS_RELOAD_DIRECTORY 4
|
||||
#define STATUS_UPDATE_ASYNC_REFRESH 8
|
||||
#define STATUS_UPDATE_SCREEN_RESIZE 16
|
||||
#define STATUS_UPDATE_SCREEN_CLEAR 32
|
||||
#define STATUS_UPDATE_SCREEN_MASK (STATUS_UPDATE_ASYNC_REFRESH | STATUS_UPDATE_SCREEN_RESIZE | STATUS_UPDATE_SCREEN_CLEAR)
|
||||
#define STATUS_UPDATE_SCREEN_RESIZE 8
|
||||
#define STATUS_UPDATE_SCREEN_CLEAR 16
|
||||
#define STATUS_USER_ROOT 128
|
||||
#define STATUS_INPUT_MATCH 256
|
||||
#define STATUS_DELTA_TIME 512
|
||||
|
||||
+21
-17
@@ -1,7 +1,6 @@
|
||||
#include <curses.h>
|
||||
#include <pthread.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -22,14 +21,12 @@ extern unsigned int terminal_height;
|
||||
extern unsigned int terminal_width;
|
||||
|
||||
extern unsigned int status;
|
||||
extern char *start_path;
|
||||
extern char *global_path;
|
||||
extern char *input;
|
||||
|
||||
extern time_t seed;
|
||||
|
||||
char search_buffer[INPUT_BUFFER_SIZE];
|
||||
unsigned int input_pass;
|
||||
unsigned long parsed_input_number;
|
||||
yank yank_files = { 0 };
|
||||
|
||||
@@ -52,6 +49,7 @@ void user_interactions() {
|
||||
char ch;
|
||||
unsigned long i;
|
||||
unsigned long binding_matches = 0;
|
||||
static unsigned int input_pass;
|
||||
|
||||
|
||||
ch = getch();
|
||||
@@ -81,6 +79,9 @@ void user_interactions() {
|
||||
|
||||
char cmp_len = strlen(input);
|
||||
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;
|
||||
}
|
||||
for (i = 0; i < binding_count; i++) {
|
||||
@@ -125,7 +126,9 @@ int read_string(WINDOW *win, int y, int x, char *str){
|
||||
while(1) {
|
||||
ch = wgetch(win);
|
||||
if (ch == '\n') {
|
||||
err = 0;
|
||||
break;
|
||||
} else if (ch == 27) { /* esc key */
|
||||
err = 1;
|
||||
break;
|
||||
} else if (ch == '\t') { /* tab */
|
||||
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--;
|
||||
mvwdelch(win, y, x + pass);
|
||||
}
|
||||
} else if (ch == 27) { /* esc key */
|
||||
err = 1;
|
||||
break;
|
||||
} else {
|
||||
mvwaddch(win, y, x + pass, ch);
|
||||
str[pass] = ch;
|
||||
@@ -155,7 +155,7 @@ void quit_program(){
|
||||
status = STATUS_QUIT_PROGRAM;
|
||||
}
|
||||
void update(){
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY );
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_CLEAR | STATUS_RELOAD_DIRECTORY );
|
||||
}
|
||||
void select_all(){
|
||||
unsigned long i;
|
||||
@@ -191,8 +191,8 @@ void move_left(unsigned long passes){
|
||||
for (i = 0; i < passes; i++) {
|
||||
change_dir("..");
|
||||
}
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void move_right(){
|
||||
|
||||
@@ -264,8 +264,8 @@ void move_right(){
|
||||
free(cmd);
|
||||
free(mime);
|
||||
}
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void toggle_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;
|
||||
move_down(1);
|
||||
}
|
||||
|
||||
status |= (STATUS_RUN_BACKEND);
|
||||
}
|
||||
void jump_bottom(){
|
||||
@@ -293,6 +294,7 @@ void open_with(){
|
||||
char *str = malloc(INPUT_BUFFER_SIZE);
|
||||
char *parsed_ui_text = parse_cmd(ui_open_with_text, mid_dir.current_file);
|
||||
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
||||
|
||||
if (read_string(win_b, 0, strlen(parsed_ui_text)+1, str) == 0) {
|
||||
if (str[0] == SETTINGS_COMMAND_FORK) {
|
||||
cmd = parse_cmd(str+1, mid_dir.current_file);
|
||||
@@ -311,8 +313,8 @@ void open_with(){
|
||||
}
|
||||
free(parsed_ui_text);
|
||||
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(){
|
||||
wclear(win_b);
|
||||
@@ -320,6 +322,7 @@ void rename_hovered(){
|
||||
tmp.file_name = malloc(INPUT_BUFFER_SIZE);
|
||||
char *parsed_ui_text = parse_cmd(ui_rename_text, mid_dir.current_file);
|
||||
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
||||
|
||||
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 *cmd1 = parse_cmd(cmd0, &tmp);
|
||||
@@ -329,8 +332,8 @@ void rename_hovered(){
|
||||
}
|
||||
free(parsed_ui_text);
|
||||
free(tmp.file_name);
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void delete(unsigned long passes){
|
||||
|
||||
@@ -371,6 +374,7 @@ void makedir(){
|
||||
free(cmd);
|
||||
}
|
||||
free(tmp.file_name);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void makefile(){
|
||||
@@ -384,6 +388,7 @@ void makefile(){
|
||||
free(cmd);
|
||||
}
|
||||
free(tmp.file_name);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void enter_shell(unsigned long passes, int index){
|
||||
@@ -399,7 +404,6 @@ void enter_shell(unsigned long passes, int index){
|
||||
curs_set(0);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
|
||||
}
|
||||
void jump_to_dir(unsigned long passes, int index){
|
||||
(void)passes;
|
||||
@@ -428,14 +432,14 @@ void jump_to_dir(unsigned long passes, int index){
|
||||
}
|
||||
free(to_env);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY );
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_CLEAR | STATUS_RELOAD_DIRECTORY );
|
||||
}
|
||||
void order_by(unsigned long passes, int index){
|
||||
(void)passes;
|
||||
|
||||
seed = time(NULL);
|
||||
|
||||
order_func = key_binding[index].black_magic;
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
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);
|
||||
system(cmd);
|
||||
free(cmd);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND);
|
||||
}
|
||||
void yank_file_path(){
|
||||
@@ -464,9 +469,8 @@ void yank_file_path(){
|
||||
free(cmd);
|
||||
free(tmp->file_name);
|
||||
free(tmp);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND);
|
||||
|
||||
|
||||
}
|
||||
void copy_file(unsigned long passes, int index){
|
||||
(void)passes;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "defines.h"
|
||||
#include "config.h"
|
||||
#include "threading.h"
|
||||
#include "window.c"
|
||||
#include "colors.h"
|
||||
#include "interactions.h"
|
||||
|
||||
@@ -18,9 +17,8 @@ unsigned int terminal_height;
|
||||
unsigned int terminal_width;
|
||||
unsigned int temp_heigth = 0; /*used for screen refresh*/
|
||||
unsigned int temp_width = 0;
|
||||
unsigned int settings;
|
||||
unsigned int file_modifiers = 0;
|
||||
unsigned int status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY) & ~STATUS_UPDATE_SCREEN_RESIZE;
|
||||
unsigned int status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_CLEAR | STATUS_UPDATE_SCREEN_RESIZE | STATUS_RELOAD_DIRECTORY) & ~STATUS_UPDATE_SCREEN_RESIZE;
|
||||
char *global_path;
|
||||
time_t seed;
|
||||
|
||||
@@ -149,9 +147,8 @@ void render_pass(){
|
||||
mvwin(win_b, terminal_height-1, 0);
|
||||
|
||||
}
|
||||
if (pthread_mutex_lock(&mutex_render) == 0 || status & STATUS_UPDATE_SCREEN_MASK) {
|
||||
if (pthread_mutex_lock(&mutex_render) == 0) {
|
||||
doupdate();
|
||||
status &= ~STATUS_UPDATE_SCREEN_MASK;
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
#include <curses.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "dir.h"
|
||||
|
||||
extern unsigned int terminal_height;
|
||||
extern unsigned int terminal_width;
|
||||
extern unsigned int status;
|
||||
extern char *input;
|
||||
|
||||
extern unsigned int timeout_time;
|
||||
extern unsigned int color_count;
|
||||
extern color *colors;
|
||||
|
||||
extern dir rgt_dir;
|
||||
extern dir mid_dir;
|
||||
extern dir lft_dir;
|
||||
extern char *top_buffer;
|
||||
extern char *rgt_buffer;
|
||||
extern char *btm_buffer;
|
||||
|
||||
|
||||
extern unsigned long top_width;
|
||||
|
||||
extern pthread_mutex_t mutex_top;
|
||||
extern pthread_mutex_t mutex_btm;
|
||||
extern pthread_mutex_t mutex_lft;
|
||||
extern pthread_mutex_t mutex_mid;
|
||||
extern pthread_mutex_t mutex_rgt;
|
||||
|
||||
void window_top(WINDOW *win){
|
||||
|
||||
if (pthread_mutex_trylock(&mutex_top) == 0) {
|
||||
if (*top_buffer != ' ') { /*printing ' ' (standard initialized value, see threading_init) makes valgrind throw a fuss*/
|
||||
wattron(win, COLOR_PAIR(COLOR_PATH));
|
||||
mvwaddstr(win, 0, 0, top_buffer);
|
||||
mvwaddch(win, 0, strlen(top_buffer), '/');
|
||||
wattroff(win, COLOR_PAIR(COLOR_PATH));
|
||||
if (mid_dir.file_count != 0) {
|
||||
mvwaddstr(win, 0, strlen(top_buffer)+1, mid_dir.current_file->file_name);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
} else {
|
||||
mvwaddstr(win, 0, terminal_width/2, "LOADING");
|
||||
/*
|
||||
status |= STATUS_UPDATE_SCREEN_GENERIC;
|
||||
*/
|
||||
}
|
||||
}
|
||||
void window_btm(WINDOW *win){
|
||||
|
||||
if (pthread_mutex_trylock(&mutex_btm) == 0) {
|
||||
if (*top_buffer != ' ') { /*printing ' ' (standard initialized value, see threading_init) makes valgrind throw a fuss*/
|
||||
mvwprintw(win, 0, 0, "%s", btm_buffer);
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_btm);
|
||||
/*the printing of the input char is done in user_interactions*/
|
||||
/*the printing of all possible inputs are done in user_interactions */
|
||||
} else {
|
||||
mvwaddstr(win, 0, terminal_width/2, "LOADING");
|
||||
/*
|
||||
status |= STATUS_UPDATE_SCREEN_GENERIC;
|
||||
*/
|
||||
}
|
||||
}
|
||||
void window_lft(WINDOW *win){
|
||||
|
||||
if (pthread_mutex_trylock(&mutex_lft) == 0) {
|
||||
print_dir(win, 0, &lft_dir);
|
||||
pthread_mutex_unlock(&mutex_lft);
|
||||
|
||||
} else {
|
||||
mvwaddstr(win, terminal_height/2, terminal_width/8, "LOADING");
|
||||
/*
|
||||
status |= STATUS_UPDATE_SCREEN_GENERIC;
|
||||
*/
|
||||
}
|
||||
}
|
||||
void window_mid(WINDOW *win){
|
||||
|
||||
if (pthread_mutex_trylock(&mutex_mid) == 0) {
|
||||
if (mid_dir.file_count == 0) {
|
||||
mvwaddstr(win, 0, 0, "empty");
|
||||
} else {
|
||||
print_dir(win, 1, &mid_dir);
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
} else {
|
||||
mvwaddstr(win, terminal_height/2, terminal_width/4, "LOADING");
|
||||
/*
|
||||
status |= STATUS_UPDATE_SCREEN_GENERIC;
|
||||
*/
|
||||
}
|
||||
}
|
||||
void window_rgt(WINDOW *win){
|
||||
|
||||
if (pthread_mutex_trylock(&mutex_rgt) == 0) {
|
||||
if (!rgt_dir.current_file) {
|
||||
mvwaddstr(win, 0, 0, "not accessible");
|
||||
}else if (rgt_dir.current_file->file_type == FILE_TYPE_OPEN_FILE) {
|
||||
mvwaddnstr(win, 0, 0, rgt_buffer, (terminal_width/2) * terminal_width);
|
||||
} else if ((rgt_dir.current_file->permissions & S_IRUSR) == 0) {
|
||||
mvwaddstr(win, 0, 0, "not accessible");
|
||||
} else {
|
||||
print_dir(win, 0, &rgt_dir);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&mutex_rgt);
|
||||
} else {
|
||||
mvwaddstr(win, terminal_height/2, terminal_width/4, "LOADING");
|
||||
/*
|
||||
status |= STATUS_UPDATE_SCREEN_GENERIC;
|
||||
*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user