1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 12:17: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:
Martin Stubenschrott
2007-10-09 01:39:31 +00:00
parent dc2e3baef3
commit d41f3e47ed
4 changed files with 92 additions and 6 deletions

1
NEWS
View File

@@ -2,6 +2,7 @@
2007-xx-xx: 2007-xx-xx:
* version 0.6 * version 0.6
* THIS VERSION ONLY WORKS WITH FIREFOX 3.0 * THIS VERSION ONLY WORKS WITH FIREFOX 3.0
* :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

@@ -21,7 +21,6 @@ FEATURES:
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 add an interface for navigating document relationships 8 add an interface for navigating document relationships
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 use ctrl-n/p in insert mode for word completion 7 use ctrl-n/p in insert mode for word completion
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()

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]"],
@@ -569,13 +597,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]"],
@@ -1540,7 +1596,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);