commit - b3884fbee299f6fe654945d9e604f954f3e3c7e1
commit + e5a2797faaeff6b9a4012a166ab9caa6c3634a5d
blob - 4921c7cc43fd690351ac45d913b66f08dfe8d63a
blob + 42c6cf2f7c3255420553a008549209927297e980
--- cmd.c
+++ cmd.c
#include <stdlib.h>
#include <string.h>
+#include "defaults.h"
#include "minibuffer.h"
#include "telescope.h"
#include "ui.h"
}
enter_minibuffer(eecmd_self_insert, eecmd_select, exit_minibuffer,
- &eecmd_history);
+ &eecmd_history, NULL, NULL);
len = sizeof(ministate.prompt);
strlcpy(ministate.prompt, "", len);
}
enter_minibuffer(lu_self_insert, lu_select, exit_minibuffer,
- &lu_history);
+ &lu_history, NULL, NULL);
strlcpy(ministate.prompt, "Load URL: ", sizeof(ministate.prompt));
strlcpy(ministate.buf, "gemini://", sizeof(ministate.buf));
cmd_move_end_of_line(&ministate.buffer);
}
enter_minibuffer(lu_self_insert, lu_select, exit_minibuffer,
- &lu_history);
+ &lu_history, NULL, NULL);
strlcpy(ministate.prompt, "Load URL: ", sizeof(ministate.prompt));
strlcpy(ministate.buf, tab->hist_cur->h, sizeof(ministate.buf));
ministate.buffer.cpoff = utf8_cplen(ministate.buf);
{
struct tab *tab = current_tab();
- enter_minibuffer(lu_self_insert, bp_select, exit_minibuffer, NULL);
+ enter_minibuffer(lu_self_insert, bp_select, exit_minibuffer, NULL,
+ NULL, NULL);
strlcpy(ministate.prompt, "Bookmark URL: ", sizeof(ministate.prompt));
strlcpy(ministate.buf, tab->hist_cur->h, sizeof(ministate.buf));
ministate.buffer.cpoff = utf8_cplen(ministate.buf);
blob - 2fe5346dd4f33ba360dc7ebbe925293061ce3f55
blob + 5354c5fd3f762db6e1f280b5d2f04c8d41708314
--- minibuffer.c
+++ minibuffer.c
void
enter_minibuffer(void (*self_insert_fn)(void), void (*donefn)(void),
- void (*abortfn)(void), struct histhead *hist)
+ void (*abortfn)(void), struct histhead *hist,
+ complfn *complfn, void *compldata)
{
in_minibuffer = 1;
base_map = &minibuffer_map;
yornp_cb = fn;
yornp_data = data;
enter_minibuffer(yornp_self_insert, yornp_self_insert,
- yornp_abort, NULL);
+ yornp_abort, NULL, NULL, NULL);
len = sizeof(ministate.prompt);
strlcpy(ministate.prompt, prompt, len);
*/
void
completing_read(const char *prompt, void (*fn)(const char *, struct tab *),
- struct tab *data)
+ struct tab *data, complfn *complfn, void *compldata)
{
size_t len;
read_cb = fn;
read_data = data;
enter_minibuffer(read_self_insert, read_select, read_abort,
- &read_history);
+ &read_history, complfn, compldata);
len = sizeof(ministate.prompt);
strlcpy(ministate.prompt, prompt, len);
blob - 0f071031d53a8afd61783699b42ee014688d2710
blob + e6577cbd7191c8338c24499cb418c43757f399fd
--- minibuffer.h
+++ minibuffer.h
#include "telescope.h"
+/* need to be true-ish */
+#define MB_READ 1
+#define MB_COMPREAD 2
+
+typedef char *(complfn)(void *);
+
void enter_minibuffer(void(*)(void), void(*)(void), void(*)(void),
- struct histhead *);
+ struct histhead *,
+ complfn *, void *);
+
void exit_minibuffer(void);
void yornp(const char *, void (*)(int, struct tab *), struct tab *);
+
+/*
+ * completing_read asks the user for something using the minibuffer.
+ * The first argument is the string prompt. The second and third are
+ * the callback to call when done and the data; the callback function
+ * can't be NULL. The last two arguments are the completion function
+ * and its data; if not given, no completion will be shown. The
+ * function providing the completion will be called asynchronously.
+ */
void completing_read(const char *,
- void (*)(const char *, struct tab *),
- struct tab *);
+ void (*)(const char *, struct tab *), struct tab *,
+ complfn *, void *);
#endif
blob - e1aaadd77b892a565108349970e26450e6f63462
blob + c976d386465eb4267bed7caa84ca7f6c1671f0a1
--- ui.c
+++ ui.c
static struct event resizeev;
static struct timeval resize_timer = { 0, 250000 };
-static WINDOW *tabline, *body, *modeline, *echoarea;
+static WINDOW *tabline, *body, *modeline, *echoarea, *minibuffer;
int body_lines, body_cols;
if ((modeline = newwin(1, COLS, LINES-2, 0)) == NULL)
return 0;
if ((echoarea = newwin(1, COLS, LINES-1, 0)) == NULL)
+ return 0;
+ if ((minibuffer = newwin(1, COLS, LINES-1, 0)) == NULL)
return 0;
if ((help = newwin(1, 1, 1, 0)) == NULL)
return 0;
switch_to_tab(tab);
enter_minibuffer(ir_self_insert, ir_select, exit_minibuffer,
- &ir_history);
+ &ir_history, NULL, NULL);
strlcpy(ministate.prompt, "Input required: ",
sizeof(ministate.prompt));
redraw_tab(tab);
ui_read(const char *prompt, void (*fn)(const char*, struct tab *),
struct tab *data)
{
- completing_read(prompt, fn, data);
+ completing_read(prompt, fn, data, NULL, NULL);
redraw_tab(current_tab());
}