Permalink
Browse files

Better support for both 'light' and 'dard' backgrounds.

Added simple visual test scripts and 'Sleep' Event.
  • Loading branch information...
1 parent 67e88de commit ee21b40b460761beb5832446963e86e13cc2d5e4 megaannum committed Aug 14, 2012
Showing with 468 additions and 48 deletions.
  1. +13 −0 README.md
  2. +162 −38 autoload/forms.vim
  3. +7 −0 autoload/forms/dialog/colorchooser.vim
  4. +10 −0 autoload/forms/dialog/confirm.vim
  5. +7 −0 autoload/forms/dialog/filebrowser.vim
  6. +8 −0 autoload/forms/dialog/info.vim
  7. +8 −0 autoload/forms/dialog/input.vim
  8. +7 −0 autoload/forms/dialog/palletdesigner.vim
  9. +15 −0 autoload/forms/dialog/textsearch.vim
  10. +6 −0 autoload/forms/example/boxchars.vim
  11. +5 −0 autoload/forms/example/checkboxes.vim
  12. +5 −0 autoload/forms/example/deck1.vim
  13. +7 −2 autoload/forms/example/deck2.vim
  14. +45 −0 autoload/forms/example/demo.vim
  15. +6 −0 autoload/forms/example/dropshadow.vim
  16. +5 −0 autoload/forms/example/editors.vim
  17. +5 −0 autoload/forms/example/editors2.vim
  18. +5 −0 autoload/forms/example/fixedlayout.vim
  19. +6 −0 autoload/forms/example/form1.vim
  20. +6 −0 autoload/forms/example/form2.vim
  21. +5 −0 autoload/forms/example/foureditors.vim
  22. +5 −0 autoload/forms/example/frame.vim
  23. +6 −0 autoload/forms/example/labels.vim
  24. +5 −0 autoload/forms/example/labels2.vim
  25. +5 −0 autoload/forms/example/labels3.vim
  26. +5 −0 autoload/forms/example/labelsaligned.vim
  27. +5 −0 autoload/forms/example/labelsingrid.vim
  28. +5 −0 autoload/forms/example/labelvaligned.vim
  29. +5 −0 autoload/forms/example/longmenu.vim
  30. +6 −0 autoload/forms/example/menusubmenu.vim
  31. +5 −0 autoload/forms/example/popdownlist.vim
  32. +6 −0 autoload/forms/example/radiobuttons.vim
  33. +5 −1 autoload/forms/example/resize.vim
  34. +5 −0 autoload/forms/example/selectlists.vim
  35. +5 −0 autoload/forms/example/slider.vim
  36. +5 −0 autoload/forms/example/subform.vim
  37. +5 −0 autoload/forms/example/text.vim
  38. +5 −0 autoload/forms/example/texteditor.vim
  39. +6 −0 autoload/forms/example/togglebuttons.vim
  40. +5 −0 autoload/forms/example/vlabels.vim
  41. +13 −4 autoload/forms/menu.vim
  42. +13 −3 doc/forms.txt
View
@@ -203,6 +203,19 @@ all but Forms developers, at least for the non-power user, having
a short, easy to remember, mnemonic mapping for menu and popup is certainly
reasonable.
+Also, there is the function 'forms#example#demo#MakeTest()' which displays
+each of the demonstrations for 5 seconds using:
+
+ :call forms#example#demo#MakeTest()
+
+While this does not exercise any of the interactive demo; it simply renders
+each in turn, it is good to see if anything causes error messages or
+does not display at all. Its the beginning (maybe) of a more complete
+Event driven tests.
+
+One can also, choose a 'light' or 'dark' colorscheme prior to running
+the tests, just to see the differences.
+
# Supported Platforms
The Forms library ought to work on any platform where Vim has 256 colors
View
@@ -6,7 +6,7 @@
" Summary: Vim Form Library
" Author: Richard Emberson <richard.n.embersonATgmailDOTcom>
" Last Modified: 06/30/2012
-" Version: 1.2
+" Version: 1.3
" Modifications:
" 1.0 : initial public release.
"
@@ -139,63 +139,178 @@ endif
" Definitions: {{{2
" ------------------------------------------------------------
-if ! hlexists("HotSpotHi") || g:self#IN_DEVELOPMENT_MODE
- " ReverseHi must use same background color, ctermbg, as BackgroundHi
- :hi ReverseHi term=reverse cterm=reverse ctermbg=253 gui=reverse guibg=#dadada
+if &background == 'light'
+
+if has("gui_running")
-" TODO if &background == 'light' ... else ... endif
-if &t_Co == 256 || has("gui_running")
- :hi HotSpotHi cterm=NONE ctermbg=46 guibg=#00ff00
- :hi ReverseHotSpotHi cterm=reverse ctermbg=46 gui=reverse guibg=#00ff00
- :hi FlashHi cterm=NONE ctermbg=228 guibg=#ffff87
+ " ReverseHi must use same background color, ctermbg, as BackgroundHi
+ :hi ReverseHi gui=reverse guibg=#dadada
+ :hi HotSpotHi gui=NONE guibg=#00ff00
+ :hi ReverseHotSpotHi gui=reverse guibg=#00ff00
+ :hi FlashHi gui=NONE guibg=#ffff87
- :hi ToggleSelectionHi cterm=bold ctermbg=87 guibg=#5fffff
+ :hi ToggleSelectionHi gui=NONE guibg=#5fffff
- :hi SelectedHi cterm=bold ctermbg=87 gui=bold guibg=#5fffff
+ :hi SelectedHi gui=bold guibg=#5fffff
- :hi ButtonHi cterm=NONE ctermbg=250 guifg=#bcbcbc
- :hi ButtonFlashHi cterm=NONE ctermbg=243 guifg=#767676
+ :hi ButtonHi gui=NONE guibg=#bcbcbc
+ :hi ButtonFlashHi gui=NONE guibg=#767676
- " :hi BackgroundHi cterm=NONE ctermbg=255 guifg=#dadada
- " :hi BackgroundHi ctermfg=124 ctermbg=200 guifg=#dadada
- :hi BackgroundHi cterm=NONE ctermbg=253 guibg=#dadada
+ :hi BackgroundHi gui=NONE guibg=#dadada
" TODO derive FrameHi values from BackgroundHi values
- :hi FrameHi cterm=NONE ctermfg=254 ctermbg=252 guifg=#e4e4e4 guibg=#d0d0d0
+ :hi FrameHi gui=NONE guifg=#e4e4e4 guibg=#d0d0d0
" TODO derive DropShadowHi values from BackgroundHi values
- :hi DropShadowHi cterm=NONE ctermbg=253 ctermfg=250 guibg=#dadada guifg=#bcbcbc
+ :hi DropShadowHi gui=NONE guibg=#dadada guifg=#bcbcbc
+
+ :hi DisableHi gui=NONE guibg=#ffaf00
+
+ :hi MenuHi gui=NONE guibg=#dadada
+ :hi MenuMnemonicHi gui=underline guibg=#dadada
+
+ :hi MenuHotSpotHi gui=NONE guibg=#ff00d7
+ :hi MenuMnemonicHotSpotHi gui=underline guibg=#ff00d7
+
+elseif &t_Co == 256
+
+ :hi ReverseHi cterm=reverse ctermbg=253
+ :hi HotSpotHi cterm=NONE ctermbg=46
+ :hi ReverseHotSpotHi cterm=reverse ctermbg=46
+ :hi FlashHi cterm=NONE ctermbg=228
+
+ :hi ToggleSelectionHi cterm=bold ctermbg=87
+
+ :hi SelectedHi cterm=bold ctermbg=87
+
+ :hi ButtonHi cterm=NONE ctermbg=250
+ :hi ButtonFlashHi cterm=NONE ctermbg=243
+
+ :hi BackgroundHi cterm=NONE ctermbg=253
+
+ :hi FrameHi cterm=NONE ctermfg=254 ctermbg=252
+
+ :hi DropShadowHi cterm=NONE ctermbg=253 ctermfg=250
- :hi DisableHi cterm=NONE ctermbg=214 guifg=#ffaf00
+ :hi DisableHi cterm=NONE ctermbg=214
- :hi MenuHi cterm=None ctermbg=253 guifg=#dadada
- :hi MenuMnemonicHi cterm=underline ctermbg=253 guifg=#dadada
+ :hi MenuHi cterm=None ctermbg=253
+ :hi MenuMnemonicHi cterm=underline ctermbg=253
- " :hi MenuHotSpotHi cterm=None ctermbg=250 guifg=#bcbcbc
- :hi MenuHotSpotHi cterm=None ctermbg=200 guifg=#bcbcbc
- :hi MenuMnemonicHotSpotHi cterm=underline ctermbg=200 gui=underline guifg=#bcbcbc
+ :hi MenuHotSpotHi cterm=None ctermbg=200
+ :hi MenuMnemonicHotSpotHi cterm=underline ctermbg=200
-else
+else " t_Co < 256
+
+ " TODO: I have no idea if these values look ok
+ :hi ReverseHi cterm=reverse ctermbg=LightGrey
:hi HotSpotHi ctermbg=Green
+ :hi ReverseHotSpotHi cterm=reverse ctermbg=Green
:hi FlashHi ctermbg=LightYellow
:hi ToggleSelectionHi cterm=bold ctermbg=LightBlue
:hi SelectedHi cterm=bold ctermbg=LightBlue
- :hi ButtonHi cterm=NONE ctermbg=250
- :hi ButtonFlashHi cterm=NONE ctermbg=243
+ :hi ButtonHi cterm=NONE ctermbg=Grey
+ :hi ButtonFlashHi cterm=NONE ctermbg=DarkGrey
+
+ :hi BackgroundHi cterm=NONE ctermbg=LightGrey
+ :hi DisableHi cterm=NONE ctermbg=LightRed
- :hi BackgroundHi cterm=NONE ctermbg=253
- :hi DisableHi cterm=NONE ctermbg=214 guifg=#ffaf00
+ :hi MenuHi cterm=None ctermbg=LightGrey
+ :hi MenuMnemonicHi cterm=underline ctermbg=LightGrey
+ :hi MenuHotSpotHi cterm=None ctermbg=LightGrey
+ :hi MenuMnemonicHotSpotHi cterm=underline ctermbg=LightMagenta
- :hi MenuHi cterm=None ctermbg=253 guifg=#dadada
- :hi MenuMnemonicHi cterm=underline ctermbg=253 guifg=#dadada
- :hi MenuHotSpotHi cterm=None ctermbg=250 guifg=#bcbcbc
- :hi MenuMnemonicHotSpotHi cterm=underline ctermbg=200 guifg=#bcbcbc
endif
+
+else " &background == 'dark'
+
+if has("gui_running")
+
+ :hi ReverseHi gui=reverse guibg=#303030
+ :hi HotSpotHi gui=NONE guibg=#00ff00
+ :hi ReverseHotSpotHi gui=reverse guibg=#00ff00
+ :hi FlashHi gui=NONE guibg=#ffff87
+
+ :hi ToggleSelectionHi gui=bold guibg=#5fffff
+
+ :hi SelectedHi gui=bold guibg=#5fffff
+
+ :hi ButtonHi gui=NONE guibg=#585858
+ :hi ButtonFlashHi gui=NONE guibg=#9e9e9e
+
+ :hi BackgroundHi gui=NONE guibg=#303030
+
+ :hi FrameHi gui=NONE guifg=#3a3a3a guibg=#262626
+
+ :hi DropShadowHi gui=NONE guibg=#303030 guifg=#080808
+
+ :hi DisableHi gui=NONE guibg=#ffaf00
+
+ :hi MenuHi gui=None guibg=#303030
+ :hi MenuMnemonicHi gui=underline guibg=#303030
+
+ :hi MenuHotSpotHi gui=None guibg=#ff00d7
+ :hi MenuMnemonicHotSpotHi gui=underline guibg=#ff00d7
+
+elseif &t_Co == 256
+
+ :hi ReverseHi cterm=reverse ctermbg=236
+ :hi HotSpotHi cterm=NONE ctermbg=46
+ :hi ReverseHotSpotHi cterm=reverse ctermbg=46
+ :hi FlashHi cterm=NONE ctermbg=228
+
+ :hi ToggleSelectionHi cterm=bold ctermbg=87
+
+ :hi SelectedHi cterm=bold ctermbg=87
+
+ :hi ButtonHi cterm=NONE ctermbg=240
+ :hi ButtonFlashHi cterm=NONE ctermbg=247
+
+ " :hi BackgroundHi cterm=NONE ctermbg=253
+ :hi BackgroundHi cterm=NONE ctermbg=236
+
+ :hi FrameHi cterm=NONE ctermfg=237 ctermbg=235
+
+ :hi DropShadowHi cterm=NONE ctermbg=236 ctermfg=232
+
+ :hi DisableHi cterm=NONE ctermbg=214
+
+ :hi MenuHi cterm=None ctermbg=236
+ :hi MenuMnemonicHi cterm=underline ctermbg=236
+
+ :hi MenuHotSpotHi cterm=None ctermbg=200
+ :hi MenuMnemonicHotSpotHi cterm=underline ctermbg=200
+
+else " t_Co < 256
+
+ " TODO: I have no idea if these values look ok
+ :hi ReverseHi cterm=reverse ctermbg=DarkGrey
+ :hi HotSpotHi ctermbg=Green
+ :hi ReverseHotSpotHi cterm=reverse ctermbg=Green
+ :hi FlashHi ctermbg=LightYellow
+
+ :hi ToggleSelectionHi cterm=bold ctermbg=LightBlue
+
+ :hi SelectedHi cterm=bold ctermbg=LightBlue
+
+ :hi ButtonHi cterm=NONE ctermbg=Grey
+ :hi ButtonFlashHi cterm=NONE ctermbg=LightGrey
+
+ :hi BackgroundHi cterm=NONE ctermbg=DarkGrey
+ :hi DisableHi cterm=NONE ctermbg=DarkGrey
+
+ :hi MenuHi cterm=None ctermbg=DarkGrey
+ :hi MenuMnemonicHi cterm=underline ctermbg=DarkGrey
+ :hi MenuHotSpotHi cterm=None ctermbg=DarkGrey
+ :hi MenuMnemonicHotSpotHi cterm=underline ctermbg=LightMagenta
+
endif
+endif " background
+
" ------------------------------------------------------------
" CleanupHighlights: {{{2
@@ -587,7 +702,7 @@ endfunction
" Context
" Action: generate context help Form with application specific help/info
" and developer tools
-" data: optional Point [line, column]
+" Data: optional Point [line, column]
" The character <RightMouse> is mapped to Context
" Drag
" Action: none
@@ -626,14 +741,18 @@ endfunction
" changed size or gone from invisible to visible
" Select
" Action: change focus and possibly glyph specific sub-selection
-" data: Point [line, column]
+" Data: Point [line, column]
" SelectDouble
" Action: a left mouse double click occured
-" data: Point [line, column]
+" Data: Point [line, column]
" The mouse <2-LeftMouse> event is mapped to SelectDouble
+" Sleep
+" Action: Viewer Event handling sleeps for given time.
+" Data: time: Number (e.g., 10) or String (Number+'m' e.g., 200m)
+" Used for visual testing
" Submit
" Action: exit form with result data
-" data: results from form
+" Data: results from form
" Also used as top-of-stack return value for Viewer
" Special Key Types
" Down
@@ -9833,7 +9952,7 @@ function! forms#loadViewerPrototype()
if type(input) == g:self#DICTIONARY_TYPE
let event = input
-call forms#log("g:forms#Viewer.run EVENT=".string(event))
+" call forms#log("g:forms#Viewer.run EVENT=".string(event))
let type = event.type
if type == 'NextFocus'
@@ -10136,6 +10255,11 @@ endif
return event
endif
+ elseif type == 'Sleep'
+ let time = event.time
+" call forms#log("g:forms#Viewer.run Sleep time=".time)
+ execute 'sleep '.time
+
else
if exists('focus')
if focus.handleEvent(event)
@@ -32,6 +32,13 @@ function! forms#dialog#colorchooser#Make()
return forms#dialog#color#Make(0)
endfunction
+" forms#dialog#colorchooser#MakeTest: {{{1
+function! forms#dialog#colorchooser#MakeTest()
+ call forms#AppendInput({'type': 'Sleep', 'time': 5})
+ call forms#AppendInput({'type': 'Exit'})
+ call forms#dialog#colorchooser#Make()
+endfunction
+
" Modelines: {{{1
" ================
" vim: ts=4 fdm=marker
@@ -134,6 +134,16 @@ function! forms#dialog#confirm#Make(textlines, choices, def)
return 0
endfunction
+" forms#dialog#confirm#MakeTest: {{{1
+function! forms#dialog#confirm#MakeTest()
+ call forms#AppendInput({'type': 'Sleep', 'time': 5})
+ call forms#AppendInput({'type': 'Exit'})
+ let textlines = "User should pick one.\nCan be on multiple lines."
+ let choices = "Apple\nOrange\nPear\nPeach"
+ let def = 2
+ call forms#dialog#confirm#Make(textlines, choices, def)
+endfunction
+
" Modelines: {{{1
" ================
" vim: ts=4 fdm=marker
@@ -204,6 +204,13 @@ function! forms#dialog#filebrowser#Make(...)
return ''
endfunction
+" forms#dialog#filebrowser#MakeTest: {{{1
+function! forms#dialog#filebrowser#MakeTest()
+ call forms#AppendInput({'type': 'Sleep', 'time': 5})
+ call forms#AppendInput({'type': 'Exit'})
+ call forms#dialog#filebrowser#Make()
+endfunction
+
" Modelines: {{{1
" ================
" vim: ts=4 fdm=marker
@@ -66,6 +66,14 @@ function! forms#dialog#info#Make(textlines)
" call forms#log("forms#dialog#info#Make: bottom")
endfunction
+" forms#dialog#info#MakeTest: {{{1
+function! forms#dialog#info#MakeTest()
+ call forms#AppendInput({'type': 'Sleep', 'time': 5})
+ call forms#AppendInput({'type': 'Exit'})
+ let textlines = "Display some information.\nText can be on multiple lines."
+ call forms#dialog#info#Make(textlines)
+endfunction
+
" Modelines: {{{1
" ================
" vim: ts=4 fdm=marker
@@ -105,6 +105,14 @@ function! forms#dialog#input#Make(textlines, ...)
endif
endfunction
+" forms#dialog#input#MakeTest: {{{1
+function! forms#dialog#input#MakeTest()
+ call forms#AppendInput({'type': 'Sleep', 'time': 5})
+ call forms#AppendInput({'type': 'Exit'})
+ let textlines = "User should add requested input.\n\nCan be on multiple lines."
+ call forms#dialog#input#Make(textlines, 'some initial text')
+endfunction
+
" Modelines: {{{1
" ================
" vim: ts=4 fdm=marker
@@ -47,6 +47,13 @@ function! forms#dialog#palletdesigner#Make()
return forms#dialog#color#Make(1)
endfunction
+" forms#dialog#palletdesigner#MakeTest: {{{1
+function! forms#dialog#palletdesigner#MakeTest()
+ call forms#AppendInput({'type': 'Sleep', 'time': 5})
+ call forms#AppendInput({'type': 'Exit'})
+ call forms#dialog#palletdesigner#Make()
+endfunction
+
" Modelines: {{{1
" ================
" vim: ts=4 fdm=marker
Oops, something went wrong.

0 comments on commit ee21b40

Please sign in to comment.