start implementation of scrollback completion
This commit is contained in:
parent
f38dfd224b
commit
25ecf2d21f
38
termite.c
38
termite.c
|
@ -1,4 +1,7 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <vte/vte.h>
|
||||
|
@ -20,6 +23,37 @@ typedef struct search_panel_info {
|
|||
bool reverse;
|
||||
} search_panel_info;
|
||||
|
||||
static gboolean always_selected(VteTerminal *vte, glong column, glong row) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void complete(VteTerminal *vte) {
|
||||
// TODO: get the full buffer
|
||||
gchar *content = vte_terminal_get_text(vte,
|
||||
(VteSelectionFunc)always_selected,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
if (!content) {
|
||||
fputs("no content", stderr);
|
||||
return;
|
||||
}
|
||||
|
||||
char *s_ptr = content, *saveptr;
|
||||
|
||||
for (int j = 1; ; j++, s_ptr = NULL) {
|
||||
char *token = strtok_r(s_ptr, " \n", &saveptr);
|
||||
if (!token) {
|
||||
break;
|
||||
}
|
||||
printf("token %d: %s\n", j, token);
|
||||
}
|
||||
|
||||
// TODO: GtkEntryCompletion widget
|
||||
|
||||
g_free(content);
|
||||
}
|
||||
|
||||
static void search(VteTerminal *vte, const char *pattern, bool reverse) {
|
||||
GRegex *regex = vte_terminal_search_get_gregex(vte);
|
||||
if (regex) g_regex_unref(regex);
|
||||
|
@ -87,6 +121,10 @@ static gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, search_panel_
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
if (modifiers == GDK_CONTROL_MASK && event->keyval == GDK_KEY_Tab) {
|
||||
complete(vte);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue