diff --git a/content/events.js b/content/events.js index b5901af3..04fe1da0 100644 --- a/content/events.js +++ b/content/events.js @@ -508,14 +508,16 @@ vimperator.Events = function() //{{{ break; case vimperator.modes.CARET: - // setting this option will trigger an observer which will care about all other details - // like setting the NORMAL mode + // setting this option will trigger an observer which will + // care about all other details like setting the NORMAL mode vimperator.options.setFirefoxPref("accessibility.browsewithcaret", false); break; case vimperator.modes.INSERT: if ((vimperator.modes.extended & vimperator.modes.TEXTAREA) && !vimperator.options["insertmode"]) + { vimperator.mode = vimperator.modes.TEXTAREA; + } else { vimperator.modes.reset(); @@ -527,9 +529,11 @@ vimperator.Events = function() //{{{ default: // clear any selection made var selection = window.content.getSelection(); - try { // a simple if (selection) does not work + try + { // a simple if (selection) does not seem to work selection.collapseToStart(); - } catch (e) { } + } + catch (e) { } vimperator.commandline.clear(); vimperator.modes.reset(); diff --git a/content/modes.js b/content/modes.js index d0ddb2ac..60afaafe 100644 --- a/content/modes.js +++ b/content/modes.js @@ -164,12 +164,13 @@ vimperator.modes = (function() }, // helper function to set both modes in one go + // if silent == true, you also need to take care of the mode handling changes yourself set: function(main_mode, extended_mode, silent) { // if a main mode is set, the extended is always cleared if (typeof main_mode === "number") { - if (main_mode != main) + if (!silent && main_mode != main) handleModeChange(main, main_mode); main = main_mode; diff --git a/content/ui.js b/content/ui.js index 578d85cd..336daade 100644 --- a/content/ui.js +++ b/content/ui.js @@ -288,6 +288,15 @@ vimperator.CommandLine = function() //{{{ this.clear(); } + this.clear = function() + { + multiline_input_widget.collapsed = true; + multiline_output_widget.collapsed = true; + completionlist.hide(); + + setLine("", this.HL_NORMAL); + }; + // TODO: add :messages entry // vimperator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst this.echo = function(str, highlight_group, flags) @@ -354,15 +363,6 @@ vimperator.CommandLine = function() //{{{ }, 10); }; - this.clear = function() - { - multiline_input_widget.collapsed = true; - multiline_output_widget.collapsed = true; - completionlist.hide(); - - setLine("", this.HL_NORMAL); - }; - this.onEvent = function(event) { var command = this.getCommand(); @@ -401,6 +401,7 @@ vimperator.CommandLine = function() //{{{ history.add(command); vimperator.modes.reset(true); //FIXME: use mode stack completionlist.hide(); + vimperator.focusContent(false); vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible return vimperator.triggerCallback("submit", mode, command); } @@ -650,6 +651,9 @@ vimperator.CommandLine = function() //{{{ switch (key) { + case "": + return; // handled globally in events.js:onEscape() + case ":": vimperator.commandline.open(":", "", vimperator.modes.EX); return;