Skip to content

Commit

Permalink
Merge branch 'cwd_displaying'
Browse files Browse the repository at this point in the history
- allow cwd to span multiple windows
- handle widechars
- keep index/itemslen clear
- resolves #9
  • Loading branch information
Ckath committed Sep 16, 2019
2 parents 8e03863 + 04e5729 commit 6198a49
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions fuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#include <wchar.h>
#include "ext/colors.h"
#include "ext/sncurses.h"
#include "ext/sort.h"
Expand Down Expand Up @@ -392,10 +393,15 @@ refresh_layout()
char cwd[PATH_MAX]; /* left corner */
bool cwdok = getcwd(cwd, PATH_MAX);
if (cwdok) {
cwd_w = snewwin(1, strlen(cwd) < COLS-strlen(index)-1 ?
strlen(cwd) : COLS-strlen(index)-1, 0, 1);
smvwaddstr(cwd_w, 0, 0, strlen(cwd) < COLS-strlen(index)-1 ?
cwd : cwd + (strlen(cwd)-COLS+strlen(index)+1));
wchar_t wcwd[PATH_MAX];
swprintf(wcwd, PATH_MAX, L"%hs", cwd);
int cwd_len = strlen(cwd) > wcslen(wcwd) ?
strlen(cwd)-(strlen(cwd)-wcslen(wcwd))/2 :
strlen(cwd);
cwd_w = snewwin(1, cwd_len < COLS-strlen(index)-3 ?
cwd_len : COLS-strlen(index)-3, 0, 1);
smvwaddstr(cwd_w, 0, 0, cwd_len < COLS-strlen(index)-3 ?
cwd : cwd + (cwd_len-COLS+strlen(index)+3));
} else {
swattron(dir_w, COLOR_PAIR(COL(COLOR_RED, COLOR_DEFAULT)) | A_BOLD);
smvwaddstr(dir_w, 0, 0, "dir not found");
Expand Down

0 comments on commit 6198a49

Please sign in to comment.