testing
This commit is contained in:
parent
2833c6eee4
commit
05cfbe7817
@ -66,9 +66,10 @@ void export_result(const char * const result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void * async_query(void * arg) {
|
void * async(void * arg) {
|
||||||
entry_t entry;
|
entry_t entry;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
if (is_input_changed) {
|
if (is_input_changed) {
|
||||||
query(rl_line_buffer, entry_lines, selection_offset);
|
query(rl_line_buffer, entry_lines, selection_offset);
|
||||||
is_input_changed = false;
|
is_input_changed = false;
|
||||||
@ -78,12 +79,13 @@ void * async_query(void * arg) {
|
|||||||
while (entry = get_entry(), entry.command != NULL) {
|
while (entry = get_entry(), entry.command != NULL) {
|
||||||
tui_append_back(entry);
|
tui_append_back(entry);
|
||||||
}
|
}
|
||||||
tui_refresh();
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
signed main(const int argc, const char * const * const argv) {
|
signed main(const int argc, const char * const * const argv) {
|
||||||
|
extern void testtest(void);
|
||||||
// NOTE: never returns on error
|
// NOTE: never returns on error
|
||||||
parse_arguments(argc, argv);
|
parse_arguments(argc, argv);
|
||||||
|
|
||||||
@ -92,10 +94,13 @@ signed main(const int argc, const char * const * const argv) {
|
|||||||
tui_refresh();
|
tui_refresh();
|
||||||
|
|
||||||
pthread_t query_thread;
|
pthread_t query_thread;
|
||||||
|
pthread_create(&query_thread, NULL, async, NULL);
|
||||||
while (do_run) {
|
while (do_run) {
|
||||||
pthread_cancel(query_thread);
|
|
||||||
pthread_create(&query_thread, NULL, async_query, NULL);
|
|
||||||
tui_take_input();
|
tui_take_input();
|
||||||
|
if (is_input_changed) {
|
||||||
|
testtest();
|
||||||
|
}
|
||||||
|
tui_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
query(rl_line_buffer, 1, selection_offset + selection_relative);
|
query(rl_line_buffer, 1, selection_offset + selection_relative);
|
||||||
|
@ -137,6 +137,10 @@ void requery(void) {
|
|||||||
sqlite3_reset(*stmt);
|
sqlite3_reset(*stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testtest(void) {
|
||||||
|
sqlite3_interrupt(db);
|
||||||
|
}
|
||||||
|
|
||||||
entry_t get_entry(void) {
|
entry_t get_entry(void) {
|
||||||
if (sqlite3_step(*stmt) != SQLITE_ROW) {
|
if (sqlite3_step(*stmt) != SQLITE_ROW) {
|
||||||
return (entry_t){
|
return (entry_t){
|
||||||
|
@ -29,7 +29,7 @@ int init_tui(void) {
|
|||||||
// Ncurses
|
// Ncurses
|
||||||
initscr();
|
initscr();
|
||||||
nonl();
|
nonl();
|
||||||
cbreak();
|
halfdelay(1);
|
||||||
noecho();
|
noecho();
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
@ -172,6 +172,7 @@ void tui_take_input(void) {
|
|||||||
case '\r': {
|
case '\r': {
|
||||||
do_run = false;
|
do_run = false;
|
||||||
} break;
|
} break;
|
||||||
|
case ERR: break;
|
||||||
default: {
|
default: {
|
||||||
input_available = true;
|
input_available = true;
|
||||||
rl_callback_read_char();
|
rl_callback_read_char();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user