commit - 7b0be57c7cb536303ba948e71fcd81f40f85f0c3
commit + bb9912eb4825aa88e6fd7804dc016d37e74422fc
blob - 2aa44576fbd43b93153f68ec9c728e22b6624be2
blob + 990fb54da8d59910be7989f661dd0bb476603254
--- telescope.c
+++ telescope.c
static void
handle_maybe_save_page(int dosave, struct tab *tab)
{
- if (dosave)
- ui_read("Save to path", handle_save_page_path, tab);
- else
+ const char *f;
+ char input[PATH_MAX];
+
+ if (!dosave) {
stop_tab(tab);
+ return;
+ }
+
+ if ((f = strrchr(tab->uri.path, '/')) == NULL)
+ f = "";
+ else
+ f++;
+
+ /* TODO: make base path customizable */
+ strlcpy(input, "/tmp/", sizeof(input));
+ strlcat(input, f, sizeof(input));
+
+ ui_read("Save to path", handle_save_page_path, tab, input);
}
static void
blob - 1d13ffc7f6a98e21d87fb1abc7cadf7f293b6b1d
blob + a622e686532715c9ae3e445390ff8fc7cdead884
--- ui.c
+++ ui.c
void
ui_read(const char *prompt, void (*fn)(const char*, struct tab *),
- struct tab *data)
+ struct tab *data, const char *input)
{
minibuffer_read(prompt, fn, data);
+
+ if (input != NULL) {
+ strlcpy(ministate.buf, input, sizeof(ministate.buf));
+ cmd_move_end_of_line(&ministate.buffer);
+ }
+
redraw_tab(current_tab);
}
blob - af94b71da5a93fc47cf93716d01eb1a2e7113e03
blob + 5b6289bc91bb36beeca2eb44c323fde71555bba1
--- ui.h
+++ ui.h
void ui_after_message_hook(void);
void ui_require_input(struct tab *, int, int);
void ui_yornp(const char *, void (*)(int, struct tab *), struct tab *);
-void ui_read(const char *, void (*)(const char *, struct tab *), struct tab *);
+void ui_read(const char *, void (*)(const char *, struct tab *), struct tab *, const char *);
void ui_other_window(void);
void ui_suspend(void);
void ui_end(void);