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