File src/hstr.c changed (mode: 100644) (index 398a862..c9f90bf) |
12 |
12 |
#include <curses.h> |
#include <curses.h> |
13 |
13 |
#include <getopt.h> |
#include <getopt.h> |
14 |
14 |
#include <regex.h> |
#include <regex.h> |
|
15 |
|
#include <locale.h> |
15 |
16 |
#include <signal.h> |
#include <signal.h> |
16 |
17 |
#include <stdbool.h> |
#include <stdbool.h> |
17 |
18 |
#include <stddef.h> |
#include <stddef.h> |
|
... |
... |
static const char *HELP_STRING= |
148 |
149 |
"\n"; |
"\n"; |
149 |
150 |
|
|
150 |
151 |
static const char *VERSION_STRING= |
static const char *VERSION_STRING= |
151 |
|
"hh version \"1.12\"" |
|
|
152 |
|
"hh version \"1.13\"" |
152 |
153 |
"\n build \""__DATE__" " __TIME__"\"" |
"\n build \""__DATE__" " __TIME__"\"" |
153 |
154 |
"\n"; |
"\n"; |
154 |
155 |
|
|
|
... |
... |
void hstr_on_exit(Hstr *hstr) |
649 |
650 |
void signal_callback_handler_ctrl_c(int signum) |
void signal_callback_handler_ctrl_c(int signum) |
650 |
651 |
{ |
{ |
651 |
652 |
if(signum==SIGINT) { |
if(signum==SIGINT) { |
652 |
|
endwin(); |
|
|
653 |
|
hstr_curses_stop(); |
653 |
654 |
hstr_on_exit(hstr); |
hstr_on_exit(hstr); |
654 |
655 |
exit(signum); |
exit(signum); |
655 |
656 |
} |
} |
|
... |
... |
void loop_to_select(Hstr *hstr) |
684 |
685 |
{ |
{ |
685 |
686 |
signal(SIGINT, signal_callback_handler_ctrl_c); |
signal(SIGINT, signal_callback_handler_ctrl_c); |
686 |
687 |
|
|
687 |
|
initscr(); |
|
688 |
|
keypad(stdscr, TRUE); |
|
689 |
|
noecho(); |
|
690 |
|
color_start(); |
|
|
688 |
|
hstr_curses_start(); |
691 |
689 |
// TODO move the code below to hstr_curses |
// TODO move the code below to hstr_curses |
692 |
690 |
color_init_pair(HH_COLOR_NORMAL, -1, -1); |
color_init_pair(HH_COLOR_NORMAL, -1, -1); |
693 |
691 |
if(hstr->hicolor) { |
if(hstr->hicolor) { |
|
... |
... |
void loop_to_select(Hstr *hstr) |
923 |
921 |
break; |
break; |
924 |
922 |
} |
} |
925 |
923 |
} |
} |
926 |
|
endwin(); |
|
|
924 |
|
hstr_curses_stop(); |
927 |
925 |
|
|
928 |
926 |
if(result!=NULL) { |
if(result!=NULL) { |
929 |
927 |
fill_terminal_input(result, TRUE); |
fill_terminal_input(result, TRUE); |
|
... |
... |
void hstr_getopt(int argc, char **argv, Hstr *hstr) |
1015 |
1013 |
|
|
1016 |
1014 |
int main(int argc, char *argv[]) |
int main(int argc, char *argv[]) |
1017 |
1015 |
{ |
{ |
|
1016 |
|
setlocale(LC_ALL, ""); |
|
1017 |
|
|
1018 |
1018 |
hstr=malloc(sizeof(Hstr)); |
hstr=malloc(sizeof(Hstr)); |
1019 |
1019 |
|
|
1020 |
1020 |
hstr_init(hstr); |
hstr_init(hstr); |
File src/hstr_curses.c changed (mode: 100644) (index 0b765e7..4840406) |
12 |
12 |
|
|
13 |
13 |
static bool terminalHasColors=FALSE; |
static bool terminalHasColors=FALSE; |
14 |
14 |
|
|
15 |
|
void color_start() |
|
|
15 |
|
void hstr_curses_start() |
16 |
16 |
{ |
{ |
|
17 |
|
initscr(); |
|
18 |
|
keypad(stdscr, TRUE); |
|
19 |
|
noecho(); |
17 |
20 |
terminalHasColors=has_colors(); |
terminalHasColors=has_colors(); |
18 |
21 |
if(terminalHasColors) { |
if(terminalHasColors) { |
19 |
22 |
start_color(); |
start_color(); |
|
... |
... |
void color_start() |
24 |
27 |
bool terminal_has_colors() { |
bool terminal_has_colors() { |
25 |
28 |
return terminalHasColors; |
return terminalHasColors; |
26 |
29 |
} |
} |
|
30 |
|
|
|
31 |
|
void hstr_curses_stop() { |
|
32 |
|
clear(); |
|
33 |
|
refresh(); |
|
34 |
|
doupdate(); |
|
35 |
|
endwin(); |
|
36 |
|
} |
File src/include/hstr_curses.h changed (mode: 100644) (index 28851d5..b98eb7b) |
16 |
16 |
#define color_attr_off(C) if(terminal_has_colors()) { attroff(C); } |
#define color_attr_off(C) if(terminal_has_colors()) { attroff(C); } |
17 |
17 |
#define color_init_pair(X, Y, Z) if(terminal_has_colors()) { init_pair(X, Y, Z); } |
#define color_init_pair(X, Y, Z) if(terminal_has_colors()) { init_pair(X, Y, Z); } |
18 |
18 |
|
|
|
19 |
|
void hstr_curses_start(); |
19 |
20 |
bool terminal_has_colors(); |
bool terminal_has_colors(); |
20 |
|
void color_start(); |
|
|
21 |
|
void hstr_curses_stop(); |
21 |
22 |
|
|
22 |
23 |
#endif |
#endif |
File tests/src/test_utf8.c changed (mode: 100644) (index 551eb8b..1303adb) |
7 |
7 |
============================================================================ |
============================================================================ |
8 |
8 |
*/ |
*/ |
9 |
9 |
|
|
10 |
|
#include <string.h> |
|
|
10 |
|
#include <locale.h> |
|
11 |
|
#include <wchar.h> |
11 |
12 |
#include <stdio.h> |
#include <stdio.h> |
|
13 |
|
#include <readline/readline.h> |
|
14 |
|
#include <readline/chardefs.h> |
|
15 |
|
|
|
16 |
|
void echo_czech() |
|
17 |
|
{ |
|
18 |
|
int c; |
|
19 |
|
while(1) { |
|
20 |
|
c = getc(stdin); |
|
21 |
|
printf("\nKey: '%3d', char: '%c'", c, c); |
|
22 |
|
} |
|
23 |
|
} |
|
24 |
|
|
|
25 |
|
void static_wide_czech() |
|
26 |
|
{ |
|
27 |
|
setlocale(LC_ALL, ""); |
|
28 |
|
|
|
29 |
|
wchar_t *w=L"Čeština."; |
|
30 |
|
wprintf(L"\nStatic wprintf: %ls", w); |
|
31 |
|
} |
|
32 |
|
|
|
33 |
|
void static_czech() |
|
34 |
|
{ |
|
35 |
|
setlocale(LC_ALL, ""); |
|
36 |
|
|
|
37 |
|
char *s="Čeština ěščřžýáíé."; |
|
38 |
|
printf("\nStatic printf: %s", s); |
|
39 |
|
} |
|
40 |
|
|
|
41 |
|
void check() |
|
42 |
|
{ |
|
43 |
|
printf("\nEnglish string."); |
|
44 |
|
} |
12 |
45 |
|
|
13 |
|
#define LINELNG 500 |
|
14 |
46 |
|
|
15 |
47 |
int main(int argc, char *argv[]) |
int main(int argc, char *argv[]) |
16 |
48 |
{ |
{ |
17 |
|
// UTF8 test: czech & chinese |
|
18 |
|
// hf @ SF.net as inspiration |
|
|
49 |
|
check(); |
|
50 |
|
static_czech(); |
|
51 |
|
static_wide_czech(); |
|
52 |
|
echo_czech(); |
|
53 |
|
printf("\n\n"); |
19 |
54 |
} |
} |