cex

C/Curses file EXplorer
git clone git://git.wimdupont.com/cex.git
Log | Files | Refs | README | LICENSE

cex.h (4601B)


      1 #ifndef DISCODL_H
      2 #define DISCODL_H
      3 
      4 #define DEFAULT_HIDE TRUE
      5 #define MIME_MAX 255
      6 #define MIME_APP_MAX 255
      7 #define BORDER_SPACE_SIZE 2
      8 #define SEARCHLEN 20
      9 #define LN_ACCESS_DIR "$HOME/access"
     10 
     11 #define KEY_QUIT 'q'
     12 #define KEY_VUP 'k'
     13 #define KEY_VDOWN 'j'
     14 #define KEY_VPUP 'K'
     15 #define KEY_VPDOWN 'J'
     16 #define KEY_VLEFT 'h'
     17 #define KEY_VRIGHT 'l'
     18 #define KEY_VRIGHT_ABS 'L'
     19 #define KEY_BOT 'G'
     20 #define KEY_NEXT_SEARCH 'n'
     21 #define KEY_PREV_SEARCH 'N'
     22 #define KEY_HIDE '.'
     23 #define KEY_SEL_FILE ' '
     24 #define KEY_CLEAR_SEL 'c'
     25 #define KEY_CLEAR_SEARCH 'C'
     26 #define KEY_MAKE_FILE 'f'
     27 #define KEY_RM_FILE 'D'
     28 #define KEY_RENAME_FILE 'r'
     29 #define KEY_CP_SEL 'p'
     30 #define KEY_RM_SEL 'd'
     31 #define KEY_MV_SEL 'M'
     32 #define KEY_SEARCH '/'
     33 
     34 #define KEY_COMBO_GO 'g'
     35 #define KEY_COMBO_GO_TOP 'g'
     36 #define KEY_COMBO_GO_HOME 'h'
     37 #define KEY_COMBO_GO_ACCESS 'a'
     38 
     39 #define KEY_COMBO_INF 'i'
     40 #define KEY_COMBO_INF_OPEN 'o'
     41 
     42 #define KEY_COMBO_OPEN 'o'
     43 #define KEY_COMBO_OPEN_EXEC 'x'
     44 #define KEY_COMBO_OPEN_NOHUP_XDG 'o'
     45 
     46 #define KEY_COMBO_MAKE 'm'
     47 #define KEY_COMBO_MAKE_FILE 'f'
     48 #define KEY_COMBO_MAKE_DIR 'd'
     49 #define KEY_COMBO_MAKE_MOD 'm'
     50 #define KEY_COMBO_MAKE_ACCESS 'a'
     51 
     52 #define DIR_COLOR COLOR_BLUE
     53 #define LN_COLOR COLOR_CYAN
     54 #define INVALID_LN_COLOR COLOR_RED
     55 #define SEARCH_MATCH_COLOR COLOR_YELLOW
     56 #define TOP_TITLE_COLOR COLOR_YELLOW
     57 #define BOT_TITLE_COUNT_COLOR COLOR_BLUE
     58 #define BOT_TITLE_INFO_COLOR COLOR_RED
     59 #define PROMPT_COLOR COLOR_MAGENTA
     60 #define CHILDWIN_MESSAGE_COLOR COLOR_MAGENTA
     61 #define MARK_SELECTED_COLOR COLOR_GREEN
     62 
     63 #define ctrl(x)		((x) & 0x1f)
     64 
     65 typedef enum {OTHER, LEFT, RIGHT, UP, DOWN} Direction;
     66 typedef enum {CURRENT, PARENT, CHILD} WinType;
     67 typedef enum {COPY, REMOVE, MOVE} SelAction;
     68 
     69 typedef struct _win_file {
     70 	char d_name[256];
     71 	unsigned char d_type;
     72 	bool selected;
     73 } WinFile;
     74 
     75 typedef struct _dir_win {
     76 	WinType wintype;
     77 	WINDOW *window;
     78 	WinFile *winfiles;
     79 	char path[PATH_MAX];
     80 	char *message;
     81 	int maxx;
     82 	int maxy;
     83 	int startpr;
     84 	int highlight;
     85 	int filecount;
     86 	bool holdupdate;
     87 	bool usehighlight;
     88 } DirWin;
     89 
     90 static void init_dirwins();
     91 static void init_screen();
     92 static void resize();
     93 static void start();
     94 static void wpath(const char *filename);
     95 static void reset_flags();
     96 static void set_startpr(DirWin *dirwin);
     97 static void set_win_files(DirWin *dirwin);
     98 static void set_win_message(DirWin *dirwin, char *message);
     99 static void print_win(DirWin *dirwin);
    100 static void update_child_win();
    101 static void print_top_title();
    102 static void print_bot_title();
    103 static void print_content();
    104 static void show_file_mime();
    105 static void select_file(const char *path);
    106 static void exe_selection(SelAction action, const char *askn);
    107 static void clear_selected();
    108 static void clear_search();
    109 static void combo_key(int keypress);
    110 static void combo_go(int keypress);
    111 static void combo_inf(int keypress);
    112 static void combo_open(int keypress);
    113 static void combo_make(int keypress);
    114 static void change_dir(const char *chdname, Direction direction, bool abspath);
    115 static void change_parent_dir(Direction direction);
    116 static void open_child(bool exec);
    117 static void open_nohup_xdg();
    118 static void search();
    119 static void move_top(DirWin *dirwin);
    120 static void move_bot(DirWin *dirwin);
    121 static void move_page_up(DirWin *dirwin);
    122 static void move_page_down(DirWin *dirwin);
    123 static void move_up(DirWin *dirwin);
    124 static void move_down(DirWin *dirwin);
    125 static void next_search();
    126 static void prev_search();
    127 static void free_dirwin(DirWin *dirwin);
    128 static void run_command(size_t size, const char *fmt, ...);
    129 static void clean();
    130 static void fatal(const char *fmt, ...);
    131 static bool is_dir(DirWin *dirwin, size_t index);
    132 static bool is_selected(DirWin *dirwin, size_t count);
    133 static bool remove_selected(const char *sel);
    134 static bool prompt_confirm(size_t size, const char *fmt, ...);
    135 static int compare_file(const void *a, const void *b);
    136 static int get_mime(char *buf, size_t bufsize, const char *path);
    137 static int get_mime_default(char *buf, size_t bufsize, const char *mime);
    138 static int read_command(char *buf, size_t bufsize, const char *cmd);
    139 static int make_file(const char *path);
    140 static int make_dir(const char *path);
    141 static int make_mod();
    142 static int make_access();
    143 static int rm_file(const char *fname);
    144 static int rename_file();
    145 static char *prompt_answer(char *buf, size_t size, const char *question);
    146 static char *cpstr(char *dest, const char *src);
    147 static char *get_file_info(char *buf, const char *filepath);
    148 static char *get_fullpath(char *buf, DirWin *dirwin, size_t index);
    149 static char *get_dirname(char *buf, const char *path);
    150 static char *replace_home(char *buf, const char *path);
    151 
    152 #endif