comparison for further typed chars.
.SH SETTINGS
All settings listed below can be set with the `:set' command.
+.TP
+.B closed-max-items (int)
+Maximum number of stored last closed URLs.
+If closed-max-items is set to 0, closed URLs will not be stored.
.SH FILES
.TP
.IR $XDG_CONFIG_HOME/vimb[/PROFILE]
Cookie store file.
.TP
.I closed
-Holds the URI of last closed browser windows.
+Holds the URIs of last closed browser windows.
.TP
.I history
This file holds the history of unique opened URIs.
{
Client *p;
webkit_web_view_stop_loading(c->webview);
+
+ /* Write last URL into file for recreation.
+ * The URL is only stored if the closed-max-items is not 0 and the file
+ * exists. */
+ if (c->state.uri && vb.config.closed_max && vb.files[FILES_CLOSED]) {
+ char **lines;
+ GString *new;
+
+ /* The latest closed URL is written first and the surplus items are
+ * removed. */
+ lines = util_get_lines(vb.files[FILES_CLOSED]);
+ new = g_string_new(c->state.uri);
+ g_string_append(new, "\n");
+ if (lines) {
+ int len, i;
+
+ len = g_strv_length(lines);
+ for (i = 0; i < len - 1 && i < vb.config.closed_max - 1; i++) {
+ g_string_append_printf(new, "%s\n", lines[i]);
+ }
+ g_strfreev(lines);
+ }
+ g_file_set_contents(vb.files[FILES_CLOSED], new->str, -1, NULL);
+ g_string_free(new, TRUE);
+ }
+
gtk_widget_destroy(c->window);
/* Look for the client in the list, if we searched through the list and
char *profile; /* profile name */
struct {
guint history_max;
+ guint closed_max;
} config;
GtkCssProvider *style_provider;
};
static VbResult normal_open(Client *c, const NormalCmdInfo *info)
{
Arg a;
- char *file;
+ if (!vb.files[FILES_CLOSED]) {
+ return RESULT_ERROR;
+ }
- file = g_build_filename(util_get_config_dir(), FILE_CLOSED, NULL);
a.i = info->key == 'U' ? TARGET_NEW : TARGET_CURRENT;
- a.s = util_get_file_contents(file, NULL);
- g_free(file);
+ a.s = util_file_pop_line(vb.files[FILES_CLOSED], NULL);
+ if (!a.s) {
+ return RESULT_ERROR;
+ }
vb_load_uri(c, &a);
g_free(a.s);
setting_add(c, "default-zoom", TYPE_INTEGER, &i, default_zoom, 0, NULL);
setting_add(c, "download-path", TYPE_CHAR, &"~/", NULL, 0, NULL);
setting_add(c, "incsearch", TYPE_BOOLEAN, &off, internal, 0, &c->config.incsearch);
+ i = 10;
+ /* TODO should be global and not overwritten by a new client */
+ setting_add(c, "closed-max-items", TYPE_INTEGER, &i, internal, 0, &vb.config.closed_max);
#ifdef FEATURE_GUI_STYLE_VIMB2_COMPAT
/* gui style settings vimb2 compatibility */