diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2011-03-26 08:09:34 +0100 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2011-03-26 08:10:11 +0100 |
commit | fd4526c2bb9caeb5cba6c3b7860287b35d4ee0bd (patch) | |
tree | 8eaac2a01890cb1c2b7999ab075808e4663710c9 | |
parent | 14783f08366242076dfe232bc0c22ba9608a67c3 (diff) | |
download | dotfiles-fd4526c2bb9caeb5cba6c3b7860287b35d4ee0bd.tar.xz |
vimperator: upgrade to v3 and Firefox 4
Removed buftabs, tinyurl, and deprecated color schemes. Imported
statusline-toolbar plugin to avoid using the Add-on bar. Minor
adjustments to vimperatorrc to port it to vimperator v3.
-rw-r--r-- | vimperator/colors/clearlooks.vimp | 63 | ||||
-rw-r--r-- | vimperator/plugin/buftabs.js | 238 | ||||
-rw-r--r-- | vimperator/plugin/statusline-toolbar.js | 176 | ||||
-rw-r--r-- | vimperator/plugin/tinyurl.js | 35 | ||||
-rw-r--r-- | vimperatorrc | 47 |
5 files changed, 186 insertions, 373 deletions
diff --git a/vimperator/colors/clearlooks.vimp b/vimperator/colors/clearlooks.vimp deleted file mode 100644 index 2dd769b..0000000 --- a/vimperator/colors/clearlooks.vimp +++ /dev/null @@ -1,63 +0,0 @@ -" ==Clearlooks_Color_Scheme== -" name: Clearlooks -" ==Clearlooks_Colorscheme_Settings== -hi Bell border: 0 none; background-color: black; -hi Boolean color: red; -hi CmdLine font-family: monospace; padding: 1px; -hi CmdOutput white-space: pre; -hi CompDesc color: gray; width: 50%; -hi CompGroup -hi CompGroup:not(:first-of-type) margin-top: .5em; -hi CompIcon width: 16px; min-width: 16px; display: inline-block; margin-right: .5ex; -hi CompIcon>img max-width: 16px; max-height: 16px; vertical-align: middle; -hi CompItem -hi CompItem>* padding: 0 .5ex; -hi CompItem[selected] background: #86ABD9; -hi CompLess text-align: center; height: 0; line-height: .5ex; padding-top: 1ex; -hi CompLess::after content: "\2303" /* Unicode up arrowhead */ -hi CompMore text-align: center; height: .5ex; line-height: .5ex; margin-bottom: -.5ex; -hi CompMore::after content: "\2304" /* Unicode down arrowhead */ -hi CompMsg font-style: italic; margin-left: 16px; -hi CompResult width: 45%; overfloaw: hidden; -hi CompTitle color: #86ABD9; background: white; font-weight: bold; -hi CompTitle>* padding: 0 .5ex; -hi ErrorMsg color: white; background: red; font-weight: bold; -hi Filter font-weight: bold; -hi FrameIndicator background-color: red; opacity: 0.5; z-index: 999; position: fixed; top: 0; bottom: 0; left: 0; right: 0; -hi Function color: navy; -hi Gradient height: 1px; margin-bottom: -1px; margin-top: -1px; -hi GradientLeft background-color: #86ABD9; -hi GradientRight background-color: white; -hi Hint font-family: monospace; font-size: 10px; font-weight: bold; color: white; background-color: red; border-color: ButtonShadow; border-width: 0px; border-style: solid; padding 0px 1px 0px 1px; -hi Hint::after content: attr(number); -hi HintActive background: #88FF00; color: black; -hi HintElem background-color: #86ABD9; color: black; -hi HintImage opacity: .5; -hi Indicator color: blue; -hi InfoMsg color: black; background: white; -hi LineNr color: orange; background: white; -hi Message white-space: normal; min-width: 100%; padding-left: 2em; text-indent: -2em; display: block; -hi ModeMsg color: black; background: white; -hi MoreMsg color: green; background: white; -hi NonText color: blue; min-height: 16px; padding-left: 2px; -hi Normal color: black; background: white; -hi Null color: blue; -hi Number color: blue; -hi Object color: maroon; -hi Preview color: gray; -hi Question color: green; background: white; font-weight: bold; -hi Search font-size: inherit; padding: 0; color: black; background-color: #86ABD9; padding: 0; -hi StatusLine color: black; background: #E6E6E6; -hi StatusLineBroken color: black; background: #FF6060; /* light-red */ -hi StatusLineSecure color: black; background: #B0FF00; /* light-green */ -hi String color: green; -hi TabClose -hi TabIcon -hi TabIconNumber font-weight: normal; color: black; text-align: center; text-shadow: black -1px 0 1px, black 0 1px 1px, black 1px 0 1px, black 0 -1px 1px; -hi TabNumber font-weight: bold; margin: 0; padding-right: .3ex; -hi TabText -hi Tag color: blue; -hi Title color: #86ABD9; background: white; font-weight: bold; -hi URL text-decoration: none; color: green; background: inherit; -hi URL:hover text-decoration: underline; cursor: pointer; -hi WarningMsg color: red; background: white; diff --git a/vimperator/plugin/buftabs.js b/vimperator/plugin/buftabs.js deleted file mode 100644 index ad1d47e..0000000 --- a/vimperator/plugin/buftabs.js +++ /dev/null @@ -1,238 +0,0 @@ -// PLUGIN_INFO {{{ -let PLUGIN_INFO = -<VimperatorPlugin> - <name>Buftabs</name> - <description>Add buffer tabs to the statusline to save space.</description> - <version>1.1</version> - <author mail="lucas@tuple-typed.org" homepage="http://tuple-typed.org/">Lucas de Vries (GGLucas)</author> - <license>WTFPL version 2 (http://sam.zoy.org/wtfpl/)</license> - <minVersion>2.2</minVersion> - <maxVersion>2.2</maxVersion> - <detail><![CDATA[ - - == Usage == - When the script is loaded it hijacks the statusline to display a list of tabs, - you can use the "buftabs" option to toggle it on or off. - - == Styling == - Use the BufTab and BufTabSelected highlight groups to style the buftabs. - Make sure you\'ve called the "loadplugins" command before using the highlight - groups in your vimperatorrc. - - == Length == - You can set the max length of a title before it is cut off with the - buftabs_maxlength option. It is set to 25 by default. - - ]]></detail> -</VimperatorPlugin>; -// }}} - -buftabs = { - // Update the tabs - updateUrl: function (url) - { - // Get buftabbar - var btabs = document.getElementById("liberator-statusline-buftabs"); - var urlWidget = document.getElementById("liberator-statusline-field-url"); - var browsers = window.getBrowser().browsers; - var position=0, selpos; - - // Make sure we have an appropriate amount of labels - while (btabs.childNodes.length > browsers.length) - { - btabs.removeChild(btabs.lastChild); - } - - while (btabs.childNodes.length < browsers.length) - { - var label = document.createElement("label"); - btabs.appendChild(label); - - label.onclick = function (ev) - { - if (ev.button == 0) - tabs.select(this.tabpos); - else if (ev.button == 1) - tabs.remove(tabs.getTab(this.tabpos), 1, false, 0); - } - } - - // Create the new tabs - for (let i=0; i < browsers.length; i++) - { - // Create label - var browser = browsers[i]; - var label = btabs.childNodes[i]; - - // Hook on load - if (browser.webProgress.isLoadingDocument) - { - browser._buftabs_label = label; - browser.contentDocument.addEventListener("load", function () - { - buftabs.fillLabel(this._buftabs_label, this); - }, false); - } - - // Fill label - label.tabpos = i; - buftabs.fillLabel(label, browser); - - if (tabs.index() == label.tabpos) - { - selpos = [position, label.clientWidth+position]; - } - - position += label.clientWidth; - } - - // Scroll - if (selpos[0] < btabs.scrollLeft || selpos[1] > btabs.scrollLeft+btabs.clientWidth) - btabs.scrollLeft = selpos[0]; - - // Show the entire line if possible - if (btabs.scrollWidth == btabs.clientWidth) - btabs.scrollLeft = 0; - - // Empty url label - urlWidget.value = ""; - }, - - // Fill a label with browser content - fillLabel: function(label, browser) - { - var maxlength = options.get("buftabs_maxlength").get(); - var tabvalue; - - // Get title - if (browser.webProgress.isLoadingDocument) - { - tabvalue = "Loading..."; - } else { - tabvalue = browser.contentTitle || "Untitled"; - } - - // Check length - if (tabvalue.length > maxlength) - tabvalue = tabvalue.substr(0, maxlength-3)+"..."; - - // Bookmark icon - if (bookmarks.isBookmarked(browser.contentDocument.location.href)) - tabvalue += "\u2764"; - - // Brackets and index - tabvalue = "["+(label.tabpos+1)+"-"+tabvalue+"]"; - - label.setAttribute("value", tabvalue); - - // Set the correct highlight group - if (tabs.index() == label.tabpos) - label.setAttributeNS(NS.uri, "highlight", "BufTabSelected"); - else - label.setAttributeNS(NS.uri, "highlight", "BufTab"); - - - }, - - // Create the horizontal box for adding the tabs to - createBar: function() - { - var statusline = document.getElementById("liberator-statusline"); - var buftabs = document.getElementById("liberator-statusline-buftabs"); - var urlWidget = document.getElementById("liberator-statusline-field-url"); - - // Only create if it doesn't exist yet - if (!buftabs) - { - buftabs = document.createElement("hbox"); - buftabs.setAttribute("id", "liberator-statusline-buftabs"); - buftabs.setAttribute("flex", "1"); - buftabs.style.overflow = "hidden" - - statusline.insertBefore(buftabs, urlWidget); - } - }, - - destroyBar: function() - { - var statusline = document.getElementById("liberator-statusline"); - var buftabs = document.getElementById("liberator-statusline-buftabs"); - - if (buftabs) - statusline.removeChild(buftabs); - } -} - -/// Attach to events in order to update the tabline -var tabContainer = window.getBrowser().mTabContainer; -buftabs._statusline_updateUrl = statusline.updateUrl; - -tabContainer.addEventListener("TabMove", function (event) { - if (options.get("buftabs").get()) - statusline.updateUrl(); -}, false); -tabContainer.addEventListener("TabOpen", function (event) { - if (options.get("buftabs").get()) - statusline.updateUrl(); -}, false); -tabContainer.addEventListener("TabClose", function (event) { - if (options.get("buftabs").get()) - setTimeout(statusline.updateUrl, 0); -}, false); -tabContainer.addEventListener("TabSelect", function (event) { - if (options.get("buftabs").get()) - statusline.updateUrl(); -}, false); - -window.getBrowser().addEventListener("load", function (event) { - if (options.get("buftabs").get()) - statusline.updateUrl(); -}, false); - -/// Initialise highlight groups -highlight.loadCSS(String(<![CDATA[ - BufTab - BufTabSelected font-weight: bold; -]]>)); - -/// Options -options.add(["buftabs"], - "Control whether to use buftabs in the statusline", - "boolean", true, - { - setter: function (value) - { - if (value) - { - buftabs.createBar(); - buftabs.updateUrl(null); - - statusline.updateUrl = buftabs.updateUrl; - } else { - buftabs.destroyBar(); - statusline.updateUrl = buftabs._statusline_updateUrl; - statusline.update(); - } - - return value; - }, - - completer: function (context) - [ - [false, "Don't show buftabs, show the url"], - [true, "Show buftabs"] - ], - - validator: Option.validateCompleter - }); - -options.add(["buftabs_maxlength"], - "Max length of an entry in the buftabs list", - "number", "25", - { - setter: function (value) - { - buftabs.updateUrl(); - return value; - } - }); diff --git a/vimperator/plugin/statusline-toolbar.js b/vimperator/plugin/statusline-toolbar.js new file mode 100644 index 0000000..89648d0 --- /dev/null +++ b/vimperator/plugin/statusline-toolbar.js @@ -0,0 +1,176 @@ +var INFO = +<plugin name="Statusline Toolbar" version="0.1" + href="http://github.com/vimpr/vimperator-plugins/raw/master/statusline-toolbar.js" + summary="Append Toolbar to Statusline" + xmlns="http://vimperator.org/namespaces/liberator"> + <author email="teramako@gmail.com">teramako</author> + <license>MPL 1.1/GPL 2.0/LGPL 2.1</license> + <project name="Vimperator" minVersion="3.0"/> + <description> + <ul> + <li>Add toolbar to status-line</li> + <li>Move the status-bar to the toolbar.</li> + <li>Make the toolbarbuttons in the toolbar palette configurable + <ul> + <li>Can customize by command (ex. <ex>:set statustoolbars=feed-button</ex>)</li> + <li>Also, can drop the toolbarbutton from Customize Toolbar window</li> + </ul> + </li> + </ul> + </description> + <item> + <tags>'statustoolbars'</tags> + <spec>'statustoolbars'</spec> + <type>stringlist</type> + <default></default> + <description> + <p> + Add/Remove toolbarbutton of the toolbar palette. + </p> + </description> + </item> +</plugin> + +var updater = { + "noscript-tbb": [ + function add(id) { noscriptOverlay.initPopups(); }, + ], + "star-button": [ + null, + function rm(elm) { + $("urlbar-icons").insertBefore(elm, $("go-button")); + } + ], +}; +function $(id) document.getElementById(id); +function createElement (name, attrs) { + var elm = document.createElement("toolbar"); + for (let [name, value] in Iterator(attrs)) { + elm.setAttribute(name, value); + } + return elm; +} + +var id = "liberator-customize-toolbar"; +if (!$(id)) { + init(); +} + +function init () { + styles.addSheet(true, "customize-toolbar", "chrome://*", <css><![CDATA[ + #liberator-customize-toolbar { + background: #3F3F3F; + border: none !important; + min-width: 5px !important; + max-height: 17px; + } + #liberator-customize-toolbar > :-moz-any(image, toolbarbutton) { + max-height: 16px; + } + #liberator-customize-toolbar .statusbar-resizerpanel { display: none; } + ]]></css>.toString(), false); + + var t = createToolbar(); + t.appendChild($("status-bar")); + $("liberator-bottombar").appendChild(t); + updateSets(t, t.currentSet.split(","), []); + + config.toolbars.statuslinetoolbar = [[id], "Statusline Toolbar"]; + + options.add(["statustoolbars"], "Statusline Toolbar Sets", + "stringlist", "", { + toolbar: t, + getter: function () { + return this.toolbar.currentSet.split(",").filter(function(id) id != "status-bar").join(",") || "none"; + }, + setter: function (val) { + if (val == "none") + val = ""; + + let newSets = [], + removeSets = this.toolbar.currentSet.split(",").filter(function(id) id != "status-bar"), + index; + for (let [, id] in Iterator(this.parseValues(val))) { + let i = removeSets.indexOf(id); + if (i != -1) { + newSets.push(id); + removeSets.splice(i, 1); + continue; + } + let elm = document.getElementById(id); + if (elm) { + if (elm.parentNode !== t) { + t.appendChild(elm); + if (updater[id] && typeof updater[id][0] == "function") + updater[id][0](elm); + } + newSets.push(id); + } else if (gNavToolbox.palette.querySelector("#" + id)) { + newSets.push(id); + } + } + t.currentSet = newSets.join(","); + t.setAttribute("currentset", newSets.join(",")); + updateSets(this.toolbar, newSets, removeSets); + document.persist(this.toolbar.id, "currentset"); + return val; + }, + completer: function (context) { + context.completions = [["none","-"]].concat(Array.map(gNavToolbox.palette.children, function(elm) { + return [ elm.id, elm.getAttribute("label") || "-" ]; + })); + }, + validator: function (val) { + return true; + }, + }); +} + +function updateSets (toolbar, newSets, removeSets) { + for (let [, id] in Iterator(newSets)) { + if (updater[id] && typeof updater[id][0] == "function") { + updater[id][0](id); + } + } + for (let [, id] in Iterator(removeSets)) { + let elm = document.getElementById(id); + if (!elm) + continue; + + toolbar.removeChild(elm); + if (updater[id] && typeof updater[id][1] == "function") { + updater[id][1](elm); + } + } +} + +function createToolbar () { + var toolbar = createElement("toolbar", { + id: id, + toolbarname: "Liberator Statusline Toolbar", + toolboxid: "navigator-toolbox", + mode: "icons", + iconsize: "small", + defaulticonsize: "small", + lockiconsize: "small", + customizable: "true", + context: "toolbar-context-menu", + }); + toolbar.setAttributeNS(NS.uri, "highlight", "ModeMsg"); + + var RDF = services.get("rdf"); + var localStore = RDF.GetDataSource("rdf:local-store"); + var currentSet = localStore.GetTarget( + RDF.GetResource(document.baseURI + "#" + toolbar.id), + RDF.GetResource("currentset"), + true); + if (currentSet) { + currentSet = currentSet.QueryInterface(Ci.nsIRDFLiteral).Value; + toolbar.setAttribute("currentset", currentSet); + toolbar.appendChild(document.getElementById("star-button")); + } + return toolbar; +} + + +// vim: sw=2 ts=2 et: diff --git a/vimperator/plugin/tinyurl.js b/vimperator/plugin/tinyurl.js deleted file mode 100644 index 0b86621..0000000 --- a/vimperator/plugin/tinyurl.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This script adds a tinyurl command to Vimperator - * - * You can map this script adding this to your .vimperatorrc - * :map <silent> your_key :exe ":tinyurl "+getBrowser().contentWindow.location.href<CR> - * @author: fox (fox91 at anche dot no) - * @version: 0.1 - * -*/ - -commands.addUserCommand(['tinyurl'], - "TinyUrl command", - function(args) { - if (args.length == 1) { - let req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] - .createInstance(Components.interfaces.nsIXMLHttpRequest); - req.open('GET', "http://tinyurl.com/api-create.php?url=" + escape(args[0]), true); - req.onreadystatechange = function (aEvt) { - if (req.readyState == 4) { - if(req.status == 200) { - let clip = Components.classes["@mozilla.org/widget/clipboardhelper;1"]. - getService(Components.interfaces.nsIClipboardHelper); - clip.copyString(req.responseText); - liberator.echo("TinyUrl: " + req.responseText); - } - else - liberator.echoerr("Error contacting tinyurl.com!\n"); - } - }; - req.send(null); - } - else { - liberator.echoerr("Please specify one url"); - } - }); diff --git a/vimperatorrc b/vimperatorrc index 76f7770..18601b0 100644 --- a/vimperatorrc +++ b/vimperatorrc @@ -20,8 +20,11 @@ colorscheme zenburn " Window title set titlestring=Firefox -" No toolbar and scrollbars by default -set go-=brT +" No toolbars or menus by default +set toolbars=noaddons,nobookmarks,nomenu,nonavigation,tabs + +" Elements of the status line +set status=input,location,tabcount,position " Editor, C-i invokes it in text fields set editor=emacsclient @@ -38,18 +41,15 @@ set hlsearch " Override ignorecase if pattern has uppercase chars set smartcase -" Show the tab bar only if more then one tab is open -set showtabline=0 - " Focus content after a page has loaded set focuscontent -" Show destination links in 1=status line, 2=command line -set showstatuslinks=2 +" Show destination links in 1=status line, 2=command line, 0=none (FF4 baloon) +set showstatuslinks=0 " Show completions and use AwesomeBar (+search plugins) +set autocomplete set complete=sl -set wildoptions=auto " Ex commands output in a new tab by default (prefs, addons...) set newtab=all @@ -193,8 +193,8 @@ map <C-x><C-f> <C-d><C-o> " {{{ Personal key bindings " " M-Up/Dn toggles the toolbar and scrollbars -map <A-Down> :set go+=brT<CR> -map <A-Up> :set go-=brT<CR> +map <A-Down> :set toolbars=navigation<CR> +map <A-Up> :set toolbars=nonavigation<CR> " Sidebar selection with s, close with S map s :sidebar<SPACE> @@ -251,34 +251,7 @@ map <A-Right> :tabmove! +1<CR> " {{{ Plugin bindings " -" Buftabs -map <C-c>b :set invbuftabs<CR> - " Noscript map <C-c>s :noscript toggletemp<CR> map <C-c>S :noscript popup<CR> - -" TinyURL -map <C-c>t :exe ":tinyurl "+getBrowser().contentWindow.location.href<CR> -" }}} " }}} - - -" {{{ Javascript functions -" -" Show the Feed and Bookmark buttons on the statusbar -javascript <<EOF -(function(){ - var statusPanel = document.createElement("statusbarpanel"); - statusPanel.setAttribute("id", "buttons-panel-clone"); - statusPanel.appendChild(document.getElementById("feed-button")); - statusPanel.appendChild(document.getElementById("star-button")); - statusPanel.firstChild.setAttribute("style", "padding: 0; max-height: 16px;"); - document.getElementById("status-bar") - .insertBefore(statusPanel, document.getElementById("security-button")); -})(); -EOF -" }}} - - -echo "[vimperator initialized]" |