aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-02-14 11:59:10 +0100
committerGabriel A. Giovanini <g.giovanini@gridx.de>2024-02-14 12:29:28 +0100
commit3967b61dfbee50d2072ddefced877486ce439582 (patch)
tree800856749a232fa5ed92ab1d51b43c1218f59232 /main.c
parent03aa0fe6c664f74e8e4e5877ef89b4e053b30bc5 (diff)
downloaddict-3967b61dfbee50d2072ddefced877486ce439582.tar.gz
dict-3967b61dfbee50d2072ddefced877486ce439582.tar.bz2
dict-3967b61dfbee50d2072ddefced877486ce439582.zip
feat: Add buggy ui component
Diffstat (limited to 'main.c')
-rw-r--r--main.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/main.c b/main.c
index dae1f2a..69a68b8 100644
--- a/main.c
+++ b/main.c
@@ -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;
}