" Vimball Archiver by Charles E. Campbell, Jr., Ph.D. UseVimball finish plugin/changingColor.vim [[[1 761 " vim:tags=changingColorTags:autochdir: " +-----------------------------------------------------------------------------+ " | CHANGING COLOR SCRIPT | " +-----------------------------------------------------------------------------+ " | Changes syntax highlight colors gradually every little while to reflect the | " | passing by of the hour. Note: this script needs the Timer script in order | " | to work properly, but Timer should be installed automatically if you use | " | :source % as it comes included in the package. | " +-----------------------------------------------------------------------------+ " | START | " +-----------------------------------------------------------------------------+ " | THU 22ND JUN 2017 22.3 | " | Took off some not necessary highlights to conserve | " | as much resources as possible. Added this missing | " | SpecialChar which is the format specifier in C scanf | " | family functions. | " | FRI 09TH JUN 2017 22.2 | " | Included Number, seems this is in MacVim not in Win Vim| " | which was weird because the number constants remained | " | the same. Also tweaks to Normal to remain more stable | " | Fixed an attempted fix in 22.0 of Operator which forgot| " | but through testing found it. Operator, SpecialKey and| " | Number were not in Win Vim. Removed messing around | " | with temp variables. Now everything is just added | " | to one big variable and done in one go. It's also a | " | lot more clearer to read. | " | THU 08TH JUN 2017: 22.2 | " | Made timing improvements to the Normal so it remains | " | better visibility at certain areas of the color roll. | " | plus embarassingly forgot to add the Operator one I | " | in 22.0 to the highlight statements so even though I | " | 'fixed' it it never got included. Now 'fixed' proper. | " | Removed some unecessary variables messing around off | " | main highlight function. | " | 22.1 | " | made the timing machanism more smooth. Should improve | " | the Vim user experience. | " | 22.0 | " | The Operator did not have a 'moving' arghh... | " | made improvements to the way timing of the callback | " | is done so that script *only* gets called when it is | " | actually time to change the colors so you get a more | " | smooth Vim experience. | " | MON 25TH JAN 2015: 21.1 | " | The Normal forground was adjusted. All I did was | " | moved the adjustment for lighter background down a bit | " | so as to be less agressive because it wasn't making it | " | much clearer. param 5 of Rgb4(). - see [ Rgb4 ] | " | (senLig) | " | FRI 15TH JAN 2015: 21.0 | " | There's two things here. First of all I removed a | " | rather ugly feature. But more importantly is the | " | TAGS i've used to do this. Basically, in the code | " | where the main change happened I've added a TAG | " | and this steps you through hand-holding style through | " | the changes I've made in the script. It's how VIM | " | is fundamentally made. That's it's power. | " | That and combined with it's incredible :help system | " | make it the best editor in the business, and maybe | " | one of the greatest of ALL TIME ever created! | " | I like it because it takes someone rather like me, | " | not that clever, and gives them power tools for | " | logic (TAGS) ability to bundle language help (:help) | " | as well as a nice code editor and sit back and enjoy. | " | I need a few hits on this so you could help and you | " | might learn something. please check out: | " | http://www.ezrider.co.uk/VimTagsHelp | " | -A.N.Other Spanish guy trying to rule the WORLD argh.. | " | (it even might be good if there weren't 1000's of us | " | all plotting and scheming the same thing arghh.... | " | should have just stuck to writing Quill adventures!) | " | WED 25TH FEB 2015: 20.7 | " | Slight improvements to Constant esp. at high light | " | settings. | " | TUE 24TH FEB 2015: 20.6 | " | Further gave tweaks to Comment because there were | " | effects that were making it worse. Cleaned it up. | " | TUE 24TH FEB 2015: 20.5 | " | Gave Comment a tweak at high brightness backgrounds | " | because it looked to much like Normal in this. | " | TUE 24TH FEB 2015: 20.4 | " | Gave Constant and Identifier a bit of a tweak at high | " | brightness background. The green of Identifier also | " | looks nice and flouro at low light backgrounds. You | " | can actually see the green still at light backgrounds. | " | WED 11TH FEB 2015: 20.3 | " | I forgot the vital tags files, only really useful if | " | you wanna see help on it. This does not affect the | " | scripts at all. If you've previously installed it | " | just make sure you run :RmVimball changingColor | " | and just re-install it by loading changingColor.vba and| " | doing :so % | " | That will get rid of any rubbish. | " | TUE 10TH FEB 2015: 20.2 | " | Had a third look and decided about 33% should do it. | " | That is about 33% of the shades are no good. | " | That's roughly 1/3 so sounds about right. They are | " | just to "in the grey area" to be clear highlight. | " | They need to be removed. | " | TUE 3RD FEB 2015: 20.1 | " | Had a look at it and decided ~25% was still too low | " | and there were still some murky shades too difficult to| " | see. I didn't want to cut too much of the continuity | " | but I think 30% is a necessary step towards improvement| " | 20.0 | " | After careful consideration have decided that some of | " | the shades in my script are too difficult to see. | " | I was trying to have one smooth continuum between light| " | and dark but the exact middle point is always making | " | me strain to read no matter what I do, and this looks | " | poor compared to other color schemes so I decided to | " | create a ramped "jump over" the exact mid-point. | " | You will still see constant changes but when it gets | " | to a certain mid point it will jump about 20% of the | " | murky shades to the next point after that. | " | WED 3RD DEC 2014: 19.3 | " | Tweaked visibility of Normal, edge case. It appears | " | that due to a calibration issue I was having with my | " | monitor I'd got this wrong previously. I had thought | " | that it was massively out but it was a "Power Saving" | " | feature of my EeePC that made it look hard to read. | " | Not generally applicable in most cases. Fixed to be | " | similar to what it was in 19.0. | " | TUE 18TH NOV 2014: 19.2 | " | Tweaked visibility of Normal, edge case. Better now | " | FRI 14TH NOV 2014: 19.1 | " | Massive adjustment to fix visibility of Normal | " | added context help for Rgb2a() | " | Now you can just press Ctrl-] over anywhere you see | " | Rgb2a() to jump straight to its definition. | " | From there you can get help on all its arguments. | " | This is finally starting to look damn good. | " | THU 30TH OCT 2014: 19.0 | " | Fix visibility of normal | " | New! Some help available on SOME of the paremeters. | " | Try Rgb2a(..) all the paremters have help, hover over | " | and press Ctrl-]. Not all parameters are covered and | " | other functions are missing but please be patient I | " | will eventually get around to better explanations | " | SAT 25TH OCT 2014: 18.1 | " | Bug fix. Accidentally overwrote user's choice of | " | color scheme did not check if it was already set. Fixed| " | THU 24TH APR 2014: 18.0 | " | Made time passing effect co-operate with when you | " | finish writing your changes vs. just browsing around | " | text without editing it. This latter now uses the | " | more intuitively named 'permanent' color scheme. | " | If you want to change it the variable is called | " | g:permanentColorScheme. Simply set that to the string | " | equalling the name of your favorite color scheme in | " | your _vimrc, e.g. "koehler", or "morning". | " | e.g. let g:permanentColorScheme = "keohler" | " | Note: this used to be referred to unintuitively as | " | 'g:changingColorStop' in previous versions of this | " | script. | " | TUE 2ND JUL 2013: 17.3 | " | Made sure this is the same version that includes the | " | user-settable g:changingColorStop variable checks | " | I had it inconsistently before. | " | ... | " | WED 27TH MAY 2009: o VER 1.00 | " +-----------------------------------------------------------------------------+ " +-----------------------------------------------------------------------------+ " | changingColor uses CursorHold, CursorHoldI to call its hilight updating | " | to do this it changingColor needs to modify the Vim system setting | " | updatetime because it's default (4000) is every 4 seconds which would cause | " | changingColor to run it's highlight updating ~ 4 secs = painful on the sys | " | you can manually set this or delete this following line if you really want | " | depending on what kind of activity level you want to see. I think 12000 = | " | ~ 12 secs is not too bad. | " +-----------------------------------------------------------------------------+ set updatetime=12000 " +------------------------------------------------------------------------------+ " | The following variable is the size of the area below and above that zone that| " | makes the text colour 'darken' to avoid clashing with the background. It | " | lasts around 2 minutes and during this time the text colour stays exactly | " | unmodified but the background is tweaked up or down to 'ease' visibility | " | while not drastically changing anything yet. This happens in that area known | " | as the 'danger' area. The bigger this value the bigger that 'ease' period | " | is, with 7200 being around 2 minutes above and below 'danger' area. | " +------------------------------------------------------------------------------+ let g:easeArea=8200 " +------------------------------------------------------------------------------+ " | the following was second thoughts about this UpTheGamma() routine, which | " | I've now decided should be OFF as default, unless the user specially | " | wants to have it. They can change it if they want | " +------------------------------------------------------------------------------+ let g:upTheGamma_enable=0 "debug "let g:mytime=16000 "let g:myhour=0 " +------------------------------------------------------------------------------+ " | Main Rgb function, used to work out amount to offset Rgb value by to avoid | " | it clashing with the background colour. | " | Return value is modified or otherwise value (not modified if no clash). | " +------------------------------------------------------------------------------+ function Rgb2(Rgb, actBgr, dangerBgr, senDar, senLig, adjust) if a:actBgr>=a:dangerBgr-a:senDar && a:actBgr<=a:dangerBgr+a:senLig let whatdoyoucallit=a:dangerBgr-a:actBgr if whatdoyoucallit<0 let whatdoyoucallit=-whatdoyoucallit endif let whatdoyoucallit=whatdoyoucallit/130 if whatdoyoucallit>255 let whatdoyoucallit=255 endif let whatdoyoucallit=-whatdoyoucallit+255 let whatdoyoucallit=whatdoyoucallit*a:adjust let whatdoyoucallit=whatdoyoucallit/800 let whatdoyoucallit=whatdoyoucallit+65 let adjustedValue=a:Rgb-whatdoyoucallit else let adjustedValue=a:Rgb endif if adjustedValue<0 let adjustedValue=0 endif if adjustedValue>255 let adjustedValue=255 endif return adjustedValue endfunction " takes a within range aMin,aMin outputs a mapped to rMin, rMin function ScaleToRange(a,aMin,aMax,rMin,rMax) let aLocal=a:a-a:aMin let rangeA=a:aMax-a:aMin let rangeR=a:rMax-a:rMin let rangeA=rangeA*1000|let rangeR=rangeR*1000 let divAR=rangeA/rangeR return aLocal/divAR+a:rMin endfunction " +------------------------------------------------------------------------------+ " | Main Rgb for Normal (like Rgb2 but brightens, not darkens - Normal is | " | a bit trickier because it is also where the general background is set | " | To see help on each paremeter, press Ctrl-]. [General_Rgb2a] | " +------------------------------------------------------------------------------+ function Rgb2a(rgb,actBgr,dngBgr,senDar,senLig,loadj,hiadj,lotail1,lotail2) let adjVal=a:rgb if a:actBgr>=a:dngBgr-a:senDar && a:actBgr<=a:dngBgr+a:senLig let adjVal+=ScaleToRange(a:actBgr,a:dngBgr-a:senDar,a:dngBgr+a:senLig,a:loadj,a:hiadj) endif if a:actBgr>=0 && a:actBgr<=a:dngBgr-a:senDar let adjVal+=ScaleToRange(a:actBgr,0,a:dngBgr-a:senDar,a:lotail1,a:lotail2) endif let adjVal-=g:whiteadd if adjVal<0 let adjVal=0 endif if adjVal>255 let adjVal=255 endif return adjVal endfunction " +------------------------------------------------------------------------------+ " | Special Rgb function for cases that needed special care. It provides | " | more control over the text's high or low lighting in the danger visibility | " | zone. | " +------------------------------------------------------------------------------+ function Rgb2b(Rgb,actBgr,dangerBgr,senDar,senLig,adjust1,adjust2,adjust3) if a:actBgr>=a:dangerBgr-a:senDar && a:actBgr<=a:dangerBgr+a:senLig let progressFrom=a:dangerBgr-a:senDar let progressLoHi=a:actBgr-progressFrom let diffLoHi=(a:dangerBgr+a:senLig)-(a:dangerBgr-a:senDar) let progressPerThou=progressLoHi/(diffLoHi/1000) if progressPerThou<500 let adjustedAdjust=ScaleToRange(a:actBgr,a:dangerBgr-a:senDar,((a:dangerBgr-a:senDar)+(a:dangerBgr+a:senLig))/2,a:adjust1,a:adjust2) else let adjustedAdjust=ScaleToRange(a:actBgr,((a:dangerBgr-a:senDar)+(a:dangerBgr+a:senLig))/2,a:dangerBgr+a:senLig,a:adjust2,a:adjust3) endif let proximity=a:dangerBgr-a:actBgr if proximity<0 let proximity=-proximity endif let proximity=proximity/130 if proximity>255 let proximity=255 endif let proximity=-proximity+255 let proximity=proximity*adjustedAdjust let proximity=proximity/800 let proximity=proximity+65 let adjustedValue=a:Rgb-proximity else let adjustedValue=a:Rgb endif let adjustedValue=adjustedValue-g:whiteadd if adjustedValue<0 let adjustedValue=0 endif if adjustedValue>255 let adjustedValue=255 endif return adjustedValue endfunction " +------------------------------------------------------------------------------+ " | Rgb function for cursor to work out amount to offset Rgb component to stop | " | it from clashing with the background colour. | " | Return value is modified or otherwise value (not modified if no clash). | " +------------------------------------------------------------------------------+ function Rgb3(Rgb,actBgr,dangerBgr,adj) let diff=a:actBgr-a:dangerBgr if diff<0 let diff=-diff endif if diff<12000 let adjustedValue=a:Rgb-a:adj if adjustedValue<0 let adjustedValue=0 endif else let adjustedValue=a:Rgb endif return adjustedValue endfunction " +------------------------------------------------------------------------------+ " | Rgb function used to work out offsetting for Rgb components pertaining to | " | a background, i.e. the bit that says guibg= of the vim highlight command. | " | Background is handled different to foreground so it needs another function. | " | You can tell this Rgb function what to do with the background if Rgb value | " | is *just* below the 'danger' general background, and above it. In each case | " | you can tell it to brighten or darken the passed Rgb value. (darkAdj, | " | lghtAdj params.) Positive values, (e.g. 40) add brightness, nagative values | " | remove it. Special cases 99 and -99 adds does this in a 'default' measure. | " | You can also tell the function what to do if the Rgb value is right inside | " | the danger zone; not to be confused with darkAdj & lghtAdj that mean the | " | two end tips outside of the danger area. This bit is the danger area itself, | " | the low-visisibility area, the 'danger zone'. (dangerZoneAdj) It works the | " | same, a positive value causes background to brighten, a negative to darken. | " | Like darkAdj & lghtAdj, you can also specify default 'brighten' or 'darken', | " | 99 or -99 respectively, but if you're not happy with the default just fine | " | tune it exactly as you would like it to look exactly as you do with darkAdj | " | & lghtAdj. Use this if you find using the normal foreground text colour | " | modification by itself (Rgb2 function) doesn't cut it. Text still looks | " | blurry over a certain background colour even after you've adjusted the danger| " | adjustment parameters available in Rgb2. Normally I found darkening text | " | with Rgb2 adjustment params makes the text 'visible' over danger zone but | " | in some cases it wasn't up to it, so I added this param: 'dangerZoneAdj'. | " | This allows you to 'fudge' the background colour up and down as desired until| " | you're happy with the result. | " | Return value is either the up or down-shifted Rgb background element if the | " | element falls just outside the 'danger' boundary, a shifted-up Rgb element | " | if the value is fully inside the danger boundary (and you set dangerZoneAdj) | " | or simply the same as you pass if the value you pass is outside the danger | " | zone AND the outer boundary ring of the 'danger zone'. | " +------------------------------------------------------------------------------+ function Rgb4(Rgb,actBgr,dangerBgr,senDar,senLig,darkAdjLo,darkAdjHi,lghtAdjLo,lghtAdjHi,dangerZoneAdj) let darkAdjLo=a:darkAdjLo let darkAdjHi=a:darkAdjHi let lghtAdjLo=a:lghtAdjLo let lghtAdjHi=a:lghtAdjHi if a:darkAdjLo==99 let darkAdjLo=11 endif if a:darkAdjLo==-99 let darkAdjLo=-11 endif if a:darkAdjHi==99 let darkAdjHi=11 endif if a:darkAdjHi==-99 let darkAdjHi=-11 endif if a:lghtAdjLo==99 let lghtAdjLo=11 endif if a:lghtAdjLo==-99 let lghtAdjLo=-11 endif if a:lghtAdjHi==99 let lghtAdjHi=11 endif if a:lghtAdjHi==-99 let lghtAdjHi=-11 endif let dangerZoneAdj=a:dangerZoneAdj if a:dangerZoneAdj==99 let dangerZoneAdj=15 endif if a:dangerZoneAdj==-99 let dangerZoneAdj=-15 endif let adjustedValue=a:Rgb if a:actBgr>=a:dangerBgr-a:senDar-g:easeArea && a:actBgra:dangerBgr+a:senLig && a:actBgr<=a:dangerBgr+a:senLig+g:easeArea let adjustedValue=adjustedValue+ScaleToRange(a:actBgr,a:dangerBgr+a:senLig,a:dangerBgr+a:senLig+g:easeArea,lghtAdjLo,lghtAdjHi) endif if a:actBgr>=(a:dangerBgr-a:senDar) && a:actBgr<=(a:dangerBgr+a:senLig) && dangerZoneAdj let adjustedValue=adjustedValue+dangerZoneAdj endif if adjustedValue<0 let adjustedValue=0 endif if adjustedValue>255 let adjustedValue=255 endif return adjustedValue endfunction " +------------------------------------------------------------------------------+ " | Like REGEl4 but adding an additional control for fine-tuning the background | " | at various ranges (instead of one flat rate.) | " +------------------------------------------------------------------------------+ function Rgb4a(Rgb,actBgr,dangerBgr,senDar,senLig,darkAdjLo,darkAdjHi,lghtAdjLo,lghtAdjHi,dangerZoneAdj1,dangerZoneAdj2,ligdown1,ligdown2,ligup1,ligup2) let darkAdjLo=a:darkAdjLo let darkAdjHi=a:darkAdjHi let lghtAdjLo=a:lghtAdjLo let lghtAdjHi=a:lghtAdjHi if a:darkAdjLo==99 let darkAdjLo=11 endif if a:darkAdjLo==-99 let darkAdjLo=-11 endif if a:darkAdjHi==99 let darkAdjHi=11 endif if a:darkAdjHi==-99 let darkAdjHi=-11 endif if a:lghtAdjLo==99 let lghtAdjLo=11 endif if a:lghtAdjLo==-99 let lghtAdjLo=-11 endif if a:lghtAdjHi==99 let lghtAdjHi=11 endif if a:lghtAdjHi==-99 let lghtAdjHi=-11 endif let dangerZoneAdj1=a:dangerZoneAdj1 if a:dangerZoneAdj1==99 let dangerZoneAdj1=15 endif if a:dangerZoneAdj1==-99 let dangerZoneAdj1=-15 endif let dangerZoneAdj2=a:dangerZoneAdj2 if a:dangerZoneAdj2==99 let dangerZoneAdj2=15 endif if a:dangerZoneAdj2==-99 let dangerZoneAdj2=-15 endif let adjustedValue=a:Rgb if a:actBgr>=a:dangerBgr-a:senDar-g:easeArea && a:actBgr=0 && a:actBgra:dangerBgr+a:senLig && a:actBgr<=a:dangerBgr+a:senLig+g:easeArea let adjustedValue=adjustedValue+ScaleToRange(a:actBgr,a:dangerBgr+a:senLig,a:dangerBgr+a:senLig+g:easeArea,lghtAdjLo,lghtAdjHi) endif if a:actBgr>a:dangerBgr+a:senLig+g:easeArea && a:actBgr<=86400 let adjustedValue=adjustedValue+ScaleToRange(a:actBgr,a:dangerBgr+a:senLig+g:easeArea,86400,a:ligup1,a:ligup2) endif if a:actBgr>=(a:dangerBgr-a:senDar) && a:actBgr<=(a:dangerBgr+a:senLig) && (dangerZoneAdj1 || dangerZoneAdj2) let adjustedValue=adjustedValue+ScaleToRange(a:actBgr,a:dangerBgr-a:senDar,a:dangerBgr+a:senLig,dangerZoneAdj1,dangerZoneAdj2) endif if adjustedValue<0 let adjustedValue=0 endif if adjustedValue>255 let adjustedValue=255 endif return adjustedValue endfunction " +------------------------------------------------------------------------------+ " | Special case of Rgb function used particularly for the Normal highlight | " | element which obviously needs to be stronger because it's background cannot | " | be 'shifted' in bad visibility cases because Normal also happens to be the | " | the general background vim uses. | " +------------------------------------------------------------------------------+ function Rgb5(Rgb,actBgr,dangerBgr,senDar,senLig) if a:actBgr>=a:dangerBgr-a:senDar && a:actBgr<=a:dangerBgr+a:senLig let adjustedValue=255 else let adjustedValue=a:Rgb endif if a:actBgr>=(a:dangerBgr+a:senLig)-21000 && a:actBgr<=a:dangerBgr+a:senLig let adjustedValue=0 endif if adjustedValue<0 let adjustedValue=0 endif if adjustedValue>255 let adjustedValue=255 endif return adjustedValue endfunction " +------------------------------------------------------------------------------+ " | This is a simple cut-off function disallowing values <0 and >255 | " +------------------------------------------------------------------------------+ function Rgb6(Rgb) let result=a:Rgb if a:Rgb<0 let result=0 endif if a:Rgb>255 let result=255 endif return result endfunction " +----------------------------------------+ " | try to increase the low contrast areas | " +----------------------------------------+ function UpTheGamma(todaysec) let result = a:todaysec if result>=43199 let result = result * 0.666 let result = result + 28857 else let result = result * 0.666 endif let result = float2nr(result) return result endfunction " +------------------------------------------------------------------------------+ " | Muscle function, calls vim highlight command for each element based on the | " | time into the current hour. | " +------------------------------------------------------------------------------+ function SetHighLight() let todaysec=(((localtime()+1800)%(60*60)))*24 if exists("g:mytime") let todaysec=g:mytime endif let s:oldactontime=todaysec if todaysec<43199 let todaysec=todaysec*2 let dusk=0 else let todaysec=-todaysec*2+172799 let dusk=1 endif if g:upTheGamma_enable let todaysec=UpTheGamma(todaysec) " [so___whatsWithThis_UpTheGamma_business___then] endif if exists("g:myhour") let myhour=g:myhour else let myhour=(localtime()/(60*60))%3 endif if (myhour==0 && dusk==0) let adjBG1=(todaysec<67000)?todaysec/380:(todaysec-43200)/271+96 let adjBG1A=(todaysec<67000)?todaysec/380:(todaysec-43200)/271+96 let adjBG2=(todaysec<67000)?todaysec/420:(todaysec-43200)/271+80 endif if (myhour==0 && dusk==1) let adjBG1=(todaysec<67000)?todaysec/420:(todaysec-43200)/271+80 let adjBG1A=(todaysec<67000)?todaysec/380:(todaysec-43200)/271+96 let adjBG2=(todaysec<67000)?todaysec/420:(todaysec-43200)/271+80 endif if (myhour==1 && dusk==0) let adjBG1=(todaysec<67000)?todaysec/380:(todaysec-43200)/271+96 let adjBG1A=(todaysec<67000)?todaysec/420:(todaysec-43200)/271+80 let adjBG2=(todaysec<67000)?todaysec/420:(todaysec-43200)/271+80 endif if (myhour==1 && dusk==1) let adjBG1=(todaysec<67000)?todaysec/420:(todaysec-43200)/271+80 let adjBG1A=(todaysec<67000)?todaysec/420:(todaysec-43200)/271+80 let adjBG2=(todaysec<67000)?todaysec/380:(todaysec-43200)/271+96 endif if (myhour==2 && dusk==0) let adjBG1=(todaysec<67000)?todaysec/420:(todaysec-43200)/271+80 let adjBG1A=(todaysec<67000)?todaysec/380:(todaysec-43200)/271+96 let adjBG2=(todaysec<67000)?todaysec/380:(todaysec-43200)/271+96 endif if (myhour==2 && dusk==1) let adjBG1=(todaysec<67000)?todaysec/380:(todaysec-43200)/271+96 let adjBG1A=(todaysec<67000)?todaysec/420:(todaysec-43200)/271+80 let adjBG2=(todaysec<67000)?todaysec/380:(todaysec-43200)/271+96 endif let g:whiteadd=(todaysec-60000)/850 if g:whiteadd>0 let adjBG1=adjBG1+g:whiteadd if adjBG1>255 let adjBG1=255 endif let adjBG1A=adjBG1A+g:whiteadd if adjBG1A>255 let adjBG1A=255 endif let adjBG2=adjBG2+g:whiteadd if adjBG2>255 let adjBG2=255 endif else let g:whiteadd=0 endif let temp1 = adjBG1-(g:whiteadd/3) let temp2 = adjBG1A-(g:whiteadd/3) let temp3 = adjBG2-(g:whiteadd/3) let adjBG3 = (todaysec>=18500)?temp1-ScaleToRange(adjBG1,54,255,4,17):adjBG1+ScaleToRange(adjBG1,0,54,32,12) let adjBG4 = (todaysec>=18500)?temp2-ScaleToRange(adjBG1A,54,255,4,17):adjBG1A+ScaleToRange(adjBG1A,0,54,32,26) let adjBG5a = (todaysec>=18500)?temp3-ScaleToRange(adjBG2,54,255,4,17):adjBG2+ScaleToRange(adjBG2,0,54,32,26) let total = printf("highlight Normal guibg=#%02x%02x%02x", adjBG1,adjBG1A,adjBG2) let adj1 = Rgb2(adjBG1+40, todaysec, 80000, 5500, 6400, 60) let adj2 = Rgb2(adjBG1+40, todaysec, 80000, 5500, 6400, 60) let adj3 = Rgb2(adjBG1+40, todaysec, 80000, 5500, 6400, 60) let total .= printf(" | highlight Folded guibg=#%02x%02x%02x", adjBG3, adjBG4, adjBG5a) let total .= printf(" | highlight CursorColumn guibg=#%02x%02x%02x", adjBG3, adjBG4, adjBG5a) let total .= printf(" | highlight CursorLine guibg=#%02x%02x%02x", adjBG3,adjBG4,adjBG5a) let total .= printf(" | highlight LineNr guibg=#%02x%02x%02x", adjBG3, adjBG4, adjBG5a) let total .= printf(" | highlight FoldColumn guibg=#%02x%02x%02x", adjBG3, adjBG4, adjBG5a) let adj1 = Rgb2a((-todaysec+86400)/338/4+160, todaysec, 57000, 16000, 23000, -100, -42, 0, 12) let adj2 = Rgb2a((-todaysec+86400)/338/4+76, todaysec, 57000, 16000, 23000, -100, -42, 0, 12) let adj3 = Rgb2a((-todaysec+86400)/338/4+23, todaysec, 57000, 16000, 23000, -100, -42, 0, 12) let adj4 = Rgb4(adjBG1, todaysec, 57000, 16000, 15000, -4, -11, -2, 0, 0) let adj5 = Rgb4(adjBG1A, todaysec, 57000, 16000, 15000, -4, -11, -2, 0, 0) let adj6 = Rgb4(adjBG2, todaysec, 57000, 16000, 15000, -4, -11, -2, 0, 0) let total .= printf(" | highlight Statement guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) let adjBG5 = (todaysec<43200)?todaysec/338/2:todaysec/450+63 let total .= printf(" | highlight VertSplit guifg=#%02x%02x%02x", adjBG3, adjBG3, adjBG5) let adj1 = Rgb2((-todaysec+86400)/338/2+40, todaysec, 44000, 8000, 20000, 100) let adj2 = Rgb2((-todaysec+86400)/338/2+54, todaysec, 44000,8000,20000,100) let adj3 = Rgb2((-todaysec+86400)/338/2+80, todaysec, 44000, 8000, 20000, 100) let total .= printf(" | highlight LineNr guifg=#%02x%02x%02x", adj1, adj2, adj3) let total .= printf(" | highlight FoldColumn guifg=#%02x%02x%02x", adj1, adj2, adj3) let total .= printf(" | highlight Folded guifg=#%02x%02x%02x", adj1, adj2, adj3) let adj1 = Rgb2a((-todaysec+86400)/220/2+27, todaysec, 52000, 17000, 5000, -140, -45, 0, 25) let adj2 = Rgb2a((-todaysec+86400)/220/2+110, todaysec, 52000, 17000, 5000, -140, -45, 0, 25) let adj4 = Rgb4a(adjBG1, todaysec, 57000, 22000, 14500, -26, -28, -3, -2, 8, 2, 25, -20, -4, -13) let adj5 = Rgb4a(adjBG1A, todaysec, 57000, 22000, 14500, -26, -28, -3, -2, 8, 2, 25, -20, -4, -13) let adj6 = Rgb4a(adjBG2, todaysec, 57000, 22000, 14500, -26, -28, -3, -2, 8, 2, 25, -20, -4, -13) let total .= printf(" | highlight Constant guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj1, adj2, adj4, adj5, adj6) let total .= printf(" | highlight SpecialKey guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj1, adj2, adj4, adj5, adj6) let total .= printf(" | highlight Number guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj1, adj2, adj4, adj5, adj6) let total .= printf(" | highlight NonText guibg=#%02x%02x%02x guifg=#%02x%02x%02x", adjBG3, adjBG1, adjBG1, adj1, adj1, adj2) let total .= printf(" | highlight JavaScriptValue guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj1, adj2, adj4, adj5, adj6) let adj1 = Rgb2a((-todaysec+86400)/338/2+110, todaysec, 55000, 11000, 20500, -420, 30, 0, 17) " problem 37500,seems ok now let adj2 = Rgb2a((-todaysec+86400)/338/2+98, todaysec, 55000, 11000, 20500, -420, 30, 0, 17) let adj3 = Rgb2a((-todaysec+86400)/338/2, todaysec, 55000, 11000, 20500, -420, 30, 0, 17) let adj4 = Rgb4(adjBG1-30, todaysec, 0, 0, 10000, 20, 20, 40, 20, 40) let adj5 = Rgb4(adjBG1A-10, todaysec, 0, 0, 10000, 20, 20, 40, 20, 40) let adj6 = Rgb4(adjBG2+10, todaysec, 0, 0, 10000, 20, 20, 40, 20, 40) let total .= printf(" | highlight Normal guifg=#%02x%02x%02x gui=NONE", adj1, adj2, adj3) let total .= printf(" | highlight Search guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) let adj4 = Rgb2(adjBG1+40, todaysec, 86399, 6000, 1, 30) let adj5 = Rgb2(adjBG1A+15, todaysec, 86399, 6000, 1, 30) let adj6 = Rgb2(adjBG2+10, todaysec, 86399, 6000, 1, 30) let total .= printf(" | highlight Visual guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) let adj1 = Rgb2a((-todaysec+86400)/338/4+0, todaysec, 57000, 10000, 29399, -168, -60, -6, 33) let adj2 = Rgb2a((-todaysec+86400)/338/4+216, todaysec, 57000, 10000, 29399, -168, -60, -6, 33) let adj3 = Rgb2a((-todaysec+86400)/338/4, todaysec, 57000, 10000, 29399, -168, -60, -6, 33) let adj4 = Rgb4a(adjBG1, todaysec, 57000, 22000, 14500, -26, -28, -3, -2, 8, 2, 25, -20, -4, -13) let adj5 = Rgb4a(adjBG1A, todaysec, 57000, 22000, 14500, -26, -28, -3, -2, 8, 2, 25, -20, -4, -13) let adj6 = Rgb4a(adjBG2, todaysec, 57000, 22000, 14500, -26, -28, -3, -2, 8, 2, 25, -20, -4, -13) let total .= printf(" | highlight Identifier guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) let total .= printf(" | highlight Operator guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) " just made Operator the same as Identifier for now " MacVim 7.4 didn't have Operator " same with SpecialKey, had to alias for now (Constant) " let adj1 = Rgb2a((-todaysec+86400)/355/2+97, todaysec, 43000, 2000, 19000, -130, -75, 0, 30) let adj2 = Rgb2a((-todaysec+86400)/355/2+0, todaysec, 43000, 2000, 19000, -130, -75, 0, 30) let adj3 = Rgb2a((-todaysec+86400)/355/2+137, todaysec, 43000, 2000, 19000, -130, -75, 0, 30) let adj4 = Rgb4(adjBG1, todaysec, 43000, 2000, 19000, -99, -99, 0, 0, 0) let adj5 = Rgb4(adjBG1A, todaysec, 43000, 2000, 19000, -99, -99, 0, 0, 0) let adj6 = Rgb4(adjBG2, todaysec, 43000, 2000, 19000, -99, -99, 0, 0, 0) let total .= printf(" | highlight PreProc guifg=#%02x%02x%02x gui=bold guibg=#%02x%02x%02x", adj1,adj2,adj3,adj4,adj5,adj6) let adj1 = Rgb2a((-todaysec+86400)/600/4+187, todaysec, 57000, 10000, 23000, -156, -68, 0, 10) let adj2 = Rgb2a((-todaysec+86400)/600/4+95, todaysec, 57000, 10000, 23000, -156, -68, 0, 10) let adj3 = Rgb2a((-todaysec+86400)/600/4+155, todaysec, 57000, 10000, 23000, -156, -68, 0, 10) let adj4 = Rgb4(adjBG1, todaysec, 57000, 10000, 15000, -2, -5, -5, -2, 0) let adj5 = Rgb4(adjBG1A, todaysec, 57000, 10000, 15000, -2, -5, -5, -2, 0) let adj6 = Rgb4(adjBG2, todaysec, 57000, 10000, 15000, -2, -5, -5, -2, 0) let total .= printf(" | highlight Special guifg=#%02x%02x%02x gui=bold guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) let total .= printf(" | highlight JavaScriptParens guifg=#%02x%02x%02x gui=bold guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) let adj1 = Rgb2((-todaysec+86400)/338/2+120, todaysec, 47000, 3000, 14000, 64) let adj2 = Rgb2((-todaysec+86400)/338/2+10, todaysec, 47000, 3000, 14000, 64) let adj3 = Rgb2((-todaysec+86400)/338/2+80, todaysec, 47000, 3000, 14000, 64) let adj4 = Rgb4(adjBG1, todaysec, 47000, 3000, 14000, -99, -99, -99, -99, 99) let adj5 = Rgb4(adjBG1A, todaysec, 47000, 3000, 14000, -99, -99, -99, -99, 99) let adj6 = Rgb4(adjBG2, todaysec, 47000, 3000, 14000, -99, -99, -99, -99, 99) let total .= printf(" | highlight Title guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) let adj1 = Rgb2b((-todaysec+86400)/280/4+140, todaysec, 50000, 12000, 22000, 220, 140, -300) let adj2 = Rgb2b((-todaysec+86400)/280/4+140, todaysec, 50000, 12000, 22000, 220, 140, -300) let adj3 = Rgb2b((-todaysec+86400)/280/4+140, todaysec, 50000, 12000, 22000, 220, 140, -300) let total .= printf(" | highlight Comment guifg=#%02x%02x%02x", adj1, adj2, adj3) let total .= printf(" | highlight htmlComment guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) let total .= printf(" | highlight htmlCommentPart guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) let total .= printf(" | highlight SpecialChar guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) let adj1 = Rgb6(todaysec/338+70) let adj2 = Rgb6(todaysec/338+30) let adj3 = Rgb6(todaysec/338-100) let adj4 = Rgb2a((-todaysec+86400)/338/2+70, todaysec, 35000, 15000, 14000, 60, 120, 0, 0) let adj5 = Rgb2a((-todaysec+86400)/338/2+60, todaysec, 35000, 15000, 14000, 60, 120, 0, 0) let adj6 = Rgb2a((-todaysec+86400)/338/2+0, todaysec, 35000, 15000, 14000, 60, 120, 0, 0) let total .= printf(" | highlight StatusLine guibg=#%02x%02x%02x guifg=#%02x%02x%02x gui=bold", adj1, adj2, adj3, adj4, adj5, adj6) let adj1 = Rgb6(todaysec/338+70) let adj2 = Rgb6(todaysec/338+60) let adj3 = Rgb6(todaysec/338-100) let adj4 = Rgb2a((-todaysec+86400)/338/2+70, todaysec, 20000, 10000, 14000, 40, 120, 0, 0) let adj5 = Rgb2a((-todaysec+86400)/338/2+0, todaysec, 20000, 10000, 14000, 40, 120, 0, 0) let adj6 = Rgb2a((-todaysec+86400)/338/2+0, todaysec, 20000, 10000, 14000, 40, 120, 0, 0) let total .= printf(" | highlight StatusLineNC guibg=#%02x%02x%02x guifg=#%02x%02x%02x gui=bold", adj1, adj2, adj3, adj4, adj5, adj6) let adj1 = Rgb2a((-todaysec+86400)/338/2+150, todaysec, 60000, 11000, 13000, -90, -45, -50, -20) let adj2 = Rgb2a((-todaysec+86400)/338/2+120, todaysec, 60000, 11000, 13000, -90, -45, -50, -20) let adj3 = Rgb2a((-todaysec+86400)/338/2+0, todaysec, 60000, 11000, 13000, -90, -45, -50, -20) let total .= printf(" | highlight Type guifg=#%02x%02x%02x", adj1, adj2, adj3) let adj1 = Rgb3(255, todaysec, 80000, 0) let adj2 = Rgb3(255, todaysec, 80000, 255) let adj3 = Rgb3(0, todaysec, 80000, 0) let total .= printf(" | highlight Cursor guibg=#%02x%02x%02x", adj1, adj2, adj3) let total .= printf(" | highlight MatchParen guibg=#%02x%02x%02x", adj1, adj2, adj3) let adj1 = Rgb2((-todaysec+86400)/338/2+100, todaysec, 44000, 10000, 26000, 40) let adj2 = Rgb2((-todaysec+86400)/338/2+0, todaysec, 44000, 10000, 26000, 40) let adj3 = Rgb2((-todaysec+86400)/338/2+180, todaysec, 44000, 10000, 26000, 40) let adj4 = Rgb4(adjBG1, todaysec, 44000, 10000, 26000, -99, -99, -99, -99, 99) let adj5 = Rgb4(adjBG1A, todaysec, 44000, 10000, 26000, -99, -99, -99, -99, 99) let adj6 = Rgb4(adjBG2, todaysec, 44000, 10000, 26000, -99, -99, -99, -99, 99) let total .= printf(" | highlight htmlLink guifg=#%02x%02x%02x guibg=#%02x%02x%02x", adj1, adj2, adj3, adj4, adj5, adj6) execute total endfunction " name of permanent color scheme " but check in case user already has one if !exists("permanentColorScheme") let g:permanentColorScheme = "darkblue" endif " this prevents repeated calls to activate the permanent color scheme let g:bIveSetTheNonMovingScheme = 0 func HandleTextChanged() if &modified == 1 && g:bIveSetTheNonMovingScheme == 0 exe "colorscheme ".g:permanentColorScheme let g:bIveSetTheNonMovingScheme = 1 endif endfunction func GetTheTimeEffectMoving() call SetHighLight() let g:bIveSetTheNonMovingScheme = 0 endfunc au CursorHold * if &modified==0 | call SetHighLight() | endif au CursorHoldI * if &modified==0 | call SetHighLight() | endif au CursorMoved * call HandleTextChanged() au CursorMovedI * call HandleTextChanged() au BufWritePost * call GetTheTimeEffectMoving() plugin/changingColorHelp.txt [[[1 367 changingColorTags For Vim version 7.3 Last change: 2014 Oct 30 vim:tags=changingColorTags filetype=help autochdir scrolloff=6 foldcolumn=1 +-------------------+~ | The rgb parameter |~ +-------------------+~ the main guts is the R,G,B parameter. The calling end tries each R, g, then b paremeter at once. The function then adjusts this individual R, g, b as necessary and passes it is a result of the function. See |hourScale|. The parameters are the creative brain of the musician trying to use all his intuition to try and create groove looking elements and these intuitions are curbed with: a. considering the background: |actBgr| b. the "perceived" horrible parts where color is similar to background: |dngBgr|, c. how thick is the "horrible" area going towards dark: |senDar| d. how thick is the "horrible" area going towards light: |senLig| +--------+--------------------------+~ | senDar | SENitivity |TO| DARkness |~ +--------+--------------------------+~ this parameter could be anything between *0* - *86399* . At *86399* it means sensitive to everything. The key to this is |hourScale|. See also |dngBgr|. |senDar| specifies the thickness amount relative to |dngBgr|. This is in relation to |ramps|. The higher it is the more artificial compensation is done to maintain visibility Putting *10000* , *12000* means something like *13* - *16* % grey offset towards black from |dngBgr| so if background is within *13* - *16* % of |dngBgr| compensation will be applied +--------+---------------------------+~ | senLig | SENitivity |TO| LIGhtness | ~ +--------+---------------------------+~ same as |senDar| but from the light end not the dark end. If you're wondering what I mean the whole thing is based on a smoothly brightening background, and points within that brightness have to be defined to prevent clashes ocurring. See |shading| and |ramps|. See also |senDar| +--------+~ | dngBgr |~ +--------+~ the "dangerous" area where text is hard to read. It is a shade *0* - *86399* as determined by myself looking at it how easy it is to read across varous brightnesses. This I feel is it it's worst. E.g. let's say I found this item hard to read at *21000* . That is around *26* - *28* % in the background grey. This might be because a text is quite dark color anyway, maybe a dark red or something. Let's say I found particular text hard to read at around *70000* or around *85* % mark. This might be quite a bright letter, maybe a pink or similar, where the background is tending to be light as well +-----------+~ | hourScale |~ +-----------+~ The basic thing this plugin does is constantly force the background to change progressing the shade but doing it in such a way so as the |syntax| elements and the |shading| do not clash and hence cause interfere with the display of code. The |hourScale| and |shading| in reality are the same because depending on what point of the hour you are at the shading should be a certain shade from *0* % to *100* %, or black - white that the script has reached. Conveniently it is mapped to an hour so it appears to progress, although you see it as two hours squeezed into one |more| on that later. +----------------------------------------+~ | squeezing the hour into two half hours |~ +----------------------------------------+~ To make things useful I thought I'd just take a "second" hour and "press it" into a second half of the hour, with the first hour being pressed into the first half hour with the second hour reversed so that the |shading| appears to be smoothly going up then down. But note as far as all the shading of |syntax| elements and the |background| is concerned internally there *is* only one hour, *0* to *86399* . It does not affect the way |syntax| elements are colored inside. I just did some creative arithmetic to squeeze the first and second hour into one hour 1st half, 2nd half respectively but reversing the |shading| so that it appears smooth +--------+-----------------------------------------------------------+~ | actBgr | continually updating background, gets lighter and darker |~ +--------+-----------------------------------------------------------+~ See also |hourScale| Every ~10 secs the system calls back the main guts function of changing color and this causes every element of the syntax to be creatively recolored |actBgr| is always slightly more / less than before. |actBgr| is the overall "brightness" at this instance of the main call that takes place approx. ~10 secs For each syntax element, the R, G, and B parameter is creatively recolored. See [|creatively_recoloring_syntax_elements|] based on |actBgr| for this ~10 secs. call to the main function. |actBgr| has a range of *0* - *86399* with *0* = black, *86399* = white. I added a hack so that the *0* - *86399* black to white progression happens twice, the second time in reverse direction. see |this|. It doesn't really affect the way syntax elements are recolor though, |actBgr| gets manipulated just actually before the call to recolor all the elements. They think it's *0* - *86399* . Actually there is another hack to remove some of the *33%* of horrible grey shades in between, but again the "creative coloring" parts don't know about this. They think it's *0* - *86399* . Also I did think should this |actBgr| really be a "global" variable. [|should_actBgr_be_global|] +------------------------------------------+~ | the idea of shade to illustrate progress |~ +------------------------------------------+~ The whole idea is to every ~10 secs recolor every syntax element creatively slightly progressed shade of a general color. The idea is you sit there and you watch beautifully recoloring syntax elements dancing before your eyes. That was the theory anyway. I don't know if the practice ended up quite so great but some people seem to like it. I think it depends on what platform you're running Vim on. Vim on Windows is a bit rough around the ears. Linux/Mac seems to be it's native platform, and the Mac version "MacVim" is very nicely finished! The effect on that indeed looks impressive!! The main parameter of this is that of |actBgr| which starts at *0* and is updated automatically to *86399* . At the same time all the syntax elements are updated with a shade based on this percentage ( *0* - *86399* ). This would be brilliant apart from a certain |shading| of |actBgr| are going to make syntax elements useless as they are too hard to see at the original range. Remember also that |they|, the |syntax| elements are also being "progressed" so you can see there is really quite a lot going on. So to try to keep all this under control the |actBgr| and |dngBgr| were introduced. Related to this are |senDar| and |senLig|. Basically they help create little color ramps to allow them to jump "over one another" to avoid clash. +------------------+~ | visibility ramps |~ +------------------+~ The problem is that |actBgr| while it does make a great job of smoothly moving a lighter and lighter shades of background, it gets such a lot of tiny little shades in that it makes the text very difficult to see. This is where visibility |ramps| come in. Basically |ramps| allow you to specify a certain amount to be added to each *R,G,B* element of the syntax highlight to stop it becoming invisible by the oncoming |actBgr| which eventually covers all the shades from *black* to *white* . I sat there and studied how hard they became to read as the |actBgr| moved along and set |dngBgr| appropriately and set up ramps so they wouldn't clash. |dngBgr|, |senDar| and |senLig| are the main ones I used. These model the |ramps|. It's not that sophisticated yet works extremely well. The other parameters you might see like *loadj* , *hiadj* are just hints to the *RgbXxxxx()* function(s) on how to change, or |ramp| the colour's *RGB* settings, each one treated singly, litereally *R* , *G* , and then *B* . That's why the |Rgb| parameter is only one integer +----------------------------------------------+~ | low adjustment peppering, seasoning to taste |~ +----------------------------------------------+~ I know this is starting to sound funky, but I wanted to get through a flavour of what it was rather than appear too technical, because it's not really clever... no really it's just the flavouring done to the colour when it's close to that of |dngBgr|. This is at the low end, that is the dark color end. The hiadj is just the same done at the bright end. Basically when |actBgr| is close or at |dngBgr| remembering that |actBgr| is a forced continuation bright |shading| that goes on over time, exactly how close is determined by |senDar| or |senLig| in the |hiadj| case, then this is the amount of flavouring that is done to bring out the color a bit more to keep it visible. See? Simple really +-----------------------------------------------+~ | high adjustment peppering, seasoning to taste |~ +-----------------------------------------------+~ Just the same as |loadj| but for the bright part +---------------------+~ | The syntax elements |~ +---------------------+~ The syntax elements in VIM are all updated dynamically throughout the |hourScale| by the script. As far as I know everything is included. The good thing is that the syntax elements remain quite constant, no matter what language you're using. This is what makes this script work for languages as diverse as PHP, AutoIT, ActionScript, JavaScript and still works. Syntax elements can all be listed with: > :highlight < As you can see there's quite a few. The main ones are: *Normal* , *Comment* , *Statement* , *Constant* , *Special* , *Identifier* , and *Type* and I think there's a few others but these are important. +---------+~ | lotail1 |~ +---------+~ To be honest I can't even remember what this means. It was done during a bleak period when I was unemployed and had the Job Centre on my case and I was desperately trying to seem clever. Check back in a few months I might have remembered by then +---------+~ | lotail2 |~ +---------+~ Something to do with |lotail1| I suppose. Can't even remember my own code. :( +--------------+~ | ScaleToRange |~ +--------------+~ This is just something I "borrowed" from the web. The basic idea is it takes a number in a range extent e.g. r1 .. r2 and then "maps" it to a different range e.g. s1 .. s2, while still keeping it in the same proportion +--------+~ | adjVal |~ +--------+~ this is is in fact just the original |rgb| parameter being "adjusted" by the function. But a temporary name for it. +------------------------------+~ | General Explanation of Rgb2a |~ +------------------------------+~ A system generated callback causes the |actBgr| to be recalculated about every ~10 seconds. See |hourScale| What the user of this function is trying to do is trying to creatively recolor each element, but is running it by this function saying "that's pretty, can you check in case it's difficult to see please?" The |actBgr| parameter no.2 is the "actual Background" shade. This gets compared with the |rgb| parameter no.1 for brightness and the *result* is an adjusted |rgb| parameter if that brightness would make |rgb| difficult to see. +---------------------------------------+~ | Creatively Recoloring Syntax Elements |~ +---------------------------------------+~ We call the artists at this stage. They produce some great sounding paths, chords, rhymths well colors actually and they do it with these "helper" functions such as |Rgb2a|(). The purpose of the call is to check if the R, G, or B are causing the coloring to become difficult to see. Depending on the syntax element, the artist calls different "helper" function. This is because the "helper" functions don't just "check" and try to do the number crunching based on the creative parameters of the caller. The creativity is thus down to the caller. The different helpers such as |Rgb2a|() are the number crunchers that represent different effects, such as Whah Whah pedals, Echo chambers etc. Plus they check for harmotic distortions, or volume checks. (to use a Cubase analogy.) +-------------------------+~ | Should actBgr be Global |~ +-------------------------+~ Because the same value for |actBgr| is used about 500 times every ~10 secs when the main function is called, and yet it's the same value each ~10 sec call, what is the point in messing around passing it to helper functions so much? See the problem is there's no context in VimScript. If I put had |actBgr| in global variable, instead of requiring it to be passed many times to helper functions, it would improve efficiency but at the sacrifice of clarity. |actBgr| would just become another orphaned global variable. You might have many plugins your Vim. Some of these guys are greedy about their use of global memory space. Some are amazing but I have seen some who just like taking up VimSpace, directories, global memory areas.. no names. So that's why in the end I decided to not use global memory variables and that's why |actBgr| gets passed every time per every R, G, and B of each syntax element to be recolored to avoid clash with helper functions such as Rgb2a(). Of course I'm probably too stupid and should have realised that VimScript provides exactly this and I ignorantly carry on thinking I'm right. But that is how you are meant to learn if you're me. What can I do. I suck. I'm sorry. +------------------------------------------------+~ | So What's with this UpTheGamma() Business then |~ -------------------------------------------------+~ This seems rather posh for something that is for editing text. LOL It sounds like it's trying to be a Photographic Studio LOL LOL Yes truly sir, that's exactly what it is. Pretending to be a lot like something a bit neither here nor there eh Basically: [|this_is_the_function_concerned_here|] It's almost too shitty to try and describe it. Basically: [|this_question_here|] ...is taken for granted that the total color spectrum is 0..86398 and so therefore: [|this_magic_number_here|] ...as you can sort of see is approx. half-way between 0..86398 so: [|what_this_crudely_tries_to_do|] and: [|also_in_this_bit_here|] ...is to crudely cut out some of the range see: [|this_crude_multiplication_here|] ...disgustingly just cuts some of the range off and shoves it higher up and then: [|this_other_bit_here|] ...disgustingly just squashaes the other possibility of the number downwards so either way it's just chopping out loads of the range if you don't understand it's not a problem brother. It's gross. don't worry. In fact it's so gross that I've now decided to keep it switched off by default, see: [|ive_now_created_a_switch_for_this|] ...see so, at least a new user who's enjoying a nice effect won't get to see [|this_crude_multiplication_here|] and [|this_other_bit_here|] doing it's dirty business. Instead, they will experience a nice flow. So obviously all we need is a way to make sure this: [|switch_is_now_checked_to_see_if_really_wanted|] So only then is: [|this_hideous_call|] actually ever made, i.e. ONLY when: [|switch_is_now_checked_to_see_if_really_wanted|] So [|this_hideous_call|] will now never happen unless this [|ive_now_created_a_switch_for_this|] ..is actually set to true plugin/changingColorTags [[[1 37 General_Rgb2a changingColorHelp.txt /| General Explanation of Rgb2a | Rgb2a changingColor.vim /function Rgb2a Rgb4 changingColor.vim /function Rgb4( Rgb4a changingColor.vim /function Rgb4a ScaleToRange changingColorHelp.txt /| ScaleToRange | actBgr changingColorHelp.txt /| actBgr | adjVal changingColorHelp.txt /| adjVal | also_in_this_bit_here changingColor.vim /let result = result * 0.666\n\tendif background changingColorHelp.txt /| actBgr | creatively_recoloring_syntax_elements changingColorHelp.txt /| Creatively Recoloring Syntax Elements | dngBgr changingColorHelp.txt /| dngBgr | hiadj changingColorHelp.txt /| high adjustment peppering, seasoning to taste | hourScale changingColorHelp.txt /| hourScale | ive_now_created_a_switch_for_this changingColor.vim /let g\:upTheGamma_enable=0 loadj changingColorHelp.txt /| low adjustment peppering, seasoning to taste | lotail1 changingColorHelp.txt /| lotail1 | lotail2 changingColorHelp.txt /| lotail2 | more changingColorHelp.txt /| squeezing the hour into two half hours | ramp changingColorHelp.txt /| visibility ramps | ramps changingColorHelp.txt /| visibility ramps | rgb changingColorHelp.txt /| The rgb parameter | senDar changingColorHelp.txt /| senDar | senLig changingColorHelp.txt /| senLig | shading changingColorHelp.txt /| the idea of shade to illustrate progress | should_actBgr_be_global changingColorHelp.txt /| Should actBgr be Global | so___whatsWithThis_UpTheGamma_business___then changingColorHelp.txt /| So What's with this UpTheGamma() Business then | switch_is_now_checked_to_see_if_really_wanted changingColor.vim /if g:upTheGamma_enable syntax changingColorHelp.txt /| The syntax elements | they changingColorHelp.txt /| The syntax elements | this changingColorHelp.txt /| squeezing the hour into two half hours | this_crude_multiplication_here changingColor.vim /* 0.666\n\t\tlet result = result + 28 this_hideous_call changingColor.vim /let todaysec=UpTheGamma(todaysec) this_is_the_function_concerned_here changingColor.vim /function UpTheGamma( this_magic_number_here changingColor.vim /43199\n\t\tlet result = result this_other_bit_here changingColor.vim /* 0.666\n\tendif this_question_here changingColor.vim /if result>=43199\n\t\tlet result what_this_crudely_tries_to_do changingColor.vim /let result = result * 0.666 plugin/timer.vim [[[1 19 " +-----------------------------------------------------------------------------+ " | TIMER | " +-----------------------------------------------------------------------------+ " | START | " +-----------------------------------------------------------------------------+ " | The following 'script' does a sort of a 'timer' function like there is on | " | other programming environments in VIM. It relies on updatetime. If the | " | updatetime is set to 4000 for example it will wait and then execute after | " | 4 seconds. | " +-----------------------------------------------------------------------------+ " | REVISONS: | " | SUN 19TH SEP 2010: 1.0 | " | Initial revision. | " +-----------------------------------------------------------------------------+ autocmd CursorHold * call Timer() function! Timer() call feedkeys("f\e") endfunction