implementation of yank_file_name and yank_file_path
This commit is contained in:
7
config.h
7
config.h
@@ -14,6 +14,8 @@
|
||||
#include "interactions.h"
|
||||
/* }}} */
|
||||
|
||||
static const char clipboard_cmd[] = "echo ^ | xsel -ib --trim"; /*used in yank_text*/
|
||||
|
||||
static const mimetype mimetype_default_cmd[] = {
|
||||
/* mimetype shell command
|
||||
* ^ substring of "file --mime-type -b ./hovered"
|
||||
@@ -67,8 +69,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" },
|
||||
{ "yn", yank_file_name, NULL, "yank filename of hovered file" },
|
||||
{ "yp", yank_file_path, NULL, "yank path of hovered file" },
|
||||
{ "yy", yank_file, "copy", "copy/yank file/directory" },
|
||||
{ "dd", yank_file, "cut", "cut file/directory" },
|
||||
{ "pp", paste, NULL, "paste" },
|
||||
@@ -114,7 +116,6 @@ 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,";
|
||||
static const char ui_open_with_text_0[] = "open"; /*ui_open_with_text_0 \"selected_file\" ui_open_with_text_1*/
|
||||
|
||||
@@ -23,6 +23,7 @@ extern unsigned int terminal_width;
|
||||
|
||||
extern unsigned int status;
|
||||
extern char *start_path;
|
||||
extern char *global_path;
|
||||
extern char *input;
|
||||
|
||||
extern time_t seed;
|
||||
@@ -349,8 +350,26 @@ void order_by(unsigned long passes, int index){
|
||||
void cmd_on_selected(unsigned long passes, int index){
|
||||
TODO;
|
||||
}
|
||||
void yank_text(unsigned long passes, int index){
|
||||
TODO;
|
||||
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(){
|
||||
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){
|
||||
TODO;
|
||||
|
||||
@@ -26,7 +26,8 @@ void not_implemented(unsigned long passes, int index);
|
||||
void jump_to_dir(unsigned long passes, int index);
|
||||
void order_by(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 paste();
|
||||
void search();
|
||||
|
||||
Reference in New Issue
Block a user