From b8d32c8e3d109657d9ee8cf3ce33d1daf79997e2 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 4 Dec 2008 15:58:19 -0500 Subject: [PATCH] Add go=r to toggle the scrollbar --- common/content/completion.js | 2 + common/content/liberator.js | 79 +++++++++++++++++++++--------------- common/content/style.js | 17 ++++++++ common/content/ui.js | 8 ++-- vimperator/NEWS | 1 + vimperator/content/config.js | 9 +++- 6 files changed, 78 insertions(+), 38 deletions(-) diff --git a/common/content/completion.js b/common/content/completion.js index 33387b3f..32e0a446 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -122,6 +122,8 @@ CompletionContext.prototype = { { let self = this; let minStart = Math.min.apply(Math, [context.offset for ([k, context] in Iterator(this.contexts)) if (context.items.length && context.hasItems)]); + if (minStart == Infinity) + minStart = 0; let items = this.contextList.map(function (context) { if (!context.hasItems) return []; diff --git a/common/content/liberator.js b/common/content/liberator.js index 43220730..372a4e4b 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -92,48 +92,63 @@ const liberator = (function () //{{{ "Allow reading of an RC file in the current directory", "boolean", false); - const tabopts = [ - ["n", "Tab number", null, highlight.selector("TabNumber")], - ["N", "Tab number over icon", null, highlight.selector("TabIconNumber")] - ]; + + const groups = { + config: { + opts: config.guioptions, + setter: function (opts) + { + for (let [opt, [,ids]] in Iterator(this.opts)) + { + ids.map(function (id) document.getElementById(id)) + .forEach(function (elem) + { + if (elem) + elem.collapsed = (opts.indexOf(opt) == -1) + }); + } + } + }, + scroll: { + opts: { r: ["Right Scrollbar"] }, + setter: function (opts) + { + if (opts.indexOf("r") == -1) + styles.addSheet("scrollbar", "*", "html|html > xul|scrollbar { visibility: collapse !important; }", true, true); + else + styles.removeSheet("scrollbar", null, null, null, true); + } + }, + tab: { + opts: { + n: ["Tab number", highlight.selector("TabNumber")], + N: ["Tab number over icon", highlight.selector("TabIconNumber")] + }, + setter: function (opts) + { + let classes = [v[1] for ([k, v] in Iterator(this.opts)) if (opts.indexOf(k) >= 0)]; + let css = classes.length ? classes.join(",") + "{ display: none; }" : ""; + styles.addSheet("taboptions", "chrome://*", css, true, true); + statusline.updateTabCount(); + } + } + }; + options.add(["guioptions", "go"], "Show or hide certain GUI elements like the menu or toolbar", "charlist", config.defaults.guioptions || "", { setter: function (value) { - for (let [opt, ids] in Iterator(config.guioptions)) - { - ids.forEach(function (id) - { - try - { - document.getElementById(id).collapsed = (value.indexOf(opt) < 0); - } - catch (e) {} - }); - } - let classes = tabopts.filter(function (o) value.indexOf(o[0]) == -1) - .map(function (a) a[3]) - if (!classes.length) - { - styles.removeSheet("taboptions", null, null, null, true); - } - else - { - storage.styles.addSheet("taboptions", "chrome://*", classes.join(",") + "{ display: none; }", true, true); - statusline.updateTabCount(); - } - + for (let [,group] in Iterator(groups)) + group.setter(value); return value; }, completer: function (filter) { - return [ - ["m", "Menubar"], - ["T", "Toolbar"], - ["b", "Bookmark bar"] - ].concat(!liberator.has("tabs") ? [] : tabopts); + let opts = [v.opts for ([k, v] in Iterator(groups))]; + opts = opts.map(function (opt) [[k, v[0]] for ([k, v] in Iterator(opt))]); + return util.Array.flatten(opts); }, validator: Option.validateCompleter }); diff --git a/common/content/style.js b/common/content/style.js index a3d7b12e..60418638 100644 --- a/common/content/style.js +++ b/common/content/style.js @@ -238,6 +238,7 @@ function Styles(name, store, serial) try { this.registerSheet(cssUri(wrapCSS(sheet)), !force); + this.registerAgentSheet(cssUri(wrapCSS(sheet))) } catch (e) { @@ -299,6 +300,7 @@ function Styles(name, store, serial) if (!sheet.ref.length) { this.unregisterSheet(cssUri(wrapCSS(sheet))); + this.unregisterAgentSheet(cssUri(wrapCSS(sheet))); if (sheets.indexOf(sheet) > -1) sheets.splice(sheets.indexOf(sheet), 1); } @@ -331,6 +333,21 @@ function Styles(name, store, serial) sss.unregisterSheet(uri, sss.USER_SHEET); } + // FIXME + this.registerAgentSheet = function (uri) + { + this.unregisterAgentSheet(uri); + uri = ios.newURI(uri, null, null); + sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET); + } + + this.unregisterAgentSheet = function (uri) + { + uri = ios.newURI(uri, null, null); + if (sss.sheetRegistered(uri, sss.AGENT_SHEET)) + sss.unregisterSheet(uri, sss.AGENT_SHEET); + } + function wrapCSS(sheet) { let filter = sheet.sites; diff --git a/common/content/ui.js b/common/content/ui.js index 502da223..ff01d439 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -232,9 +232,9 @@ function CommandLine() //{{{ this.wildtypes = this.wildmode.values; this.wildIndex = -1; - this.prefix = this.context.value.substr(0, this.start); - this.value = this.context.value.substr(this.start, this.context.caret); - this.suffix = this.context.value.substr(this.context.caret); + this.prefix = this.context.value.substring(0, this.start); + this.value = this.context.value.substring(this.start, this.caret); + this.suffix = this.context.value.substring(this.caret); if (show) { @@ -1372,7 +1372,7 @@ function CommandLine() //{{{ if (completions) { completions.context.reset(); - completions.reset(); + //completions.reset(); } historyIndex = UNINITIALIZED; removeSuffix = ""; diff --git a/vimperator/NEWS b/vimperator/NEWS index 24a37938..22cdf524 100644 --- a/vimperator/NEWS +++ b/vimperator/NEWS @@ -18,6 +18,7 @@ * IMPORTANT: renamed Startup and Quit autocmd events to VimperatorEnter and VimperatorLeave respectively + * add 'guioptions'=r to toggle the scrollbar. * remove spaces and newlines when open urls starting with http:// or similar before :o http://linux .com would search for http://linux and for .com, now it just opens linux.com. Also handy when pasting broken urls with p or P. diff --git a/vimperator/content/config.js b/vimperator/content/config.js index d52b5a74..83289fc0 100644 --- a/vimperator/content/config.js +++ b/vimperator/content/config.js @@ -33,8 +33,13 @@ const config = { //{{{ /*** optional options, there are checked for existance and a fallback provided ***/ features: ["bookmarks", "hints", "history", "marks", "quickmarks", "session", "tabs", "windows"], - defaults: { guioptions: "" }, - guioptions: { m: ["toolbar-menubar"], T: ["nav-bar"], b: ["PersonalToolbar"] }, + defaults: { guioptions: "r" }, + + guioptions: { + m: ["MenuBar", ["toolbar-menubar"]], + T: ["Toolbar", ["nav-bar"]], + b: ["Bookmark bar", ["PersonalToolbar"]] + }, get visualbellWindow() getBrowser().mPanelContainer, styleableChrome: "chrome://browser/content/browser.xul",