1diff --git a/CMakeLists.txt b/CMakeLists.txt
2index fd48cee9086754409f9cec0ac69cc280720c3188..f253be6cd6bd7109239ee826e9c19e0ce59e03b2 100644
3--- a/CMakeLists.txt
4+++ b/CMakeLists.txt
5@@ -7,7 +7,7 @@ add_executable(dict ${src})
6
7 target_compile_options(dict PRIVATE -Wall -Wextra -Wpedantic -Werror)
8 target_include_directories(dict PUBLIC "${PROJECT_BINARY_DIR}")
9-target_link_libraries(dict sqlite3 ncursesw m)
10+target_link_libraries(dict sqlite3 ncursesw m c)
11
12
13 add_subdirectory(ext)
14diff --git a/main.c b/main.c
15index f95a4659d4627d23ca5804896b624110400ada9c..026b4b5e244137c725d6f3a6e21f789a7f9bf88f 100644
16--- a/main.c
17+++ b/main.c
18@@ -11,14 +11,15 @@ unsigned int count_lines(FILE* file);
19 int load_or_save_db(sqlite3 *pInMemory, const char *zFilename, int isSave);
20
21 int main() {
22-
23 Data *data = new_data(":memory:");
24 bootstrap(data);
25
26 setlocale(LC_ALL, "");
27- initscr();
28 noecho();
29 cbreak();
30+ nonl();
31+ keypad(stdscr, TRUE);
32+ initscr();
33
34 FILE *f = fopen("dict.txt", "r");
35 unsigned int lines = count_lines(f);
36@@ -43,6 +44,13 @@ load_or_save_db(data->db, "backup.db", 1);
37
38 clear();
39 refresh();
40+
41+ TEXT_BOX *box = new_text_box(stdscr, 10);
42+ get_char(box);
43+
44+ clear();
45+ refresh();
46+
47 endwin();
48
49 free_data(data);
50diff --git a/ui.c b/ui.c
51index 2e779e3a4c4dc055987446d7be311e27ba0b7a7e..9762859cc6dadb17f0c06acc2387f0027477af5f 100644
52--- a/ui.c
53+++ b/ui.c
54@@ -1,6 +1,10 @@
55-#include "math.h"
56+#define NCURSES_WIDECHAR 1
57+
58 #include <ncurses.h>
59+#include <math.h>
60 #include <stdlib.h>
61+#include <string.h>
62+#include <wchar.h>
63 #include "ui.h"
64
65 const char *uload = "█";
66@@ -42,3 +46,37 @@
67 wmove(bar->scr,0,0);
68 wrefresh(bar->scr);
69 }
70+
71+
72+TEXT_BOX* new_text_box(WINDOW* scr, int length) {
73+ TEXT_BOX *text = (TEXT_BOX*)malloc(sizeof(TEXT_BOX));
74+ text->scr = scr;
75+ text->length = length;
76+ text->current = 0;
77+ text->text = malloc(sizeof(char)*(length+1));
78+ memset(text->text, '\0', length);
79+ return text;
80+}
81+
82+void get_char(TEXT_BOX* text) {
83+ while(1){
84+ wchar_t c;
85+ get_wch((wint_t*)&c);
86+
87+ switch(c) {
88+ case KEY_BACKSPACE:
89+ if (text->current > 0) {
90+ text->text[text->current--] = '\0';
91+ }
92+ break;
93+ default:
94+ if (text->current < (text->length-2)) {
95+ text->text[text->current] = c;
96+ text->text[++text->current] = '\0';
97+ }
98+ }
99+ move(0,0);
100+ wrefresh(text->scr);
101+ wprintw(text->scr, "%*ls", text->current,text->text);
102+ }
103+}
104diff --git a/ui.h b/ui.h
105index 8035d6f9955b77119212f3920905a615f49fc912..cdc0539b61f5d717ee843d9ac164d6c18c54ca7a 100644
106--- a/ui.h
107+++ b/ui.h
108@@ -7,5 +7,16 @@ WINDOW *scr;
109 } PROGRESS_BAR;
110
111 PROGRESS_BAR* new_progress_bar(WINDOW*, float);
112+void bar_step(PROGRESS_BAR*, float);
113
114-void bar_step(PROGRESS_BAR*, float);
115+
116+typedef struct text_box {
117+ wchar_t *text;
118+ int length;
119+ int current;
120+ WINDOW *scr;
121+} TEXT_BOX;
122+
123+TEXT_BOX* new_text_box(WINDOW*, int);
124+void get_char(TEXT_BOX* text);
125+