diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 28 |
1 files changed, 11 insertions, 17 deletions
@@ -3,6 +3,7 @@ #include <sqlite3.h> #include <ncurses.h> #include "data.h" +#include "ui.h" #define BUF_SIZE 100 @@ -10,14 +11,13 @@ 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(); + initscr(); + noecho(); + cbreak(); - int maxx=getmaxx(stdscr); + Data *data = new_data(":memory:"); + bootstrap(data); FILE *f = fopen("dict.txt", "r"); unsigned int lines = count_lines(f); @@ -26,22 +26,13 @@ int main() { char * line = NULL; size_t len = 0; ssize_t read; - int count = 0; + PROGRESS_BAR *bar = new_progress_bar(stdscr, lines); while ((read = getline(&line, &len, f)) != -1) { if (line[0] == '#' || line[0] == '\n') continue; insert(data, line, read-1); - count ++; - move(0,0); - float total = ((float)count/(float)lines); - printw("%03.0f%% ", total*100); - for (int x = 0; x < ((maxx-4)*total); x++) { - printw("█"); - } - move(1,0); - printw("%d/%d",count,lines); - refresh(); + bar_step(bar, 1); } move(2,0); @@ -51,6 +42,9 @@ int main() { clear(); refresh(); + endwin(); + + free_data(data); return 0; } |