File src/hstr.c changed (mode: 100644) (index c9f90bf..3512e94) |
21 |
21 |
#include <string.h> |
#include <string.h> |
22 |
22 |
#include <termios.h> |
#include <termios.h> |
23 |
23 |
#include <unistd.h> |
#include <unistd.h> |
|
24 |
|
#include <wchar.h> |
24 |
25 |
#include <readline/chardefs.h> |
#include <readline/chardefs.h> |
25 |
26 |
|
|
26 |
27 |
#include "include/hashset.h" |
#include "include/hashset.h" |
|
106 |
107 |
#define LOGCURSOR(Y) |
#define LOGCURSOR(Y) |
107 |
108 |
#endif |
#endif |
108 |
109 |
|
|
|
110 |
|
#define DEBUG_UTF8 |
|
111 |
|
|
|
112 |
|
#ifdef DEBUG_UTF8 |
|
113 |
|
#define LOGUTF8(Y,P,C) mvprintw(Y, 0, "strlen(): %d, wcslen(): %d, getch(): %d ",strlen(P),wcslen(P),C) |
|
114 |
|
#else |
|
115 |
|
#define LOGUTF8(Y,P) |
|
116 |
|
#endif |
|
117 |
|
|
109 |
118 |
static const char *HH_VIEW_LABELS[]={ |
static const char *HH_VIEW_LABELS[]={ |
110 |
119 |
"ranking", |
"ranking", |
111 |
120 |
"history", |
"history", |
|
... |
... |
void loop_to_select(Hstr *hstr) |
831 |
840 |
case K_CTRL_H: |
case K_CTRL_H: |
832 |
841 |
case K_BACKSPACE: |
case K_BACKSPACE: |
833 |
842 |
case KEY_BACKSPACE: |
case KEY_BACKSPACE: |
|
843 |
|
TODO count how many characters to move back in case of utf8 strings/multibyte |
|
844 |
|
|
|
845 |
|
> google strlen(pattern) for wide characters/multibyte |
|
846 |
|
SOME SOLUTION: iterate over pattern and use function from debug to determine size of one char |
|
847 |
|
|
834 |
848 |
if(strlen(pattern)>0) { |
if(strlen(pattern)>0) { |
835 |
849 |
pattern[strlen(pattern)-1]=0; |
pattern[strlen(pattern)-1]=0; |
836 |
850 |
x--; |
x--; |
|
... |
... |
void loop_to_select(Hstr *hstr) |
908 |
922 |
selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT; |
selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT; |
909 |
923 |
|
|
910 |
924 |
if(strlen(pattern)<(width-basex-1)) { |
if(strlen(pattern)<(width-basex-1)) { |
|
925 |
|
LOGUTF8(Y_OFFSET_HELP,pattern,c); |
|
926 |
|
|
911 |
927 |
strcat(pattern, (char*)(&c)); |
strcat(pattern, (char*)(&c)); |
912 |
928 |
print_prefix(pattern, y, basex); |
print_prefix(pattern, y, basex); |
913 |
929 |
cursorX=getcurx(stdscr); |
cursorX=getcurx(stdscr); |