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 568f4b524ebd563356f4f91ac4c1d23c10fc6cc3

Switching to ncursesw to handle utf8.
Author: Martin Dvorak
Author date (UTC): 2014-07-19 04:34
Committer name: Martin Dvorak
Committer date (UTC): 2014-09-11 16:33
Parent(s): 21ea4c288efeb75c4037b4e9ee168ee2c81347b8
Signing key:
Tree: 74e67257161c0db4d7757824b7118f1b7a0586e0
File Lines added Lines deleted
configure.ac 1 1
tests/bin/hh-env-utf8.sh 1 1
tests/resources/.bash_history_cz 29 0
tests/src/test_utf8.c 38 10
tests/test_utf8.sh 3 1
File configure.ac changed (mode: 100644) (index ea00353..022b1bc)
... ... AC_CONFIG_SRCDIR([src/hstr.c])
17 17 AC_PROG_CC AC_PROG_CC
18 18
19 19 # Checks for libraries. # Checks for libraries.
20 AC_CHECK_LIB(ncurses, initscr, [], [AC_MSG_ERROR([Could not find Curses library])])
20 AC_CHECK_LIB(ncursesw, initscr, [], [AC_MSG_ERROR([Could not find Curses library])])
21 21 AC_CHECK_LIB(m, cos, [], [AC_MSG_ERROR([Could not find Math library])]) AC_CHECK_LIB(m, cos, [], [AC_MSG_ERROR([Could not find Math library])])
22 22 AC_CHECK_LIB(readline, using_history, [], [AC_MSG_ERROR([Could not find Readline library])]) AC_CHECK_LIB(readline, using_history, [], [AC_MSG_ERROR([Could not find Readline library])])
23 23
File tests/bin/hh-env-utf8.sh changed (mode: 100755) (index 9d4976a..0bb7926)
1 1 #!/bin/bash #!/bin/bash
2 2
3 export HISTFILE=/home/dvorka/p/hstr/github/tests/resources/.bash_history_cz
3 export HISTFILE=~/p/hstr/github/hstr/tests/resources/.bash_history_cz
4 4
5 5 # eof # eof
File tests/resources/.bash_history_cz changed (mode: 100644) (index a2adbb9..4edc9d6)
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 ./hh
29 š
30 ./hh
31 tig
File tests/src/test_utf8.c changed (mode: 100644) (index 1303adb..7f2f269)
10 10 #include <locale.h> #include <locale.h>
11 11 #include <wchar.h> #include <wchar.h>
12 12 #include <stdio.h> #include <stdio.h>
13 #include <ncurses.h>
13 14 #include <readline/readline.h> #include <readline/readline.h>
14 15 #include <readline/chardefs.h> #include <readline/chardefs.h>
15 16
16 void echo_czech()
17 void console_echo_czech()
17 18 { {
18 19 int c; int c;
19 20 while(1) { while(1) {
 
... ... void echo_czech()
22 23 } }
23 24 } }
24 25
25 void static_wide_czech()
26 void console_static_wide_czech()
26 27 { {
27 28 setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
28 29
29 wchar_t *w=L"Čeština.";
30 wprintf(L"\nStatic wprintf: %ls", w);
30 wchar_t *w=L"Čeština."; // wide
31 char multibyte[100]; // multi-byte
32 if(iswprint(*w)) {
33 printf("\nString to be printed is UTF8 wide!");
34 int offset=wctomb(multibyte, w);
35 printf("\nStatic (wide) printf: %s", multibyte);
36 } else {
37 printf("\nString to be printed is NOT UTF8 wide!");
38 wprintf(L"\nStatic wprintf: %ls", w);
39 }
31 40 } }
32 41
33 void static_czech()
42 void console_static_czech()
34 43 { {
35 44 setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
36 45
 
... ... void static_czech()
38 47 printf("\nStatic printf: %s", s); printf("\nStatic printf: %s", s);
39 48 } }
40 49
41 void check()
50 void console_check()
42 51 { {
43 52 printf("\nEnglish string."); printf("\nEnglish string.");
44 53 } }
45 54
55 void curses_wide_czech()
56 {
57 char *s="Čeština ěščřžýáíé.";
58 printf("Going to print the following string in Curses: '%s'", s);
59 getch();
60
61 WINDOW *stdscr;
62 setlocale(LC_ALL, "");
63
64 stdscr=initscr();
65 mvwprintw(stdscr,0,0,s);
66 getch();
67 endwin();
68 }
46 69
47 70 int main(int argc, char *argv[]) int main(int argc, char *argv[])
48 71 { {
49 check();
50 static_czech();
51 static_wide_czech();
52 echo_czech();
72 //console_check();
73 //console_static_czech();
74 //console_static_wide_czech();
75 //console_echo_czech();
76
77 // TODO study print_selection_row()
78
79 curses_wide_czech();
80
53 81 printf("\n\n"); printf("\n\n");
54 82 } }
File tests/test_utf8.sh changed (mode: 100755) (index b0a9578..001bd25)
1 1 #!/bin/bash #!/bin/bash
2 2
3 3 clear clear
4 gcc ./src/test_utf8.c -o _utf8
4 rm -vf ./_utf8
5 echo "Linking wide version of Curses library (libncursesw5-dev)..."
6 gcc ./src/test_utf8.c -o _utf8 -lncursesw
5 7 ./_utf8 ./_utf8
6 8
7 9 # eof # eof
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