diff --git a/NEWS b/NEWS index bdfe8ee0..559e136e 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ 2007-xx-xx: * version 0.6 * THIS VERSION ONLY WORKS WITH FIREFOX 3.0 + * :back/:forward can use tabcompletion * :undoall support, and tabcompletion for :undo * new :redraw and Ctrl-L commands for forced redrawing of the screen * added new 'laststatus' option and removed "s" value from 'guioptions' diff --git a/TODO b/TODO index b3cc6e88..b4d2b76e 100644 --- a/TODO +++ b/TODO @@ -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) 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 it would be nice to have :(undo|back|forward) w/ tab completion support 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 whereever possible: get rid of dialogs and ask console-like dialog questions or write error prompts directly on the webpage or with :echo() diff --git a/content/commands.js b/content/commands.js index 163e9ae7..38774040 100644 --- a/content/commands.js +++ b/content/commands.js @@ -240,13 +240,41 @@ function Commands() //{{{ if (special) vimperator.history.goToStart(); 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); + } }, { - usage: ["[count]ba[ck][!]"], + usage: ["[count]ba[ck][!] [url]"], short_help: "Go back in the browser history", help: "Count is supported, :3back goes back 3 pages in the browser history.
" + - "The special version :back! goes to the beginning of the browser history." + "The special version :back! 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]"], @@ -569,13 +597,41 @@ function Commands() //{{{ if (special) vimperator.history.goToEnd(); 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); + } }, { - usage: ["[count]fo[rward][!]"], + usage: ["[count]fo[rward][!] [url]"], short_help: "Go forward in the browser history", help: "Count is supported, :3forward goes forward 3 pages in the browser history.
" + - "The special version :forward! goes to the end of the browser history." + "The special version :forward! 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]"], @@ -1540,7 +1596,10 @@ function Commands() //{{{ for (var i = 0; i < undoItems.length; i++) { // 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; } diff --git a/content/completion.js b/content/completion.js index 36b64530..c35950dd 100644 --- a/content/completion.js +++ b/content/completion.js @@ -540,6 +540,33 @@ vimperator.completion = (function() // {{{ 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) //{{{ { var [count, cmd, special, args] = vimperator.commands.parseCommand(str);