Adding wide character logging.

This commit is contained in:
Martin Dvorak 2014-07-20 23:03:10 +02:00
parent 568f4b524e
commit c09566fd29
2 changed files with 16 additions and 28 deletions

View file

@ -21,6 +21,7 @@
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <wchar.h>
#include <readline/chardefs.h>
#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);

View file

@ -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