diff --git a/NEWS b/NEWS index 74f6380f..f3621909 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ special versions for the old behavior * IMPORTANT: renamed Startup and Quit autocmd events to VimperatorEnter and VimperatorLeave respectively + * add guioptions=nN to number tabs * add :loadplugins command * add . mapping * add N% normal mode command diff --git a/content/bindings.xml b/content/bindings.xml index f1e1b9f2..967b7dc6 100644 --- a/content/bindings.xml +++ b/content/bindings.xml @@ -1,6 +1,14 @@ + +%tabBrowserDTD; + +%globalDTD; +]> + @@ -10,6 +18,23 @@ + + + + + + + + + + + + + + + diff --git a/content/buffer.js b/content/buffer.js index 2614d25b..b75b1357 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -36,8 +36,8 @@ liberator.Buffer = function () //{{{ const highlightClasses = ["Boolean", "ErrorMsg", "Filter", "Function", "InfoMsg", "Keyword", "LineNr", "ModeMsg", "MoreMsg", "Normal", "Null", "Number", "Object", "Question", - "StatusLine", "StatusLineBroken", "StatusLineSecure", "String", "Tag", - "Title", "URL", "WarningMsg", + "StatusLine", "StatusLineBroken", "StatusLineSecure", "String", "TabClose", "TabIcon", + "TabIconNumber", "TabNumber", "TabText", "Tag", "Title", "URL", "WarningMsg", ["Hint", ".liberator-hint", "*"], ["Search", ".__liberator-search", "*"], ["Bell", "#liberator-visualbell"], diff --git a/content/liberator.js b/content/liberator.js index fc38fd2e..5fd00cdf 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -59,6 +59,10 @@ const liberator = (function () //{{{ // Only general options are added here, which are valid for all vimperator like extensions function addOptions() { + const tabopts = [ + ["n", "Tab number", null, ".hl-TabNumber"], + ["N", "Tab number over icon", null, ".hl-TabIconNumber"], + ]; liberator.options.add(["guioptions", "go"], "Show or hide certain GUI elements like the menu or toolbar", "charlist", liberator.config.defaults.guioptions || "", @@ -69,14 +73,23 @@ const liberator = (function () //{{{ for (let option in guioptions) { - guioptions[option].forEach(function (elem) { - try - { - document.getElementById(elem).collapsed = (value.indexOf(option.toString()) < 0); - } - catch (e) {} - }); + if (option in guioptions) + { + guioptions[option].forEach(function (elem) { + try + { + document.getElementById(elem).collapsed = (value.indexOf(option.toString()) < 0); + } + catch (e) {} + }); + } } + let classes = tabopts.filter(function (o) value.indexOf(o[0]) == -1) + .map(function (a) a[3]) + if (!classes.length) + liberator.storage.styles.removeSheet("taboptions", null, null, null, true); + else + liberator.storage.styles.addSheet("taboptions", "chrome://*", classes.join(",") + "{ display: none; }", true, true); return value; }, @@ -86,17 +99,9 @@ const liberator = (function () //{{{ ["m", "Menubar"], ["T", "Toolbar"], ["b", "Bookmark bar"] - ]; + ].concat(!liberator.has("tabs") ? [] : tabopts); }, - validator: function (value) - { - var regex = "[^"; - - for (let option in liberator.config.guioptions) - regex += option.toString(); - - return !(new RegExp(regex + "]").test(value)); - } + validator: function (value) Array.every(value, function (c) c in liberator.config.guioptions || tabopts.some(function (a) a[0] == c)), }); liberator.options.add(["helpfile", "hf"], diff --git a/content/ui.js b/content/ui.js index 3148a957..b6c6cbaa 100644 --- a/content/ui.js +++ b/content/ui.js @@ -603,13 +603,6 @@ liberator.CommandLine = function () //{{{ // liberator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst echo: function (str, highlightGroup, flags) { - // if we are modifing the GUI while we are not in the main thread - // Firefox will hang up - var threadManager = Components.classes["@mozilla.org/thread-manager;1"] - .getService(Components.interfaces.nsIThreadManager); - if (!threadManager.isMainThread) - return false; - var focused = document.commandDispatcher.focusedElement; if (focused && focused == commandWidget.inputField || focused == multilineInputWidget.inputField) return false; @@ -619,6 +612,13 @@ liberator.CommandLine = function () //{{{ if (flags & this.APPEND_TO_MESSAGES) messageHistory.add({ str: str, highlight: highlightGroup }); + // if we are modifing the GUI while we are not in the main thread + // Firefox will hang up + var threadManager = Components.classes["@mozilla.org/thread-manager;1"] + .getService(Components.interfaces.nsIThreadManager); + if (!threadManager.isMainThread) + return false; + var where = setLine; if (flags & this.FORCE_MULTILINE) where = setMultiline; @@ -1593,6 +1593,10 @@ liberator.StatusLine = function () //{{{ return; } + let tabs = getBrowser().mTabs; + for (let i = 0; i < tabs.length; i++) + tabs[i].setAttribute("ordinal", i + 1); + if (!currentIndex || typeof currentIndex != "number") currentIndex = liberator.tabs.index() + 1; if (!totalTabs || typeof currentIndex != "number") diff --git a/content/vimperator.js b/content/vimperator.js index dbb7a120..a399a2be 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -33,7 +33,7 @@ liberator.config = { //{{{ /*** optional options, there are checked for existance and a fallback provided ***/ features: ["bookmarks", "hints", "history", "marks", "quickmarks", "session", "tabs", "windows"], - defaults: { guioptions: "" }, + defaults: { guioptions: "N" }, guioptions: { m: ["toolbar-menubar"], T: ["nav-bar"], b: ["PersonalToolbar"] }, get visualbellWindow() getBrowser().mPanelContainer, diff --git a/locale/en-US/options.txt b/locale/en-US/options.txt index b710a2eb..92c6a301 100644 --- a/locale/en-US/options.txt +++ b/locale/en-US/options.txt @@ -318,6 +318,8 @@ Show or hide certain GUI elements like the menu or toolbar. Supported characters *m* Menubar *T* Toolbar *b* Bookmark bar +*n* Tab number +*N* Tab number over image ---------------- You can also hide the tab bar with [c]:set showtabline=0[c]. diff --git a/skin/liberator.css b/skin/liberator.css index 93d680f2..b8b3d6a4 100644 --- a/skin/liberator.css +++ b/skin/liberator.css @@ -120,6 +120,22 @@ the terms of any one of the MPL, the GPL or the LGPL. @-moz-document url-prefix(chrome://) { +.tabbrowser-tab { + -moz-binding: url(chrome://liberator/content/bindings.xml#tab); +} + +.hl-TabIconNumber { + font-weight: bold; + text-shadow: black -1px 0 1px, black 0 1px 1px, black 1px 0 1px, black 0 -1px 1px; + text-align: center; + color: white; +} + +.hl-TabNumber { + font-weight: bold; + padding-right: .3ex; +} + #liberator-container { font-family: monospace; }