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

back/:forward has tab completion, slightly broken for wildmode=longest for now,

as we need to refactor g_substrings later
This commit is contained in:
Doug Kearns
2007-10-09 13:34:59 +00:00
parent 5dfa3f6e19
commit c3a62852d1
4 changed files with 92 additions and 6 deletions

1
NEWS
View File

@@ -3,6 +3,7 @@
* version 0.5.2 * version 0.5.2
* added "s" and "a" mappings to extended hints mode for saving hint * added "s" and "a" mappings to extended hints mode for saving hint
targets targets
* :back/:forward can use tabcompletion
* :undoall support, and tabcompletion for :undo <tab> * :undoall support, and tabcompletion for :undo <tab>
* new :redraw and Ctrl-L commands for forced redrawing of the screen * new :redraw and Ctrl-L commands for forced redrawing of the screen
* added new 'laststatus' option and removed "s" value from 'guioptions' * added new 'laststatus' option and removed "s" value from 'guioptions'

1
TODO
View File

@@ -22,7 +22,6 @@ FEATURES:
9 Use our own find-as-you-type mechanism (like conkeror does) 9 Use our own find-as-you-type mechanism (like conkeror does)
9 make hints smarter, not only with characters from from hintchars, but use "NE" or "NP" for 'new posts' e.g. (might be too slow) 9 make hints smarter, not only with characters from from hintchars, but use "NE" or "NP" for 'new posts' e.g. (might be too slow)
8 middleclick in content == p, and if command line is open, paste there the clipboard buffer 8 middleclick in content == p, and if command line is open, paste there the clipboard buffer
8 it would be nice to have :(undo|back|forward) <url> w/ tab completion support
7 [ctrl-o/i] to Go back to a Previous Position (done partly, however currenty does not use a per tab jumplist) 7 [ctrl-o/i] to Go back to a Previous Position (done partly, however currenty does not use a per tab jumplist)
7 whereever possible: get rid of dialogs and ask console-like dialog questions or write error prompts directly on the webpage or with :echo() 7 whereever possible: get rid of dialogs and ask console-like dialog questions or write error prompts directly on the webpage or with :echo()
7 3d should delete 3 tabs 7 3d should delete 3 tabs

View File

@@ -240,13 +240,41 @@ function Commands() //{{{
if (special) if (special)
vimperator.history.goToStart(); vimperator.history.goToStart();
else else
{
if (args)
{
var sh = getWebNavigation().sessionHistory;
for (var i = sh.index - 1; i >= 0; i--)
{
if (sh.getEntryAtIndex(i, false).URI.spec == args)
{
getWebNavigation().gotoIndex(i);
return;
}
}
}
vimperator.history.stepTo(count > 0 ? -1 * count : -1); vimperator.history.stepTo(count > 0 ? -1 * count : -1);
}
}, },
{ {
usage: ["[count]ba[ck][!]"], usage: ["[count]ba[ck][!] [url]"],
short_help: "Go back in the browser history", short_help: "Go back in the browser history",
help: "Count is supported, <code class=\"command\">:3back</code> goes back 3 pages in the browser history.<br/>" + help: "Count is supported, <code class=\"command\">:3back</code> goes back 3 pages in the browser history.<br/>" +
"The special version <code class=\"command\">:back!</code> goes to the beginning of the browser history." "The special version <code class=\"command\">:back!</code> goes to the beginning of the browser history.",
completer: function(filter)
{
var sh = getWebNavigation().sessionHistory;
var completions = [];
for (var i = sh.index - 1; i >= 0; i--)
{
var entry = sh.getEntryAtIndex(i, false);
var url = entry.URI.spec;
var title = entry.title;
if (vimperator.completion.match(filter, [url, title], false))
completions.push([url, title]);
}
return completions;
}
} }
)); ));
addDefaultCommand(new Command(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"], addDefaultCommand(new Command(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
@@ -570,13 +598,41 @@ function Commands() //{{{
if (special) if (special)
vimperator.history.goToEnd(); vimperator.history.goToEnd();
else else
{
if (args)
{
var sh = getWebNavigation().sessionHistory;
for (var i = sh.index + 1; i < sh.count; i++)
{
if (sh.getEntryAtIndex(i, false).URI.spec == args)
{
getWebNavigation().gotoIndex(i);
return;
}
}
}
vimperator.history.stepTo(count > 0 ? count : 1); vimperator.history.stepTo(count > 0 ? count : 1);
}
}, },
{ {
usage: ["[count]fo[rward][!]"], usage: ["[count]fo[rward][!] [url]"],
short_help: "Go forward in the browser history", short_help: "Go forward in the browser history",
help: "Count is supported, <code class=\"command\">:3forward</code> goes forward 3 pages in the browser history.<br/>" + help: "Count is supported, <code class=\"command\">:3forward</code> goes forward 3 pages in the browser history.<br/>" +
"The special version <code class=\"command\">:forward!</code> goes to the end of the browser history." "The special version <code class=\"command\">:forward!</code> goes to the end of the browser history.",
completer: function(filter)
{
var sh = getWebNavigation().sessionHistory;
var completions = [];
for (var i = sh.index + 1; i < sh.count; i++)
{
var entry = sh.getEntryAtIndex(i, false);
var url = entry.URI.spec;
var title = entry.title;
if (vimperator.completion.match(filter, [url, title], false))
completions.push([url, title]);
}
return completions;
}
} }
)); ));
addDefaultCommand(new Command(["ha[rdcopy]"], addDefaultCommand(new Command(["ha[rdcopy]"],
@@ -1538,7 +1594,10 @@ function Commands() //{{{
for (var i = 0; i < undoItems.length; i++) for (var i = 0; i < undoItems.length; i++)
{ {
// undoItems[i].image is also available if need for favicons // undoItems[i].image is also available if need for favicons
completions.push([undoItems[i].state.entries[0].url, undoItems[i].title]); var url = undoItems[i].state.entries[0].url;
var title = undoItems[i].title;
if (vimperator.completion.match(filter, [url, title], false))
completions.push([url, title]);
} }
return completions; return completions;
} }

View File

@@ -540,6 +540,33 @@ vimperator.completion = (function() // {{{
return build_longest_starting_substring(completions, filter); return build_longest_starting_substring(completions, filter);
}, // }}} }, // }}}
// helper function which checks if the given arguments pass "filter"
// items must be an array of strings
// if case_sensitive == true, be sure to pass filter already in lowercased version
match: function(filter, items, case_sensitive)
{
if (typeof(filter) != "string" || !items)
return false;
if (case_sensitive)
{
for (var i = 0; i < items.length; i++)
{
if (items[i].toLowerCase().indexOf(filter) > -1)
return true;
}
}
else
{
for (var i = 0; i < items.length; i++)
{
if (items[i].indexOf(filter) > -1)
return true;
}
}
return false;
},
exTabCompletion: function(str) //{{{ exTabCompletion: function(str) //{{{
{ {
var [count, cmd, special, args] = vimperator.commands.parseCommand(str); var [count, cmd, special, args] = vimperator.commands.parseCommand(str);