From 8266a2517a3e16cb33ef3a30bc439bb25c271a52 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Mon, 17 Sep 2007 12:43:17 +0000 Subject: [PATCH] add an initial implementation of :sidebar --- NEWS | 1 + TODO | 1 - chrome/content/vimperator/commands.js | 26 +++++++++++++++++++++++++ chrome/content/vimperator/completion.js | 11 +++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index f8dffbe7..a73c7f3e 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ 2007-xx-xx: * version 0.6 * THIS VERSION ONLY WORKS WITH FIREFOX 3.0 + * added a new :sidebar command * added 'more' and standard more-prompt key mappings to control behaviour of the message list pager * added 'hlsearchstyle' option to allow for user CSS styling of the diff --git a/TODO b/TODO index 9bf5a903..71bc9078 100644 --- a/TODO +++ b/TODO @@ -19,7 +19,6 @@ BUGS: FEATURES: 9 :command for new commands 9 :sidebar {addons/bookmarks/history/downloads/...} command with tab completion - (and automatically getting possible sidebar elements from View->sidebar 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 diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js index 7c5da97c..2754437f 100644 --- a/chrome/content/vimperator/commands.js +++ b/chrome/content/vimperator/commands.js @@ -1076,6 +1076,32 @@ function Commands() //{{{ completer: function(filter) { return vimperator.completion.get_options_completions(filter); } } )); + addDefaultCommand(new Command(["sideb[ar]"], + function(args) + { + if (!args) + { + vimperator.echoerr("E471: Argument required"); + return; + } + + var menu = document.getElementById("viewSidebarMenu") + + for (var i = 0; i < menu.childNodes.length; i++) + { + if (menu.childNodes[i].label == args) + { + eval(menu.childNodes[i].getAttribute('oncommand')) + break; + } + } + }, + { + short_help: "Open the sidebar", + help: "TODO", + completer: function(filter) { return vimperator.completion.get_sidebar_completions(filter); } + } + )); addDefaultCommand(new Command(["so[urce]"], function(args) { diff --git a/chrome/content/vimperator/completion.js b/chrome/content/vimperator/completion.js index b290f42a..3a6603f8 100644 --- a/chrome/content/vimperator/completion.js +++ b/chrome/content/vimperator/completion.js @@ -461,6 +461,17 @@ vimperator.completion = (function() // {{{ return build_longest_common_substring(items, filter); }, //}}} + get_sidebar_completions: function(filter) //{{{ + { + var menu = document.getElementById("viewSidebarMenu") + var nodes = []; + + for (var i = 0; i < menu.childNodes.length; i++) + nodes.push([[menu.childNodes[i].label], ""]); + + return build_longest_starting_substring(nodes, filter); + }, //}}} + exTabCompletion: function(str) //{{{ { var [count, cmd, special, args] = vimperator.commands.parseCommand(str);