diff --git a/ChangeLog b/ChangeLog index 8b24cd37..8a31cb6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,8 @@ date: * version 0.4 * extension GUID was changed to 'vimperator@mozdev.net' -> YOU WILL HAVE TO UNINSTALL ANY OLD VIMPERATOR INSTALLATION BEFORE INSTALLING THIS VERSION - * support for 'wildmode' completion setting + * support for 'wildmode' completion setting with support for matching the + longest common substring * changed regexp search to normal text search for completion -> massive speedup, but limited functionality * support for :open ./ , :open .. and :open ... (patch from Lee Hinman) 'gu' and goes up a directory component, gU and to the root directory @@ -12,7 +13,7 @@ date: * :back! goes to beginning of history now * diabled firefox 3.0 support for now, as there are just too many small bugs - * :help section supported, :help set will show help for the :set command + * :help section supported, :help :set will show help for the :set command (patch from Viktor Kojouharov) * :source support, and auto-sourcing ~/.vimperatorrc on startup * :javascript < w/ tab completion support 6 macros (qq) diff --git a/chrome/content/vimperator/bookmarks.js b/chrome/content/vimperator/bookmarks.js index 915a38b7..eda26d14 100644 --- a/chrome/content/vimperator/bookmarks.js +++ b/chrome/content/vimperator/bookmarks.js @@ -151,4 +151,32 @@ function parseBookmarkString(str, res) return true; } +function getSearchEngines() +{ + const nsSS = Components.classes["@mozilla.org/browser/search-service;1"]. + getService(Components.interfaces.nsIBrowserSearchService); + var engines = nsSS.getVisibleEngines({ }); + for(var i in engines) + { + alert(engines[i].alias); + if (!engines[i].alias || !engines[i].alias.match(/^\w+$/)) + { + alias = engines[i].name.replace(/^\W*(\w+).*/, "$1").toLowerCase(); + engines[i].alias = alias; + } + +// alert(engines[i].alias); +// alert(engines[i].name); +// alert(engines[i].description); + } +// var def = nsSS.getDefaultEngine(); +// if(def) +// { +// alert('DEFAULT'): +// alert(def.alias); +// } +// alert(def.name); +// alert(def.description); +} + // vim: set fdm=marker sw=4 ts=4 et: diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js index 64013f19..0c06ea26 100644 --- a/chrome/content/vimperator/commands.js +++ b/chrome/content/vimperator/commands.js @@ -191,7 +191,7 @@ var g_commands = [/*{{{*/ ["history", "hs"], ["history {filter}"], "Show recently visited URLs", - "Open the preview window at the bottom of the screen for all history items which match the filter string either in the title or URL.", + "Open the preview window at the bottom of the screen for all history items which match the filter string either in the title or URL."+ "Close this window with :pclose or open entries with double click in the current tab or middle click in a new tab.", hsshow, function(filter) { return get_history_completions(filter); } @@ -591,7 +591,7 @@ var g_mappings = [/*{{{*/ ["t"], ["t"], "Open one or more URLs in a new tab", - "Like o but open URLs in a new tab."+ + "Like o but open URLs in a new tab.
"+ "See :tabopen for more details", function(count) { openVimperatorBar('tabopen '); } ], @@ -773,15 +773,15 @@ var g_mappings = [/*{{{*/ function(count) { stepInHistory(count > 0 ? count : 1); } ], [ - ["gu", ""], - ["{count}gu", "{count}"], + ["gu", ""], + ["{count}gu", "{count}"], "Go to parent directory", "Count is supported, 2gu on http://www.example.com/dir1/dir2/file.htm would open http://www.example.com/dir1/", goUp ], [ - ["gU", ""], - ["gU", ""], + ["gU", ""], + ["gU", ""], "Go to the root of the website", "gU on http://www.example.com/dir1/dir2/file.htm opens http://www.example.com/.
"+ "When browsing a local directory, it goes to the root document.", @@ -1954,8 +1954,8 @@ function set(args, special) } else { - if (oper == '+' && !cur_val.match(val)) - val = cur_val + ',' + val; + if (oper == '+' && !cur_val.match(val) && cur_val.length > 0) + val = cur_val + ',' + val; if (oper == '-') { val = cur_val.replace(new RegExp(',?' + val), ''); diff --git a/chrome/content/vimperator/completion.js b/chrome/content/vimperator/completion.js index 464a9255..60359cef 100644 --- a/chrome/content/vimperator/completion.js +++ b/chrome/content/vimperator/completion.js @@ -287,15 +287,16 @@ function build_longest_starting_substring(list, filter)/*{{{*/ /* * filter a list of urls * - * may consist of searchengines, boorkmarks and history, + * may consist of searchengines, filenames, bookmarks and history, * depending on the 'complete' option + * if the 'complete' argument is passed like "h", it temproarily overrides the complete option */ -function get_url_completions(filter)/*{{{*/ +function get_url_completions(filter, complete)/*{{{*/ { g_completions = []; g_substrings = []; - var cpt = get_pref("complete"); + var cpt = complete || get_pref("complete"); // join all completion arrays together for (var i = 0; i < cpt.length; i++) { @@ -305,6 +306,8 @@ function get_url_completions(filter)/*{{{*/ g_completions = g_completions.concat(get_bookmark_completions(filter)); else if (cpt[i] == 'h') g_completions = g_completions.concat(get_history_completions(filter)); + else if (cpt[i] == 'f') + g_completions = g_completions.concat(get_file_completions(filter)); } return g_completions; @@ -321,7 +324,10 @@ function filter_url_array(urls, filter)/*{{{*/ if (!filter) return urls.map(function($_) { return [$_[0], $_[1]] }); + var filter_length = filter.length; + filter = filter.toLowerCase(); + /* * Longest Common Subsequence * This shouldn't use build_longest_common_substring @@ -329,26 +335,29 @@ function filter_url_array(urls, filter)/*{{{*/ */ for (var i = 0; i < urls.length; i++) { - if (urls[i][0].indexOf(filter) == -1) + var url = urls[i][0].toLowerCase(); + var title = urls[i][1].toLowerCase(); + + if (url.indexOf(filter) == -1) { - if (urls[i][1].indexOf(filter) != -1) - additional_completions.push([urls[i][0], urls[i][1] ]); + if (title.indexOf(filter) != -1) + additional_completions.push([ urls[i][0], urls[i][1] ]); continue; } if (g_substrings.length == 0) // Build the substrings { - var last_index = urls[i][0].lastIndexOf(filter); - var url_length = urls[i][0].length; - for (var k = urls[i][0].indexOf(filter); k != -1 && k <= last_index; k = urls[i][0].indexOf(filter, k + 1)) + var last_index = url.lastIndexOf(filter); + var url_length = url.length; + for (var k = url.indexOf(filter); k != -1 && k <= last_index; k = url.indexOf(filter, k + 1)) { for (var l = k + filter_length; l <= url_length; l++) - g_substrings.push(urls[i][0].substring(k, l)); + g_substrings.push(url.substring(k, l)); } } else { g_substrings = g_substrings.filter(function($_) { - return urls[i][0].indexOf($_) >= 0; + return url.indexOf($_) >= 0; }); } filtered.push([urls[i][0], urls[i][1]]); @@ -380,7 +389,7 @@ function get_history_completions(filter)/*{{{*/ history.hidden = false; var globalHistory = Components.classes["@mozilla.org/browser/global-history;2"].getService(Components.interfaces.nsIRDFDataSource); history.database.AddDataSource(globalHistory); - history_completions = []; + g_history = []; } if (!history.ref) @@ -414,10 +423,8 @@ function get_history_completions(filter)/*{{{*/ g_history.push([url, title]); } - // if(url.toLowerCase().indexOf(filter.toLowerCase()) > -1) history_loaded = true; } - return filter_url_array(g_history, filter); }/*}}}*/ @@ -431,14 +438,30 @@ function get_bookmark_completions(filter)/*{{{*/ bookmarks = []; // here getAllChildren will store the bookmarks g_bookmarks = []; // also clear our bookmark cache BookmarksUtils.getAllChildren(root, bookmarks); +// alert(bookmarks[0].length); for(var i = 0; i < bookmarks.length; i++) { if (bookmarks[i][0] && bookmarks[i][1]) + { g_bookmarks.push([bookmarks[i][1].Value, bookmarks[i][0].Value ]); + } + // for(var j=0; j < bookmarks[i].length; j++) + // { +// if(bookmarks[i][2]) +// alert("2: " + bookmarks[i][2].Value); +// if(bookmarks[i][3]) +// alert("3: " + bookmarks[i][3].Value); +// if(bookmarks[i][4]) +// alert("4: " + bookmarks[i][4].Value); +// if(bookmarks[i][5]) +// alert("5: " + bookmarks[i][5].Value); + //alert("0: " + bookmarks[i][0].Value + " - 1: " + bookmarks[i][1].Value + "- 2:" + bookmarks[i][2].Value);// + "- 3:"+ bookmarks[i][3].Value + "- 4:" + bookmarks[i][4].Value);// + "- 5:" + bookmarks[i][5].Value); + //} } bookmarks_loaded = true; } + return filter_url_array(g_bookmarks, filter); }/*}}}*/ diff --git a/chrome/content/vimperator/settings.js b/chrome/content/vimperator/settings.js index b0ad65d9..ce9d6dce 100644 --- a/chrome/content/vimperator/settings.js +++ b/chrome/content/vimperator/settings.js @@ -64,15 +64,16 @@ var g_settings = [/*{{{*/ "Items which are completed at the :[tab]open prompt", "Available items:
"+ "
  • s: Search machines
  • "+ - " b: Bookmarks
  • "+ - " h: History
"+ + "f: Local files
  • "+ + "b: Bookmarks
  • "+ + "h: History
  • "+ "The order is important, so :set complete=bs would list bookmarks first, and then any available quick searches.
    "+ - "Set the 'wildsort' setting if you want all entries sorted.", + "Add 'sort' to the 'wildoptions' setting if you want all entries sorted.", "charlist", null, function(value) { set_pref("complete", value); }, function() { return get_pref("complete"); }, - "sbh", + "sfbh", null ], [ @@ -262,15 +263,19 @@ var g_settings = [/*{{{*/ null ], [ - ["wildsort", "wis", "nowildsort", "nowis"], - ["wildsort", "wis"], - "Define whether command line completion is sorted", - "If you don't want a sorted completion list, set this to false.", - "boolean", + ["wildoptions", "wop"], + ["wildoptions", "wop"], + "Change how command line completion is done", + "A list of words that change how command line completion is done.
    "+ + "Currently only one word is allowed:
    "+ + "
    "+
    +        "
    " + + "
    sortAlways sorts completion list, overriding the 'complete' option.
    ", + "stringlist", null, - function(value) { set_pref("wildsort", value); }, - function() { return get_pref("wildsort"); }, - false, + function(value) { set_pref("wildoptions", value); }, + function() { return get_pref("wildoptions"); }, + "", null ] ]/*}}}*/ diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index e51df2cc..1dd75125 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -578,7 +578,7 @@ function onCommandBarKeypress(evt)/*{{{*/ { g_completions = command[COMPLETEFUNC].call(this, args); // Sort the completion list - if (get_pref('wildsort')) + if (get_pref('wildoptions').match(/\bsort\b/)) { g_completions.sort(function(a, b) { if (a[0] < b[0])