1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 18:27:57 +01:00

Many small bugfixes

changed wildsort -> wildoptions=sort
added completion for filenames
This commit is contained in:
Martin Stubenschrott
2007-04-29 15:04:00 +00:00
parent abeafde55f
commit d4844c2429
7 changed files with 95 additions and 37 deletions

View File

@@ -3,7 +3,8 @@ date:
* version 0.4 * version 0.4
* extension GUID was changed to 'vimperator@mozdev.net' -> YOU WILL HAVE * extension GUID was changed to 'vimperator@mozdev.net' -> YOU WILL HAVE
TO UNINSTALL ANY OLD VIMPERATOR INSTALLATION BEFORE INSTALLING THIS VERSION 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 * changed regexp search to normal text search for completion -> massive speedup, but limited functionality
* support for :open ./ , :open .. and :open ... (patch from Lee Hinman) * support for :open ./ , :open .. and :open ... (patch from Lee Hinman)
'gu' and <BackSpace> goes up a directory component, gU and <C-BackSpace> to the root directory 'gu' and <BackSpace> goes up a directory component, gU and <C-BackSpace> to the root directory
@@ -12,7 +13,7 @@ date:
* :back! goes to beginning of history now * :back! goes to beginning of history now
* diabled firefox 3.0 support for now, as there are just too many small * diabled firefox 3.0 support for now, as there are just too many small
bugs 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) (patch from Viktor Kojouharov)
* :source support, and auto-sourcing ~/.vimperatorrc on startup * :source support, and auto-sourcing ~/.vimperatorrc on startup
* :javascript <<EOF support to execute multiline javascript code * :javascript <<EOF support to execute multiline javascript code

1
TODO
View File

@@ -31,6 +31,7 @@ FEATURES:
6 :map commands to keys 6 :map commands to keys
6 autocommands (BrowserStart, BrowserQuit, TabClose, TabOpen, TabChanged, PageLoaded, any more?) 6 autocommands (BrowserStart, BrowserQuit, TabClose, TabOpen, TabChanged, PageLoaded, any more?)
6 vim like mappings for caret mode and textboxes (i to start caret mode?) 6 vim like mappings for caret mode and textboxes (i to start caret mode?)
http://nigel.mcnie.name/gnawt/ has a somewhat working implementation
6 pipe selected text/link/website to an external command 6 pipe selected text/link/website to an external command
6 it would be nice to have :(undo|back|forward) <url> w/ tab completion support 6 it would be nice to have :(undo|back|forward) <url> w/ tab completion support
6 macros (qq) 6 macros (qq)

View File

@@ -151,4 +151,32 @@ function parseBookmarkString(str, res)
return true; 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: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -191,7 +191,7 @@ var g_commands = [/*{{{*/
["history", "hs"], ["history", "hs"],
["history {filter}"], ["history {filter}"],
"Show recently visited URLs", "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 <code>:pclose</code> or open entries with double click in the current tab or middle click in a new tab.", "Close this window with <code>:pclose</code> or open entries with double click in the current tab or middle click in a new tab.",
hsshow, hsshow,
function(filter) { return get_history_completions(filter); } function(filter) { return get_history_completions(filter); }
@@ -591,7 +591,7 @@ var g_mappings = [/*{{{*/
["t"], ["t"],
["t"], ["t"],
"Open one or more URLs in a new tab", "Open one or more URLs in a new tab",
"Like <code class=mapping>o</code> but open URLs in a new tab."+ "Like <code class=mapping>o</code> but open URLs in a new tab.<br/>"+
"See <code class=command>:tabopen</code> for more details", "See <code class=command>:tabopen</code> for more details",
function(count) { openVimperatorBar('tabopen '); } function(count) { openVimperatorBar('tabopen '); }
], ],
@@ -773,15 +773,15 @@ var g_mappings = [/*{{{*/
function(count) { stepInHistory(count > 0 ? count : 1); } function(count) { stepInHistory(count > 0 ? count : 1); }
], ],
[ [
["gu", "<BackSpace>"], ["gu", "<BS>"],
["{count}gu", "{count}<BackSpace>"], ["{count}gu", "{count}<BS>"],
"Go to parent directory", "Go to parent directory",
"Count is supported, <code class=mapping>2gu</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> would open <code>http://www.example.com/dir1/</code>", "Count is supported, <code class=mapping>2gu</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> would open <code>http://www.example.com/dir1/</code>",
goUp goUp
], ],
[ [
["gU", "<C-BackSpace>"], ["gU", "<C-BS>"],
["gU", "<C-BackSpace>"], ["gU", "<C-BS>"],
"Go to the root of the website", "Go to the root of the website",
"<code class=mapping>gU</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> opens <code>http://www.example.com/</code>.<br/>"+ "<code class=mapping>gU</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> opens <code>http://www.example.com/</code>.<br/>"+
"When browsing a local directory, it goes to the root document.", "When browsing a local directory, it goes to the root document.",
@@ -1954,8 +1954,8 @@ function set(args, special)
} }
else else
{ {
if (oper == '+' && !cur_val.match(val)) if (oper == '+' && !cur_val.match(val) && cur_val.length > 0)
val = cur_val + ',' + val; val = cur_val + ',' + val;
if (oper == '-') if (oper == '-')
{ {
val = cur_val.replace(new RegExp(',?' + val), ''); val = cur_val.replace(new RegExp(',?' + val), '');

View File

@@ -287,15 +287,16 @@ function build_longest_starting_substring(list, filter)/*{{{*/
/* /*
* filter a list of urls * 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 * 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_completions = [];
g_substrings = []; g_substrings = [];
var cpt = get_pref("complete"); var cpt = complete || get_pref("complete");
// join all completion arrays together // join all completion arrays together
for (var i = 0; i < cpt.length; i++) 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)); g_completions = g_completions.concat(get_bookmark_completions(filter));
else if (cpt[i] == 'h') else if (cpt[i] == 'h')
g_completions = g_completions.concat(get_history_completions(filter)); 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; return g_completions;
@@ -321,7 +324,10 @@ function filter_url_array(urls, filter)/*{{{*/
if (!filter) return urls.map(function($_) { if (!filter) return urls.map(function($_) {
return [$_[0], $_[1]] return [$_[0], $_[1]]
}); });
var filter_length = filter.length; var filter_length = filter.length;
filter = filter.toLowerCase();
/* /*
* Longest Common Subsequence * Longest Common Subsequence
* This shouldn't use build_longest_common_substring * 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++) 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) if (title.indexOf(filter) != -1)
additional_completions.push([urls[i][0], urls[i][1] ]); additional_completions.push([ urls[i][0], urls[i][1] ]);
continue; continue;
} }
if (g_substrings.length == 0) // Build the substrings if (g_substrings.length == 0) // Build the substrings
{ {
var last_index = urls[i][0].lastIndexOf(filter); var last_index = url.lastIndexOf(filter);
var url_length = urls[i][0].length; var url_length = url.length;
for (var k = urls[i][0].indexOf(filter); k != -1 && k <= last_index; k = urls[i][0].indexOf(filter, k + 1)) 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++) 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 else
{ {
g_substrings = g_substrings.filter(function($_) { g_substrings = g_substrings.filter(function($_) {
return urls[i][0].indexOf($_) >= 0; return url.indexOf($_) >= 0;
}); });
} }
filtered.push([urls[i][0], urls[i][1]]); filtered.push([urls[i][0], urls[i][1]]);
@@ -380,7 +389,7 @@ function get_history_completions(filter)/*{{{*/
history.hidden = false; history.hidden = false;
var globalHistory = Components.classes["@mozilla.org/browser/global-history;2"].getService(Components.interfaces.nsIRDFDataSource); var globalHistory = Components.classes["@mozilla.org/browser/global-history;2"].getService(Components.interfaces.nsIRDFDataSource);
history.database.AddDataSource(globalHistory); history.database.AddDataSource(globalHistory);
history_completions = []; g_history = [];
} }
if (!history.ref) if (!history.ref)
@@ -414,10 +423,8 @@ function get_history_completions(filter)/*{{{*/
g_history.push([url, title]); g_history.push([url, title]);
} }
// if(url.toLowerCase().indexOf(filter.toLowerCase()) > -1)
history_loaded = true; history_loaded = true;
} }
return filter_url_array(g_history, filter); return filter_url_array(g_history, filter);
}/*}}}*/ }/*}}}*/
@@ -431,14 +438,30 @@ function get_bookmark_completions(filter)/*{{{*/
bookmarks = []; // here getAllChildren will store the bookmarks bookmarks = []; // here getAllChildren will store the bookmarks
g_bookmarks = []; // also clear our bookmark cache g_bookmarks = []; // also clear our bookmark cache
BookmarksUtils.getAllChildren(root, bookmarks); BookmarksUtils.getAllChildren(root, bookmarks);
// alert(bookmarks[0].length);
for(var i = 0; i < bookmarks.length; i++) for(var i = 0; i < bookmarks.length; i++)
{ {
if (bookmarks[i][0] && bookmarks[i][1]) if (bookmarks[i][0] && bookmarks[i][1])
{
g_bookmarks.push([bookmarks[i][1].Value, bookmarks[i][0].Value ]); 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; bookmarks_loaded = true;
} }
return filter_url_array(g_bookmarks, filter); return filter_url_array(g_bookmarks, filter);
}/*}}}*/ }/*}}}*/

View File

@@ -64,15 +64,16 @@ var g_settings = [/*{{{*/
"Items which are completed at the :[tab]open prompt", "Items which are completed at the :[tab]open prompt",
"Available items:<br>"+ "Available items:<br>"+
"<ul><li><b>s</b>: Search machines</li><li>"+ "<ul><li><b>s</b>: Search machines</li><li>"+
" <b>b</b>: Bookmarks</li><li>"+ "<b>f</b>: Local files</li><li>"+
" <b>h</b>: History</li></ul>"+ "<b>b</b>: Bookmarks</li><li>"+
"<b>h</b>: History</li></ul>"+
"The order is important, so <code class=command>:set complete=bs</code> would list bookmarks first, and then any available quick searches.<br/>"+ "The order is important, so <code class=command>:set complete=bs</code> would list bookmarks first, and then any available quick searches.<br/>"+
"Set the <code class=setting>'wildsort'</code> setting if you want all entries sorted.", "Add 'sort' to the <code class=setting>'wildoptions'</code> setting if you want all entries sorted.",
"charlist", "charlist",
null, null,
function(value) { set_pref("complete", value); }, function(value) { set_pref("complete", value); },
function() { return get_pref("complete"); }, function() { return get_pref("complete"); },
"sbh", "sfbh",
null null
], ],
[ [
@@ -262,15 +263,19 @@ var g_settings = [/*{{{*/
null null
], ],
[ [
["wildsort", "wis", "nowildsort", "nowis"], ["wildoptions", "wop"],
["wildsort", "wis"], ["wildoptions", "wop"],
"Define whether command line completion is sorted", "Change how command line completion is done",
"If you don't want a sorted completion list, set this to false.", "A list of words that change how command line completion is done.<br/>"+
"boolean", "Currently only one word is allowed:<br/>"+
"<table><pre>"+
"<tr><td><b>sort</b></td><td>Always sorts completion list, overriding the <code class=setting>'complete'</code> option.</td></tr>" +
"</pre></table>",
"stringlist",
null, null,
function(value) { set_pref("wildsort", value); }, function(value) { set_pref("wildoptions", value); },
function() { return get_pref("wildsort"); }, function() { return get_pref("wildoptions"); },
false, "",
null null
] ]
]/*}}}*/ ]/*}}}*/

View File

@@ -578,7 +578,7 @@ function onCommandBarKeypress(evt)/*{{{*/
{ {
g_completions = command[COMPLETEFUNC].call(this, args); g_completions = command[COMPLETEFUNC].call(this, args);
// Sort the completion list // Sort the completion list
if (get_pref('wildsort')) if (get_pref('wildoptions').match(/\bsort\b/))
{ {
g_completions.sort(function(a, b) { g_completions.sort(function(a, b) {
if (a[0] < b[0]) if (a[0] < b[0])