From 7ac9a0580345a7a8931e855083fcaccbc1666831 Mon Sep 17 00:00:00 2001 From: Martin Stubenschrott Date: Fri, 11 May 2007 12:42:17 +0000 Subject: [PATCH] First attempt in making vimperator object orietened. For now only the CommandLine widget was made a real encapsulated object. --- Makefile | 2 +- chrome/content/vimperator/bookmarks.js | 33 ++ chrome/content/vimperator/commands.js | 199 ++++++----- chrome/content/vimperator/completion.js | 225 ++----------- chrome/content/vimperator/help.js | 4 +- chrome/content/vimperator/hints.js | 6 +- chrome/content/vimperator/settings.js | 30 +- chrome/content/vimperator/tags | 37 ++- chrome/content/vimperator/vimperator.js | 400 ++++++----------------- chrome/content/vimperator/vimperator.xul | 210 ++++++------ 10 files changed, 426 insertions(+), 720 deletions(-) diff --git a/Makefile b/Makefile index cab6cf1f..e4a7a76d 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ TOP = $(shell pwd) -VERSION = 0.4.1 +VERSION = 0.5 OS = $(shell uname -s) BUILD_DATE = $(shell date "+%Y/%m/%d %H:%M:%S") diff --git a/chrome/content/vimperator/bookmarks.js b/chrome/content/vimperator/bookmarks.js index f8c2c173..726b7621 100644 --- a/chrome/content/vimperator/bookmarks.js +++ b/chrome/content/vimperator/bookmarks.js @@ -240,4 +240,37 @@ function Bookmarks() } var bookmarks = new Bookmarks(); // FIXME, must it really be here? doesn't work in vimperator.js + + + +Vimperator.prototype.quickmarks = new function() +{ + //logObject(vimperator); + //setTimeout(function() {logObject(vimperator)}, 1000); + //Vimperator.echo("test"); + //alert(vimperator.getpr("hinttags")); + this.add = function() { alert('add');}; + this.rem = function() { vimperator.echo("rem"); logObject(vimperator)}; + + logMessage("quickmarks initialized."); +} + + +function QM() +{ + //logObject(vimperator); + logMessage(vimperator.getpr("complete")); +// var command_widget = document.getElementById('new-vim-commandbar'); +// logMessage(command_widget); + //setTimeout(function() {logObject(vimperator)}, 1000); + //Vimperator.echo("test"); + this.add = function() { alert('add');}; + this.rem = function() { vimperator.echo("rem"); logObject(vimperator)}; + this.zoom = function() { vimperator.zoom_to(200); logObject(vimperator)}; + + logMessage("QM initialized."); +} + + + // vim: set fdm=marker sw=4 ts=4 et: diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js index abb93d53..4ef79787 100644 --- a/chrome/content/vimperator/commands.js +++ b/chrome/content/vimperator/commands.js @@ -120,7 +120,7 @@ var g_commands = [/*{{{*/ "Go to buffer from buffer list", "Argument can be either the buffer index or the full URL.", buffer_switch, - function (filter) {return get_buffer_completions(filter);} + function (filter) { return get_buffer_completions(filter); } ], [ ["buffers", "files", "ls"], @@ -219,7 +219,7 @@ var g_commands = [/*{{{*/ try { eval(args); } catch(e) { - echoerr(e.name + ": " + e.message); + vimperator.echoerr(e.name + ": " + e.message); } }, null @@ -470,7 +470,7 @@ var g_commands = [/*{{{*/ ["ve[rsion][!]"], "Show version information", "You can show the Firefox version page with :version!.", - function (args, special) { if (special) openURLs("about:"); else echo("Vimperator version: " + g_vimperator_version); }, + function (args, special) { if (special) openURLs("about:"); else vimperator.echo("Vimperator version: " + vimperator.ver); }, null ], [ @@ -478,7 +478,7 @@ var g_commands = [/*{{{*/ ["win[open] [url] [| url]"], "Open an URL in a new window", "Not implemented yet", - function () { echo("winopen not yet implemented"); }, + function () { vimperator.echo("winopen not yet implemented"); }, null ], [ @@ -524,7 +524,7 @@ var g_mappings = [/*{{{*/ ["b {number}"], "Open a prompt to switch buffers", "Typing the corresponding number opens switches to this buffer", - function (args) { bufshow("", true); openVimperatorBar('buffer '); } + function (args) { bufshow("", true); vimperator.commandline.open(":", "buffer ", MODE_EX); } ], [ ["B"], @@ -547,14 +547,14 @@ var g_mappings = [/*{{{*/ "Count WILL be supported in future releases, then 2D removes two tabs and the one the left is selected.", function(count) { tab_remove(count, true, 0); } ], - [ + /*[ ["ge"], ["ge {cmd}"], "Execute an Ex command", "Go Execute works like :execute.
"+ "This mapping is for debugging purposes, and may be removed in future.", function(count) { openVimperatorBar('execute '); } - ], + ],*/ [ ["gh"], ["gh"], @@ -597,14 +597,14 @@ var g_mappings = [/*{{{*/ ["o"], "Open one or more URLs in the current tab", "See :open for more details", - function(count) { openVimperatorBar('open '); } + function(count) { vimperator.commandline.open(":", "open ", MODE_EX); } ], [ ["O"], ["O"], "Open one ore more URLs in the current tab, based on current location", "Works like o, but preselects current URL in the :open query.", - function(count) { openVimperatorBar('open ' + getCurrentLocation()); } + function(count) { vimperator.commandline.open(":", "open " + getCurrentLocation(), MODE_EX); } ], [ ["p", ""], @@ -641,14 +641,14 @@ var g_mappings = [/*{{{*/ "Open one or more URLs in a new tab", "Like o but open URLs in a new tab.
"+ "See :tabopen for more details", - function(count) { openVimperatorBar('tabopen '); } + function(count) { vimperator.commandline.open(":", "tabopen ", MODE_EX); } ], [ ["T"], ["T"], "Open one ore more URLs in a new tab, based on current location", "Works like t, but preselects current URL in the :tabopen query.", - function(count) { openVimperatorBar('tabopen ' + getCurrentLocation()); } + function(count) { vimperator.commandline.open(":", "tabopen " + getCurrentLocation(), MODE_EX); } ], [ ["u"], @@ -879,21 +879,26 @@ var g_mappings = [/*{{{*/ ], /* search managment */ + [ + ["g/"], + ["g/"], + "Open search dialog", + "", + function(count) { vimperator.search.openSearchDialog(); } + ], [ ["n"], ["n"], "Find next", "Repeat the last \"/\" 1 time (until count is supported).", - // don't use a closure for this, is just DoesNotWork (TM) - function(count) { gFindBar.onFindAgainCmd(); } // this does not work, why?: goDoCommand('cmd_findAgain'); } + function(count) { vimperator.search.findNext(); } ], [ ["N"], ["N"], "Find previous", "Repeat the last \"/\" 1 time (until count is supported) in the opposite direction.", - // don't use a closure for this, is just DoesNotWork (TM) - function(count) { gFindBar.onFindPreviousCmd(); } // this does not work, why?: goDoCommand('cmd_findPrevious'); } + function(count) { vimperator.search.findPrevious(); } ], /* vimperator managment */ @@ -909,7 +914,7 @@ var g_mappings = [/*{{{*/ [":"], "Start command line mode", "In command line mode, you can perform extended commands, which may require arguments.", - function(count) { openVimperatorBar(null); } + function(count) { vimperator.commandline.open(":", "", MODE_EX); } ], [ ["I"], @@ -1019,14 +1024,14 @@ var g_mappings = [/*{{{*/ ] ];/*}}}*/ -var g_insert_mappings = [ /*{{{*/ - ["xxx", "todo"], - ["", "delete word"], - ["", "delete beginning"], - ["", "go beginning"], - ["", "go end"], - ["", "cancel"] -]; /*}}}*/ +// var g_insert_mappings = [ /*{{{*/ +// ["xxx", "todo"], +// ["", "delete word"], +// ["", "delete beginning"], +// ["", "go beginning"], +// ["", "go end"], +// ["", "cancel"] +// ]; /*}}}*/ /* [command, action, cancel_hint_mode, always_active] */ var g_hint_mappings = [ /*{{{*/ @@ -1034,11 +1039,11 @@ var g_hint_mappings = [ /*{{{*/ ["o", "hah.openHints(false, false);", true, false], ["t", "hah.openHints(true, false);", true, false], ["", "hah.openHints(false, true );", true, false], - ["s", "echoerr('Saving of links not yet implemented');", true, false], + ["s", "vimperator.echoerr('Saving of links not yet implemented');", true, false], ["y", "hah.yankUrlHints();", true, false], ["Y", "hah.yankTextHints();", true, false], [",", "g_inputbuffer+=','; hah.setCurrentState(0);", false, true], - [":", "openVimperatorBar(null);", false, true], + [":", "vimperator.commandline.open(':', '', MODE_EX);", false, true], /* movement keys */ ["", "scrollBufferRelative(0, 1);", false, true], ["", "scrollBufferRelative(0, -1);", false, true], @@ -1094,10 +1099,10 @@ g_modemessages[MODE_INSERT] = "INSERT"; g_modemessages[MODE_VISUAL] = "VISUAL"; // returns null, if the cmd cannot be found in our g_commands array, or -// otherwise a refernce to our command +// otherwise a reference to our command function get_command(cmd) // {{{ { - commands = []; + var commands = []; var added; for (var i = 0; i < g_commands.length; i++, added = false) { @@ -1117,15 +1122,20 @@ function get_command(cmd) // {{{ } } } + // return an unambigious command even if it was only given partly if (commands.length == 1) return commands[0]; + return null; } // }}} function execute_command(count, cmd, special, args, modifiers) // {{{ { - if (!cmd) return; - if (!modifiers) modifiers = {}; + if (!cmd) + return; + if (!modifiers) + modifiers = {}; + var command = get_command(cmd); if (command === null) { @@ -1145,11 +1155,13 @@ function execute_command(count, cmd, special, args, modifiers) // {{{ } // }}} +// return [null, null, null, null, heredoc_tag || false]; +// [count, cmd, special, args] = match; function tokenize_ex(string, tag) { // removing comments string.replace(/\s*".*$/, ''); - if (tag) + if (tag) // we already have a multiline heredoc construct { if (string == tag) return [null, null, null, null, false]; @@ -1159,68 +1171,34 @@ function tokenize_ex(string, tag) // 0 - count, 1 - cmd, 2 - special, 3 - args, 4 - heredoc tag var matches = string.match(/^:*(\d+)?([a-zA-Z]+)(!)?(?:\s+(.*?))?$/); - if (!matches) return [null, null, null, null, null]; + if (!matches) + return [null, null, null, null, null]; matches.shift(); + // parse count if (matches[0]) { matches[0] = parseInt(matches[0]); - if (isNaN(matches[0])) matches[0] = 0; + if (isNaN(matches[0])) + matches[0] = 0; // 0 is the default if no count given } - else matches[0] = 0; + else + matches[0] = 0; + matches[2] = !!matches[2]; matches.push(null); if (matches[3]) { - tag = matches[3].match(/<<\s*(\w+)/); + tag = matches[3].match(/<<\s*(\w+)\s*$/); if (tag && tag[1]) matches[4] = tag[1]; } - else matches[3] = ''; + else + matches[3] = ''; return matches; } -function multiliner(line, prev_match, heredoc) -{ - var end = true; - var match = tokenize_ex(line, prev_match[4]); - if (prev_match[3] === undefined) prev_match[3] = ''; - if (match[4] === null) - { - focusContent(false, true); // also sets comp_tab_index to -1 - execute_command.apply(this, match); - } - else - { - if (match[4] === false) - { - prev_match[3] = prev_match[3].replace(new RegExp('<<\s*' + prev_match[4]), heredoc.replace(/\n$/, '')); - focusContent(false, true); // also sets comp_tab_index to -1 - execute_command.apply(this, prev_match); - prev_match = new Array(5); - prev_match[3] = ''; - heredoc = ''; - } - else - { - end = false; - if (!prev_match[3]) - { - prev_match[0] = match[0]; - prev_match[1] = match[1]; - prev_match[2] = match[2]; - prev_match[3] = match[3]; - prev_match[4] = match[4]; - } - else - { - heredoc += match[3] + '\n'; - } - } - } - return [prev_match, heredoc, end]; -} function execute(string) { @@ -1235,33 +1213,33 @@ function execute(string) //////////////////////////////////////////////////////////////////////// // statusbar/commandbar handling ////////////////////////////////// {{{1 //////////////////////////////////////////////////////////////////////// -function echo(msg) -{ - /* In Mozilla, the XUL textbox is implemented as a wrapper around an HTML - * input element. The read only property '.inputField' holds a reference to this inner - * input element. */ - var bar = command_line.inputField; - var focused = document.commandDispatcher.focusedElement; - if (focused && focused == bar) - return; - - bar.setAttribute("style","font-family: monospace;"); - bar.value = msg; -} - -function echoerr(msg) -{ - /* In Mozilla, the XUL textbox is implemented as a wrapper around an HTML - * input element. The read only property '.inputField' holds a reference to this inner - * input element. */ - var bar = command_line.inputField; - var focused = document.commandDispatcher.focusedElement; - if (focused && focused == bar) - return; - - bar.setAttribute("style", "font-family: monospace; color:white; background-color:red; font-weight: bold"); - bar.value = msg; -} + function echo(msg) + { + /* In Mozilla, the XUL textbox is implemented as a wrapper around an HTML + * input element. The read only property '.inputField' holds a reference to this inner + * input element. */ + var bar = command_line.inputField; + var focused = document.commandDispatcher.focusedElement; + if (focused && focused == bar) + return; + + bar.setAttribute("style","font-family: monospace;"); + bar.value = msg; + } + + function echoerr(msg) + { + /* In Mozilla, the XUL textbox is implemented as a wrapper around an HTML + * input element. The read only property '.inputField' holds a reference to this inner + * input element. */ + var bar = command_line.inputField; + var focused = document.commandDispatcher.focusedElement; + if (focused && focused == bar) + return; + + bar.setAttribute("style", "font-family: monospace; color:white; background-color:red; font-weight: bold"); + bar.value = msg; + } //////////////////////////////////////////////////////////////////////// // navigation functions /////////////////////////////////////////// {{{1 @@ -1276,7 +1254,7 @@ function stepInHistory(steps) else { beep(); - if(index<0) + if(index < 0) echo("Cannot go past beginning of history"); else echo("Cannot go past end of history"); @@ -1706,9 +1684,10 @@ function bufshow(filter, in_comp_window) { if (in_comp_window) // fill the completion list { - g_completions = get_buffer_completions(filter); - completion_fill_list(0); - completion_show_list(); + // FIXME + // g_completions = get_buffer_completions(filter); + // completion_fill_list(0); + // completion_show_list(); } else // in the preview window { @@ -1856,7 +1835,8 @@ function zoom_in(factor) } } -function zoom_to(value) +function zoom_to(value) {}; +Vimperator.prototype.zoom_to = function(value) { var zoomMgr = ZoomManager.prototype.getInstance(); value = parseInt(value); @@ -2281,6 +2261,9 @@ function removeMode(mode) function showMode() { + // XXX: remove + showStatusbarMessage(g_current_mode, STATUSFIELD_INPUTBUFFER); + if (!get_pref("showmode") || !g_modemessages[g_current_mode]) return; diff --git a/chrome/content/vimperator/completion.js b/chrome/content/vimperator/completion.js index e7821454..a58e960b 100644 --- a/chrome/content/vimperator/completion.js +++ b/chrome/content/vimperator/completion.js @@ -30,180 +30,6 @@ var g_completions = new Array(); // The completion substrings, used for showing the longest common match var g_substrings = []; -var comp_tab_index = COMPLETION_UNINITIALIZED; // the index in the internal g_completions array -var comp_tab_list_offset = 0; // how many items is the displayed list shifted from the internal tab index -var comp_tab_startstring = ""; -var comp_history = new Array(); -var comp_history_index = -1; - - - -/* uses the entries in g_completions to fill the listbox - * starts at index 'startindex', and shows COMPLETION_MAXITEMS - * returns the number of items */ -function completion_fill_list(startindex)/*{{{*/ -{ - // remove all old items first - var items = completion_list.getElementsByTagName("listitem"); - while (items.length > 0) { completion_list.removeChild(items[0]);} - - // find start index - //var i = index - 3; // 3 lines of context - if (startindex + COMPLETION_MAXITEMS > g_completions.length) - startindex = g_completions.length - COMPLETION_MAXITEMS; - if (startindex < 0) - startindex = 0; - - for(i=startindex; i 0) // XXX: respect completetopt setting -// completion_list.hidden = false; -// else -// completion_list.hidden = true; -// completion_list.setAttribute("rows", (i-startindex).toString()); - - return (i-startindex); -}/*}}}*/ - -function completion_show_list()/*{{{*/ -{ - var items = g_completions.length; - if (items > COMPLETION_MAXITEMS) - items = COMPLETION_MAXITEMS; - if (items > 1) // FIXME - { - completion_list.setAttribute("rows", items.toString()); - completion_list.hidden = false; - } - else - completion_list.hidden = true; -}/*}}}*/ - -/* add a single completion item to the list */ -function completion_add_to_list(completion_item, at_beginning)/*{{{*/ -{ - var item = document.createElement("listitem"); - var cell1 = document.createElement("listcell"); - var cell2 = document.createElement("listcell"); - - cell1.setAttribute("label", completion_item[0]); - cell1.setAttribute("width", "200"); - cell2.setAttribute("label", completion_item[1]); - cell2.setAttribute("style", "color:green; font-family: sans"); - - item.appendChild(cell1); - item.appendChild(cell2); - if (at_beginning == true) - { - var items = completion_list.getElementsByTagName("listitem"); - if (items.length > 0) - completion_list.insertBefore(item, items[0]); - else - completion_list.appendChild(item); - } - else - completion_list.appendChild(item); -}/*}}}*/ - -/* select the next index, refill list if necessary - * - * changes 'comp_tab_index' */ -function completion_select_next_item(has_list, has_full, has_longest)/*{{{*/ -{ - if (has_full) - comp_tab_index++; - has_list = has_list || (!completion_list.hidden && (has_full || has_longest)); - if (comp_tab_index >= g_completions.length) /* wrap around */ - { - comp_tab_index = -1; - if (has_list && has_full) - completion_list.selectedIndex = -1; - return; - } - - if (has_full) - showStatusbarMessage(" match " + (comp_tab_index + 1).toString() + " of " + g_completions.length.toString() + " ", STATUSFIELD_PROGRESS); - if (!has_list) return; - - if (comp_tab_index < 1) // at the top of the list - { - completion_fill_list(0); - comp_tab_list_offset = 0; - } - - var listindex = comp_tab_index - comp_tab_list_offset; - // only move the list, if there are still items we can move - if (listindex >= COMPLETION_MAXITEMS - COMPLETION_CONTEXTLINES && - comp_tab_list_offset < g_completions.length - COMPLETION_MAXITEMS) - { - // for speed reason: just remove old item, and add new at the end of the list - var items = completion_list.getElementsByTagName("listitem"); - completion_list.removeChild(items[0]); - completion_add_to_list(g_completions[comp_tab_index + COMPLETION_CONTEXTLINES], false); - comp_tab_list_offset++; - } - - if (has_full) - { - listindex = comp_tab_index - comp_tab_list_offset; - completion_list.selectedIndex = listindex; - } -}/*}}}*/ - -/* select the previous index, refill list if necessary - * - * changes 'comp_tab_index' */ -function completion_select_previous_item(has_list, has_full, has_longest)/*{{{*/ -{ - if (has_full) - comp_tab_index--; - has_list = has_list || (!completion_list.hidden && (has_full || has_longest)); - if (comp_tab_index == -1) - { - if (has_list && has_full) - completion_list.selectedIndex = -1; - return; - } - - if (has_full) - showStatusbarMessage("match " + (comp_tab_index+1).toString() + " of " + g_completions.length.toString(), STATUSFIELD_PROGRESS); - - if (comp_tab_index < -1) // go to the end of the list - { - comp_tab_index = g_completions.length -1; - if (!has_list) return; - completion_fill_list(g_completions.length - COMPLETION_MAXITEMS); - comp_tab_list_offset = g_completions.length - COMPLETION_MAXITEMS;//COMPLETION_MAXITEMS - 1; - if (comp_tab_list_offset < 0) - comp_tab_list_offset = 0; - } - if (!has_list) return; - - var listindex = comp_tab_index - comp_tab_list_offset; - // only move the list, if there are still items we can move - if (listindex < COMPLETION_CONTEXTLINES && comp_tab_list_offset > 0) - { - // for speed reason: just remove old item, and add new at the end of the list - if (has_list) - { - var items = completion_list.getElementsByTagName("listitem"); - completion_list.removeChild(items[items.length-1]); - completion_add_to_list(g_completions[comp_tab_index - COMPLETION_CONTEXTLINES], true); - } - comp_tab_list_offset--; - } - - if (has_full) - { - listindex = comp_tab_index - comp_tab_list_offset; - completion_list.selectedIndex = listindex; - } -}/*}}}*/ /* * returns the longest common substring @@ -224,7 +50,7 @@ function get_longest_substring()/*{{{*/ return longest; }/*}}}*/ -// function is case insensitive +// function uses smartcase // list = [ [['com1', 'com2'], 'text'], [['com3', 'com4'], 'text'] ] function build_longest_common_substring(list, filter)/*{{{*/ { @@ -271,7 +97,7 @@ function build_longest_common_substring(list, filter)/*{{{*/ return filtered; }/*}}}*/ -/* this function is case senstitive */ +/* this function is case sensitive */ function build_longest_starting_substring(list, filter)/*{{{*/ { var filtered = []; @@ -691,27 +517,42 @@ function get_buffer_completions(filter)/*{{{*/ return build_longest_common_substring(items, filter); }/*}}}*/ -////////// COMMAND HISTORY HANDLING //////////// -function add_to_command_history(str) + +// return [startindex, [[itemtext, itemhelp],...]] +function exTabCompletion(str) { - /* add string to the command line history */ - if (str.length >= 2 && comp_history.push(str) > COMMAND_LINE_HISTORY_SIZE) - comp_history.shift(); -} + var [count, cmd, special, args] = tokenize_ex(str); + var completions = new Array; + var start = 0; + var s = 0; //FIXME, command specific start setting -function save_history() -{ - set_pref("comp_history", comp_history.join("\n")); + // if there is no space between the command name and the cursor + // then get completions of the command name + var matches = str.match(/^(:*\d*)\w*$/); + if(matches) + { + completions = get_command_completions(cmd); + start = matches[1].length; + } + else // dynamically get completions as specified in the g_commands array + { + var command = get_command(cmd); + if (command && command[COMPLETEFUNC]) + { + completions = command[COMPLETEFUNC].call(this, args); +// if (command[COMMANDS][0] == "open" || +// command[COMMANDS][0] == "tabopen" || +// command[COMMANDS][0] == "winopen") +// start = str.search(/^:*\d*\w+(\s+|.*\|)/); // up to the last | or the first space +// else + matches = str.match(/^:*\d*\w+\s+/); // up to the first spaces only + start = matches[0].length; + } + } + return [start, completions]; } -function load_history() -{ - var hist = get_pref("comp_history", ""); - comp_history = hist.split("\n"); -} - - ///////// PREVIEW WINDOW ////////////////////// /* uses the entries in completions to fill the listbox */ diff --git a/chrome/content/vimperator/help.js b/chrome/content/vimperator/help.js index a8defbcb..04949cc2 100644 --- a/chrome/content/vimperator/help.js +++ b/chrome/content/vimperator/help.js @@ -30,7 +30,7 @@ function help(section, easter) { if (easter) { - echoerr("E478: Don't panic!"); + vimperator.echoerr("E478: Don't panic!"); return; } if ((arguments[3] && arguments[3].inTab))// || !window.content.document.open) @@ -238,7 +238,7 @@ function help(section, easter) var element = doc.getElementById(section); if (!element) { - echoerr("E149: Sorry, no help for " + section); + vimperator.echoerr("E149: Sorry, no help for " + section); return; } var pos = cumulativeOffset(element.parentNode); diff --git a/chrome/content/vimperator/hints.js b/chrome/content/vimperator/hints.js index a2aead3e..5769af4f 100644 --- a/chrome/content/vimperator/hints.js +++ b/chrome/content/vimperator/hints.js @@ -430,7 +430,7 @@ function hit_a_hint() linkNumString = ''; hintedElems = []; if (!silent && get_pref("showmode")) - echo(''); + vimperator.echo(''); removeHints(win); return 0; @@ -531,7 +531,7 @@ function hit_a_hint() this.disableHahMode(null, true); copyToClipboard(loc); - echo("Yanked " + loc); + vimperator.echo("Yanked " + loc); }; this.yankTextHints = function() @@ -550,7 +550,7 @@ function hit_a_hint() this.disableHahMode(null, true); copyToClipboard(loc); - echo("Yanked " + loc); + vimperator.echo("Yanked " + loc); }; function setMouseOverElement(elem) diff --git a/chrome/content/vimperator/settings.js b/chrome/content/vimperator/settings.js index bfd893bd..5b58f3be 100644 --- a/chrome/content/vimperator/settings.js +++ b/chrome/content/vimperator/settings.js @@ -321,6 +321,21 @@ function get_setting(cmd)/*{{{*/ ///////////////////////////////////////////////// // preference getter functions ///////////// {{{1 ///////////////////////////////////////////////// +Vimperator.prototype.getpr = function(name){ + //alert('in here'); + if (!g_vimperator_prefs) + g_vimperator_prefs = g_firefox_prefs.getBranch("extensions.vimperator."); + try{ + pref = g_vimperator_prefs.getCharPref(name); + } catch(e) { pref = "no idea"; } + return pref; +} +// does not work: +vimperator.getpref2 = function(name){ + pref = g_vimperator_prefs.getCharPref(name); + return pref; +} + function get_pref(name, forced_default) { var pref = null; @@ -361,6 +376,7 @@ function get_pref(name, forced_default) } return pref; } +Vimperator.prototype.getpref = get_pref; function get_firefox_pref(name, default_value) @@ -399,7 +415,7 @@ function set_pref(name, value) else if (typeof(value) == "boolean") g_vimperator_prefs.setBoolPref(name, value); else - echoerr("Unkown typeof pref: " + value); + vimperator.echoerr("Unkown typeof pref: " + value); } function set_firefox_pref(name, value) @@ -413,7 +429,7 @@ function set_firefox_pref(name, value) else if (typeof(value) == "boolean") g_firefox_prefs.setBoolPref(name, value); else - echoerr("Unkown typeof pref: " + value); + vimperator.echoerr("Unkown typeof pref: " + value); } @@ -442,15 +458,15 @@ function set_showtabline(value) // hide tabbar if(value == 0) { - gBrowser.mStrip.collapsed = true; - gBrowser.mStrip.hidden = true; + getBrowser().mStrip.collapsed = true; + getBrowser().mStrip.hidden = true; } else if(value == 1) - echo("show tabline only with > 1 page open not impl. yet"); + vimperator.echo("show tabline only with > 1 page open not impl. yet"); else { - gBrowser.mStrip.collapsed = false; - gBrowser.mStrip.hidden = false; + getBrowser().mStrip.collapsed = false; + getBrowser().mStrip.hidden = false; } } diff --git a/chrome/content/vimperator/tags b/chrome/content/vimperator/tags index 8dac41a5..f8e75aeb 100644 --- a/chrome/content/vimperator/tags +++ b/chrome/content/vimperator/tags @@ -8,7 +8,8 @@ abs_point find.js /^function abs_point (node) {$/;" f addBookmark bookmarks.js /^function addBookmark(title, uri)$/;" f addEventListeners vimperator.js /^function addEventListeners()$/;" f addMode commands.js /^function addMode(mode)$/;" f -add_to_command_history completion.js /^function add_to_command_history(str)$/;" f +addToHistory commandline.js /^ function addToHistory(str)$/;" f +add_to_command_history commandline.js /^function add_to_command_history(str)$/;" f beep commands.js /^function beep()$/;" f bmadd commands.js /^function bmadd(str)$/;" f bmdel commands.js /^function bmdel(str)$/;" f @@ -23,11 +24,12 @@ build_longest_starting_substring completion.js /^function build_longest_starting changeHintFocus hints.js /^ function changeHintFocus(linkNumString, oldLinkNumString)$/;" f clearHighlight find.js /^function clearHighlight()$/;" f clearSelection find.js /^function clearSelection() {$/;" f -completion_add_to_list completion.js /^function completion_add_to_list(completion_item, at_beginning)\/*{{{*\/$/;" f -completion_fill_list completion.js /^function completion_fill_list(startindex)\/*{{{*\/$/;" f -completion_select_next_item completion.js /^function completion_select_next_item(has_list, has_full, has_longest)\/*{{{*\/$/;" f -completion_select_previous_item completion.js /^function completion_select_previous_item(has_list, has_full, has_longest)\/*{{{*\/$/;" f -completion_show_list completion.js /^function completion_show_list()\/*{{{*\/$/;" f +CommandLine commandline.js /^function CommandLine ()$/;" f +completion_add_to_list commandline.js /^function completion_add_to_list(completion_item, at_beginning)\/*{{{*\/$/;" f +completion_fill_list commandline.js /^function completion_fill_list(startindex)\/*{{{*\/$/;" f +completion_select_next_item commandline.js /^function completion_select_next_item(has_list, has_full, has_longest)\/*{{{*\/$/;" f +completion_select_previous_item commandline.js /^function completion_select_previous_item(has_list, has_full, has_longest)\/*{{{*\/$/;" f +completion_show_list commandline.js /^function completion_show_list()\/*{{{*\/$/;" f copyToClipboard commands.js /^function copyToClipboard(str)$/;" f createCursorPositionString vimperator.js /^function createCursorPositionString()$/;" f createHints hints.js /^ function createHints(win)$/;" f @@ -37,8 +39,10 @@ deleteBookmark bookmarks.js /^function deleteBookmark(url)$/;" f del_url_mark commands.js /^function del_url_mark(mark)$/;" f echo commands.js /^function echo(msg)$/;" f echoerr commands.js /^function echoerr(msg)$/;" f +evaluateXPath commands.js /^function evaluateXPath(expression, doc, ordered)$/;" f execute commands.js /^function execute(string)$/;" f execute_command commands.js /^function execute_command(count, cmd, special, args, modifiers) \/\/ {{{$/;" f +exTabCompletion completion.js /^function exTabCompletion(str)$/;" f filter_url_array completion.js /^function filter_url_array(urls, filter)\/*{{{*\/$/;" f focusContent vimperator.js /^function focusContent(clear_command_line, clear_statusline)$/;" f focusNextFrame commands.js /^function focusNextFrame()$/;" f @@ -85,17 +89,16 @@ invalidateCoords hints.js /^ function invalidateCoords(doc)$/;" f isDirectory commands.js /^function isDirectory(url)$/;" f isFormElemFocused vimperator.js /^function isFormElemFocused()$/;" f keyToString vimperator.js /^function keyToString(event)$/;" f -load_history completion.js /^function load_history()$/;" f +load_history commandline.js /^function load_history()$/;" f LocalFile file.js /^function LocalFile(file, mode, perms, tmp)$/;" f logMessage vimperator.js /^function logMessage(msg)$/;" f logObject vimperator.js /^function logObject(object)$/;" f +lookupNamespaceURI commands.js /^ function lookupNamespaceURI(prefix) { $/;" f makeHelpString help.js /^ function makeHelpString(commands, color, beg, end, func)$/;" f makeSettingsHelpString help.js /^ function makeSettingsHelpString(command)$/;" f -multiliner commands.js /^function multiliner(line, prev_match, heredoc)$/;" f +multiliner commandline.js /^function multiliner(line, prev_match, heredoc)$/;" f nsBrowserStatusHandler vimperator.js /^function nsBrowserStatusHandler() \/*{{{*\/$/;" f -onCommandBarInput vimperator.js /^function onCommandBarInput(event)$/;" f -onCommandBarKeypress vimperator.js /^function onCommandBarKeypress(evt)\/*{{{*\/$/;" f -onCommandBarMouseDown vimperator.js /^function onCommandBarMouseDown(event)$/;" f +onCommandBar2Keypress vimperator.js /^function onCommandBar2Keypress(evt)\/*{{{*\/$/;" f onEscape vimperator.js /^function onEscape()$/;" f onResize hints.js /^ function onResize(event)$/;" f onVimperatorKeypress vimperator.js /^function onVimperatorKeypress(event)\/*{{{*\/$/;" f @@ -107,20 +110,25 @@ parseBookmarkString bookmarks.js /^function parseBookmarkString(str, res)$/;" f preview_window_fill completion.js /^function preview_window_fill(completions)\/*{{{*\/$/;" f preview_window_select completion.js /^function preview_window_select(event)\/*{{{*\/$/;" f preview_window_show completion.js /^function preview_window_show()\/*{{{*\/$/;" f +QM bookmarks.js /^function QM()$/;" f quit commands.js /^function quit(save_session)$/;" f reload commands.js /^function reload(all_tabs)$/;" f removeHints hints.js /^ function removeHints(win)$/;" f removeMode commands.js /^function removeMode(mode)$/;" f restart commands.js /^function restart()$/;" f -save_history completion.js /^function save_history()$/;" f +save_history commandline.js /^function save_history()$/;" f scrollBufferAbsolute commands.js /^function scrollBufferAbsolute(horizontal, vertical)$/;" f scrollBufferRelative commands.js /^function scrollBufferRelative(right, down)$/;" f -searcher find.js /^function searcher () {$/;" f +Search find.js /^function Search()$/;" f selectInput commands.js /^function selectInput()$/;" f set commands.js /^function set(args, special)$/;" f +setCommand commandline.js /^ function setCommand(cmd)$/;" f setCurrentMode commands.js /^function setCurrentMode(mode)$/;" f +setErrorStyle commandline.js /^ function setErrorStyle()$/;" f setHintStyle hints.js /^ function setHintStyle(hintElem, styleString)$/;" f setMouseOverElement hints.js /^ function setMouseOverElement(elem)$/;" f +setNormalStyle commandline.js /^ function setNormalStyle()$/;" f +setPrompt commandline.js /^ function setPrompt(prompt)$/;" f setSelection find.js /^function setSelection(range) {$/;" f setStatusbarColor vimperator.js /^function setStatusbarColor(color)$/;" f set_firefox_pref settings.js /^function set_firefox_pref(name, value)$/;" f @@ -145,6 +153,7 @@ toggle_images commands.js /^function toggle_images() {$/;" f tokenize_ex commands.js /^function tokenize_ex(string, tag)$/;" f unload vimperator.js /^function unload()$/;" f updateStatusbar vimperator.js /^function updateStatusbar(message)$/;" f +Vimperator vimperator.js /^function Vimperator()$/;" f yankCurrentLocation commands.js /^function yankCurrentLocation()$/;" f zoom_in commands.js /^function zoom_in(factor)$/;" f -zoom_to commands.js /^function zoom_to(value)$/;" f +zoom_to commands.js /^function zoom_to(value) {};$/;" f diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index e7a6bde3..dad747d4 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -26,19 +26,27 @@ 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 *****/ -var g_vimperator_version = "###VERSION### (created: ###DATE###)"; // all our objects -//var search = new Search(); // FIXME, put somewhere else, does not work here +var vimperator = null; -const MODE_NORMAL = 1; -const MODE_INSERT = 2; -const MODE_VISUAL = 4; -const MODE_ESCAPE_ONE_KEY = 8; +// major modes - FIXME: major cleanup needed +const MODE_NORMAL = 1; +const MODE_INSERT = 2; +const MODE_VISUAL = 4; +const MODE_ESCAPE_ONE_KEY = 8; const MODE_ESCAPE_ALL_KEYS = 16; -const HINT_MODE_QUICK = 32; -const HINT_MODE_ALWAYS = 64; -const HINT_MODE_EXTENDED = 128; +const MODE_HINTS = 2048; + const HINT_MODE_QUICK = 32; + const HINT_MODE_ALWAYS = 64; + const HINT_MODE_EXTENDED = 128; +const MODE_COMMAND_LINE = 4096; + const MODE_EX = 256; + const MODE_SEARCH = 512; + const MODE_SEARCH_BACKWARD = 1024; +// need later? +//const MODE_BROWSER +//const MODE_CARET var g_current_mode = MODE_NORMAL; @@ -48,8 +56,12 @@ var g_inputbuffer = ""; // here we store partial commands (e.g. 'g' if you want var g_count = -1; // the parsed integer of g_inputbuffer, or -1 if no count was given var g_bufshow = false; // keeps track if the preview window shows current buffers ('B') +// handlers for vimperator triggered events, such as typing in the command +// line. See triggerVimperatorEvent and registerVimperatorEventHandler +//var g_vimperator_event_handlers = new Array(); + // handles wildmode tab index -var wild_tab_index = 0; +//var wild_tab_index = 0; // handles multi-line commands var prev_match = new Array(5); @@ -93,8 +105,8 @@ nsBrowserStatusHandler.prototype = setOverLink : function(link, b) { - // updateStatusbar(link); - echo(link); + //updateStatusbar(link); + //vimperator.echo(link); if (link == "") showMode(); @@ -181,24 +193,20 @@ nsBrowserStatusHandler.prototype = window.addEventListener("load", init, false); - -// the global vimperator object, quit empty right now -// add functions with vimperator.prototype.func = ... -// var vimperator = null; -// var Vimperator = function() { -// this.keywordsLoaded = false; -// this.keywords = []; -// this.searchEngines = []; -// this.bookmarks = new Bookmarks(); -// }; - - //////////////////////////////////////////////////////////////////////// // init/uninit //////////////////////////////////////////////////// {{{1 //////////////////////////////////////////////////////////////////////// function init() { -// vimperator = new Vimperator; + // init the main object + vimperator = new Vimperator; + Vimperator.prototype.qm = new QM; + Vimperator.prototype.search = new Search; + + // XXX: move elsewhere + vimperator.registerCallback("submit", MODE_EX, function(command) { /*vimperator.*/execute(command); } ); + vimperator.registerCallback("complete", MODE_EX, function(str) { return exTabCompletion(str); } ); + preview_window = document.getElementById("vim-preview_window"); status_line = document.getElementById("vim-statusbar"); @@ -225,7 +233,7 @@ function init() setCurrentMode(MODE_NORMAL); /*** load our preferences ***/ - load_history(); + // load_history(); FIXME set_showtabline(get_pref("showtabline")); set_guioptions(get_pref("guioptions")); @@ -278,7 +286,7 @@ function init() function unload() { /*** save our preferences ***/ - save_history(); + // save_history(); FIXME // reset firefox pref if (get_firefox_pref('dom.popup_allowed_events', 'change click dblclick mouseup reset submit') @@ -461,6 +469,7 @@ function onVimperatorKeypress(event)/*{{{*/ var mapping = g_mappings[i][COMMANDS][j]; // alert("key: " + key +" - mapping: "+ mapping + " - g_input: " + g_inputbuffer); if(count_str + mapping == g_inputbuffer + key) + //if (count_str + mapping == vimperator.commandline.getCommand() + key) { g_count = parseInt(count_str, 10); if (isNaN(g_count)) @@ -478,6 +487,7 @@ function onVimperatorKeypress(event)/*{{{*/ return false; } else if ((count_str+mapping).indexOf(g_inputbuffer + key) == 0) + //else if ((count_str+mapping).indexOf(vimperator.commandline.getCommand() + key) == 0) { couldBecomeCompleteMapping = true; } @@ -500,238 +510,6 @@ function onVimperatorKeypress(event)/*{{{*/ return false; }/*}}}*/ -function onCommandBarKeypress(evt)/*{{{*/ -{ - var end = false; - try - { - /* parse our command string into tokens */ - var command = command_line.value; - - /* user pressed ENTER to carry out a command */ - if (evt.keyCode == KeyEvent.DOM_VK_RETURN) - { - // unfocus command line first - add_to_command_history(command); - - try { - [prev_match, heredoc, end] = multiliner(command, prev_match, heredoc); - } catch(e) { - logObject(e); - echoerr(e.name + ": " + e.message); - prev_match = new Array(5); - heredoc = ''; - return; - } - if (!end) - command_line.value = ""; - } - - else if ((evt.keyCode == KeyEvent.DOM_VK_ESCAPE) || - (keyToString(evt) == "")) - { - add_to_command_history(command); - focusContent(true, true); - } - - /* user pressed UP or DOWN arrow to cycle completion */ - else if (evt.keyCode == KeyEvent.DOM_VK_UP || evt.keyCode == KeyEvent.DOM_VK_DOWN) - { - /* save 'start' position for iterating through the history */ - if (comp_history_index == -1) - { - comp_history_index = comp_history.length; - comp_history_start = command_line.value; - } - - while (comp_history_index >= -1 && comp_history_index <= comp_history.length) - { - evt.keyCode == KeyEvent.DOM_VK_UP ? comp_history_index-- : comp_history_index++; - if (comp_history_index == comp_history.length) // user pressed DOWN when there is no newer history item - { - command_line.value = comp_history_start; - return; - } - - /* if we are at either end of the list, reset the counter, break the loop and beep */ - if((evt.keyCode == KeyEvent.DOM_VK_UP && comp_history_index <= -1) || - (evt.keyCode == KeyEvent.DOM_VK_DOWN && comp_history_index >= comp_history.length)) - { - evt.keyCode == KeyEvent.DOM_VK_UP ? comp_history_index++ : comp_history_index--; - break; - } - - if (comp_history[comp_history_index].indexOf(comp_history_start) == 0) - { - command_line.value = comp_history[comp_history_index]; - return; - } - - } - beep(); - } - - /* user pressed TAB to get completions of a command */ - else if (evt.keyCode == KeyEvent.DOM_VK_TAB) - { - var start_cmd = command; - var match = tokenize_ex(command); - var [count, cmd, special, args] = match; - var command = get_command(cmd); - //always reset our completion history so up/down keys will start with new values - comp_history_index = -1; - - // we need to build our completion list first - if (comp_tab_index == COMPLETION_UNINITIALIZED) - { - g_completions = []; - comp_tab_index = -1; - comp_tab_list_offset = 0; - comp_tab_startstring = start_cmd; - wild_tab_index = 0; - - /* if there is no space between the command name and the cursor - * then get completions of the command name - */ - if(command_line.value.substring(0, command_line.selectionStart).search(/[ \t]/) == -1) - { - get_command_completions(cmd); - } - else // dynamically get completions as specified in the g_commands array - { - if (command && command[COMPLETEFUNC]) - { - g_completions = command[COMPLETEFUNC].call(this, args); - // Sort the completion list - if (get_pref('wildoptions').match(/\bsort\b/)) - { - g_completions.sort(function(a, b) { - if (a[0] < b[0]) - return -1; - else if (a[0] > b[0]) - return 1; - else - return 0; - }); - } - } - } - } - - /* now we have the g_completions, so lets show them */ - if (comp_tab_index >= -1) - { - // we could also return when no completion is found - // but we fall through to the cleanup anyway - if (g_completions.length == 0) - beep(); - - var wim = get_pref('wildmode').split(/,/); - var has_list = false; - var longest = false; - var full = false; - var wildtype = wim[wild_tab_index++] || wim[wim.length - 1]; - if (wildtype == 'list' || wildtype == 'list:full' || wildtype == 'list:longest') - has_list = true; - if (wildtype == 'longest' || wildtype == 'list:longest') - longest = true; - if (wildtype == 'full' || wildtype == 'list:full') - full = true; - // show the list - if (has_list) - completion_show_list(); - - if (evt.shiftKey) - completion_select_previous_item(has_list, full, longest); - else - completion_select_next_item(has_list, full, longest); - //command_line.focus(); // workaraound only need for RICHlistbox - - - if (comp_tab_index == -1 && !longest) // wrapped around matches, reset command line - { - if (full && g_completions.length > 1) - { - command_line.value = comp_tab_startstring; - completion_list.selectedIndex = -1; - } - } - else - { - if (longest && g_completions.length > 1) - var compl = get_longest_substring(); - if (full) - var compl = g_completions[comp_tab_index][0]; - if (g_completions.length == 1) - var compl = g_completions[0][0]; - - if (compl) - { - /* if there is no space between the command name and the cursor - * the completions are for the command name - */ - if(command_line.value.substring(0, command_line.selectionStart).search(/[ \t]/) == -1) - { - command_line.value = ":" + (count ? count.toString() : "") + compl; - } - else // completions are for an argument - { - command_line.value = ":" + (count ? count.toString() : "") + - cmd + (special ? "!" : "") + " " + compl; - // Start a new completion in the next iteration. Useful for commands like :source - if (g_completions.length == 1 && !full) // RFC: perhaps the command can indicate whether the completion should be restarted - comp_tab_index = COMPLETION_UNINITIALIZED; - } - } - } - } - - // prevent tab from moving to the next field - evt.preventDefault(); - evt.stopPropagation(); - - } - else if (evt.keyCode == KeyEvent.DOM_VK_BACK_SPACE) - { - if (command_line.value == ":") - { - evt.preventDefault(); - focusContent(true, true); - } - comp_tab_index = COMPLETION_UNINITIALIZED; - comp_history_index = -1; - } - else - { - // some key hit, check if the cursor is before the : - if (command_line.selectionStart == 0) - command_line.selectionStart = 1; - - // and reset the tab completion - comp_tab_index = COMPLETION_UNINITIALIZED; - comp_history_index = -1; - - } - } catch(e) { alert(e); } -}/*}}}*/ - -function onCommandBarInput(event) -{ - if (command_line.value == "") - command_line.value = ":"; -} - -function onCommandBarMouseDown(event) -{ - if (command_line.value.indexOf(':') != 0) - { - command_line.blur(); - event.preventDefault(); - event.stopPropagation(); - return false; - } -} - //////////////////////////////////////////////////////////////////////// // focus and mode handling //////////////////////////////////////// {{{1 //////////////////////////////////////////////////////////////////////// @@ -742,19 +520,25 @@ function focusContent(clear_command_line, clear_statusline) { g_count = -1; // clear count - if(clear_command_line) - { - command_line.value = ""; - command_line.inputField.setAttribute("style","font-family: monospace;"); - } - - if(clear_statusline) - { - completion_list.hidden = true; - comp_tab_index = COMPLETION_UNINITIALIZED; - comp_history_index = -1; - updateStatusbar(); - } +// if(clear_command_line) +// { +// command_line.value = ""; +// command_line.inputField.setAttribute("style","font-family: monospace;"); +// +// var commandBarPrompt = document.getElementById('vim-commandbar-prompt'); +// commandBarPrompt.style.visibility = 'collapsed'; +// commandBarPrompt.value = ''; +// +// //vimperator.commandline.clear(); +// } +// +// if(clear_statusline) +// { +// completion_list.hidden = true; +// comp_tab_index = COMPLETION_UNINITIALIZED; +// comp_history_index = -1; +// updateStatusbar(); +// } var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] .getService(Components.interfaces.nsIWindowWatcher); @@ -766,31 +550,10 @@ function focusContent(clear_command_line, clear_statusline) } catch(e) { - echoerr(e); + vimperator.echoerr(e); } } -function openVimperatorBar(str) -{ - // make sure the input field is not red anymore if we had an echoerr() first - command_line.inputField.setAttribute("style","font-family: monospace;"); - - if(str == null) - str = ""; - - if (g_count > 1) - command_line.value = ":" + g_count.toString() + str; - else - command_line.value = ":" + str; - - try { - command_line.focus(); - } catch(e) { - echo(e); - } -} - - function onEscape() { if (!hasMode(MODE_ESCAPE_ONE_KEY)) @@ -1012,11 +775,19 @@ function isFormElemFocused() var gConsoleService = Components.classes['@mozilla.org/consoleservice;1'] .getService(Components.interfaces.nsIConsoleService); +/** + * logs any object to the javascript error console + * also prints all properties of thie object + */ function logMessage(msg) { gConsoleService.logStringMessage('vimperator: ' + msg); } +/** + * logs any object to the javascript error console + * also prints all properties of thie object + */ function logObject(object) { if (typeof object != 'object') @@ -1178,6 +949,45 @@ function getLinkNodes(doc) } return links; -} +}//}}} +//vimperator = new function() +function Vimperator() +{ + //////////////////////////////////////////////////////////////////////////////// + ////////////////////// PRIVATE SECTION ///////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + var callbacks = new Array(); + + //////////////////////////////////////////////////////////////////////////////// + ////////////////////// PUBLIC SECTION ////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + this.ver = "###VERSION### CVS (created: ###DATE###)"; + this.commandline = new CommandLine(); +// this.search = new Search(); + + /////////////// callbacks //////////////////////////// + // type='[submit|change|cancel|complete]' + this.registerCallback = function(type, mode, func) + { + // TODO: check if callback is already registered + callbacks.push([type, mode, func]); + } + this.triggerCallback = function(type, data) + { + for (i in callbacks) + { + [typ, mode, func] = callbacks[i]; + if (hasMode(mode) && type == typ) + return func.call(this, data); + } + return false; + } + +this.foo = function () {alert("foo");}; + + // just forward these echo commands + this.echo = this.commandline.echo; + this.echoerr = this.commandline.echoErr; +} // vim: set fdm=marker sw=4 ts=4 et: diff --git a/chrome/content/vimperator/vimperator.xul b/chrome/content/vimperator/vimperator.xul index 945a1670..fc285183 100644 --- a/chrome/content/vimperator/vimperator.xul +++ b/chrome/content/vimperator/vimperator.xul @@ -1,98 +1,112 @@ - - - - - - - - - - - -