query = arg->s;
/* add new search query to history and search register */
vb_register_add('/', query);
+ history_add(HISTORY_SEARCH, query, NULL);
} else {
/* no search phrase given - continue a previous search */
query = vb_register_get('/');
text = vb_get_input_text();
/* skip leading prompt char like ':' or '/' */
- /* TODO should we use a flag to determine if we should record the command
- * into the history - maybe it's not good to save commands in history that
- * where triggered by a map like ':name \, :set scripts!<cr>' - by the way
- * does vim also skip history recording for such mapped commands */
cmd = text + 1;
switch (*text) {
case '/': count = 1; /* fall through */
case '?':
mode_enter('n');
command_search(&((Arg){count, cmd}));
- history_add(HISTORY_SEARCH, cmd, NULL);
break;
case ';': /* fall through */
case ':':
mode_enter('n');
ex_run_string(cmd);
- /* TODO fill register and history in ex_run_string but not if this
- * is called on reading the config file */
- vb_register_add(':', cmd);
- history_add(HISTORY_COMMAND, cmd, NULL);
break;
}
arg->lhs = g_string_new("");
arg->rhs = g_string_new("");
+ vb_register_add(':', input);
+ history_add(HISTORY_COMMAND, input, NULL);
+
while (input && *input) {
if (!parse(&input, arg) || !execute(arg)) {
free_cmdarg(arg);
*/
void history_add(HistoryType type, const char *value, const char *additional)
{
- const char *file = get_file_by_type(type);
+ const char *file;
+
+ if (!vb.state.enable_history) {
+ return;
+ }
+ file = get_file_by_type(type);
if (additional) {
util_file_append(file, "%s\t%s\n", value, additional);
} else {
static void init_core(void)
{
Gui *gui = &vb.gui;
- WebKitWebSettings *setting;
if (vb.embed) {
gui->window = gtk_plug_new(vb.embed);
gtk_box_pack_start(gui->box, gui->eventbox, false, false, 0);
gtk_box_pack_end(gui->box, gui->input, false, false, 0);
+ /* init some state variable */
+ vb.state.enable_register = false;
+ vb.state.enable_history = false;
+
/* initialize the modes */
mode_init();
mode_add('n', normal_enter, normal_leave, normal_keypress, NULL);
setup_signals();
- setting = webkit_web_view_get_settings(gui->webview);
-
/* make sure the main window and all its contents are visible */
gtk_widget_show_all(gui->window);
if (vb.config.kioskmode) {
+ WebKitWebSettings *setting = webkit_web_view_get_settings(gui->webview);
+
/* hide input box - to not create it would be better, but this needs a
* lot of changes in the code where the input is used */
gtk_widget_hide(vb.gui.input);
}
/* enter normal mode */
+ vb.state.enable_register = true;
+ vb.state.enable_history = true;
mode_enter('n');
vb.config.default_zoom = 1.0;
GdkScreen *screen = gdk_window_get_screen(gtk_widget_get_window(vb.gui.window));
gdouble dpi = gdk_screen_get_resolution(screen);
if (dpi != -1) {
+ WebKitWebSettings *setting = webkit_web_view_get_settings(gui->webview);
webkit_web_view_set_full_content_zoom(gui->webview, true);
g_object_set(G_OBJECT(setting), "enforce-96-dpi", true, NULL);
char *mark;
int idx;
+ if (!vb.state.enable_register) {
+ return;
+ }
+
/* make sure the mark is a valid mark char */
if ((mark = strchr(VB_REG_CHARS, buf))) {
/* get the index of the mark char */
gdouble marks[VB_MARK_SIZE]; /* holds marks set to page with 'm{markchar}' */
char *linkhover; /* the uri of the curret hovered link */
char *reg[VB_REG_SIZE]; /* holds the yank buffer */
+ gboolean enable_register; /* indicates if registers are filled */
+ gboolean enable_history; /* indicates if history entries are written */
} State;
typedef struct {