diff --git a/src/hstr.c b/src/hstr.c index c9f90bf..3512e94 100644 --- a/src/hstr.c +++ b/src/hstr.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "include/hashset.h" @@ -106,6 +107,14 @@ #define LOGCURSOR(Y) #endif +#define DEBUG_UTF8 + +#ifdef DEBUG_UTF8 +#define LOGUTF8(Y,P,C) mvprintw(Y, 0, "strlen(): %d, wcslen(): %d, getch(): %d ",strlen(P),wcslen(P),C) +#else +#define LOGUTF8(Y,P) +#endif + static const char *HH_VIEW_LABELS[]={ "ranking", "history", @@ -831,6 +840,11 @@ void loop_to_select(Hstr *hstr) case K_CTRL_H: case K_BACKSPACE: case KEY_BACKSPACE: + TODO count how many characters to move back in case of utf8 strings/multibyte + + > google strlen(pattern) for wide characters/multibyte + SOME SOLUTION: iterate over pattern and use function from debug to determine size of one char + if(strlen(pattern)>0) { pattern[strlen(pattern)-1]=0; x--; @@ -908,6 +922,8 @@ void loop_to_select(Hstr *hstr) selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT; if(strlen(pattern)<(width-basex-1)) { + LOGUTF8(Y_OFFSET_HELP,pattern,c); + strcat(pattern, (char*)(&c)); print_prefix(pattern, y, basex); cursorX=getcurx(stdscr); diff --git a/tests/resources/.bash_history_cz b/tests/resources/.bash_history_cz index 4edc9d6..7243576 100644 --- a/tests/resources/.bash_history_cz +++ b/tests/resources/.bash_history_cz @@ -1,31 +1,3 @@ ěščřžýáíé ŘŠČŽ -source ./hh-env-utf8.sh -set | grep HI -ls -al /home/dvorka/p/hstr/github/tests/resources/.bash_history_cz -ls -al /home/dvorka/p/hstr/github/tests/resources -ls -al /home/dvorka/p/hstr/github/tests -ls -al /home/dvorka/p/hstr/github -cemacs hh-env-utf8.sh -source ./hh-env-utf8.sh -cemacs hh-env-utf8.sh -cd .. -cd .. -ls -cd .. -ls -cd .. -ls -cd forks/ -ls -cemacs hf.c -. hh-env-utf8.sh -set | grep HIS -cd .. -cd .. -cd Debug/ -ls ./hh -š -./hh -tig