Compare commits
12 Commits
905f6e8588
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a31f452ea | ||
|
|
daf43daa00 | ||
|
|
cf03a230b6 | ||
|
|
87bfdd1b86 | ||
|
|
20fee198ae | ||
|
|
632904fd89 | ||
|
|
dd5307b411 | ||
|
|
41933eb6d0 | ||
|
|
0a45d1e3e8 | ||
|
|
d33ac88de2 | ||
|
|
e42d55e66a | ||
|
|
f6380ddeda |
@@ -124,8 +124,8 @@ char* parse_cmd(const char *cmd, file *f){
|
|||||||
|
|
||||||
if (offset) {
|
if (offset) {
|
||||||
pos[1]= ' ';
|
pos[1]= ' ';
|
||||||
memcpy(pos + 1, offset+1, strlen(offset+1));
|
memcpy(pos + 1, offset+1, strlen(offset)+1);
|
||||||
pos[strlen(offset+1)] = '\0';
|
pos[strlen(offset)+1] = '\0';
|
||||||
} else {
|
} else {
|
||||||
pos[1] = '\0';
|
pos[1] = '\0';
|
||||||
}
|
}
|
||||||
|
|||||||
3
colors.c
3
colors.c
@@ -102,8 +102,7 @@ void colors_init() {
|
|||||||
while (getline(&line, &size, dircolors) != -1) {
|
while (getline(&line, &size, dircolors) != -1) {
|
||||||
fg = 7;
|
fg = 7;
|
||||||
bg = 0;
|
bg = 0;
|
||||||
if (line[0] == '.') {
|
if (line[0] == '.' && (extension = strtok(line, " ")) != NULL) {
|
||||||
extension = strtok(line, " ");
|
|
||||||
colors[i].file_extension = malloc(strlen(extension)+1);
|
colors[i].file_extension = malloc(strlen(extension)+1);
|
||||||
memcpy(colors[i].file_extension, extension, strlen(extension)+1);
|
memcpy(colors[i].file_extension, extension, strlen(extension)+1);
|
||||||
|
|
||||||
|
|||||||
31
config.h
31
config.h
@@ -14,6 +14,11 @@
|
|||||||
#include "interactions.h"
|
#include "interactions.h"
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
static const char clipboard_cmd[] = "echo ^ | xsel -ib --trim"; /*used in yank_text*/
|
||||||
|
static const char rename_cmd[] = "mv"; /* as used in rename_hovered, makedir and makefile */
|
||||||
|
static const char makefile_cmd[] = "touch"; /*as of now both only do ``rename_cmd new_name``*/
|
||||||
|
static const char makedir_cmd[] = "mkdir";
|
||||||
|
|
||||||
static const mimetype mimetype_default_cmd[] = {
|
static const mimetype mimetype_default_cmd[] = {
|
||||||
/* mimetype shell command
|
/* mimetype shell command
|
||||||
* ^ substring of "file --mime-type -b ./hovered"
|
* ^ substring of "file --mime-type -b ./hovered"
|
||||||
@@ -63,12 +68,12 @@ static const binding key_binding[] = {
|
|||||||
{ "n", move_up, NULL, "move up" },
|
{ "n", move_up, NULL, "move up" },
|
||||||
{ "s", move_right, NULL, "move right" }, /* if a dir is hovered, cd into it, if a file is selected, see mimetype_default_cmd */
|
{ "s", move_right, NULL, "move right" }, /* if a dir is hovered, cd into it, if a file is selected, see mimetype_default_cmd */
|
||||||
|
|
||||||
{ "\n", open_with, NULL, "open \"open with\" dialog" }, /* opens the hovered file with an arbitrary command */
|
{ "\n", open_with, NULL, "open \"open with\" dialog" }, /* execute shell cmd on file, accounts for SETTINGS_COMMAND_FORK */
|
||||||
{ "r", rename_hovered, NULL, "rename hovered file" }, /* renames currently hovered file/directory */
|
{ "r", rename_hovered, NULL, "rename hovered file" }, /* renames currently hovered file/directory */
|
||||||
{ "dD", delete, NULL, "delete file" }, /* deletes currently hovered OR selected file/directory
|
{ "dD", delete, NULL, "delete file" }, /* deletes currently hovered OR selected file/directory
|
||||||
* this means that it does not delete the hovered files if files are already selected */
|
* this means that it does not delete the hovered files if files are already selected */
|
||||||
{ "yn", yank_text, "name", "yank filename of hovered file" },
|
{ "yn", yank_file_name, NULL, "yank filename of hovered file" },
|
||||||
{ "yp", yank_text, "path", "yank path of hovered file" },
|
{ "yp", yank_file_path, NULL, "yank path of hovered file" },
|
||||||
{ "yy", yank_file, "copy", "copy/yank file/directory" },
|
{ "yy", yank_file, "copy", "copy/yank file/directory" },
|
||||||
{ "dd", yank_file, "cut", "cut file/directory" },
|
{ "dd", yank_file, "cut", "cut file/directory" },
|
||||||
{ "pp", paste, NULL, "paste" },
|
{ "pp", paste, NULL, "paste" },
|
||||||
@@ -114,13 +119,12 @@ static const binding key_binding[] = {
|
|||||||
|
|
||||||
static const char size_unit[] = { 'B', 'K', 'M', 'G', 'T', 'P' }; /* this defines the maximum size unit, deleting everything except B results in all sizes being displayed in byte */
|
static const char size_unit[] = { 'B', 'K', 'M', 'G', 'T', 'P' }; /* this defines the maximum size unit, deleting everything except B results in all sizes being displayed in byte */
|
||||||
|
|
||||||
static const char clipboard_cmd[] = "xsel -ib --trim"; /* assembles the following shell cmd: echo "hovered_file" | clipboard_cmd */
|
|
||||||
static const char ui_btm_text_storage_left[] = "total free";
|
static const char ui_btm_text_storage_left[] = "total free";
|
||||||
static const char ui_btm_current_dir_size[] = "sum of dir,";
|
static const char ui_btm_current_dir_size[] = "sum of dir,";
|
||||||
static const char ui_open_with_text_0[] = "open"; /*ui_open_with_text_0 \"selected_file\" ui_open_with_text_1*/
|
static const char ui_open_with_text[] = "open "SETTINGS_COMMAND_REPLACE_STR" with:";
|
||||||
static const char ui_open_with_text_1[] = "with:";
|
static const char ui_rename_text[] = "rename "SETTINGS_COMMAND_REPLACE_STR" to:";
|
||||||
static const char ui_rename_text_0[] = "rename"; /*ui_rename_text_0 \"selected_file\" ui_rename_text_1*/
|
static const char ui_makefile_text[] = "makedir:";
|
||||||
static const char ui_rename_text_1[] = "to:";
|
static const char ui_makedir_text[] = "makefile:";
|
||||||
static const char ui_delete_text[] = "delete:";
|
static const char ui_delete_text[] = "delete:";
|
||||||
|
|
||||||
/* {{{ */
|
/* {{{ */
|
||||||
@@ -130,6 +134,9 @@ static const unsigned long file_extension_default_count = sizeof(file_extension_
|
|||||||
static const char size_unit_count = (sizeof(size_unit) / sizeof(size_unit[0])) - 1;
|
static const char size_unit_count = (sizeof(size_unit) / sizeof(size_unit[0])) - 1;
|
||||||
#else
|
#else
|
||||||
static const char clipboard_cmd[];
|
static const char clipboard_cmd[];
|
||||||
|
static const char rename_cmd[];
|
||||||
|
static const char makefile_cmd[];
|
||||||
|
static const char makedir_cmd[];
|
||||||
static const mimetype mimetype_default_cmd[];
|
static const mimetype mimetype_default_cmd[];
|
||||||
static const extension file_extension_default_cmd[];
|
static const extension file_extension_default_cmd[];
|
||||||
static const binding key_binding[];
|
static const binding key_binding[];
|
||||||
@@ -138,10 +145,10 @@ static const unsigned long mimetype_default_count;
|
|||||||
static const unsigned long file_extension_default_count;
|
static const unsigned long file_extension_default_count;
|
||||||
static const char size_unit[];
|
static const char size_unit[];
|
||||||
static const char size_unit_count;
|
static const char size_unit_count;
|
||||||
static const char ui_open_with_text_0[];
|
static const char ui_open_with_text[];
|
||||||
static const char ui_open_with_text_1[];
|
static const char ui_makedir_text[];
|
||||||
static const char ui_rename_text_0[];
|
static const char ui_makefile_text[];
|
||||||
static const char ui_rename_text_1[];
|
static const char ui_rename_text[];
|
||||||
static const char ui_delete_text[];
|
static const char ui_delete_text[];
|
||||||
#endif
|
#endif
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ typedef struct Yank {
|
|||||||
} yank;
|
} yank;
|
||||||
typedef struct Linked_dir {
|
typedef struct Linked_dir {
|
||||||
char *path;
|
char *path;
|
||||||
unsigned long selected_file_current;
|
unsigned long index;
|
||||||
struct Linked_dir *next;
|
struct Linked_dir *next;
|
||||||
} linked_dir;
|
} linked_dir;
|
||||||
|
|
||||||
|
|||||||
89
dir.c
89
dir.c
@@ -17,23 +17,25 @@ extern unsigned int settings;
|
|||||||
extern unsigned int file_modifiers;
|
extern unsigned int file_modifiers;
|
||||||
extern unsigned int color_count;
|
extern unsigned int color_count;
|
||||||
extern unsigned int terminal_height;
|
extern unsigned int terminal_height;
|
||||||
|
extern char *global_path;
|
||||||
extern color *colors;
|
extern color *colors;
|
||||||
int (*order_func)() = sort_natural;
|
int (*order_func)() = sort_natural;
|
||||||
linked_dir *visited_dirs;
|
linked_dir *list_beginning;
|
||||||
linked_dir *current_dir;
|
linked_dir *current_linked_dir;
|
||||||
|
|
||||||
|
|
||||||
unsigned long get_dir_size(char *path){
|
unsigned long get_dir_size(char *path){
|
||||||
DIR *dir = opendir(path);
|
DIR *dir = opendir(path);
|
||||||
unsigned long entry_count = 0;
|
unsigned long entry_count = 0;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
if (dir && file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) {
|
if (dir) {
|
||||||
|
if (file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) {
|
||||||
while ((entry=readdir(dir))) {
|
while ((entry=readdir(dir))) {
|
||||||
entry_count++;
|
entry_count++;
|
||||||
}
|
}
|
||||||
/* removes files "." and ".." */
|
/* removes files "." and ".." */
|
||||||
entry_count -= 2;
|
entry_count -= 2;
|
||||||
} else if (dir) {
|
} else {
|
||||||
while ((entry=readdir(dir))) {
|
while ((entry=readdir(dir))) {
|
||||||
if (entry->d_name[0] != '.') {
|
if (entry->d_name[0] != '.') {
|
||||||
entry_count++;
|
entry_count++;
|
||||||
@@ -41,6 +43,7 @@ unsigned long get_dir_size(char *path){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
}
|
||||||
return entry_count;
|
return entry_count;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -294,13 +297,81 @@ void print_dir(WINDOW *win, char print_info, dir *dir){
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void dir_changed(){
|
||||||
|
|
||||||
|
char *path = getcwd(NULL, 0);
|
||||||
|
current_linked_dir = list_beginning;
|
||||||
|
while (current_linked_dir->next != NULL) {
|
||||||
|
if(strcmp(current_linked_dir->path, path) == 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
current_linked_dir = current_linked_dir->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strcmp(current_linked_dir->path, path) == 0) {
|
||||||
|
mid_dir.current_file = &mid_dir.file_list[current_linked_dir->index];
|
||||||
|
} else {
|
||||||
|
/**/
|
||||||
|
|
||||||
|
current_linked_dir->next = malloc(sizeof(linked_dir));
|
||||||
|
current_linked_dir->next->path = malloc(strlen(global_path)+1);
|
||||||
|
memcpy(current_linked_dir->next->path, global_path, strlen(global_path)+1);
|
||||||
|
current_linked_dir->next->next = NULL;
|
||||||
|
current_linked_dir->next->index = 0;
|
||||||
|
|
||||||
|
mid_dir.current_file = mid_dir.file_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
void change_dir(char *new_path){
|
||||||
|
|
||||||
|
char *old_path = getcwd(NULL, 0);
|
||||||
|
current_linked_dir = list_beginning;
|
||||||
|
while (current_linked_dir->next != NULL) {
|
||||||
|
if(strcmp(current_linked_dir->path, old_path) == 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
current_linked_dir = current_linked_dir->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strcmp(current_linked_dir->path, old_path) == 0) {
|
||||||
|
current_linked_dir->index = mid_dir.current_file - mid_dir.file_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir(new_path);
|
||||||
|
char *new_path_real = getcwd(NULL, 0);
|
||||||
|
|
||||||
|
current_linked_dir = list_beginning;
|
||||||
|
while (current_linked_dir->next != NULL) {
|
||||||
|
if(strcmp(current_linked_dir->path, new_path_real) == 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
current_linked_dir = current_linked_dir->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strcmp(current_linked_dir->path, new_path_real) != 0) {
|
||||||
|
current_linked_dir->next = malloc(sizeof(linked_dir));
|
||||||
|
current_linked_dir = current_linked_dir->next;
|
||||||
|
current_linked_dir->path = malloc(strlen(new_path_real)+1);
|
||||||
|
memcpy(current_linked_dir->path, new_path_real, strlen(new_path_real)+1);
|
||||||
|
current_linked_dir->next = NULL;
|
||||||
|
current_linked_dir->index = 0;
|
||||||
|
/*TODO(2026-05-25T22:49:30)
|
||||||
|
*handle if new_path == "..", should this case be true, focus the index on which the old_path falls on*/
|
||||||
|
}
|
||||||
|
mid_dir.current_file = &mid_dir.file_list[current_linked_dir->index];
|
||||||
|
|
||||||
|
free(old_path);
|
||||||
|
free(new_path_real);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void dir_init(){
|
void dir_init(){
|
||||||
visited_dirs = malloc(sizeof(linked_dir));
|
list_beginning = malloc(sizeof(linked_dir));
|
||||||
visited_dirs->path = getcwd(NULL, 0);
|
list_beginning->path = getcwd(NULL, 0);
|
||||||
visited_dirs->selected_file_current = 0;
|
list_beginning->index = 0;
|
||||||
visited_dirs->next = NULL;
|
list_beginning->next = NULL;
|
||||||
current_dir = visited_dirs;
|
current_linked_dir = list_beginning;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
154
interactions.c
154
interactions.c
@@ -23,6 +23,7 @@ extern unsigned int terminal_width;
|
|||||||
|
|
||||||
extern unsigned int status;
|
extern unsigned int status;
|
||||||
extern char *start_path;
|
extern char *start_path;
|
||||||
|
extern char *global_path;
|
||||||
extern char *input;
|
extern char *input;
|
||||||
|
|
||||||
extern time_t seed;
|
extern time_t seed;
|
||||||
@@ -127,18 +128,18 @@ int read_string(WINDOW *win, int y, int x, char *str){
|
|||||||
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));
|
||||||
mvwaddstr(win, y, x +pass, mid_dir.current_file->file_name);
|
mvwaddstr(win, y, x + pass, mid_dir.current_file->file_name);
|
||||||
pass += strlen(mid_dir.current_file->file_name);
|
pass += strlen(mid_dir.current_file->file_name);
|
||||||
} else if (ch == 127) { /* backspace */
|
} else if (ch == 127) { /* backspace */
|
||||||
if (pass > 0) {
|
if (pass > 0) {
|
||||||
pass--;
|
pass--;
|
||||||
mvwdelch(win, y, pass);
|
mvwdelch(win, y, x + pass);
|
||||||
}
|
}
|
||||||
} else if (ch == 27) { /* esc key */
|
} else if (ch == 27) { /* esc key */
|
||||||
err = 1;
|
err = 1;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
mvwaddch(win, y, x +pass, ch);
|
mvwaddch(win, y, x + pass, ch);
|
||||||
str[pass] = ch;
|
str[pass] = ch;
|
||||||
pass++;
|
pass++;
|
||||||
}
|
}
|
||||||
@@ -162,15 +163,6 @@ void select_all(){
|
|||||||
}
|
}
|
||||||
status |= (STATUS_RUN_BACKEND);
|
status |= (STATUS_RUN_BACKEND);
|
||||||
}
|
}
|
||||||
void dir_changed(){
|
|
||||||
unsigned long i;
|
|
||||||
|
|
||||||
for(i = 0; i < mid_dir.file_count; i++) {
|
|
||||||
mid_dir.file_list[i].status = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY );
|
|
||||||
}
|
|
||||||
void move_down(unsigned long passes){
|
void move_down(unsigned long passes){
|
||||||
|
|
||||||
mid_dir.current_file += passes;
|
mid_dir.current_file += passes;
|
||||||
@@ -192,11 +184,7 @@ void move_up(unsigned long passes){
|
|||||||
void move_left(unsigned long passes){
|
void move_left(unsigned long passes){
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
for (i = 0; i < passes; i++) {
|
for (i = 0; i < passes; i++) {
|
||||||
if (chdir("..") != 0) {
|
change_dir("..");
|
||||||
/* TODO(2025-07-09T00:30:05) fix */
|
|
||||||
FAIL("move_left", "unhandled error of chdir");
|
|
||||||
}
|
|
||||||
dir_changed();
|
|
||||||
}
|
}
|
||||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||||
|
|
||||||
@@ -204,13 +192,8 @@ void move_left(unsigned long passes){
|
|||||||
void move_right(){
|
void move_right(){
|
||||||
|
|
||||||
if (mid_dir.current_file->file_type & FILE_TYPE_DIR) {
|
if (mid_dir.current_file->file_type & FILE_TYPE_DIR) {
|
||||||
if (chdir(mid_dir.current_file->file_name) != 0) {
|
change_dir(mid_dir.current_file->file_name);
|
||||||
/* TODO(2026-05-05T20:12:14) fix */
|
|
||||||
FAIL("move_right", "unhandled error of chdir");
|
|
||||||
}
|
|
||||||
dir_changed();
|
|
||||||
} else if (mid_dir.current_file->file_type & FILE_TYPE_EXEC) {
|
} else if (mid_dir.current_file->file_type & FILE_TYPE_EXEC) {
|
||||||
chdir(".");
|
|
||||||
char *cmd = parse_cmd("./"SETTINGS_COMMAND_REPLACE_STR,mid_dir.current_file);
|
char *cmd = parse_cmd("./"SETTINGS_COMMAND_REPLACE_STR,mid_dir.current_file);
|
||||||
if (system(cmd)) {
|
if (system(cmd)) {
|
||||||
}
|
}
|
||||||
@@ -298,19 +281,78 @@ void jump_top(){
|
|||||||
status |= (STATUS_RUN_BACKEND);
|
status |= (STATUS_RUN_BACKEND);
|
||||||
}
|
}
|
||||||
void open_with(){
|
void open_with(){
|
||||||
TODO;
|
wclear(win_b);
|
||||||
|
char *cmd;
|
||||||
|
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);
|
||||||
|
pid_t pid = fork();
|
||||||
|
if (pid == 0 && setsid()) {
|
||||||
|
system(cmd);
|
||||||
|
status = STATUS_QUIT_PROGRAM;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cmd = parse_cmd(str, mid_dir.current_file);
|
||||||
|
if (system(cmd)) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(cmd);
|
||||||
|
}
|
||||||
|
free(parsed_ui_text);
|
||||||
|
free(str);
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_CLEAR);
|
||||||
|
|
||||||
}
|
}
|
||||||
void rename_hovered(){
|
void rename_hovered(){
|
||||||
TODO;
|
wclear(win_b);
|
||||||
|
file tmp;
|
||||||
|
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);
|
||||||
|
system(cmd1);
|
||||||
|
free(cmd0);
|
||||||
|
free(cmd1);
|
||||||
|
}
|
||||||
|
free(parsed_ui_text);
|
||||||
|
free(tmp.file_name);
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||||
|
|
||||||
}
|
}
|
||||||
void delete(){
|
void delete(){
|
||||||
TODO;
|
TODO;
|
||||||
}
|
}
|
||||||
void makedir(){
|
void makedir(){
|
||||||
TODO;
|
wclear(win_b);
|
||||||
|
file tmp;
|
||||||
|
tmp.file_name = malloc(INPUT_BUFFER_SIZE);
|
||||||
|
mvwprintw(win_b, 0, 0, ui_makedir_text);
|
||||||
|
if (read_string(win_b, 0, strlen(ui_makedir_text)+1, tmp.file_name) == 0) {
|
||||||
|
char *cmd = parse_cmd(makedir_cmd, &tmp);
|
||||||
|
system(cmd);
|
||||||
|
free(cmd);
|
||||||
|
}
|
||||||
|
free(tmp.file_name);
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
void makefile(){
|
void makefile(){
|
||||||
TODO;
|
wclear(win_b);
|
||||||
|
file tmp;
|
||||||
|
tmp.file_name = malloc(INPUT_BUFFER_SIZE);
|
||||||
|
mvwprintw(win_b, 0, 0, ui_makefile_text);
|
||||||
|
if (read_string(win_b, 0, strlen(ui_makefile_text)+1, tmp.file_name) == 0) {
|
||||||
|
char *cmd = parse_cmd(makefile_cmd, &tmp);
|
||||||
|
system(cmd);
|
||||||
|
free(cmd);
|
||||||
|
}
|
||||||
|
free(tmp.file_name);
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||||
}
|
}
|
||||||
void enter_shell(unsigned long passes, int index){
|
void enter_shell(unsigned long passes, int index){
|
||||||
(void)passes; /*remove compiler warning*/
|
(void)passes; /*remove compiler warning*/
|
||||||
@@ -336,7 +378,33 @@ void not_implemented(unsigned long passes, int index){
|
|||||||
TODO;
|
TODO;
|
||||||
}
|
}
|
||||||
void jump_to_dir(unsigned long passes, int index){
|
void jump_to_dir(unsigned long passes, int index){
|
||||||
TODO;
|
(void)passes;
|
||||||
|
|
||||||
|
unsigned long len;
|
||||||
|
char *c = strchr(key_binding[index].black_magic, '/');
|
||||||
|
if (c) {
|
||||||
|
len = c - (char*)key_binding[index].black_magic;
|
||||||
|
} else {
|
||||||
|
len = strlen(key_binding[index].black_magic);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *to_env = malloc(len + 1);
|
||||||
|
memcpy(to_env, key_binding[index].black_magic, len);
|
||||||
|
to_env[len] = '\0';
|
||||||
|
char *env = getenv(to_env + 1); /*+1 to remove the '$' prefix, freeing env always segfaults*/
|
||||||
|
|
||||||
|
if (env) {
|
||||||
|
char *path = malloc(strlen(key_binding[index].black_magic) + strlen(env) + 1);
|
||||||
|
memcpy(path, env, strlen(env));
|
||||||
|
memcpy(path + strlen(env), key_binding[index].black_magic + len, strlen(key_binding[index].black_magic)+1);
|
||||||
|
change_dir(path);
|
||||||
|
free(path);
|
||||||
|
} else {
|
||||||
|
change_dir(key_binding[index].black_magic);
|
||||||
|
}
|
||||||
|
free(to_env);
|
||||||
|
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY );
|
||||||
}
|
}
|
||||||
void order_by(unsigned long passes, int index){
|
void order_by(unsigned long passes, int index){
|
||||||
(void)passes;
|
(void)passes;
|
||||||
@@ -347,10 +415,34 @@ void order_by(unsigned long passes, int index){
|
|||||||
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){
|
||||||
TODO;
|
(void)passes;
|
||||||
|
|
||||||
|
char *cmd = parse_cmd(key_binding[index].black_magic, mid_dir.current_file);
|
||||||
|
system(cmd);
|
||||||
|
free(cmd);
|
||||||
|
|
||||||
|
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_CLEAR);
|
||||||
}
|
}
|
||||||
void yank_text(unsigned long passes, int index){
|
void yank_file_name(){
|
||||||
TODO;
|
char *cmd = parse_cmd(clipboard_cmd, mid_dir.current_file);
|
||||||
|
system(cmd);
|
||||||
|
free(cmd);
|
||||||
|
status |= (STATUS_RUN_BACKEND);
|
||||||
|
}
|
||||||
|
void yank_file_path(){
|
||||||
|
file *tmp = malloc(sizeof(file));
|
||||||
|
tmp->file_name = malloc(strlen(global_path)+1+strlen(mid_dir.current_file->file_name)+1);
|
||||||
|
memcpy(tmp->file_name, global_path, strlen(global_path));
|
||||||
|
memcpy(tmp->file_name+strlen(global_path)+1, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1);
|
||||||
|
tmp->file_name[strlen(global_path)] = '/'; /*no +1 is needed*/
|
||||||
|
char *cmd = parse_cmd(clipboard_cmd, tmp);
|
||||||
|
system(cmd);
|
||||||
|
free(cmd);
|
||||||
|
free(tmp->file_name);
|
||||||
|
free(tmp);
|
||||||
|
status |= (STATUS_RUN_BACKEND);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void yank_file(unsigned long passes, int index){
|
void yank_file(unsigned long passes, int index){
|
||||||
TODO;
|
TODO;
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ void not_implemented(unsigned long passes, int index);
|
|||||||
void jump_to_dir(unsigned long passes, int index);
|
void jump_to_dir(unsigned long passes, int index);
|
||||||
void order_by(unsigned long passes, int index);
|
void order_by(unsigned long passes, int index);
|
||||||
void cmd_on_selected(unsigned long passes, int index);
|
void cmd_on_selected(unsigned long passes, int index);
|
||||||
void yank_text(unsigned long passes, int index);
|
void yank_file_name();
|
||||||
|
void yank_file_path();
|
||||||
void yank_file(unsigned long passes, int index);
|
void yank_file(unsigned long passes, int index);
|
||||||
void paste();
|
void paste();
|
||||||
void search();
|
void search();
|
||||||
|
|||||||
Reference in New Issue
Block a user