sfm

simple file manager
git clone git://git.afify.dev/sfm
Log | Files | Refs | README | LICENSE

commit 6577dc495b23cf5b26e5c3db874d857d1b83ac9c
parent 9e5fe7eddf09fe3fa15e12e81e5680ce8eb2fdb5
Author: afify <hassan@afify.dev>
Date:   Tue, 14 Jul 2020 20:55:10 +0300

[feat] show one cursor

Diffstat:
Msfm.c | 36++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+), 0 deletions(-)

diff --git a/sfm.c b/sfm.c @@ -83,6 +83,9 @@ static void print_prompt(char*); static void clear(int, int, int, uint16_t); static void clear_status(void); static void clear_pane(int); +static void print_row(Pane*, int, int16_t, int16_t); +static void add_hi(Pane*, size_t); +static void rm_hi(Pane*, size_t); static char *get_extentions(char*); static char *get_full_path(char*, char*); static char *get_file_info(Entry*); @@ -234,6 +237,34 @@ clear_pane(int pane) } +static void +print_row(Pane *pane, int entpos, int16_t fg, int16_t bg) +{ + int x, y; + char *result; + int width; + + width = (tb_width() / 2) - 4; + result = pane->direntr[entpos-1].name; + x = pane->dirx; + y = entpos; + + printf_tb(x, y, fg, bg, "%*.*s", ~width, width, result); +} + +static void +add_hi(Pane *pane, size_t entpos) +{ + print_row(pane, entpos, + TB_DEFAULT|TB_REVERSE|TB_BOLD, TB_DEFAULT|TB_REVERSE); +} + +static void +rm_hi(Pane *pane, size_t entpos) +{ + print_row(pane, entpos, TB_DEFAULT, TB_DEFAULT); +} + static char * get_extentions(char *str) { @@ -941,9 +972,13 @@ start_ev(void) if (ev.key == TB_KEY_SPACE) { if (cpane == &pane_l) { + rm_hi(&pane_l, pane_l.hdir); + add_hi(&pane_r, pane_r.hdir); chdir(pane_r.dirn); cpane = &pane_r; }else if (cpane == &pane_r) { + rm_hi(&pane_r, pane_r.hdir); + add_hi(&pane_l, pane_l.hdir); chdir(pane_l.dirn); cpane = &pane_l; } @@ -1380,6 +1415,7 @@ start(void) listdir(NULL); cpane = &pane_l; listdir(NULL); + rm_hi(&pane_r, pane_r.hdir); tb_present(); start_ev(); return 0;