commit - c7453a38f43cf40a80834cb129c6b64bd7b2bc2c
commit + d7ee7b5e9bf19ebdfdef9ec0d887871ee6aedeae
blob - 646346235203e6d091672273a2a1e41746ec7314
blob + bda216af5d2d4091efe0a0de4e7e40fb95b40cab
--- minibuffer.c
+++ minibuffer.c
#include "ui.h"
#include "utf8.h"
+static void *minibuffer_metadata(void);
static void minibuffer_hist_save_entry(void);
static void yornp_self_insert(void);
static void yornp_abort(void);
vl->parent->type = LINE_COMPL_CURRENT;
}
+static void *
+minibuffer_metadata(void)
+{
+ struct vline *vl;
+
+ vl = ministate.compl.buffer.current_line;
+
+ if (vl == NULL || vl->parent->flags & L_HIDDEN)
+ return NULL;
+
+ return vl->parent->meta.data;
+}
+
static void
minibuffer_hist_save_entry(void)
{
void
ts_select(void)
{
- struct vline *vl;
struct tab *tab;
- vl = ministate.compl.buffer.current_line;
-
- if (vl == NULL || vl->parent->flags & L_HIDDEN) {
+ if ((tab = minibuffer_metadata()) == NULL) {
message("No tab selected");
return;
}
- tab = vl->parent->meta.data;
exit_minibuffer();
switch_to_tab(tab);
}
ls_select(void)
{
struct line *l;
- struct vline *vl;
- vl = ministate.compl.buffer.current_line;
-
- if (vl == NULL || vl->parent->flags & L_HIDDEN) {
+ if ((l = minibuffer_metadata()) == NULL) {
message("No link selected");
return;
}
- l = vl->parent->meta.data;
exit_minibuffer();
-
load_url_in_tab(current_tab(), l->meta.alt);
}
-void
-swiper_select(void)
+static inline void
+jump_to_line(struct line *l)
{
- struct line *l;
struct vline *vl;
struct tab *tab;
- vl = ministate.compl.buffer.current_line;
-
- if (vl == NULL || vl->parent->flags & L_HIDDEN) {
- message("No line selected");
- return;
- }
-
- l = vl->parent->meta.data;
- exit_minibuffer();
-
tab = current_tab();
TAILQ_FOREACH(vl, &tab->buffer.head, vlines) {
}
if (vl == NULL)
- message("Ops, swiper error! Please report to %s",
- PACKAGE_BUGREPORT);
+ message("Ops, %s error! Please report to %s",
+ __func__, PACKAGE_BUGREPORT);
else
tab->buffer.current_line = vl;
}
+void
+swiper_select(void)
+{
+ struct line *l;
+
+ if ((l = minibuffer_metadata()) == NULL) {
+ message("No line selected");
+ return;
+ }
+
+ exit_minibuffer();
+ jump_to_line(l);
+}
+
static void
yornp_self_insert(void)
{