dict @ c573d3b7954296d95a0f8a79b8ac2ca261d86a02

fix: Add better support for utf-8
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd48cee9086754409f9cec0ac69cc280720c3188..f253be6cd6bd7109239ee826e9c19e0ce59e03b2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,7 +7,7 @@ add_executable(dict ${src})
 
 target_compile_options(dict PRIVATE -Wall -Wextra -Wpedantic -Werror)
 target_include_directories(dict PUBLIC "${PROJECT_BINARY_DIR}")
-target_link_libraries(dict sqlite3 ncursesw m)
+target_link_libraries(dict sqlite3 ncursesw m c)
 
 
 add_subdirectory(ext)
diff --git a/main.c b/main.c
index f95a4659d4627d23ca5804896b624110400ada9c..026b4b5e244137c725d6f3a6e21f789a7f9bf88f 100644
--- a/main.c
+++ b/main.c
@@ -11,14 +11,15 @@ unsigned int count_lines(FILE* file);
 int load_or_save_db(sqlite3 *pInMemory, const char *zFilename, int isSave);
 
 int main() {
-
     Data *data = new_data(":memory:");
     bootstrap(data);
 
     setlocale(LC_ALL, "");
-    initscr(); 
     noecho();
     cbreak();
+	nonl();
+    keypad(stdscr, TRUE);
+    initscr(); 
 
     FILE *f = fopen("dict.txt", "r");
     unsigned int lines = count_lines(f);
@@ -43,6 +44,13 @@     load_or_save_db(data->db, "backup.db", 1);
 
     clear();
     refresh();
+
+    TEXT_BOX *box = new_text_box(stdscr, 10);
+    get_char(box);
+
+    clear();
+    refresh();
+
     endwin();
 
     free_data(data);
diff --git a/ui.c b/ui.c
index 2e779e3a4c4dc055987446d7be311e27ba0b7a7e..9762859cc6dadb17f0c06acc2387f0027477af5f 100644
--- a/ui.c
+++ b/ui.c
@@ -1,6 +1,10 @@
-#include "math.h"
+#define NCURSES_WIDECHAR 1
+
 #include <ncurses.h>
+#include <math.h>
 #include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
 #include "ui.h"
 
 const char *uload = "█";
@@ -42,3 +46,37 @@
     wmove(bar->scr,0,0);
     wrefresh(bar->scr);
 }
+
+
+TEXT_BOX* new_text_box(WINDOW* scr, int length) {
+    TEXT_BOX *text = (TEXT_BOX*)malloc(sizeof(TEXT_BOX));
+    text->scr = scr;
+    text->length = length;
+    text->current = 0;
+    text->text = malloc(sizeof(char)*(length+1));
+    memset(text->text, '\0', length);
+    return text;
+}
+
+void get_char(TEXT_BOX* text) {
+    while(1){
+        wchar_t c;
+        get_wch((wint_t*)&c);
+
+        switch(c) {
+            case KEY_BACKSPACE:
+                if (text->current > 0) {
+                    text->text[text->current--] = '\0';
+                }
+                break;
+            default:
+                if (text->current < (text->length-2)) {
+                    text->text[text->current] = c;
+                    text->text[++text->current] = '\0';
+                }
+        }
+        move(0,0);
+        wrefresh(text->scr);
+        wprintw(text->scr, "%*ls", text->current,text->text);
+    }
+}
diff --git a/ui.h b/ui.h
index 8035d6f9955b77119212f3920905a615f49fc912..cdc0539b61f5d717ee843d9ac164d6c18c54ca7a 100644
--- a/ui.h
+++ b/ui.h
@@ -7,5 +7,16 @@     WINDOW *scr;
 } PROGRESS_BAR;
 
 PROGRESS_BAR* new_progress_bar(WINDOW*, float);
+void bar_step(PROGRESS_BAR*, float);
 
-void bar_step(PROGRESS_BAR*, float);
+
+typedef struct text_box {
+    wchar_t *text;
+    int length;
+    int current;
+    WINDOW *scr;
+} TEXT_BOX;
+
+TEXT_BOX* new_text_box(WINDOW*, int);
+void get_char(TEXT_BOX* text);
+