Compare commits
2 Commits
8839f737c5
...
4d9dc46691
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d9dc46691 | ||
|
|
8dcf88baea |
4
config.h
4
config.h
@@ -60,6 +60,8 @@ static const binding key_binding[] = {
|
||||
{ "r", rename_hovered, NULL, "rename hovered file" }, /* renames currently hovered 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 */
|
||||
{ "yn", yank_text, "name", "yank filename of hovered file" },
|
||||
{ "yp", yank_text, "path", "yank path of hovered file" },
|
||||
{ "yy", yank_file, "copy", "copy/yank file/directory" },
|
||||
{ "dd", yank_file, "cut", "cut file/directory" },
|
||||
{ "pp", paste, NULL, "paste" },
|
||||
@@ -101,6 +103,7 @@ 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 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_current_dir_size[] = "sum of dir";
|
||||
|
||||
@@ -110,6 +113,7 @@ static const unsigned long mimetype_default_count = sizeof(mimetype_default_cmd)
|
||||
static const unsigned long file_extension_default_count = sizeof(file_extension_default_cmd) / sizeof(extension);
|
||||
static const char size_unit_count = (sizeof(size_unit) / sizeof(size_unit[0])) - 1;
|
||||
#else
|
||||
static const char clipboard_cmd[];
|
||||
static const mimetype mimetype_default_cmd[];
|
||||
static const extension file_extension_default_cmd[];
|
||||
static const binding key_binding[];
|
||||
|
||||
@@ -703,6 +703,27 @@ void cmd_on_selected(int passes, int index){
|
||||
free(file_str);
|
||||
}
|
||||
}
|
||||
void yank_text(int passes, int index){
|
||||
(void)passes;
|
||||
char *cmd;
|
||||
if (strncmp((char*)key_binding[index].black_magic, "path", 4) == 0) {
|
||||
char *path=getcwd(NULL, 0);
|
||||
cmd = concat("echo \"", path);
|
||||
cmd = concat(cmd, "/");
|
||||
cmd = concat(cmd, mid_content[selected_file_current].file_name);
|
||||
cmd = concat(cmd, "\" | ");
|
||||
cmd = concat(cmd, clipboard_cmd);
|
||||
free(path);
|
||||
} else {
|
||||
cmd = concat("echo \"", mid_content[selected_file_current].file_name);
|
||||
cmd = concat(cmd, "\" | ");
|
||||
cmd = concat(cmd, clipboard_cmd);
|
||||
}
|
||||
if (system(cmd) == -1) {
|
||||
/*do nothing*/
|
||||
}
|
||||
free(cmd);
|
||||
}
|
||||
void yank_file(int passes, int index){
|
||||
(void)passes;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ void not_implemented(int passes, int index);
|
||||
void jump_to_dir(int passes, int index);
|
||||
void order_by(int passes, int index);
|
||||
void cmd_on_selected(int passes, int index);
|
||||
void yank_text(int passes, int index);
|
||||
void yank_file(int passes, int index);
|
||||
void paste();
|
||||
void search();
|
||||
|
||||
28
threading.c
28
threading.c
@@ -277,6 +277,16 @@ void *thread_btm(){
|
||||
|
||||
char size_index = -1;
|
||||
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
unsigned long i;
|
||||
unsigned long total_dir_size = 0;
|
||||
for(i = 0; i < mid_file_count; i++) {
|
||||
if (!(mid_content[i].file_type & (FILE_TYPE_DIR | FILE_TYPE_SYMLINK))) {
|
||||
total_dir_size += mid_content[i].file_size;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
|
||||
do {
|
||||
parsed_number=disk_size_free;
|
||||
disk_size_free /= 1024;
|
||||
@@ -286,9 +296,25 @@ void *thread_btm(){
|
||||
|
||||
snprintf(float_str, 10, "%0.2lf", parsed_number);
|
||||
|
||||
memcpy(btm_buffer + (offset_back - strlen(float_str) - 1), float_str, strlen(float_str));
|
||||
btm_buffer[offset_back - 2] = size_unit[(unsigned)size_index];
|
||||
offset_back -= strlen(float_str) + 2;
|
||||
memcpy(btm_buffer + offset_back, float_str, strlen(float_str));
|
||||
|
||||
parsed_number = 0;
|
||||
size_index = -1;
|
||||
do {
|
||||
parsed_number=total_dir_size;
|
||||
total_dir_size /= 1024;
|
||||
size_index++;
|
||||
} while (total_dir_size > 1 && size_index < size_unit_count);
|
||||
|
||||
offset_back -= strlen(ui_btm_current_dir_size) + 5;
|
||||
memcpy(btm_buffer + offset_back, ui_btm_current_dir_size, strlen(ui_btm_current_dir_size));
|
||||
|
||||
snprintf(float_str, 10, "%0.2lf", parsed_number);
|
||||
btm_buffer[offset_back - 2] = size_unit[(unsigned)size_index];
|
||||
offset_back -= strlen(float_str) + 2;
|
||||
memcpy(btm_buffer + offset_back, float_str, strlen(float_str));
|
||||
|
||||
pthread_mutex_unlock(&mutex_btm);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user