testing
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#include <pthread.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include "cli.hpp"
|
#include "cli.hpp"
|
||||||
#include "bash_history.yy.hpp"
|
#include "bash_history.yy.hpp"
|
||||||
@ -65,6 +66,23 @@ void export_result(const char * const result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void * async_query(void * arg) {
|
||||||
|
entry_t entry;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
tui_refresh();
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
signed main(const int argc, const char * const * const argv) {
|
signed main(const int argc, const char * const * const argv) {
|
||||||
// NOTE: never returns on error
|
// NOTE: never returns on error
|
||||||
parse_arguments(argc, argv);
|
parse_arguments(argc, argv);
|
||||||
@ -73,18 +91,10 @@ signed main(const int argc, const char * const * const argv) {
|
|||||||
|
|
||||||
tui_refresh();
|
tui_refresh();
|
||||||
|
|
||||||
entry_t entry;
|
pthread_t query_thread;
|
||||||
while (do_run) {
|
while (do_run) {
|
||||||
if (is_input_changed) {
|
pthread_cancel(query_thread);
|
||||||
query(rl_line_buffer, entry_lines, selection_offset);
|
pthread_create(&query_thread, NULL, async_query, NULL);
|
||||||
is_input_changed = false;
|
|
||||||
} else {
|
|
||||||
requery();
|
|
||||||
}
|
|
||||||
while (entry = get_entry(), entry.command != NULL) {
|
|
||||||
tui_append_back(entry);
|
|
||||||
}
|
|
||||||
tui_refresh();
|
|
||||||
tui_take_input();
|
tui_take_input();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user