diff --git a/NEWS b/NEWS index c7ebbced..3a17ee96 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ special versions for the old behavior * IMPORTANT: renamed Startup and Quit autocmd events to VimperatorEnter and VimperatorLeave respectively + * add :colorscheme * multibyte support for hints (thanks Xie&Tian) * add 'exrc' * add 'errorbells' diff --git a/content/completion.js b/content/completion.js index a7116bea..70d60ef0 100644 --- a/content/completion.js +++ b/content/completion.js @@ -813,6 +813,19 @@ function Completion() //{{{ return [0, buildLongestCommonSubstring(items, filter)]; }, + colorScheme: function colorScheme(filter) + { + let schemes = []; + let rtp = options["runtimepath"].split(","); + + rtp.forEach(function (path) { + schemes = schemes.concat([[c[0].replace(/\.vimp$/, ""), ""] + for each (c in completion.file(path + "/colors/", true)[1])]); + }); + + return [0, completion.filter(schemes, filter)]; + }, + command: function command(filter) { var completions = []; diff --git a/content/style.js b/content/style.js index 5d1ad72f..620ebbb8 100644 --- a/content/style.js +++ b/content/style.js @@ -362,30 +362,21 @@ const highlight = storage.newObject("highlight", Highlights, false); liberator.registerObserver("load_commands", function () { + // TODO: :colo default needs :hi clear commands.add(["colo[rscheme]"], "Load a color scheme", function (args) { let scheme = args.arguments[0]; - if (!io.sourceFromRuntimePath(["colors/" + scheme + ".vimp"])) + if (io.sourceFromRuntimePath(["colors/" + scheme + ".vimp"])) + autocommands.trigger("ColorScheme", {}); + else liberator.echoerr("E185: Cannot find color scheme " + scheme); }, { argCount: 1, - completer: function (filter) - { - let rtp = options["runtimepath"].split(","); - let schemes = []; - - rtp.forEach(function (path) { - schemes = schemes.concat( - [[c[0].replace(/\.vimp$/, ""), ""] for each (c in completion.file(path + "/colors/", true)[1])] - ) - }); - - return [0, completion.filter(schemes, filter)]; - } + completer: function (filter) completion.colorScheme(filter) }); commands.add(["sty[le]"], diff --git a/content/vimperator.js b/content/vimperator.js index 9234fc8f..4073c142 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -39,6 +39,7 @@ const config = { //{{{ get visualbellWindow() getBrowser().mPanelContainer, autocommands: [["BookmarkAdd", "Triggered after a page is bookmarked"], + ["ColorScheme", "Triggered after a color scheme has been loaded"], ["DOMLoad", "Triggered when a page's DOM content has fully loaded"], ["DownloadPost", "Triggered when a download has completed"], ["LocationChange", "Triggered when changing tabs or when naviagtion to a new location"], diff --git a/locale/en-US/autocommands.txt b/locale/en-US/autocommands.txt index 022536dd..a801524d 100644 --- a/locale/en-US/autocommands.txt +++ b/locale/en-US/autocommands.txt @@ -21,6 +21,7 @@ Available {events}: `--------------------`---------------------------------------- *BookmarkAdd* Triggered after a page is bookmarked +*ColorScheme* Triggered after a color scheme has been loaded *DOMLoad* Triggered when a page's DOM content has fully loaded *DownloadPost* Triggered when a download has completed *LocationChange* Triggered when changing tabs or when navigating to a new location diff --git a/locale/en-US/index.txt b/locale/en-US/index.txt index c544e208..f407de06 100644 --- a/locale/en-US/index.txt +++ b/locale/en-US/index.txt @@ -153,6 +153,7 @@ section:Ex{nbsp}commands[ex-cmd-index,:index] ||:cmap|| Map a key sequence in command-line mode + ||:cmapclear|| Remove all mappings in command-line mode + ||:cnoremap|| Map a key sequence without remapping keys in command-line mode + +||:colorscheme|| Load a color scheme + ||:comclear|| Delete all user-defined commands + ||:command|| List and define commands + ||:cunabbrev|| Remove an abbreviation in command-line mode + diff --git a/locale/en-US/styling.txt b/locale/en-US/styling.txt index 3940684b..f92f0875 100644 --- a/locale/en-US/styling.txt +++ b/locale/en-US/styling.txt @@ -7,6 +7,16 @@ styling is specified via CSS. Although you may style any user interface element via the [c]:style[c] command, most Vimperator elements can be styled with the [c]:highlight[c] command, for convenience. +|E185| |:colo| |:colorscheme| + +||:colo[rscheme] {name}|| + +________________________________________________________________________________ +Load a color scheme. {name} is found by searching the 'runtimepath' for the +first file matching colors/{name}.vimp. + +The ColorScheme autocommand is triggered after the color scheme has been +sourced. +________________________________________________________________________________ + |:hi| |:highlight| + ||:hi[light][!] [-append] {group}[{selector}] [{css}]|| + ________________________________________________________________________________ diff --git a/vimperator.vim b/vimperator.vim index 27dc9d20..57f5ea67 100644 --- a/vimperator.vim +++ b/vimperator.vim @@ -19,11 +19,11 @@ unlet b:current_syntax syn match vimperatorCommandStart "\%(^\s*:\=\)\@<=" nextgroup=vimperatorCommand,vimperatorAutoCmd syn keyword vimperatorCommand ab[breviate] ab[clear] addo[ns] b[uffer] ba[ck] bd[elete] beep bf[irst] bl[ast] bma[rk] bmarks - \ bn[ext] bN[ext] bp[revious] br[ewind] buffers bun[load] bw[ipeout] ca[bbrev] cabc[lear] cd chd[ir] cuna[bbrev] cm[ap] - \ cmapc[lear] cno[remap] comc[lear] com[mand] cu[nmap] do[autocmd] doautoa[ll] delbm[arks] delc[ommand] delmac[ros] delm[arks] - \ delqm[arks] dels[tyle] dia[log] dl downl[oads] e[dit] ec[ho] echoe[rr] echom[sg] em[enu] exe[cute] exu[sage] fini[sh] files - \ fo[rward] fw h[elp] ha[rdcopy] hi[ghlight] hist[ory] hs ia[bbrev] iabc[lear] im[ap] imapc[lear] ino[remap] iuna[bbrev] - \ iu[nmap] javas[cript] ju[mps] js let ls macros ma[rk] map mapc[lear] marks mes[sages] mkv[imperatorrc] no[remap] + \ bn[ext] bN[ext] bp[revious] br[ewind] buffers bun[load] bw[ipeout] ca[bbrev] cabc[lear] cd chd[ir] colo[rscheme] cuna[bbrev] + \ cm[ap] cmapc[lear] cno[remap] comc[lear] com[mand] cu[nmap] do[autocmd] doautoa[ll] delbm[arks] delc[ommand] delmac[ros] + \ delm[arks] delqm[arks] dels[tyle] dia[log] dl downl[oads] e[dit] ec[ho] echoe[rr] echom[sg] em[enu] exe[cute] exu[sage] + \ fini[sh] files fo[rward] fw h[elp] ha[rdcopy] hi[ghlight] hist[ory] hs ia[bbrev] iabc[lear] im[ap] imapc[lear] ino[remap] + \ iuna[bbrev] iu[nmap] javas[cript] ju[mps] js let ls macros ma[rk] map mapc[lear] marks mes[sages] mkv[imperatorrc] no[remap] \ noh[lsearch] norm[al] o[pen] optionu[sage] pa[geinfo] pagest[yle] pc[lose] pl[ay] pref[erences] prefs pw[d] q[uit] qa[ll] \ qma[rk] qmarks quita[ll] re[draw] re[load] reloada[ll] res[tart] run runt[ime] sty[le] sav[eas] sb[ar] sb[open] sbcl[ose] \ scrip[tnames] se[t] setg[lobal] setl[ocal] sideb[ar] so[urce] st[op] tN[ext] t[open] tab tabde[tach] tabd[uplicate]