From 2028ebba19763bb8d5bd2c9819afa4a32890898e Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Sat, 6 Oct 2007 13:16:01 +0000 Subject: [PATCH] merge MOW improvements --- content/bookmarks.js | 48 ++++++--- content/buffers.js | 16 +-- content/commands.js | 28 +++--- content/find.js | 4 +- content/mappings.js | 7 +- content/options.js | 10 +- content/ui.js | 220 +++++++++++++++++++++-------------------- content/util.js | 38 +++++++ content/vimperator.js | 8 +- content/vimperator.xul | 1 + skin/vimperator.css | 89 ++++++++++++++--- 11 files changed, 305 insertions(+), 164 deletions(-) create mode 100644 content/util.js diff --git a/content/bookmarks.js b/content/bookmarks.js index b265caa2..8ce25daa 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -271,17 +271,26 @@ function Bookmarks() //{{{ for (var i = 0; i < items.length; i++) { - var list = ""; + var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + + "
titleURL
"; for (var i = 0; i < items.length; i++) { - list += ""; + var title = vimperator.util.escapeHTML(items[i][1]); + if (title.length > 50) + title = title.substr(0, 47) + "..."; + var keyword = "".substr(0,12); // maximum 12 chars + var url = vimperator.util.escapeHTML(items[i][0]); + var tags = "tag1, tag2"; + list += ""; // TODO: change that list to something like this when we have keywords //list += ""; } list += "
titlekeywordURLtags
" + items[i][1] + "" + items[i][0] + "
" + title + "" + keyword + + "" + url + + "" + tags + "
" + items[i][1].substr(0,20) + "" + items[i][0] + "
" + "Keyword: foo Tags: computer, news" + "
"; - vimperator.commandline.echo(list, true); + vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, true); } } } @@ -441,6 +450,7 @@ function History() //{{{ }; // TODO: better names? + // and move to vimperator.buffer.? this.stepTo = function(steps) { var index = getWebNavigation().sessionHistory.index + steps; @@ -504,14 +514,19 @@ function History() //{{{ for (var i = 0; i < items.length; i++) { - var list = ""; + var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + + "
titleURL
"; for (var i = 0; i < items.length; i++) { - list += ""; + var title = vimperator.util.escapeHTML(items[i][1]); + if (title.length > 50) + title = title.substr(0, 47) + "..."; + var url = vimperator.util.escapeHTML(items[i][0]); + list += ""; } list += "
titleURL
" + items[i][1] + "" + items[i][0] + "
" + title + "" + url + "
"; - vimperator.commandline.echo(list, true); + vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, true); } } } @@ -755,19 +770,20 @@ function Marks() //{{{ } } - var list = ""; + var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + + "
marklinecolfile
"; for (var i = 0; i < marks.length; i++) { list += "" - + "" - + "" - + "" - + "" + + "" + + "" + + "" + + "" + ""; } list += "
marklinecolfile
 " + marks[i][0] + "" + Math.round(marks[i][1].position.y * 100) + "%" + Math.round(marks[i][1].position.x * 100) + "%" + marks[i][1].location + " " + marks[i][0] + "" + Math.round(marks[i][1].position.y * 100) + "%" + Math.round(marks[i][1].position.x * 100) + "%" + vimperator.util.escapeHTML(marks[i][1].location) + "
"; - vimperator.commandline.echo(list, true); // TODO: force of multiline widget a better way + vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, true); // TODO: force of multiline widget a better way } //}}} } //}}} @@ -850,14 +866,16 @@ function QuickMarks() //{{{ } } - var list = ""; + var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + + "
QuickMarkURL
"; for (var i = 0; i < marks.length; i++) { - list += ""; + list += ""; } list += "
QuickMarkURL
    " + marks[i][0] + "" + marks[i][1] + "
" + marks[i][0] + + "" + vimperator.util.escapeHTML(marks[i][1]) + "
"; - vimperator.commandline.echo(list, true); // TODO: force of multiline widget a better way + vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, true); // TODO: force of multiline widget a better way } this.destroy = function() diff --git a/content/buffers.js b/content/buffers.js index bdb68bc9..07facc69 100644 --- a/content/buffers.js +++ b/content/buffers.js @@ -185,24 +185,28 @@ function Buffer() //{{{ var items = vimperator.completion.get_buffer_completions(""); var number, indicator, title, url; - var list = "" + var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + "
"; for (var i = 0; i < items.length; i++) { if (i == vimperator.tabs.index()) - indicator = " % "; + indicator = " % "; else if (i == vimperator.tabs.index(vimperator.tabs.alternate)) - indicator = " # "; + indicator = " # "; else - indicator = "   "; + indicator = " "; [number, title] = items[i][0].split(/:\s+/, 2); url = items[i][1]; + url = vimperator.util.escapeHTML(url); + title = vimperator.util.escapeHTML(title); - list += ""; + list += ""; } list += "
  " + number + "" + indicator + "" + title + "" + url + "
" + number + "" + indicator + + "" + title + + "" + url + "
"; - vimperator.commandline.echo(list, true); + vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, true); } } diff --git a/content/commands.js b/content/commands.js index 25df755d..bac54358 100644 --- a/content/commands.js +++ b/content/commands.js @@ -503,7 +503,7 @@ function Commands() //{{{ if (typeof arg === "object") arg = vimperator.objectToString(arg, color); else if (typeof arg === "function") - arg = arg.toString().replace(//, ">"); + arg = vimperator.util.escapeHTML(arg.toString()); else if (typeof arg === "number" || typeof arg === "boolean") arg = "" + arg; else if (typeof arg === "undefined") @@ -1423,25 +1423,31 @@ function Commands() //{{{ var after_time = Date.now(); if ((after_time - before_time) / count >= 100) - var each = "  Each time:  " + + var each = " Each time:" + ((after_time - before_time) / 1000.0 / count) + - " sec
"; + "
sec"; else - var each = "  Each time:  " + + var each = " Each time:" + ((after_time - before_time) / count) + - " msec
"; + "
msec"; if (after_time - before_time >= 100) - var total = "  Total time: " + + var total = " Total time:" + ((after_time - before_time) / 1000.0) + - " sec"; + "sec"; else - var total = "  Total time: " + - (after_time - before_time) + " msec"; + var total = " Total time:" + + (after_time - before_time) + "msec"; + var str = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + + "" + + "" + + "" + + "" + each + "" + + "" + total + "" + "
Code execution summary
Executed:" + count + "times
"; - vimperator.echo("Code execution summary:
" + - "  Executed:   " + count + " times
" + each + total); + vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, true); } else { diff --git a/content/find.js b/content/find.js index eeed6073..6df14a8f 100644 --- a/content/find.js +++ b/content/find.js @@ -166,9 +166,9 @@ function Search() //{{{ // our command line setTimeout(function() { if (up) - vimperator.echoerr("search hit TOP, continuing at BOTTOM"); + vimperator.commandline.echo("search hit TOP, continuing at BOTTOM", vimperator.commandline.HL_WARNING); else - vimperator.echoerr("search hit BOTTOM, continuing at TOP"); + vimperator.commandline.echo("search hit BOTTOM, continuing at TOP", vimperator.commandline.HL_WARNING); }, 0); } else diff --git a/content/mappings.js b/content/mappings.js index 2ca9a642..19537a4d 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -270,21 +270,20 @@ function Mappings() //{{{ } var list = ""; - for (var i = 0; i < maps.length; i++) { for (var j = 0; j < maps[i].names.length; j++) { list += ""; - list += "" + list += "" if (maps[i].rhs) - list += "" + list += "" list += ""; } } list += "
 " + maps[i].names[j].replace(//g, ">") + " " + vimperator.util.escapeHTML(maps[i].names[j]) + " " + maps[i].rhs.replace(//g, ">") + " " + vimperator.util.escapeHTML(maps[i].rhs) + "
"; - vimperator.commandline.echo(list, true); // TODO: force of multiline widget a better way + vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, true); // TODO: force of multiline widget a better way } /////////////////////////////////////////////////////////////////////////////}}} diff --git a/content/options.js b/content/options.js index 577b46a4..6fc6c922 100644 --- a/content/options.js +++ b/content/options.js @@ -304,8 +304,8 @@ function Options() //{{{ this.list = function() { // TODO: columns like Vim? - var list = "" + - ""; + var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + + "
--- Options ---
"; var name, value; for (var i = 0; i < options.length; i++) @@ -315,18 +315,18 @@ function Options() //{{{ if (options[i].type == "boolean") { - name = value ? "  " + name : "no" + name; + name = value ? " " + name : "no" + name; list += ""; } else { - list += ""; + list += ""; } } list += "
--- Options ---
" + name + "
" + "  " + name + "=" + value + "
" + " " + name + "=" + value + "
"; - vimperator.commandline.echo(list, true); + vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, true); } // TODO: separate Preferences from Options? Would these utility functions diff --git a/content/ui.js b/content/ui.js index e190fe27..4fe76132 100644 --- a/content/ui.js +++ b/content/ui.js @@ -110,12 +110,6 @@ function CommandLine() //{{{ var multiline_output_widget = document.getElementById("vimperator-multiline-output"); multiline_output_widget.contentDocument.body.setAttribute("style", "margin: 0px; font-family: -moz-fixed;"); // get rid of the default border multiline_output_widget.contentDocument.body.innerHTML = ""; - // we need this hack, or otherwise the first use of setMultiline() will have a wrong height - setTimeout(function() { - multiline_output_widget.collapsed = false; - var content_height = multiline_output_widget.contentDocument.height; - multiline_output_widget.collapsed = true; - }, 100); // the widget used for multiline intput var multiline_input_widget = document.getElementById("vimperator-multiline-input"); @@ -133,20 +127,12 @@ function CommandLine() //{{{ var multiline_regexp = null; var multiline_callback = null; - function setNormalStyle() + function setHighlightGroup(group) { - commandline_widget.setAttribute("class", "normal"); - } - function setMessageStyle() - { - commandline_widget.setAttribute("class", "message"); - } - function setErrorStyle() - { - commandline_widget.setAttribute("class", "error"); + commandline_widget.setAttribute("class", group); } - // Sets the prompt - for example, : or / + // sets the prompt - for example, : or / function setPrompt(prompt) { if (typeof prompt != "string") @@ -155,7 +141,7 @@ function CommandLine() //{{{ prompt_widget.value = prompt; if (prompt) { - // Initially (in the xul) the prompt is 'collapsed', this makes + // initially (in the xul) the prompt is 'collapsed', this makes // sure it's visible, then we toggle the display which works better prompt_widget.style.visibility = 'visible'; prompt_widget.style.display = 'inline'; @@ -167,53 +153,67 @@ function CommandLine() //{{{ } } - // Sets the command - e.g. 'tabopen', 'open http://example.com/' + // sets the command - e.g. 'tabopen', 'open http://example.com/' function setCommand(cmd) { + command_widget.hidden = false; command_widget.value = cmd; } - // TODO: the invoking command should be pasted at the top of the MOW and - // the MOW messages should actually be displayed in the commandline - // : extract CSS + // TODO: extract CSS // : resize upon a window resize + // : echoed lines longer than v-c-c.width should wrap and use MOW function setMultiline(str) { - // TODO: we should retain any previous command output like Vim - if (!multiline_output_widget.collapsed) - multiline_output_widget.collapsed = true; - multiline_input_widget.collapsed = true; - var output = str.replace(/\n|\\n/g, "
"); - //output = ":" + command_widget.value + "
" + output; - output += "
" - output += 'Press ENTER or type command to continue'; - output += ''; - output += ''; + var output = "
" + str + "
"; + if (!multiline_output_widget.collapsed) + { + // FIXME: need to make sure an open MOW is closed when commands + // that don't generate output are executed + output = multiline_output_widget.contentDocument.body.innerHTML + output; + multiline_output_widget.collapsed = true; + } + + var font_size = document.defaultView.getComputedStyle(document.getElementById("main-window"), null).getPropertyValue("font-size"); + multiline_output_widget.contentDocument.body.setAttribute("style", "font-size: " + font_size); multiline_output_widget.contentDocument.body.innerHTML = output; + multiline_output_widget.contentDocument.body.id = "vimperator-multiline-output-content"; + + var stylesheet = multiline_output_widget.contentDocument.createElement("link"); + stylesheet.setAttribute("rel", "Stylesheet"); + stylesheet.setAttribute("href", "chrome://vimperator/skin/vimperator.css"); + multiline_output_widget.contentDocument.getElementsByTagName("head")[0].appendChild(stylesheet); var available_height = getBrowser().mPanelContainer.boxObject.height; var content_height = multiline_output_widget.contentDocument.height; var height = content_height < available_height ? content_height : available_height; - //multiline_output_widget.style.height = height + "px"; multiline_output_widget.height = height + "px"; multiline_output_widget.collapsed = false; if (vimperator.options["more"] && multiline_output_widget.contentWindow.scrollMaxY > 0) { - multiline_output_widget.contentWindow.document.getElementById("more-prompt").style.display = "inline"; - multiline_output_widget.contentWindow.scrollTo(0, 0); + // start the last executed command's output at the top of the screen + var elements = multiline_output_widget.contentDocument.getElementsByTagName("div"); + for (var i = 0; i < elements.length; i++) + { + if (elements[i].className != "ex-command-output") + elements.splice(i, 1); + } + elements[elements.length - 1].scrollIntoView(true); + + if (multiline_output_widget.contentWindow.scrollY >= multiline_output_widget.contentWindow.scrollMaxY) + vimperator.commandline.echo("Press ENTER or type command to continue", vimperator.commandline.HL_QUESTION); + else + vimperator.commandline.echo("-- More --", vimperator.commandline.HL_MOREMSG); } else { multiline_output_widget.contentWindow.scrollTo(0, content_height); + vimperator.commandline.echo("Press ENTER or type command to continue", vimperator.commandline.HL_QUESTION); } multiline_output_widget.contentWindow.focus(); @@ -243,6 +243,18 @@ function CommandLine() //{{{ ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ + this.HL_NORMAL = "hl-Normal"; + this.HL_ERRORMSG = "hl-ErrorMsg"; + this.HL_MODEMSG = "hl-ModeMsg"; + this.HL_MOREMSG = "hl-MoreMsg"; + this.HL_QUESTION = "hl-Question"; + this.HL_WARNING = "hl-Warning"; + + // not yet used + this.FORCE_MULTILINE = 1 << 0; + this.FORCE_SINGLELINE = 1 << 1; + this.FORCE_ECHO = 1 << 2; // also echoes if the commandline has focus + this.getCommand = function() { return command_widget.value; @@ -256,7 +268,7 @@ function CommandLine() //{{{ cur_command = cmd || ""; cur_extended_mode = ext_mode || null; - setNormalStyle(); + setHighlightGroup(this.HL_NORMAL); history_index = UNINITIALIZED; completion_index = UNINITIALIZED; @@ -269,8 +281,19 @@ function CommandLine() //{{{ command_widget.focus(); }; + // normally used when pressing esc, does not execute a command + this.close = function() + { + var res = vimperator.triggerCallback("cancel", cur_extended_mode); + history.add(this.getCommand()); + //vimperator.modes.set(old_mode, old_extended_mode); + vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible + this.clear(); + } + // FIXME: flags not yet really functional --mst - this.echo = function(str, flags) + // multiline string don't obey highlight_group + this.echo = function(str, highlight_group, flags) { var focused = document.commandDispatcher.focusedElement; if (focused && focused == command_widget.inputField || focused == multiline_input_widget.inputField) @@ -279,42 +302,42 @@ function CommandLine() //{{{ if (typeof str != "string") str = ""; - setNormalStyle(); - if (flags || str.indexOf("\n") > -1 || str.indexOf("\\n") > -1 || str.indexOf("
") > -1 || str.indexOf("
") > -1) + highlight_group = highlight_group || this.HL_NORMAL; + setHighlightGroup(highlight_group); + if (flags /*|| !multiline_output_widget.collapsed*/ || /\n|/.test(str)) { setMultiline(str); } else { - setPrompt(""); - setCommand(str); + if (!str) + str = ""; + + setCommand(""); + setPrompt(str); + // FIXME: this causes the commandline to lose focus in FF2 + //command_widget.hidden = true; + + // initially (in the xul) the prompt is 'collapsed', this makes + // sure it's visible, then we toggle the display which works better + prompt_widget.style.visibility = 'visible'; + prompt_widget.style.display = 'inline'; + prompt_widget.size = str.length; } cur_extended_mode = null; return true; }; - this.echoErr = function(str) - { - var focused = document.commandDispatcher.focusedElement; - if (focused && focused == command_widget.inputField || focused == multiline_input_widget.inputField) - return false; - - setErrorStyle(); - setPrompt(""); - setCommand(str); - cur_extended_mode = null; - return true; - }; - // this will prompt the user for a string // vimperator.commandline.input("(s)ave or (o)pen the file?") this.input = function(str) { // TODO: unfinished, need to find out how/if we can block the execution of code // to make this code synchronous or at least use a callback - setMessageStyle(); + setHighlightGroup(this.HL_QUESTION); setPrompt(str); setCommand(""); + command_widget.focus(); return "not implemented"; }; @@ -345,9 +368,7 @@ function CommandLine() //{{{ multiline_output_widget.collapsed = true; completionlist.hide(); - setPrompt(" "); // looks faster than an empty string as most prompts are 1 char long - setCommand(""); - setNormalStyle(); + this.echo(""); }; this.onEvent = function(event) @@ -366,7 +387,7 @@ function CommandLine() //{{{ } else if (event.type == "focus") { - if (!cur_extended_mode) + if (!cur_extended_mode && event.target == command_widget.inputField) event.target.blur(); } else if (event.type == "input") @@ -478,7 +499,7 @@ function CommandLine() //{{{ if (res) [completion_start_index, completions] = res; - // Sort the completion list + // sort the completion list if (vimperator.options["wildoptions"].search(/\bsort\b/) > -1) { completions.sort(function(a, b) { @@ -638,31 +659,20 @@ function CommandLine() //{{{ var show_more_help_prompt = false; var show_more_prompt = false; + var close_window = false; + var pass_event = false; function isScrollable() { return !win.scrollMaxY == 0; } function atEnd() { return win.scrollY / win.scrollMaxY >= 1; } - function close() - { - multiline_output_widget.collapsed = true; - vimperator.setMode(vimperator.modes.NORMAL); - vimperator.focusContent(); - } - - function pass(event) - { - close(); - vimperator.events.onKeyPress(event); - } - var key = vimperator.events.toString(event); switch (key) { case ":": vimperator.commandline.open(":", "", vimperator.modes.EX); - break; + return; // down a line case "j": @@ -670,7 +680,7 @@ function CommandLine() //{{{ if (vimperator.options["more"] && isScrollable()) win.scrollByLines(1); else - pass(event); + pass_event = true; break; case "": @@ -679,7 +689,7 @@ function CommandLine() //{{{ if (vimperator.options["more"] && isScrollable() && !atEnd()) win.scrollByLines(1); else - close(); // don't propagate the event for accept keys + close_window = true;; // don't propagate the event for accept keys break; // up a line @@ -691,7 +701,7 @@ function CommandLine() //{{{ else if (vimperator.options["more"] && !isScrollable()) show_more_prompt = true; else - pass(event); + pass_event = true; break; // half page down @@ -699,7 +709,7 @@ function CommandLine() //{{{ if (vimperator.options["more"] && isScrollable()) win.scrollBy(0, win.innerHeight / 2); else - pass(event); + pass_event = true; break; case "": @@ -716,7 +726,7 @@ function CommandLine() //{{{ if (vimperator.options["more"] && isScrollable()) win.scrollByPages(1); else - pass(event); + pass_event = true; break; case "": @@ -724,7 +734,7 @@ function CommandLine() //{{{ if (vimperator.options["more"] && isScrollable() && !atEnd()) win.scrollByPages(1); else - pass(event); + pass_event = true; break; // half page up @@ -733,7 +743,7 @@ function CommandLine() //{{{ if (vimperator.options["more"] && isScrollable()) win.scrollBy(0, -(win.innerHeight / 2)); else - pass(event); + pass_event = true; break; // page up @@ -743,14 +753,14 @@ function CommandLine() //{{{ else if (vimperator.options["more"] && !isScrollable()) show_more_prompt = true; else - pass(event); + pass_event = true; break; case "": if (vimperator.options["more"] && isScrollable()) win.scrollByPages(-1); else - pass(event); + pass_event = true; break; // top of page @@ -760,7 +770,7 @@ function CommandLine() //{{{ else if (vimperator.options["more"] && !isScrollable()) show_more_prompt = true; else - pass(event); + pass_event = true; break; // bottom of page @@ -768,7 +778,7 @@ function CommandLine() //{{{ if (vimperator.options["more"] && isScrollable() && !atEnd()) win.scrollTo(0, win.scrollMaxY); else - pass(event); + pass_event = true; break; // copy text to clipboard @@ -778,34 +788,34 @@ function CommandLine() //{{{ // close the window case "q": - close(); + close_window = true;; break; // unmapped key default: if (!vimperator.options["more"] || !isScrollable() || atEnd() || vimperator.events.isCancelKey(key)) - pass(event); + pass_event = true; else show_more_help_prompt = true; } - // set appropriate prompt string - var more_prompt = win.document.getElementById("more-prompt"); - var more_help_prompt = win.document.getElementById("more-help-prompt"); + if (pass_event || close_window) + { + vimperator.setMode(vimperator.modes.NORMAL); + vimperator.focusContent(); + this.clear(); - if (show_more_help_prompt) - { - more_prompt.style.display = "none"; - more_help_prompt.style.display = "inline"; + if (pass_event) + vimperator.events.onKeyPress(event); } - else if (show_more_prompt || (vimperator.options["more"] && isScrollable() && !atEnd())) + else // set update the prompt string { - more_help_prompt.style.display = "none"; - more_prompt.style.display = "inline"; - } - else - { - more_prompt.style.display = more_help_prompt.style.display = "none"; + if (show_more_help_prompt) + this.echo("-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit", this.HL_MOREMSG); + else if (show_more_prompt || (vimperator.options["more"] && isScrollable() && !atEnd())) + this.echo("-- More --", this.HL_MOREMSG); + else + this.echo("Press ENTER or type command to continue", this.HL_QUESTION); } } diff --git a/content/util.js b/content/util.js new file mode 100644 index 00000000..b6572d04 --- /dev/null +++ b/content/util.js @@ -0,0 +1,38 @@ +/***** BEGIN LICENSE BLOCK ***** {{{ +Version: MPL 1.1/GPL 2.0/LGPL 2.1 + +The contents of this file are subject to the Mozilla Public License Version +1.1 (the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +for the specific language governing rights and limitations under the +License. + +(c) 2006-2007: Martin Stubenschrott + +Alternatively, the contents of this file may be used under the terms of +either the GNU General Public License Version 2 or later (the "GPL"), or +the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +in which case the provisions of the GPL or the LGPL are applicable instead +of those above. If you wish to allow use of your version of this file only +under the terms of either the GPL or the LGPL, and not to allow others to +use your version of this file under the terms of the MPL, indicate your +decision by deleting the provisions above and replace them with the notice +and other provisions required by the GPL or the LGPL. If you do not delete +the provisions above, a recipient may use your version of this file under +the terms of any one of the MPL, the GPL or the LGPL. +}}} ***** END LICENSE BLOCK *****/ + +vimperator.util = { + escapeHTML: function(str) + { + var e = window.content.document.createElement("div"); + e.appendChild(window.content.document.createTextNode(str)); + return e.innerHTML; + } +} + +// vim: set fdm=marker sw=4 ts=4 et: diff --git a/content/vimperator.js b/content/vimperator.js index c2ca5035..d73ffe1c 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -451,7 +451,7 @@ const vimperator = (function() //{{{ } if (color) - string += "" + obj + "::\n"; + string += "" + obj + "::\n"; else string += obj + "::\n"; @@ -494,7 +494,7 @@ const vimperator = (function() //{{{ { var str = value.toString(); if (typeof str == "string") // can be "undefined" - value = str.replace(//g, ">"); + value = vimperator.util.escapeHTML(str); } } @@ -746,8 +746,8 @@ const vimperator = (function() //{{{ vimperator.hints = new Hints(); vimperator.log("All modules loaded", 3); - vimperator.echo = vimperator.commandline.echo; - vimperator.echoerr = vimperator.commandline.echoErr; + vimperator.echo = function(str) { vimperator.commandline.echo(str); } + vimperator.echoerr = function(str) { vimperator.commandline.echo(str, vimperator.commandline.HL_ERRORMSG); } vimperator.globalVariables = {}; diff --git a/content/vimperator.xul b/content/vimperator.xul index 456e7de8..ad423199 100644 --- a/content/vimperator.xul +++ b/content/vimperator.xul @@ -51,6 +51,7 @@ the terms of any one of the MPL, the GPL or the LGPL.