xaizek / hstr (License: Apachev2) (since 2018-12-07)
Bash and Zsh shell history suggest box - easily view, navigate, search and manage your command history.
Commit d16c26dd6f33e827c2fb02cc7b6cb731513e4d79

Adding wide character logging.
Author: Martin Dvorak
Author date (UTC): 2014-07-20 21:03
Committer name: Martin Dvorak
Committer date (UTC): 2014-07-20 21:03
Parent(s): c35a607da5cc49ca018f6c01e7f5bc811b6f4f76
Signing key:
Tree: 436aaaa3fb895a987fda553a91aa810b75c2a919
File Lines added Lines deleted
src/hstr.c 16 0
tests/resources/.bash_history_cz 0 28
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);
File tests/resources/.bash_history_cz changed (mode: 100644) (index 4edc9d6..7243576)
1 1 ěščřžýáíé ěščřžýáíé
2 2 ŘŠČŽ ŘŠČŽ
3 source ./hh-env-utf8.sh
4 set | grep HI
5 ls -al /home/dvorka/p/hstr/github/tests/resources/.bash_history_cz
6 ls -al /home/dvorka/p/hstr/github/tests/resources
7 ls -al /home/dvorka/p/hstr/github/tests
8 ls -al /home/dvorka/p/hstr/github
9 cemacs hh-env-utf8.sh
10 source ./hh-env-utf8.sh
11 cemacs hh-env-utf8.sh
12 cd ..
13 cd ..
14 ls
15 cd ..
16 ls
17 cd ..
18 ls
19 cd forks/
20 ls
21 cemacs hf.c
22 . hh-env-utf8.sh
23 set | grep HIS
24 cd ..
25 cd ..
26 cd Debug/
27 ls
28 3 ./hh ./hh
29 š
30 ./hh
31 tig
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/hstr

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/hstr

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master