Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 0.4.0

Big change was the addition of the ActWin (Action Window) which
is now the default window for both compiler errors (via Ensime or
SBT) and the uses-of-symbol-at-point command. Very configurable.
The quickfix window can still be use if desired via configuration.
Now Vimside supports either initialization with the Option files
'options_user.vim' and a project specific options file (and/) or
with Properties file 'vimside.properties' and a project specific
properties file. See the 'data/vimside/PROPERTIES' file for
available Properties (or, changing '.' to '-', Options).
Also, bumped (after a long time, the version number.
  • Loading branch information...
commit 537ec1981d5238f468c38c7eb34423c0d0d9ddc5 1 parent f6c395f
richard emberson authored committed
Showing with 28,710 additions and 1,873 deletions.
  1. +18 −8 README
  2. +320 −7 README.md
  3. +237 −180 autoload/vimside.vim
  4. +4,716 −0 autoload/vimside/actwin.vim
  5. +3,686 −0 autoload/vimside/actwin.vim.old
  6. +416 −0 autoload/vimside/color/eterm.vim
  7. +436 −0 autoload/vimside/color/konsole.vim
  8. +176 −0 autoload/vimside/color/rxvt.vim
  9. +168 −0 autoload/vimside/color/term.vim
  10. +271 −0 autoload/vimside/color/urxvt.vim
  11. +2,019 −0 autoload/vimside/color/util.vim
  12. +173 −0 autoload/vimside/color/xterm16.vim
  13. +612 −0 autoload/vimside/color/xterm256.vim
  14. +150 −0 autoload/vimside/color/xterm8.vim
  15. +279 −0 autoload/vimside/color/xterm88.vim
  16. +114 −1 autoload/vimside/command.vim
  17. +992 −0 autoload/vimside/command/debug.vim
  18. +12 −21 autoload/vimside/command/inspector.vim
  19. +49 −24 autoload/vimside/command/sbt.vim
  20. +1 −0  autoload/vimside/command/show_doc_symbol_at_point.vim
  21. +733 −4 autoload/vimside/command/show_errors_and_warning.vim
  22. +1 −0  autoload/vimside/command/typecheck_all.vim
  23. +798 −2 autoload/vimside/command/uses_of_symbol_at_point.vim
  24. +1 −0  autoload/vimside/ensime/io.vim
  25. +10 −16 autoload/vimside/ensime/swank.vim
  26. +4 −4 autoload/vimside/forms/optioneditor.vim
  27. +103 −0 autoload/vimside/highlight.vim
  28. +162 −4 autoload/vimside/hooks.vim
  29. +229 −0 autoload/vimside/locationlist.vim
  30. +31 −0 autoload/vimside/log.vim
  31. +0 −316 autoload/vimside/options/default.vim
  32. +4,061 −612 autoload/vimside/options/defined.vim
  33. +367 −134 autoload/vimside/options/manager.vim
  34. +462 −0 autoload/vimside/options/option.vim
  35. +389 −0 autoload/vimside/property.vim
  36. +209 −11 autoload/vimside/quickfix.vim
  37. +10 −10 autoload/vimside/scheduler.vim
  38. +720 −0 autoload/vimside/sign.vim
  39. +5 −1 autoload/vimside/swank/event/clear_all_java_notes.vim
  40. +5 −1 autoload/vimside/swank/event/clear_all_scala_notes.vim
  41. +0 −19 autoload/vimside/swank/event/debug_breakpoint.vim
  42. +0 −20 autoload/vimside/swank/event/debug_death.vim
  43. +0 −20 autoload/vimside/swank/event/debug_disconnect.vim
  44. +0 −20 autoload/vimside/swank/event/debug_exception.vim
  45. +0 −19 autoload/vimside/swank/event/debug_output.vim
  46. +0 −20 autoload/vimside/swank/event/debug_start.vim
  47. +0 −20 autoload/vimside/swank/event/debug_stop.vim
  48. +0 −20 autoload/vimside/swank/event/debug_thread_death.vim
  49. +0 −20 autoload/vimside/swank/event/debug_thread_start.vim
  50. +12 −2 autoload/vimside/swank/event/full_typecheck_finished.vim
  51. +1 −2  autoload/vimside/swank/event/indexer_ready.vim
  52. +2 −0  autoload/vimside/swank/event/java_notes.vim
  53. +2 −0  autoload/vimside/swank/event/scala_notes.vim
  54. +1 −5 autoload/vimside/swank/rpc/debug_active_vm.vim
  55. +4 −6 autoload/vimside/swank/rpc/debug_attach.vim
  56. +6 −2 autoload/vimside/swank/rpc/debug_backtrace.vim
  57. +1 −5 autoload/vimside/swank/rpc/debug_clear_all_breaks.vim
  58. +4 −6 autoload/vimside/swank/rpc/debug_clear_break.vim
  59. +4 −7 autoload/vimside/swank/rpc/debug_continue.vim
  60. +1 −5 autoload/vimside/swank/rpc/debug_list_breakpoints.vim
  61. +3 −1 autoload/vimside/swank/rpc/debug_locate_name.vim
  62. +4 −7 autoload/vimside/swank/rpc/debug_next.vim
  63. +1 −5 autoload/vimside/swank/rpc/debug_run.vim
  64. +4 −6 autoload/vimside/swank/rpc/debug_set_break.vim
  65. +3 −6 autoload/vimside/swank/rpc/debug_start.vim
  66. +10 −13 autoload/vimside/swank/rpc/debug_step.vim
  67. +10 −13 autoload/vimside/swank/rpc/debug_step_out.vim
  68. +22 −3 autoload/vimside/swank/rpc/debug_value.vim
  69. +5 −15 autoload/vimside/swank/rpc/repl_config.vim
  70. +2 −2 autoload/vimside/swank/rpc/symbol_at_point.vim
  71. +2 −108 autoload/vimside/swank/rpc/uses_of_symbol_at_point.vim
  72. +157 −2 autoload/vimside/util.vim
  73. +2 −2 autoload/vimside/version.vim
  74. +4,567 −0 data/vimside/PROPERTIES
  75. +49 −0 data/vimside/example_options_user.vim
  76. +194 −0 data/vimside/example_vimside.properties
  77. +2 −3 data/vimside/projects/sbt/build.sbt
  78. +2 −2 data/vimside/projects/sbt/options_project.vim
  79. +2 −0  data/vimside/projects/sbt/src/main/scala/com/megaannum/HW.scala
  80. +18 −0 data/vimside/projects/sbt/src/main/scala/com/megaannum/SW.scala
  81. +1 −1  data/vimside/projects/simple/options_project.vim
  82. +301 −22 data/vimside/tests/utils.vim
  83. +151 −86 doc/vimside.txt
  84. +15 −2 plugin/vimside.vim
View
26 README
@@ -1,15 +1,26 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=4298
-This is the alpha release of Vimside (Vim Scala IDE). Vimside is
+
+This is the alpha release of Vimside (Vim Scala IDE). Vimside is
built upon the ENSIME server: github: https://github.com/aemoncannon/ensime
-manual: http://aemoncannon.github.com/ensime/index.html
+manual: http://aemoncannon.github.com/ensime/index.html
Two outstanding Ensime features to be implemented are more
-regression tests and debugging.
-
-With this release, variable at bottom of the plugin/vimside.vim file
+regression tests and debugging. I also hope to port the latest
+verion of InSynth over to Ensime.
+
+With this release there has been added the ActWin (Action Window)
+which can be used to display compile errors (generated by either
+Ensime or SBT) (a quickfix window replacement) and the result of
+the command "use-of-symbol-at-point" can use the ActWin (rather
+than quickfix window). The ActWin is highly configurable.
+Also, User and Project Options can now be defined
+in Java-like properties files (rather than in the option.vim files).
+By default the
+
+With previous releases a variable at bottom of the plugin/vimside.vim file
have been added which allows one to turn on logging during Vimside Option
-loading. For the Vimside logger, Options must first be loaded
+loading. For the Vimside logger, Options must first be loaded
in order to configure it. Thus, no logging when loading Options.
So, I added a non-configurable logger that only logs in the
vimside#options#manager.vim file. Hopefully, this will help
@@ -21,7 +32,7 @@ and will be a couple more in the future. Additionally, the tests
have been moved under data/vimside/tests. I will be adding more
unit/regression tests in the future.
-I expect to continue to update the sources on github frequently, flushing
+I expect to continue to update the sources on github frequently, flushing
out the features. https://github.com/megaannum/vimside
Vimside communicates with the Ensime server using Shougo vimproc
@@ -148,7 +159,6 @@ Current Supported Ensime Commands:
Inline local.
Add import for type at point.
Import suggestions
-
Useful.
Implementations: 1
View
327 README.md
@@ -11,8 +11,8 @@ Most of the ENSIME capabilities have been implemented and
but it has only been tested against the
very small Scala/Java test source project bundled with it.
-Two outstanding Ensime features to be implemented are more
-regression tests and debugging.
+Three outstanding Ensime features to be implemented are more
+regression tests, debugging and InSynth integeration.
I added variable at bottom of the plugin/vimside.vim file
which allows one to turn on logging during Vimside Option
@@ -28,7 +28,323 @@ and will be a couple more in the future. Additionally, the tests
have been moved under data/vimside/tests. I will be adding more
unit/regression tests in the future.
-With lastest checkin, there is the first cut of the Type and
+## Latest checkin
+
+Now Vimside supports either initialization with the Option files
+'options_user.vim' and a project specific options file (and/) or
+with Properties file 'vimside.properties' and a project specific
+properties file. See the 'data/vimside/PROPERTIES' file for
+available Properties (or, changing '.' to '-', Options).
+Also, bumped (after a long time, the version number.
+
+Just checking in of a snapshot of work in progess: the actwin.vim
+(ActionWindow) code.
+
+Updated "sbt" project build.sbt example file and now allow Option
+enum values to be Vim patterns (e,g., vimside-scala-version == 2.10.*).
+
+ShowErrorAndWarning (Compiling by directly invoking the Scala compiler
+or via SBT) can use ActWin (the default) and is configurable with, again,
+a myriad of Options. The PROPERTIES file contains the new Options
+(see tailor-show-errors-and-warning-actwin-... Options).
+
+UsesOfSymbolAtPoint use of ActWin is now configurable with a
+myriad of Options (some 100 Options) covering definition of commands
+(mapping, command and abbreviations) controlling Scala and ActWin
+navigation; Options for how information is displayed in the Scala
+and ActWin windows and Options for highlights and signs.
+Now, by default, the "uses_of_symbol_at_point" uses the ActWin.
+For all available Options, see the newly added PROPERTIES file.
+Four new Option "kind"s have been defined supporting Option String
+types specialized for "commands", "highlight" definitions,
+highlight "group" names and "highlight" or "group" name.
+As examples (see PROPERTIES file), the (current) default value
+of 'tailor-actwin-display-actwin-cursor-line-highlight' is
+"cterm=bold ctermfg=DarkYellow ctermbg=Cyan" and the (current)
+default value of 'tailor-actwin-display-scala-color-line-kinds-marker-linehl'
+is "Search" (a highlight group name).
+In the future, rather than using the existing options_project.vim
+and options_user.vim files, Options will be able to be set
+using a (standard Java format) properties file. While some code
+to do this has been checkin, it has not been extensively tested.
+
+ActWin's behavior is defined by the client that creates an instance.
+
+The UsesOfSymbolAtPoint can now use ActWin (as alternate to Quickfix
+window).
+
+Options:
+'tailor-uses-of-symbol-at-point-window' : 'actwin' (default) or 'quickfix'
+
+Per use of the ActWin, there are numerous Options. For now this is
+an initial set that control how lines in Scala files and in the ActWin
+itself are highlighted:
+
+Use sign in Scala files (all lines highlighted at once):
+'tailor-uses-of-symbol-at-point-use-actwin-display-scala-sign-enable' : 0 or 1
+
+Use a (sign-based) color line in Scala files (current line only):
+'tailor-uses-of-symbol-at-point-use-actwin-display-scala-color-line-enable' : 0 or 1
+
+Use a color column in Scala files (current column only):
+'tailor-uses-of-symbol-at-point-use-actwin-display-scala-color-column-enable' : 0 or 1
+
+Use a cursor line in ActWin (current line only):
+'tailor-uses-of-symbol-at-point-use-actwin-display-actwin-cursor-line-enable' : 0 or 1
+
+Use a highlight line in ActWin (current line only):
+'tailor-uses-of-symbol-at-point-use-actwin-display-actwin-highlight-line-enable' : 0 or 1
+
+Use a (sign-based) color line in ActWin (current line only):
+'tailor-uses-of-symbol-at-point-use-actwin-display-actwin-sign-enable' : 0 or 1
+
+Ultimately all ActWin commands and highlight features (colors and text)
+will be Option based.
+
+
+
+Added delete entry commands to ActWin.
+Merged the options default.vim file into the defined.vim file.
+Added highlight parsing code.
+Changed functions to return error message rather than throw exceptions.
+Added cterm/gui color management code.
+Clean up DoToggleCmds function so that on exit mappings, commands
+and abbrs are removed.
+Fixed property file reader so that values can be Dictionaries.
+Toggling Actwin "scala" and "actwin" features can now be done
+with Option based :map, :cabbr and :command.
+Got color cursor toggling working.
+Got color cursor working.
+Invoking built-in command overrides no longer are placed in the
+command line history.
+Fixed both window/source display rendering.
+Scala window per-line sign highlighting option now supported.
+Fixed <F2>, <F3>, <F4> toggle keys.
+Options can now be defined in property files.
+
+Can print out current Options as properties.
+
+Added logging warning messages.
+
+Now property.vim file reading code mirrors Java's Properties code.
+
+Added property.vim which can convert properties to Options.
+
+Added "sign" base highlighting to actwin text.
+
+Generalized the definition and create to both "source" and "actwin"
+commands (keymap cmds, leader-based cmds and the redefinition of
+existing cmds using abbreviations).
+
+Added key_map, builtin_cmd and user_cmd "fasthelp" toggle displays
+using \<F2>, \<F3> and \<F4>.
+
+Added ActWin client-defined help and keymappings.
+
+Added multi-line content support.
+
+As an Option, the actwin will allow for an
+alternate way to visualize and act upon compiler error from standard
+quickfix; but, quickfix will, as an Option, still be available.
+Use of actwin is not documented nor does any code actually use it
+yet, but a flavor of how it might work can be seen by executing:
+
+ vimside#actwin#TestQuickFix()
+
+Go to the project: data/vimside/projects/simple,
+"vi src/main/scala/com/megaannum/Foo.scala" and then call the
+above function.
+
+See the functions:
+
+ MakeKeyMappings
+ MakeUserCommands
+ MakeOverrideCommands
+
+for some mappings.
+
+## Previous checkin
+
+Make sure when 'sign' definition is added via vimside#sign#AddCategory
+that the data has an 'ids' entry.
+Made sure that when a 'sign' Clear function is called that the associate
+id is removed from the 'ids' Dictionary.
+There is now an Option, 'sign-start-place-id' with default value 2656
+which is the value of the first 'sign' id. Subsequent ids are one greater
+than there predecessor.
+
+The latest checkin included an initial (un-tested and thus not usable)
+snapshot of the debug code along with a "sign" module that supports
+quickfix window, location window and debug breakpoint visualization.
+Each "sign" has (currently) three (manditory) attributes that can be set by
+the Vimside user: linehl, text and texthl (icon not support yet).
+A "sign" has a "kind" and a "category". For the quickfix window,
+compile errors, etc., the "category" is "QuickFix" and the "kinds"
+are "error", "warn", "info" and "marker". So, that is 4 kinds of
+signs where each sign has 3 attributes which means for "QuickFix" there
+are 12 Options that control how things can be displayed.
+The "LocationList" window category has two kinds: "info" and "marker" and,
+thus, has 6 Options. The "Debug" category has kinds: "active",
+"pasive" and "marker" for 9 Options - but, again, the debug code
+is untested.
+
+A "marker" kind is used to indicate the starting or current cursor position
+and can be enabled/disabled via Option for the 'uses of symbol at point'
+command.
+
+In addition, for each part of Vimside that can use the new sign feature
+there is an Option used to determine if signs should be generated.
+
+The new sign capability can be used during the display of QuickFix
+compile errors for both normal and SBT compiles. And, it can be used
+as part of the action "use of symbol at point" command
+
+ List all references to the symbol under the cursor.
+ autocmd FileType scala nmap <silent> <Leader>vr :call vimside#command#UsesOfSymbolAtPoint()<CR>
+
+New Options and default values:
+
+ quickfix
+
+ 'sign-quickfix-error-linehl' 'Error'
+ 'sign-quickfix-error-text' 'E>'
+ 'sign-quickfix-error-texthl' 'Todo'
+
+ 'sign-quickfix-warn-linehl' 'StatusLine'
+ 'sign-quickfix-warn-text' 'W>'
+ 'sign-quickfix-warn-texthl' 'Todo'
+
+ 'sign-quickfix-info-linehl' 'DiffAdd'
+ 'sign-quickfix-info-text' 'I>'
+ 'sign-quickfix-info-texthl' 'TODO'
+
+ 'sign-quickfix-marker-linehl' 'Search'
+ 'sign-quickfix-marker-text' 'M>'
+ 'sign-quickfix-marker-texthl' 'Ignore'
+
+ locationlist
+
+ 'sign-locationlist-info-linehl' 'DiffAdd'
+ 'sign-locationlist-info-text' 'I>'
+ 'sign-locationlist-info-texthl' 'TODO'
+
+ 'sign-locationlist-marker-linehl' 'Search'
+ 'sign-locationlist-marker-text' 'M>'
+ 'sign-locationlist-marker-texthl' 'Ignore'
+
+ debug
+
+ 'sign-debug-active-linehl' 'DiffText'
+ 'sign-debug-active-text' 'A>'
+ 'sign-debug-active-texthl' 'SpellCap'
+
+ 'sign-debug-pending-linehl' 'DiffAdd'
+ 'sign-debug-pending-text' 'P>'
+ 'sign-debug-pending-texthl' 'DiffDelete'
+
+ 'sign-debug-marker-linehl' 'Search'
+ 'sign-debug-marker-text' 'M>'
+ 'sign-debug-marker-texthl' 'Ignore'
+
+
+ sbt
+ tailor-sbt-use-signs '1'
+
+ show-errors-and-warnings
+ tailor-show-errors-and-warnings-use-signs '1'
+
+ full-typecheck-finished
+ tailor-full-typecheck-finished-use-signs '1'
+
+ uses-of-symbol-at-point
+ tailor-uses-of-symbol-at-point-use-signs '1'
+ tailor-uses-of-symbol-at-point-use-sign-kind-marker '1'
+
+ tailor-uses-of-symbol-at-point-window
+ quickfix (default)
+ mixed
+
+
+## Previous checkin
+
+With this checkin, there are features to expore running
+multiple Vim processes connected to the same Ensime Server.
+
+Vimside has been tested with multiple Vim processes. One Vim
+can start the Ensime Server (normal start command) and a second
+Vim editor (not window, but another Vim process) in the same
+project is asked to start the Ensime server ('\<Leader> vs'), it will find the
+Ensime port file and simply connect to the already running server.
+This seems to work with the caveats:
+
+ - If the configuration is to stop the server when Vim is exited,
+ then when the Vim editor that started the server exits, then
+ the server is stopped even if other Vim editor are still connected
+ to it. Have to implement some kind of Vim connection counter if
+ this becomes an issue.
+
+ - If the Ensime configuration file is changed between starting the
+ first and second Vim, things might not work (since the Ensime
+ server will only know about the configuration that the first
+ Vim process passed to it).
+
+If the configuration is that the Ensime server is not stopped when
+the launching Vim process is exited, then any Vim process that
+connects to the server can explicitly generate the stop server
+command ('\<Leader> vS') to kill the server (or using 'ps' and 'kill -9').
+
+Previously, when Vim stopped, the Ensime server was stopped
+(with a call to shut it down). Now, this is optional.
+There is a new Options 'ensime-shutdown-on-vim-exit' which if
+set to true (1), then the old behavior is seen; the Ensime server
+is shutdown when the Vim editor is exited. But, now if the
+Option is false (0), then when Vim stops, the Ensime server
+is not stopped. To stop the server one must explicitly issue the
+command:
+ nmap <silent> \<Leader>vS :call vimside#command#StopEnsime()<CR>
+This lets one save the running server between Vim sessions and, in
+addition, allows one to use multiple Vim processes to edit the
+same project's files. To enable this, Vimside was also changed so
+that if it finds an Ensime port file, rather than start Ensime
+it reads the file, gets the port, and tries to connect to Ensime.
+If this fails, then it starts Ensime.
+A note of caution, if you change your Ensime config file between
+Vim invocations but do not re-start the Ensime server, the second
+Vim invocation will be talking to an Ensime server which is out of sync.
+Default value for this Options is true, the old behavior -
+shutdown Ensime when Vim exits.
+
+Add Option 'vimside-log-file-use-pid'. If true then current Vim
+process id is a suffix to the log file name. Useful when you
+have more than one Vim process or if you are running a series
+of tests on Vimside code and wish to generate separate log file
+for each test. Default is false, no pid suffix.
+
+Add Option 'ensime-log-file-use-pid'. If true then the Ensime log
+file as a suffix has the process id of the Vim process that started
+it. Useful to coordinate Ensime log files with Vim process that
+launched the server. Default is false, no pid suffix.
+
+Removed the call to vimside#scheduler#ClearAuto during
+shutdown; the function did not exist.
+
+The Option 'tailor-sbt-error-read-size' is used as the size of
+the socket buffer used to read results returned by a SBT compile
+request. This should be large enough to read all of the errors.
+If it is too small, then only a partial read occurs and the
+code that converts the errors to Quickfix window entries may
+fail. Default value is 10000 which, hopefully, is big enough for
+most SBT compile error results.
+
+The Option 'vimside-port-file-wait-time' is the time to wait
+after starting the Ensime Server before attempting to read the
+port file generated by the server (the port is the server socket
+port). Default is 4 seconds, but anywhere from 0 to 5 seconds might
+be OK.
+
+## Type Inspector checkin
+
+An earlier checkin, there is the first cut of the Type and
Package Inspector. There will certainly be bugs.
For types, place cursor over type and enter \<Leader>ti.
For package, place cursor over package path and enter \<Leader>tp.
@@ -404,9 +720,8 @@ copy `example_options_user.vim` to `options_user.vim`.
> cd $HOME/.vim/data/vimside
> /bin/cp example_options_user.vim options_user.vim
-Then, in `options_user.vim` uncomment the following two lines:
+Then, in `options_user.vim` uncomment the following line:
- call a:option.Set("test-ensime-file-use", 1)
call a:option.Set("ensime-config-file-name", "ensime_config.vim")
This tells Vimside to use the test project code and to use the
@@ -502,8 +817,6 @@ basis), but enabling the above Option is all that is need in this file.
" To run against ensime test project code
" Location of test directory
call owner.Set("test-ensime-file-dir", s:full_dir)
- " Uncomment to run against demonstration test code
- call owner.Set("test-ensime-file-use", 1)
" The Ensime Config information is in a file called 'ensime_config.vim'
call owner.Set("ensime-config-file-name", "ensime_config.vim")
"--------------
View
417 autoload/vimside.vim
@@ -162,159 +162,271 @@ function! vimside#EnsimeConfigLoad(filename)
endfunction
function! vimside#PreStart()
- if ! g:vimside.pre_started
- " Ok, are all of the plugins we need avaiable
- call vimside#vimplugins#Check()
+ if g:vimside.pre_started
+ return
+ endif
- if len(g:vimside.errors) != 0
- throw "Plugin Error: ". string(g:vimside.errors)
- endif
+ " Ok, are all of the plugins we need avaiable
+ call vimside#vimplugins#Check()
- " Next, load options
- call vimside#options#manager#Load()
+ if len(g:vimside.errors) != 0
+ throw "Plugin Error: ". string(g:vimside.errors)
+ endif
- if len(g:vimside.errors) != 0
- throw "Option Load Errors: ". string(g:vimside.errors)
- endif
+ " Next, load options
+ call vimside#options#manager#Load()
+ if len(g:vimside.errors) != 0
+ throw "Option Load Errors: ". string(g:vimside.errors)
+ endif
- " Next, load event handlers
- call vimside#ensime#swank#load_handlers()
- if len(g:vimside.errors) != 0
- throw "Load Handlers Errors: ". string(g:vimside.errors)
- endif
+ " Next, load event handlers
+ call vimside#ensime#swank#load_handlers()
- " Now, load rpc and event ping info
- call vimside#ensime#swank#load_ping_info()
+ if len(g:vimside.errors) != 0
+ throw "Load Handlers Errors: ". string(g:vimside.errors)
+ endif
- if len(g:vimside.errors) != 0
- throw "Load Ping Info Errors: ". string(g:vimside.errors)
- endif
+ " Now, load rpc and event ping info
+ call vimside#ensime#swank#load_ping_info()
- let g:vimside.pre_started = 1
+ if len(g:vimside.errors) != 0
+ throw "Load Ping Info Errors: ". string(g:vimside.errors)
endif
+
+ let g:vimside.pre_started = 1
+
endfunction
+"
+" Main entry point
+"
function! vimside#StartEnsime()
- if ! g:vimside.started
- let msg = "Starting Ensime Engine ..."
+ if g:vimside.started
+call s:LOG("vimside#StartEnsime Ensime Engine Already Running")
+ let msg = "Ensime Engine Already Running ..."
call vimside#cmdline#Display(msg)
+ return
+ endif
+
+ let msg = "Starting Ensime Engine ..."
+ call vimside#cmdline#Display(msg)
- call vimside#PreStart()
+ call vimside#PreStart()
+call s:LOG("vimside#StartEnsime after vimside#PreStart")
- call vimside#StartEnsimeServer()
+ " How long to sleep after starting Ensime Server before
+ " trying to read ther port file (written by server)
+ " 2 to 4 seconds is about right
+ let [found, wtime] = g:vimside.GetOption('vimside-port-file-wait-time')
+ if found
+ let l:wait_time = wtime
+ else
+ let l:wait_time = 4
+ endif
+
+ let l:try_again_attempts = 2
+ let l:try_again = 1
+ while l:try_again
+
+ let l:try_again = 0
+
+ let l:had_to_start = vimside#StartEnsimeServer()
+call s:LOG("vimside#StartEnsime had_to_start=". l:had_to_start)
let g:vimside.started = 1
-sleep 4
+ execute "sleep ". l:wait_time
call vimside#GetPortEnsime()
- let l:name = "ping_ensime_server"
- let l:Func = function("vimside#PingEnsimeServer")
- let l:sec = 1
- let l:msec = 0
- let l:charcnt = 200
- let l:repeat = 1
- call vimside#scheduler#AddJob(l:name, l:Func, l:sec, l:msec, l:charcnt, l:repeat)
-
-sleep 2
call s:LOG("vimside#StartEnsime get connection")
- let g:vimside['socket'] = vimside#GetConnectionSocketEnsime()
+ try
+ let [found, socket] = vimside#GetConnectionSocketEnsime()
+ if found
+" call s:LOG("vimside#StartEnsime set vimside socket")
+ let g:vimside['socket'] = socket
+ endif
+ catch /.*/
+ call s:ERROR("vimside#StartEnsime socket connect:". v:exception)
+ if ! l:had_to_start
+ " maybe a bad port file
+ let [found, portfile] = g:vimside.GetOption('ensime-port-file-path')
+ if found
+ call delete(portfile)
+ if l:try_again_attempts > 0
+ let l:try_again_attempts -= 1
+ let l:try_again = 1
+ endif
+ endif
+ endif
+ endtry
+
+ endwhile
+
+ " Test to see if we shutdown Ensime when we exit Vim
+ let [s:found, l:auto_shutdown] = g:vimside.GetOption('ensime-shutdown-on-vim-exit')
+ if ! s:found
+ echoerr "Option not found: "'ensime-shutdown-on-vim-exit'"
+ elseif l:auto_shutdown
+call s:LOG("vimside#StartEnsime Register vimside#StopEnsime")
+ call vimside#hooks#AddHook('VimLeave', function("vimside#StopEnsime"))
+
+ endif
+
+
+call s:LOG("vimside#StartEnsime register pinger")
+ let l:name = "ping_ensime_server"
+ let l:Func = function("vimside#PingEnsimeServer")
+ let l:sec = 1
+ let l:msec = 0
+ let l:charcnt = 200
+ let l:repeat = 1
+ call vimside#scheduler#AddJob(l:name, l:Func, l:sec, l:msec, l:charcnt, l:repeat)
+" sleep 2
+
call s:LOG("vimside#StartEnsime call vimside#swank#rpc#connection_info#Run")
- call vimside#swank#rpc#connection_info#Run()
+ call vimside#swank#rpc#connection_info#Run()
+ if l:had_to_start
call s:LOG("vimside#StartEnsime call vimside#swank#rpc#init_project#Run")
call vimside#swank#rpc#init_project#Run()
-
-call s:LOG("vimside#StartEnsime call vimside#hooks#StartAutoCmd")
- call vimside#hooks#StartAutoCmd()
- else
- let msg = "Ensime Engine Already Running ..."
- call vimside#cmdline#Display(msg)
endif
+
+ " REMOVE
+"call s:LOG("vimside#StartEnsime call vimside#hooks#StartAutoCmd")
+ " call vimside#hooks#StartAutoCmd()
+" call s:LOG("vimside#StartEnsime call vimside#hooks#AssciateHooksAutoCmd")
+" call vimside#hooks#AssciateHooksAutoCmd()
+
+call s:LOG("vimside#StartEnsime call vimside#hooks#Run('PostStartUp')")
+ call vimside#hooks#Run('PostStartUp')
+
+call s:LOG("vimside#StartEnsime BOTTOM")
endfunction
function! vimside#StopEnsime()
- if g:vimside.started
-" XXXXXXXXXXXXX
- call vimside#hooks#StopAutoCmd()
+ if ! g:vimside.started
+ endif
- " call vimside#RemoveAutoCmds()
- vimside#scheduler#ClearAuto()
- call vimside#swank#rpc#shutdown_server#Run()
+ call vimside#hooks#Run('PreShutDown')
- call vimside#ensime#io#close()
- let g:vimside.started = 0
- endif
+" XXXXXXXXXXXXX REMOVE
+ " call vimside#hooks#StopAutoCmd()
+ "call vimside#scheduler#StopAuto()
+
+
+ " call vimside#RemoveAutoCmds()
+ " vimside#scheduler#ClearAuto()
+
+ call vimside#swank#rpc#shutdown_server#Run()
+
+ call vimside#ensime#io#close()
+
+ let g:vimside.started = 0
endfunction
+" return 0 port file already exists, so Ensime server already running
+" return 1 port file does not exist, so start Ensime server
function! vimside#StartEnsimeServer()
let [found, portfile] = g:vimside.GetOption('ensime-port-file-path')
if ! found
echoerr "Option not found: "'ensime-port-file-path'"
+ return 0
endif
call s:LOG("vimside#StartEnsimeServer portfile=" . portfile)
let [found, dpath] = g:vimside.GetOption('ensime-dist-path')
if ! found
echoerr "Option not found: "'ensime-dist-path'"
+ return0
endif
- let cmd = 'cd ' . dpath . ' && ./bin/server ' . shellescape(portfile)
+ let portFileExists = filereadable(portfile)
+call s:LOG("vimside#StartEnsimeServer portFileExists=". portFileExists)
- let [s:found, l:log_enabled] = g:vimside.GetOption('ensime-log-enabled')
- if ! s:found
- echoerr "Option not found: "'ensime-log-enabled'"
- endif
+ if portFileExists
+ return 0
+ else
+
+ let cmd = 'cd ' . dpath . ' && ./bin/server ' . shellescape(portfile)
-" echo "StartEnsimeServer: log_enabled=" . l:log_enabled
- if l:log_enabled
- let lines = [
- \ "##################################################################",
- \ "Title: Ensime Server log file",
- \ "Date: " . strftime("%Y%m%d %T"),
- \ "##################################################################"
- \ ]
-
- let [found, l:logfile] = g:vimside.GetOption('ensime-log-file-path')
- if ! found
- echoerr "Option not found: "'ensime-log-file-path'"
+ let [s:found, l:log_enabled] = g:vimside.GetOption('ensime-log-enabled')
+ if ! s:found
+ echoerr "Option not found: "'ensime-log-enabled'"
endif
- call writefile(lines, l:logfile)
+ " echo "StartEnsimeServer: log_enabled=" . l:log_enabled
+ if l:log_enabled
+ let [found, l:logfile] = g:vimside.GetOption('ensime-log-file-path')
+ if ! found
+ echoerr "Option not found: "'ensime-log-file-path'"
+ else
+ let [s:found, s:use_pid] = g:vimside.GetOption('ensime-log-file-use-pid')
+ if s:found
+ if s:use_pid
+ let l:logfile .= "_". getpid()
+ endif
+ else
+ echoerr "Option not found: " . 'ensime-log-file-use-pid'
+ endif
+ endif
+
- execute "silent !" . cmd . " &>> " . l:logfile . " &"
+ let separator = repeat("-", 80)
+ let l:lines = [
+ \ separator,
+ \ 'Title: Ensime Server log file',
+ \ 'Date: ' . strftime("%Y%m%d %T"),
+ \ separator
+ \ ]
+
+ for line in l:lines
+ execute "silent !echo \"". line . "\" >> ". l:logfile
+ endfor
+
+ " bash pre-4.0
+ " cmd >> outfile 2>&1
+ execute "silent !" . cmd . " >> " . l:logfile . " 2>&1 &"
+
+ " bash post-4.0
+ " execute "silent !" . cmd . " &>> " . l:logfile . " &"
- else
- " TODO remove
- " if has('win16') || has('win32') || has('win64')
-
- if g:vimside.os.is_mswin
- " Note: do not know if this is correct
- let l:logfile = "NUL"
else
- let l:logfile = "/dev/null"
- endif
+
+ if g:vimside.os.is_mswin
+ " Note: do not know if this is correct
+ let l:logfile = "NUL"
+ else
+ let l:logfile = "/dev/null"
+ endif
- execute "silent !" . cmd . " &> " . l:logfile . " &"
+ execute "silent !" . cmd . " &> " . l:logfile . " &"
+ endif
endif
+call s:LOG("vimside#StartEnsimeServer Ensime launched")
+ return 1
+
endfunction
function! vimside#GetPortEnsime()
call s:LOG("vimside#GetPortEnsime TOP")
let [found, portfile] = g:vimside.GetOption('ensime-port-file-path')
if ! found
- echoerr "Option not found: "'ensime-port-file-path'"
+ let msg = "Option not found: "'ensime-port-file-path'"
+ echoerr msg
+ throw msg
endif
" wait for port file to be created and written to
let cnt = 0
let [found, max_cnt] = g:vimside.GetOption('ensime-port-file-max-wait')
if ! found
- echoerr "Option not found: "'ensime-port-file-max-wait'"
+ let msg = "Option not found: "'ensime-port-file-max-wait'"
+ echoerr msg
+ throw msg
endif
call s:LOG("vimside#GetPortEnsime max_cnt=" . max_cnt)
@@ -324,18 +436,22 @@ call s:LOG("vimside#GetPortEnsime max_cnt=" . max_cnt)
endwhile
if ! filereadable(portfile)
- echoerr "Vimside Failed to start Ensime Server port file does not exists"
+ let msg = "Vimside Failed to start Ensime Server port file does not exists"
+ echoerr msg
+ throw msg
endif
let portfile_lines = readfile(portfile)
if len(portfile_lines) != 1
- echoerr "Vimside Ensime Server port file not single line: " . string(portfile_lines)
+ let msg = "Vimside Ensime Server port file not single line: " . string(portfile_lines)
+ echoerr msg
+ throw msg
endif
let portstr = portfile_lines[0]
let port = 0 + portstr
- call g:vimside.SetOption('ensime_port_number', port)
-call s:LOG("vimside#GetPortEnsime BOTTOM")
+call s:LOG("vimside#GetPortEnsime port=". port)
+ call g:vimside.UpdateOption('ensime_port_number', port)
endfunction
function! vimside#GetConnectionSocketEnsime()
@@ -344,18 +460,20 @@ call s:LOG("vimside#GetConnectionSocketEnsime TOP")
let [found, port] = g:vimside.GetOption('ensime_port_number')
if ! found
echoerr "Option not found: "'ensime_port_number'"
+ return [0, ""]
endif
let [found, host] = g:vimside.GetOption('ensime-host-name')
if ! found
echoerr "Option not found: "'ensime-host-name'"
+ return [0, ""]
endif
-call s:LOG("host:port=" . host .":". port)
+call s:LOG("vimside#GetConnectionSocketEnsime host:port=" . host .":". port)
let l:socket = vimside#ensime#io#open(host, port)
-" call s:LOG("socket=" . string(l:socket))
- return l:socket
+call s:LOG("socket=" . string(l:socket))
+ return [1, l:socket]
endfunction
" ============================================================================
@@ -365,106 +483,45 @@ endfunction
function! vimside#PingEnsimeServer()
call s:LOG("vimside#PingEnsimeServer")
let timeout = g:vimside.ping.info.read_timeout
+call s:LOG("vimside#PingEnsimeServer: timeout=". timeout)
let success = vimside#ensime#io#ping(timeout)
while success
let success = vimside#ensime#io#ping(timeout)
endwhile
endfunction
-if 0 " YYYYYYYYYYYYYYY
-" ============================================================================
-" Completion code
-" ============================================================================
-"
-" 1) get completions
-" GetCompletions
-" 2) display completions
-" DisplayCompletions
-"
-"
-let s:completions_phase = 0
-let g:completions_in_process = 0
-let s:completions_start = 0
-let g:completions_base = ''
-let g:completions_results = []
-function! vimside#Completions(findstart, base)
-" call s:LOG("vimside#Completions findstart=". a:findstart .", base=". a:base)
- if ! g:vimside.started
- return
- endif
-" call s:LOG("vimside#Completions completions_phase=". s:completions_phase)
-
- if s:completions_phase == 0
- " Get Completions
- if a:findstart
- let g:completions_in_process = 1
- w
- let line = getline('.')
- let pos = col('.') -1
- let bc = strpart(line,0,pos)
- let match_text = matchstr(bc, '\zs[^ \t#().[\]{}\''\";: ]*$')
-" call s:LOG("vimside#Completions match_text=". match_text)
- let s:completions_start = len(bc)-len(match_text)
-" call s:LOG("vimside#Completions completions_start=". s:completions_start)
- call vimside#StartAutoCmdCompletions()
- return s:completions_start
- elseif ! g:completions_in_process
- return []
- else
- if len(a:base) > 0
- let g:completions_base = a:base
- let g:completions_results = []
- call vimside#swank#rpc#completions#Run()
- let s:completions_phase = 1
- else
- let s:completions_phase = 0
- endif
-" call s:LOG("vimside#Completions return []")
- return []
- endif
- elseif ! g:completions_in_process
- if a:findstart
- return ''
- else
- return []
- endif
- else
- " Display Completions
- if a:findstart
-" call s:LOG("vimside#Completions completions_start=". s:completions_start)
- return s:completions_start
+" ============================================================================
+" Signal an event. Send to testing harness if it exists.
+" Used to drive asynchronous regression tests.
+" event optional value
+" ============================================================================
+function! vimside#EventSignal(event, ...)
+ if exists("g:vimside.test.signal")
+ if if a:0 == 1
+ call g:vimside.test.signal(a:event, a:1)
else
- let s:completions_phase = 0
- let g:completions_base = ''
-" call s:LOG("vimside#Completions g:completions_results=". string(g:completions_results))
- let g:completions_in_process = 0
- call vimside#StopAutoCmdCompletions()
- return g:completions_results
+ call g:vimside.test.signal(a:event)
endif
-
endif
endfunction
-function! vimside#AbortCompletions()
-" call s:LOG("vimside#AbortCompletions")
- if pumvisible() == 0
- let s:completions_phase = 0
- let g:completions_in_process = 0
- call vimside#StopAutoCmdCompletions()
- endif
-endfunction
+" ============================================================================
+" Register Hooks
+" ============================================================================
-function! vimside#StartAutoCmdCompletions()
- augroup VIMSIDE_COMPLETIONS
- au!
- autocmd CursorMovedI,InsertLeave *.scala call vimside#AbortCompletions()
- augroup end
-endfunction
-function! vimside#StopAutoCmdCompletions()
- augroup VIMSIDE_COMPLETIONS
- au!
- augroup END
-endfunction
-endif " YYYYYYYYYYYYYYY
+call vimside#hooks#AddHook('PostStartUp', function("vimside#hooks#AssciateHooksAutoCmd"))
+
+call vimside#hooks#AddHook('PostBufferRead', function("vimside#command#TypecheckFileOnWrite"))
+call vimside#hooks#AddHook('PostBufferWrite', function("vimside#command#TypecheckFileOnWrite"))
+call vimside#hooks#AddHook('PostBufferWrite', function("vimside#command#BuilderTrackFile"))
+
+" ---------------------------------
+" these two pairs have some overlap
+" ---------------------------------
+call vimside#hooks#AddHook('PreShutDown', function("vimside#hooks#ClearHooksAutoCmd"))
+call vimside#hooks#AddHook('PreShutDown', function("vimside#scheduler#StopAuto"))
+call vimside#hooks#AddHook('VimLeave', function("vimside#hooks#ClearHooksAutoCmd"))
+call vimside#hooks#AddHook('VimLeave', function("vimside#hooks#ClearHooksAutoCmd"))
+call vimside#hooks#AddHook('VimLeave', function("vimside#scheduler#StopAuto"))
View
4,716 autoload/vimside/actwin.vim
4,716 additions, 0 deletions not shown
View
3,686 autoload/vimside/actwin.vim.old
3,686 additions, 0 deletions not shown
View
416 autoload/vimside/color/eterm.vim
@@ -0,0 +1,416 @@
+" ============================================================================
+" eterm.vim
+"
+" File: eterm.vim
+" Summary: ETerm (part of Forms Library)
+" Author: Richard Emberson <richard.n.embersonATgmailDOTcom>
+" ============================================================================
+
+" ------------------------------------------------------------
+" Define Int256_2_RGB Dictionary: {{{2
+" Refs:
+" http://www.gnu-darwin.org/www001/src/ports/x11/eterm/work/Eterm-0.9.4/src/term.c.html
+" ------------------------------------------------------------
+let s:Int256_2_RGB = {
+ \ '0': '000000',
+ \ '1': 'cc0000',
+ \ '2': '00cc00',
+ \ '3': 'cccc00',
+ \ '4': '0000cc',
+ \ '5': 'cc00cc',
+ \ '6': '00cccc',
+ \ '7': 'aaaaaa',
+ \ '8': '333333',
+ \ '9': 'ff0000',
+ \ '10': '00ff00',
+ \ '11': 'ffff00',
+ \ '12': '0000ff',
+ \ '13': 'ff00ff',
+ \ '14': '00ffff',
+ \ '15': 'ffffff',
+ \ '16': '000000',
+ \ '17': '00002a',
+ \ '18': '000055',
+ \ '19': '00007f',
+ \ '20': '0000aa',
+ \ '21': '0000d4',
+ \ '22': '002a00',
+ \ '23': '002a2a',
+ \ '24': '002a55',
+ \ '25': '002a7f',
+ \ '26': '002aaa',
+ \ '27': '002ad4',
+ \ '28': '005500',
+ \ '29': '00552a',
+ \ '30': '005555',
+ \ '31': '00557f',
+ \ '32': '0055aa',
+ \ '33': '0055d4',
+ \ '34': '007f00',
+ \ '35': '007f2a',
+ \ '36': '007f55',
+ \ '37': '007f7f',
+ \ '38': '007faa',
+ \ '39': '007fd4',
+ \ '40': '00aa00',
+ \ '41': '00aa2a',
+ \ '42': '00aa55',
+ \ '43': '00aa7f',
+ \ '44': '00aaaa',
+ \ '45': '00aad4',
+ \ '46': '00d400',
+ \ '47': '00d42a',
+ \ '48': '00d455',
+ \ '49': '00d47f',
+ \ '50': '00d4aa',
+ \ '51': '00d4d4',
+ \ '52': '2a0000',
+ \ '53': '2a002a',
+ \ '54': '2a0055',
+ \ '55': '2a007f',
+ \ '56': '2a00aa',
+ \ '57': '2a00d4',
+ \ '58': '2a2a00',
+ \ '59': '2a2a2a',
+ \ '60': '2a2a55',
+ \ '61': '2a2a7f',
+ \ '62': '2a2aaa',
+ \ '63': '2a2ad4',
+ \ '64': '2a5500',
+ \ '65': '2a552a',
+ \ '66': '2a5555',
+ \ '67': '2a557f',
+ \ '68': '2a55aa',
+ \ '69': '2a55d4',
+ \ '70': '2a7f00',
+ \ '71': '2a7f2a',
+ \ '72': '2a7f55',
+ \ '73': '2a7f7f',
+ \ '74': '2a7faa',
+ \ '75': '2a7fd4',
+ \ '76': '2aaa00',
+ \ '77': '2aaa2a',
+ \ '78': '2aaa55',
+ \ '79': '2aaa7f',
+ \ '80': '2aaaaa',
+ \ '81': '2aaad4',
+ \ '82': '2ad400',
+ \ '83': '2ad42a',
+ \ '84': '2ad455',
+ \ '85': '2ad47f',
+ \ '86': '2ad4aa',
+ \ '87': '2ad4d4',
+ \ '88': '550000',
+ \ '89': '55002a',
+ \ '90': '550055',
+ \ '91': '55007f',
+ \ '92': '5500aa',
+ \ '93': '5500d4',
+ \ '94': '552a00',
+ \ '95': '552a2a',
+ \ '96': '552a55',
+ \ '97': '552a7f',
+ \ '98': '552aaa',
+ \ '99': '552ad4',
+ \ '100': '555500',
+ \ '101': '55552a',
+ \ '102': '555555',
+ \ '103': '55557f',
+ \ '104': '5555aa',
+ \ '105': '5555d4',
+ \ '106': '557f00',
+ \ '107': '557f2a',
+ \ '108': '557f55',
+ \ '109': '557f7f',
+ \ '110': '557faa',
+ \ '111': '557fd4',
+ \ '112': '55aa00',
+ \ '113': '55aa2a',
+ \ '114': '55aa55',
+ \ '115': '55aa7f',
+ \ '116': '55aaaa',
+ \ '117': '55aad4',
+ \ '118': '55d400',
+ \ '119': '55d42a',
+ \ '120': '55d455',
+ \ '121': '55d47f',
+ \ '122': '55d4aa',
+ \ '123': '55d4d4',
+ \ '124': '7f0000',
+ \ '125': '7f002a',
+ \ '126': '7f0055',
+ \ '127': '7f007f',
+ \ '128': '7f00aa',
+ \ '129': '7f00d4',
+ \ '130': '7f2a00',
+ \ '131': '7f2a2a',
+ \ '132': '7f2a55',
+ \ '133': '7f2a7f',
+ \ '134': '7f2aaa',
+ \ '135': '7f2ad4',
+ \ '136': '7f5500',
+ \ '137': '7f552a',
+ \ '138': '7f5555',
+ \ '139': '7f557f',
+ \ '140': '7f55aa',
+ \ '141': '7f55d4',
+ \ '142': '7f7f00',
+ \ '143': '7f7f2a',
+ \ '144': '7f7f55',
+ \ '145': '7f7f7f',
+ \ '146': '7f7faa',
+ \ '147': '7f7fd4',
+ \ '148': '7faa00',
+ \ '149': '7faa2a',
+ \ '150': '7faa55',
+ \ '151': '7faa7f',
+ \ '152': '7faaaa',
+ \ '153': '7faad4',
+ \ '154': '7fd400',
+ \ '155': '7fd42a',
+ \ '156': '7fd455',
+ \ '157': '7fd47f',
+ \ '158': '7fd4aa',
+ \ '159': '7fd4d4',
+ \ '160': 'aa0000',
+ \ '161': 'aa002a',
+ \ '162': 'aa0055',
+ \ '163': 'aa007f',
+ \ '164': 'aa00aa',
+ \ '165': 'aa00d4',
+ \ '166': 'aa2a00',
+ \ '167': 'aa2a2a',
+ \ '168': 'aa2a55',
+ \ '169': 'aa2a7f',
+ \ '170': 'aa2aaa',
+ \ '171': 'aa2ad4',
+ \ '172': 'aa5500',
+ \ '173': 'aa552a',
+ \ '174': 'aa5555',
+ \ '175': 'aa557f',
+ \ '176': 'aa55aa',
+ \ '177': 'aa55d4',
+ \ '178': 'aa7f00',
+ \ '179': 'aa7f2a',
+ \ '180': 'aa7f55',
+ \ '181': 'aa7f7f',
+ \ '182': 'aa7faa',
+ \ '183': 'aa7fd4',
+ \ '184': 'aaaa00',
+ \ '185': 'aaaa2a',
+ \ '186': 'aaaa55',
+ \ '187': 'aaaa7f',
+ \ '188': 'aaaaaa',
+ \ '189': 'aaaad4',
+ \ '190': 'aad400',
+ \ '191': 'aad42a',
+ \ '192': 'aad455',
+ \ '193': 'aad47f',
+ \ '194': 'aad4aa',
+ \ '195': 'aad4d4',
+ \ '196': 'd40000',
+ \ '197': 'd4002a',
+ \ '198': 'd40055',
+ \ '199': 'd4007f',
+ \ '200': 'd400aa',
+ \ '201': 'd400d4',
+ \ '202': 'd42a00',
+ \ '203': 'd42a2a',
+ \ '204': 'd42a55',
+ \ '205': 'd42a7f',
+ \ '206': 'd42aaa',
+ \ '207': 'd42ad4',
+ \ '208': 'd45500',
+ \ '209': 'd4552a',
+ \ '210': 'd45555',
+ \ '211': 'd4557f',
+ \ '212': 'd455aa',
+ \ '213': 'd455d4',
+ \ '214': 'd47f00',
+ \ '215': 'd47f2a',
+ \ '216': 'd47f55',
+ \ '217': 'd47f7f',
+ \ '218': 'd47faa',
+ \ '219': 'd47fd4',
+ \ '220': 'd4aa00',
+ \ '221': 'd4aa2a',
+ \ '222': 'd4aa55',
+ \ '223': 'd4aa7f',
+ \ '224': 'd4aaaa',
+ \ '225': 'd4aad4',
+ \ '226': 'd4d400',
+ \ '227': 'd4d42a',
+ \ '228': 'd4d455',
+ \ '229': 'd4d47f',
+ \ '230': 'd4d4aa',
+ \ '231': 'd4d4d4',
+ \ '232': '080808',
+ \ '233': '121212',
+ \ '234': '1c1c1c',
+ \ '235': '262626',
+ \ '236': '303030',
+ \ '237': '3a3a3a',
+ \ '238': '444444',
+ \ '239': '4e4e4e',
+ \ '240': '585858',
+ \ '241': '626262',
+ \ '242': '6c6c6c',
+ \ '243': '767676',
+ \ '244': '808080',
+ \ '245': '8a8a8a',
+ \ '246': '949494',
+ \ '247': '9e9e9e',
+ \ '248': 'a8a8a8',
+ \ '249': 'b2b2b2',
+ \ '250': 'bcbcbc',
+ \ '251': 'c6c6c6',
+ \ '252': 'd0d0d0',
+ \ '253': 'dadada',
+ \ '254': 'e4e4e4',
+ \ '255': 'eeeeee',
+ \ }
+
+" ------------------------------------------------------------
+" Generate RGB_2_Int256 Dictionary: {{{2
+" ------------------------------------------------------------
+let s:RGB_2_Int256 = {}
+for key in sort(keys(s:Int256_2_RGB))
+ let s:RGB_2_Int256[s:Int256_2_RGB[key]] = key
+endfor
+
+" eterm number to rgb string
+let s:ColorTable256 = []
+" TODO make into list of [r,g,b] values
+let cnt = 0
+while cnt < 256
+ let rgb = s:Int256_2_RGB[cnt]
+ let r = rgb[0:1]
+ let g = rgb[2:3]
+ let b = rgb[4:5]
+ let rn = str2nr(r, 16)
+ let gn = str2nr(g, 16)
+ let bn = str2nr(b, 16)
+ call add(s:ColorTable256, [rn,gn,bn])
+
+ let cnt += 1
+endwhile
+
+" 6 intensity RGB
+" intensities = [0, 42, 85, 127, 170, 212]
+" intensities = (0x00, 0x2a, 0x55, 0x7f, 0xaa, 0xd4)
+let s:intensities = [
+ \ str2nr("0x00",16),
+ \ str2nr("0x2a",16),
+ \ str2nr("0x55",16),
+ \ str2nr("0x7f",16),
+ \ str2nr("0xaa",16),
+ \ str2nr("0xd4",16)
+ \ ]
+
+" ------------------------------------------------------------
+" ConvertRGB_2_Int256: {{{2
+" Converts an rgb String to a eterm 256 Number
+" Tried to make this fast.
+" Returns the eterm 256 Number
+" parameters:
+" rgb : Parameters accepted by ParseRGB
+" ------------------------------------------------------------
+
+" binary search over possible intensities256
+function! s:GetPartial_Int256(n)
+ " intensities = [0, 42, 85, 127, 170, 212]
+ " intensities = (0x00, 0x2a, 0x55, 0x7f, 0xaa, 0xd4)
+ let n = a:n
+ let n2 = n+n
+
+ if n <= 85
+ if n <= 42
+ return (n2 <= 42) ? 0 : 42
+ else
+ return (n2 <= 127) ? 42 : 85
+ endif
+ else
+ if n <= 170
+ if n <= 127
+ return (n2 <= 212) ? 85 : 127
+ else
+ return (n2 <= 297) ? 127 : 170
+ endif
+ else
+ return (n2 <= 382) ? 170 : 212
+ endif
+ endif
+endfunction
+
+function! vimside#color#eterm#ConvertRGB_2_Int256(rn, gn, bn)
+"let start = reltime()
+ let rn = a:rn
+ let gn = a:gn
+ let bn = a:bn
+
+"call vimside#log("ConvertRGB_2_Int256: in rn=". rn)
+"call vimside#log("ConvertRGB_2_Int256: in gn=". gn)
+"call vimside#log("ConvertRGB_2_Int256: in bn=". bn)
+
+ let rnx = s:GetPartial_Int256(rn)
+ let gnx = s:GetPartial_Int256(gn)
+ let bnx = s:GetPartial_Int256(bn)
+"call vimside#log("ConvertRGB_2_Int256: outjrnx=". rnx)
+"call vimside#log("ConvertRGB_2_Int256: outjgnx=". gnx)
+"call vimside#log("ConvertRGB_2_Int256: outjbnx=". bnx)
+
+ " must check grey levels which can be a closer match
+ " TODO how to tell if we are near a grey level and
+ " only do the following if we are near?
+ let diff = abs(rnx-rn) + abs(gnx-gn) + abs(bnx-bn)
+ let best_match = -1
+ let cnt = 232
+ while cnt < 256
+ let [rx,gx,bx] = s:ColorTable256[cnt]
+ let d = abs(rx-rn) + abs(gx-gn) + abs(bx-bn)
+
+ " on equals, prefer gray to color
+ if d < diff
+ let diff = d
+ let best_match = cnt
+ endif
+
+ let cnt += 1
+ endwhile
+
+ if best_match != -1
+"call vimside#log("ConvertRGB_2_Int256: best_match=". best_match)
+ let n = best_match
+ else
+ let rgbtxt = printf('%02x%02x%02x',rnx,gnx,bnx)
+"call vimside#log("ConvertRGB_2_Int256: rgbtxt=". rgbtxt)
+ let n = s:RGB_2_Int256[rgbtxt]
+ endif
+" call vimside#log("ConvertRGB_2_Int256: time=". reltimestr(reltime(start)))
+"call vimside#log("ConvertRGB_2_Int256: n=". n)
+ return n
+endfunction
+
+" ------------------------------------------------------------
+" ConvertInt256_2_RGB: {{{2
+" Converts an eterm 256 String or Number to an rgb String
+" Returns the rgb String
+" parameters:
+" nr : String or Number or eterm 256 value
+" value must be 0 <= value <= 255
+" ------------------------------------------------------------
+" return [0, errormsg] or [1, rgb]
+function! vimside#color#eterm#ConvertInt256_2_RGB(nr)
+ if (type(a:nr) == g:self#NUMBER_TYPE)
+ return [1, s:Int256_2_RGB[a:nr]]
+ elseif (type(a:nr) == g:self#STRING_TYPE)
+ return [1, s:Int256_2_RGB[a:nr]]
+ else
+ return [0, "Bad number: " . string(a:nsstr)]
+ endif
+endfunction
+
+" ================
+" Modelines: {{{1
+" ================
+" vim: ts=4 fdm=marker
View
436 autoload/vimside/color/konsole.vim
@@ -0,0 +1,436 @@
+" ============================================================================
+" konsole.vim
+"
+" File: konsole.vim
+" Summary: Konsole (part of Forms Library)
+" Author: Richard Emberson <richard.n.embersonATgmailDOTcom>
+" ============================================================================
+
+" ------------------------------------------------------------
+" Define Int256_2_RGB Dictionary: {{{2
+" Refs:
+" https://github.com/vim-scripts/colorsupport.vim/blob/master/plugin/colorsupport.vim
+" ------------------------------------------------------------
+let s:Int256_2_RGB = {
+ \ '0': '000000',
+ \ '1': 'cd0000',
+ \ '2': '00cd00',
+ \ '3': 'cdcd00',
+ \ '4': '0000cd',
+ \ '5': 'cd00cd',
+ \ '6': '00cdcd',
+ \ '7': 'e5e5e5',
+ \ '8': '4d4d4d',
+ \ '9': 'ff0000',
+ \ '10': '00ff00',
+ \ '11': 'ffff00',
+ \ '12': '0000ff',
+ \ '13': 'ff00ff',
+ \ '14': '00ffff',
+ \ '15': 'ffffff',
+ \ '16': '000000',
+ \ '17': '000033',
+ \ '18': '000066',
+ \ '19': '000099',
+ \ '20': '0000cc',
+ \ '21': '0000ff',
+ \ '22': '003300',
+ \ '23': '003333',
+ \ '24': '003366',
+ \ '25': '003399',
+ \ '26': '0033cc',
+ \ '27': '0033ff',
+ \ '28': '006600',
+ \ '29': '006633',
+ \ '30': '006666',
+ \ '31': '006699',
+ \ '32': '0066cc',
+ \ '33': '0066ff',
+ \ '34': '009900',
+ \ '35': '009933',
+ \ '36': '009966',
+ \ '37': '009999',
+ \ '38': '0099cc',
+ \ '39': '0099ff',
+ \ '40': '00cc00',
+ \ '41': '00cc33',
+ \ '42': '00cc66',
+ \ '43': '00cc99',
+ \ '44': '00cccc',
+ \ '45': '00ccff',
+ \ '46': '00ff00',
+ \ '47': '00ff33',
+ \ '48': '00ff66',
+ \ '49': '00ff99',
+ \ '50': '00ffcc',
+ \ '51': '00ffff',
+ \ '52': '330000',
+ \ '53': '330033',
+ \ '54': '330066',
+ \ '55': '330099',
+ \ '56': '3300cc',
+ \ '57': '3300ff',
+ \ '58': '333300',
+ \ '59': '333333',
+ \ '60': '333366',
+ \ '61': '333399',
+ \ '62': '3333cc',
+ \ '63': '3333ff',
+ \ '64': '336600',
+ \ '65': '336633',
+ \ '66': '336666',
+ \ '67': '336699',
+ \ '68': '3366cc',
+ \ '69': '3366ff',
+ \ '70': '339900',
+ \ '71': '339933',
+ \ '72': '339966',
+ \ '73': '339999',
+ \ '74': '3399cc',
+ \ '75': '3399ff',
+ \ '76': '33cc00',
+ \ '77': '33cc33',
+ \ '78': '33cc66',
+ \ '79': '33cc99',
+ \ '80': '33cccc',
+ \ '81': '33ccff',
+ \ '82': '33ff00',
+ \ '83': '33ff33',
+ \ '84': '33ff66',
+ \ '85': '33ff99',
+ \ '86': '33ffcc',
+ \ '87': '33ffff',
+ \ '88': '660000',
+ \ '89': '660033',
+ \ '90': '660066',
+ \ '91': '660099',
+ \ '92': '6600cc',
+ \ '93': '6600ff',
+ \ '94': '663300',
+ \ '95': '663333',
+ \ '96': '663366',
+ \ '97': '663399',
+ \ '98': '6633cc',
+ \ '99': '6633ff',
+ \ '100': '666600',
+ \ '101': '666633',
+ \ '102': '666666',
+ \ '103': '666699',
+ \ '104': '6666cc',
+ \ '105': '6666ff',
+ \ '106': '669900',
+ \ '107': '669933',
+ \ '108': '669966',
+ \ '109': '669999',
+ \ '110': '6699cc',
+ \ '111': '6699ff',
+ \ '112': '66cc00',
+ \ '113': '66cc33',
+ \ '114': '66cc66',
+ \ '115': '66cc99',
+ \ '116': '66cccc',
+ \ '117': '66ccff',
+ \ '118': '66ff00',
+ \ '119': '66ff33',
+ \ '120': '66ff66',
+ \ '121': '66ff99',
+ \ '122': '66ffcc',
+ \ '123': '66ffff',
+ \ '124': '990000',
+ \ '125': '990033',
+ \ '126': '990066',
+ \ '127': '990099',
+ \ '128': '9900cc',
+ \ '129': '9900ff',
+ \ '130': '993300',
+ \ '131': '993333',
+ \ '132': '993366',
+ \ '133': '993399',
+ \ '134': '9933cc',
+ \ '135': '9933ff',
+ \ '136': '996600',
+ \ '137': '996633',
+ \ '138': '996666',
+ \ '139': '996699',
+ \ '140': '9966cc',
+ \ '141': '9966ff',
+ \ '142': '999900',
+ \ '143': '999933',
+ \ '144': '999966',
+ \ '145': '999999',
+ \ '146': '9999cc',
+ \ '147': '9999ff',
+ \ '148': '99cc00',
+ \ '149': '99cc33',
+ \ '150': '99cc66',
+ \ '151': '99cc99',
+ \ '152': '99cccc',
+ \ '153': '99ccff',
+ \ '154': '99ff00',
+ \ '155': '99ff33',
+ \ '156': '99ff66',
+ \ '157': '99ff99',
+ \ '158': '99ffcc',
+ \ '159': '99ffff',
+ \ '160': 'cc0000',
+ \ '161': 'cc0033',
+ \ '162': 'cc0066',
+ \ '163': 'cc0099',
+ \ '164': 'cc00cc',
+ \ '165': 'cc00ff',
+ \ '166': 'cc3300',
+ \ '167': 'cc3333',
+ \ '168': 'cc3366',
+ \ '169': 'cc3399',
+ \ '170': 'cc33cc',
+ \ '171': 'cc33ff',
+ \ '172': 'cc6600',
+ \ '173': 'cc6633',
+ \ '174': 'cc6666',
+ \ '175': 'cc6699',
+ \ '176': 'cc66cc',
+ \ '177': 'cc66ff',
+ \ '178': 'cc9900',
+ \ '179': 'cc9933',
+ \ '180': 'cc9966',
+ \ '181': 'cc9999',
+ \ '182': 'cc99cc',
+ \ '183': 'cc99ff',
+ \ '184': 'cccc00',
+ \ '185': 'cccc33',
+ \ '186': 'cccc66',
+ \ '187': 'cccc99',
+ \ '188': 'cccccc',
+ \ '189': 'ccccff',
+ \ '190': 'ccff00',
+ \ '191': 'ccff33',
+ \ '192': 'ccff66',
+ \ '193': 'ccff99',
+ \ '194': 'ccffcc',
+ \ '195': 'ccffff',
+ \ '196': 'ff0000',
+ \ '197': 'ff0033',
+ \ '198': 'ff0066',
+ \ '199': 'ff0099',
+ \ '200': 'ff00cc',
+ \ '201': 'ff00ff',
+ \ '202': 'ff3300',
+ \ '203': 'ff3333',
+ \ '204': 'ff3366',
+ \ '205': 'ff3399',
+ \ '206': 'ff33cc',
+ \ '207': 'ff33ff',
+ \ '208': 'ff6600',
+ \ '209': 'ff6633',
+ \ '210': 'ff6666',
+ \ '211': 'ff6699',
+ \ '212': 'ff66cc',
+ \ '213': 'ff66ff',
+ \ '214': 'ff9900',
+ \ '215': 'ff9933',
+ \ '216': 'ff9966',
+ \ '217': 'ff9999',
+ \ '218': 'ff99cc',
+ \ '219': 'ff99ff',
+ \ '220': 'ffcc00',
+ \ '221': 'ffcc33',
+ \ '222': 'ffcc66',
+ \ '223': 'ffcc99',
+ \ '224': 'ffcccc',
+ \ '225': 'ffccff',
+ \ '226': 'ffff00',
+ \ '227': 'ffff33',
+ \ '228': 'ffff66',
+ \ '229': 'ffff99',
+ \ '230': 'ffffcc',
+ \ '231': 'ffffff',
+ \ '232': '080808',
+ \ '233': '121212',
+ \ '234': '1c1c1c',
+ \ '235': '262626',
+ \ '236': '303030',
+ \ '237': '3a3a3a',
+ \ '238': '444444',
+ \ '239': '4e4e4e',
+ \ '240': '585858',
+ \ '241': '626262',
+ \ '242': '6c6c6c',
+ \ '243': '767676',
+ \ '244': '808080',
+ \ '245': '8a8a8a',
+ \ '246': '949494',
+ \ '247': '9e9e9e',
+ \ '248': 'a8a8a8',
+ \ '249': 'b2b2b2',
+ \ '250': 'bcbcbc',
+ \ '251': 'c6c6c6',
+ \ '252': 'd0d0d0',
+ \ '253': 'dadada',
+ \ '254': 'e4e4e4',
+ \ '255': 'eeeeee'
+ \ }
+
+" ------------------------------------------------------------
+" Generate RGB_2_Int256 Dictionary: {{{2
+" ------------------------------------------------------------
+let s:RGB_2_Int256 = {}
+for key in sort(keys(s:Int256_2_RGB))
+ let s:RGB_2_Int256[s:Int256_2_RGB[key]] = key
+endfor
+
+" konsole number to rgb string
+let s:ColorTable256 = []
+" TODO make into list of [r,g,b] values
+let cnt = 0
+while cnt < 256
+ let rgb = s:Int256_2_RGB[cnt]
+ let r = rgb[0:1]
+ let g = rgb[2:3]
+ let b = rgb[4:5]
+ let rn = str2nr(r, 16)
+ let gn = str2nr(g, 16)
+ let bn = str2nr(b, 16)
+ call add(s:ColorTable256, [rn,gn,bn])
+
+ let cnt += 1
+endwhile
+
+" 6 intensity RGB
+" intensities = [0, 51, 102, 153, 204, 255]
+" intensities = (0x00, 0x33, 0x66, 0x99, 0xcc, 0xff )
+let s:intensities = [
+ \ str2nr("0x00",16),
+ \ str2nr("0x33",16),
+ \ str2nr("0x66",16),
+ \ str2nr("0x99",16),
+ \ str2nr("0xcc",16),
+ \ str2nr("0xff",16)
+ \ ]
+
+" ------------------------------------------------------------
+" ConvertRGB_2_Int256: {{{2
+" Converts an rgb String to a konsole 256 Number
+" Tried to make this fast.
+" Returns the konsole 256 Number
+" parameters:
+" rgb : Parameters accepted by ParseRGB
+" ------------------------------------------------------------
+
+" binary search over possible intensities
+function! s:GetPartial_Int256(n)
+ " intensities = [0, 51, 102, 153, 204, 255]
+ " intensities = (0x00, 0x33, 0x66, 0x99, 0xcc, 0xff )
+ let n = a:n
+ let n2 = n+n
+
+ if n <= 102
+ if n <= 51
+ return (n2 <= 51) ? 0 : 51
+ else
+ return (n2 <= 153) ? 51 : 102
+ endif
+ else
+ if n <= 204
+ if n <= 153
+ return (n2 <= 255) ? 102 : 153
+ else
+ return (n2 <= 357) ? 153 : 204
+ endif
+ else
+ return (n2 <= 459) ? 204 : 255
+ endif
+ endif
+endfunction
+
+function! vimside#color#konsole#ConvertRGB_2_Int256(rn, gn, bn)
+"let start = reltime()
+ let rn = a:rn
+ let gn = a:gn
+ let bn = a:bn
+
+"call vimside#log("ConvertRGB_2_Int256: in rn=". rn)
+"call vimside#log("ConvertRGB_2_Int256: in gn=". gn)
+"call vimside#log("ConvertRGB_2_Int256: in bn=". bn)
+
+ let rnx = s:GetPartial_Int256(rn)
+ let gnx = s:GetPartial_Int256(gn)
+ let bnx = s:GetPartial_Int256(bn)
+"call vimside#log("ConvertRGB_2_Int256: outjrnx=". rnx)
+"call vimside#log("ConvertRGB_2_Int256: outjgnx=". gnx)
+"call vimside#log("ConvertRGB_2_Int256: outjbnx=". bnx)
+
+ " must check grey levels which can be a closer match
+ " TODO how to tell if we are near a grey level and
+ " only do the following if we are near?
+ let diff = abs(rnx-rn) + abs(gnx-gn) + abs(bnx-bn)
+ let best_match = -1
+ let cnt = 232
+ while cnt < 256
+ let [rx,gx,bx] = s:ColorTable256[cnt]
+ let d = abs(rx-rn) + abs(gx-gn) + abs(bx-bn)
+
+ " on equals, prefer gray to color
+ if d < diff
+ let diff = d
+ let best_match = cnt
+ endif
+
+ let cnt += 1
+ endwhile
+
+ if best_match != -1
+"call vimside#log("ConvertRGB_2_Int256: best_match=". best_match)
+ let n = best_match
+ else
+ let rgbtxt = printf('%02x%02x%02x',rnx,gnx,bnx)
+"call vimside#log("ConvertRGB_2_Int256: rgbtxt=". rgbtxt)
+ let n = s:RGB_2_Int256[rgbtxt]
+ endif
+" call vimside#log("ConvertRGB_2_Int256: time=". reltimestr(reltime(start)))
+"call vimside#log("ConvertRGB_2_Int256: n=". n)
+ return n
+endfunction
+
+" ------------------------------------------------------------
+" ConvertInt256_2_RGB: {{{2
+" Converts an konsole 256 String or Number to an rgb String
+" Returns the rgb String
+" parameters:
+" nr : String or Number or konsole 256 value
+" value must be 0 <= value <= 255
+" ------------------------------------------------------------
+" return [0, errormsg] or [1, rgb]
+function! vimside#color#konsole#ConvertInt256_2_RGB(nr)
+ if (type(a:nr) == g:self#NUMBER_TYPE)
+ return [1, s:Int256_2_RGB[a:nr]]
+ elseif (type(a:nr) == g:self#STRING_TYPE)
+ return [1, s:Int256_2_RGB[a:nr]]
+ else
+ return [0, "Bad number: " . string(a:nsstr)]
+ endif
+endfunction
+
+if 0
+" code to unroll cube
+let cube = range(0x00, 0xFF, 0x33)
+call vimside#log("Konsole: cube=". string(cube))
+
+let cnt = 0
+for r in cube
+ for g in cube
+ for b in cube
+ let rgbtxt = printf('%02x%02x%02x',r,g,b)
+ call vimside#log(" \\ '". (cnt+16) . "': '" . rgbtxt . "',")
+ let cnt += 1
+ endfor
+ endfor
+endfor
+
+function! vimside#color#konsole#DoIT()
+endfunction
+endif
+
+" ================
+" Modelines: {{{1
+" ================
+" vim: ts=4 fdm=marker
View
176 autoload/vimside/color/rxvt.vim
@@ -0,0 +1,176 @@
+" ============================================================================
+" rxvt.vim
+"
+" File: rxvt.vim
+" Summary: Rxvt 8 colors (part of Forms Library)
+" Author: Richard Emberson <richard.n.embersonATgmailDOTcom>
+" ============================================================================
+
+" ------------------------------------------------------------
+" Define Int_2_Name Dictionary: {{{2
+" Refs:
+" rxvt-unicode-9.1.5 src/init.C
+" ------------------------------------------------------------
+let s:Int_2_Name = {
+ \ '0': 'black',
+ \ '1': 'red3',
+ \ '2': 'green3',
+ \ '3': 'yellow3',
+ \ '4': 'blue3',
+ \ '5': 'magenta3',
+ \ '6': 'cyan3',
+ \ '7': 'AntiqueWhite'
+ \ }
+
+" ------------------------------------------------------------
+" Define Int_2_RGB Dictionary: {{{2
+" Refs:
+" rxvt-9.1.5 src/init.C
+" ------------------------------------------------------------
+let s:Int_2_RGB = {
+ \ '0': '000000',
+ \ '1': 'cd0000',
+ \ '2': '00cd00',
+ \ '3': 'cdcd00',
+ \ '4': '0000cd',
+ \ '5': 'cd00cd',
+ \ '6': '00cdcd',
+ \ '7': 'faebd7'
+ \ }
+
+" ------------------------------------------------------------
+" Generate RGB_2_Int Dictionary: {{{2
+" WHAT A HACK!!!
+" ------------------------------------------------------------
+let s:RGB_2_Int = {}
+for key in sort(keys(s:Int_2_RGB))
+ let s:RGB_2_Int[s:Int_2_RGB[key]] = key
+endfor
+let s:RGB_2_Int['cdcdcd'] = '7'
+
+let s:RGB_2_Int['cdcdd7'] = '7'
+let s:RGB_2_Int['cdebcd'] = '7'
+let s:RGB_2_Int['facdcd'] = '7'
+
+let s:RGB_2_Int['cdebd7'] = '7'
+let s:RGB_2_Int['facdd7'] = '7'
+let s:RGB_2_Int['faebcd'] = '7'
+
+let s:RGB_2_Int['fa0000'] = '1'
+let s:RGB_2_Int['00eb00'] = '2'
+let s:RGB_2_Int['0000d7'] = '4'
+
+let s:RGB_2_Int['faeb00'] = '3'
+let s:RGB_2_Int['cdeb00'] = '3'
+let s:RGB_2_Int['facd00'] = '3'
+
+let s:RGB_2_Int['fa00cd'] = '5'
+let s:RGB_2_Int['fa00d7'] = '5'
+let s:RGB_2_Int['cd00d7'] = '5'
+
+let s:RGB_2_Int['00ebd7'] = '6'
+let s:RGB_2_Int['00cdd7'] = '6'
+let s:RGB_2_Int['00ebcd'] = '6'
+
+
+" rxvt number to rgb string
+let s:ColorTable= []
+" TODO make into list of [r,g,b] values
+let cnt = 0
+while cnt < 8
+ let rgb = s:Int_2_RGB[cnt]
+ let r = rgb[0:1]
+ let g = rgb[2:3]
+ let b = rgb[4:5]
+ let rn = str2nr(r, 16)
+ let gn = str2nr(g, 16)
+ let bn = str2nr(b, 16)
+ call add(s:ColorTable, [rn,gn,bn])
+
+ let cnt += 1
+endwhile
+
+if 0
+" intensities=[0, 139, 205, 255]
+" intensities = (0x00, 0x8b, 0xcd, 0xff)
+let s:intensities = [
+ \ str2nr("0x00",16),
+ \ str2nr("0x8b",16),
+ \ str2nr("0xcd",16),
+ \ str2nr("0xff",16)
+ \ ]
+endif
+
+
+" ------------------------------------------------------------
+" ConvertRGB_2_Int: {{{2
+" Converts an rgb String to a rxvt 8 Number
+" Tried to make this fast.
+" Returns the rxvt 8 Number
+" parameters:
+" rgb : Parameters accepted by ParseRGB
+" ------------------------------------------------------------
+function! vimside#color#rxvt#ConvertRGB_2_Int(rn, gn, bn)
+"let start = reltime()
+ let rn = a:rn
+ let gn = a:gn
+ let bn = a:bn
+
+" call vimside#log("ConvertRGB_2_Int: in rn=". rn)
+" call vimside#log("ConvertRGB_2_Int: in gn=". gn)
+" call vimside#log("ConvertRGB_2_Int: in bn=". bn)
+
+ " red
+ if rn <= 205
+ let rnx = ((rn+rn) <= 205) ? 0 : 205
+ else
+ let rnx = ((rn+rn) <= 455) ? 205 : 250
+ endif
+
+ " green
+ if gn <= 205
+ let gnx = ((gn+gn) <= 205) ? 0 : 205
+ else
+ let gnx = ((gn+gn) <= 440) ? 205 : 235
+ endif
+ if bn <= 205
+ let bnx = ((bn+bn) <= 205) ? 0 : 205
+ else
+ let bnx = ((bn+bn) <= 420) ? 205 : 215
+ endif
+
+" call vimside#log("ConvertRGB_2_Int: outjrnx=". rnx)
+" call vimside#log("ConvertRGB_2_Int: outjgnx=". gnx)
+" call vimside#log("ConvertRGB_2_Int: outjbnx=". bnx)
+
+ let rgbtxt = printf('%02x%02x%02x',rnx,gnx,bnx)
+" call vimside#log("ConvertRGB_2_Int: rgbtxt=". rgbtxt)
+ let n = s:RGB_2_Int[rgbtxt]
+"call vimside#log("ConvertRGB_2_Int: time=". reltimestr(reltime(start)))
+" call vimside#log("ConvertRGB_2_Int: n=". n)
+ return n
+endfunction
+
+" ------------------------------------------------------------
+" ConvertInt_2_RGB: {{{2
+" Converts an 8 String or Number to an rgb String
+" Returns the rgb String
+" parameters:
+" nr : String or Number or rxvt 8 value
+" value must be 0 <= value <= 8
+" ------------------------------------------------------------
+" return [0, errormsg] or [1, rgb]
+function! vimside#color#rxvt#ConvertInt_2_RGB(nr)
+ if (type(a:nr) == g:self#NUMBER_TYPE)
+ return [1, s:Int_2_RGB[a:nr]]
+ elseif (type(a:nr) == g:self#STRING_TYPE)
+ return [1, s:Int_2_RGB[a:nr]]
+ else
+ return [0, "Bad number: " . string(a:nsstr)]
+ endif
+endfunction
+
+" ================
+" Modelines: {{{1
+" ================
+" vim: ts=4 fdm=marker
View
168 autoload/vimside/color/term.vim
@@ -0,0 +1,168 @@
+" ============================================================================
+" term.vim
+"
+" File: term.vim
+" Summary: Term (part of Forms Library)
+" Author: Richard Emberson <richard.n.embersonATgmailDOTcom>
+" ============================================================================
+
+" http://vim.wikia.com/wiki/256_colors_setup_for_console_Vim
+
+
+
+
+" ------------------------------------------------------------
+" eterm types:
+" eterm No Color
+" eterm-color (8color)
+" Eterm types:
+" Eterm (8color)
+" Eterm-color (8color)
+" Eterm-88color
+" Eterm-256color
+" Konsole types:
+" * konsole (8color)
+" konsole-256color
+" Rxvt types:
+" rxvt (8color)
+" * rxvt-color (8color)
+" * rxvt-16color note: map to xterm 16
+" rxvt-88color
+" * rxvt-unicode (88color)
+" rxvt-unicode-256color
+" * rxvt-256color
+" XTerm types:
+" * xterm-color (8color0
+" * xterm-16color
+" * xterm-88color
+" * xterm-256color
+"
+" and there are others
+" Refs:
+" /usr/share/terminfo/*
+" ------------------------------------------------------------
+
+" ------------------------------------------------------------
+" Define konsole and eterm variables: {{{2
+" Refs:
+" ------------------------------------------------------------
+if ! exists("g:FORMS_COLOR_TERM_KONSOLE")
+ let g:FORMS_COLOR_TERM_KONSOLE = 0
+endif
+if ! exists("g:FORMS_COLOR_TERM_ETERM")
+ let g:FORMS_COLOR_TERM_ETERM = 0
+endif
+
+" ------------------------------------------------------------
+" Set current session Term functions: {{{2
+" There are two independent variables involved, encoding and
+" number of colors.
+" The encoding can be: 'utf-8' or not 'utf-8'.
+" The colors count can be: 256, 88, 16 or 8 (where gui == 256).
+" This code ONLY deals with the number of colors.
+" Refs:
+" ------------------------------------------------------------
+if has("gui_running")
+ " Want to support Forms in GVim, so must still set term functions
+ " Use Xterm
+ let g:FORMS_COLOR_TERM_TYPE = 'gui'
+ let g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT = function("vimside#color#xterm256#ConvertRGB_2_Int")
+ let g:FORMS_COLOR_TERM_CONVERT_INT_2_RGB = function("vimside#color#xterm256#ConvertInt_2_RGB")
+ let g:FORMS_COLOR_TERM_NUMBER_COLORS = 256
+
+
+elseif &t_Co == 256
+ if &term =~? '^konsole' || g:FORMS_COLOR_TERM_KONSOLE
+ let g:FORMS_COLOR_TERM_TYPE = 'konsole'
+ let g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT = function("vimside#color#konsole#ConvertRGB_2_Int")
+ let g:FORMS_COLOR_TERM_CONVERT_INT_2_RGB = function("vimside#color#konsole#ConvertInt256_2_RGB")
+ let g:FORMS_COLOR_TERM_NUMBER_COLORS = 256
+
+ elseif &term =~? '^eterm' || g:FORMS_COLOR_TERM_ETERM
+ let g:FORMS_COLOR_TERM_TYPE = 'eterm'
+ let g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT = function("vimside#color#eterm#ConvertRGB_2_Int")
+ let g:FORMS_COLOR_TERM_CONVERT_INT_2_RGB = function("vimside#color#eterm#ConvertInt256_2_RGB")
+ let g:FORMS_COLOR_TERM_NUMBER_COLORS = 256
+
+ elseif &term =~? '^rxvt'
+ " Use Xterm functions for rxvt-unicode-256color
+ " rxvt-unicode-256color
+ let g:FORMS_COLOR_TERM_TYPE = 'urxvt256'
+ let g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT = function("vimside#color#xterm256#ConvertRGB_2_Int")
+ let g:FORMS_COLOR_TERM_CONVERT_INT_2_RGB = function("vimside#color#xterm256#ConvertInt_2_RGB")
+ let g:FORMS_COLOR_TERM_NUMBER_COLORS = 256
+
+ else
+ " xterm
+ let g:FORMS_COLOR_TERM_TYPE = 'xterm'
+ let g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT = function("vimside#color#xterm256#ConvertRGB_2_Int")
+ let g:FORMS_COLOR_TERM_CONVERT_INT_2_RGB = function("vimside#color#xterm256#ConvertInt_2_RGB")
+ let g:FORMS_COLOR_TERM_NUMBER_COLORS = 256
+ endif
+
+elseif &t_Co == 88
+ if &term =~? '^rxvt'
+ " rxvt-unicode
+ let g:FORMS_COLOR_TERM_TYPE = 'urxvt'
+ let g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT = function("vimside#color#urxvt#ConvertRGB_2_Int")
+ let g:FORMS_COLOR_TERM_CONVERT_INT_2_RGB = function("vimside#color#urxvt#ConvertInt_2_RGB")
+ let g:FORMS_COLOR_TERM_NUMBER_COLORS = 88
+
+ else
+ let g:FORMS_COLOR_TERM_TYPE = 'xterm'
+ let g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT = function("vimside#color#xterm88#ConvertRGB_2_Int")
+ let g:FORMS_COLOR_TERM_CONVERT_INT_2_RGB = function("vimside#color#xterm88#ConvertInt_2_RGB")
+ let g:FORMS_COLOR_TERM_NUMBER_COLORS = 88
+
+ endif
+
+elseif &t_Co == 16
+ let g:FORMS_COLOR_TERM_TYPE = 'xterm'
+ let g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT = function("vimside#color#xterm16#ConvertRGB_2_Int")
+ let g:FORMS_COLOR_TERM_CONVERT_INT_2_RGB = function("vimside#color#xterm16#ConvertInt_2_RGB")
+ let g:FORMS_COLOR_TERM_NUMBER_COLORS = 16
+
+elseif &t_Co == 8
+ if &term =~? '^rxvt'
+ let g:FORMS_COLOR_TERM_TYPE = 'rxvt'
+ let g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT = function("vimside#color#rxvt#ConvertRGB_2_Int")
+ let g:FORMS_COLOR_TERM_CONVERT_INT_2_RGB = function("vimside#color#rxvt#ConvertInt_2_RGB")
+ let g:FORMS_COLOR_TERM_NUMBER_COLORS = 8
+
+ else
+ " Punt: for now use rxvt code
+ let g:FORMS_COLOR_TERM_TYPE = 'xterm'
+ let g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT = function("vimside#color#xterm8#ConvertRGB_2_Int")
+ let g:FORMS_COLOR_TERM_CONVERT_INT_2_RGB = function("vimside#color#xterm8#ConvertInt_2_RGB")
+ let g:FORMS_COLOR_TERM_NUMBER_COLORS = 8
+
+ endif
+endif
+
+function! vimside#color#term#ConvertRGBTxt_2_Int(rgbtxt)
+ let [l:found, l:value] = vimside#color#util#ParseRGB(a:rgbtxt)
+ if l:found
+ let [r,g,b] = l:value
+ return g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT(r, g, b)
+ else
+ return 1
+ endif
+endfunction
+
+function! vimside#color#term#ConvertRGB_2_Int(rn, gn, bn)
+ return g:FORMS_COLOR_TERM_CONVERT_RGB_2_INT(a:rn, a:gn, a:bn)
+endfunction
+
+" return [0, errormsg] or [1, rgb]
+function! vimside#color#term#ConvertInt_2_RGB(n)
+ return g:FORMS_COLOR_TERM_CONVERT_INT_2_RGB(a:n)
+endfunction
+
+function! vimside#color#term#NumberColors()
+ return g:FORMS_COLOR_TERM_NUMBER_COLORS
+endfunction
+
+" ================
+" Modelines: {{{1
+" ================
+" vim: ts=4 fdm=marker
View
271 autoload/vimside/color/urxvt.vim
@@ -0,0 +1,271 @@
+" ============================================================================
+" urxvt.vim
+"
+" File: urxvt.vim
+" Summary: Rxvt-Unicode (part of Forms Library)
+" Author: Richard Emberson <richard.n.embersonATgmailDOTcom>
+" ============================================================================
+
+" ------------------------------------------------------------
+" Define Int_2_Name Dictionary: {{{2
+" Refs:
+" rxvt-unicode-9.1.5 src/init.C
+" ------------------------------------------------------------
+let s:Int_2_Name = {
+ \ '0': 'black',
+ \ '1': 'red3',
+ \ '2': 'green3',
+ \ '3': 'yellow3',
+ \ '4': 'blue3',
+ \ '5': 'magenta3',
+ \ '6': 'cyan3',
+ \ '7': 'AntiqueWhite',
+ \ '8': 'gray25',
+ \ '9': 'red',
+ \ '10': 'green',
+ \ '11': 'yellow',
+ \ '12': 'SteelBlue1',
+ \ '13': 'magenta',
+ \ '14': 'cyan',
+ \ '15': 'white'
+ \ }
+
+" ------------------------------------------------------------
+" Define Int_2_RGB Dictionary: {{{2
+" Refs:
+" rxvt-unicode-9.1.5 src/init.C
+" ------------------------------------------------------------
+let s:Int_2_RGB = {
+ \ '0': '000000',
+ \ '1': 'cd0000',
+ \ '2': '00cd00',
+ \ '3': 'cdcd00',
+ \ '4': '0000cd',
+ \ '5': 'cd00cd',
+ \ '6': '00cdcd',
+ \ '7': 'faebd7',
+ \ '8': '404040',
+ \ '9': 'ff0000',
+ \ '10': '00ff00',
+ \ '11': 'ffff00',
+ \ '12': '0000ff',
+ \ '13': 'ff00ff',
+ \ '14': '00ffff',
+ \ '15': 'ffffff',
+ \ '16': '000000',
+ \ '17': '00008b',
+ \ '18': '0000cd',
+ \ '19': '0000ff',
+ \ '20': '008b00',
+ \ '21': '008b8b',
+ \ '22': '008bcd',
+ \ '23': '008bff',
+ \ '24': '00cd00',
+ \ '25': '00cd8b',
+ \ '26': '00cdcd',
+ \ '27': '00cdff',
+ \ '28': '00ff00',
+ \ '29': '00ff8b',
+ \ '30': '00ffcd',
+ \ '31': '00ffff',
+ \ '32': '8b0000',
+ \ '33': '8b008b',
+ \ '34': '8b00cd',
+ \ '35': '8b00ff',
+ \ '36': '8b8b00',
+ \ '37': '8b8b8b',
+ \ '38': '8b8bcd',
+ \ '39': '8b8bff',
+ \ '40': '8bcd00',
+ \ '41': '8bcd8b',
+ \ '42': '8bcdcd',
+ \ '43': '8bcdff',
+ \ '44': '8bff00',
+ \ '45': '8bff8b',
+ \ '46': '8bffcd',
+ \ '47': '8bffff',
+ \ '48': 'cd0000',
+ \ '49': 'cd008b',
+ \ '50': 'cd00cd',
+ \ '51': 'cd00ff',
+ \ '52': 'cd8b00',
+ \ '53': 'cd8b8b',
+ \ '54': 'cd8bcd',
+ \ '55': 'cd8bff',
+ \ '56': 'cdcd00',
+ \ '57': 'cdcd8b',
+ \ '58': 'cdcdcd',
+ \ '59': 'cdcdff',
+ \ '60': 'cdff00',
+ \ '61': 'cdff8b',
+ \ '62': 'cdffcd',
+ \ '63': 'cdffff',
+ \ '64': 'ff0000',
+ \ '65': 'ff008b',
+ \ '66': 'ff00cd',
+ \ '67': 'ff00ff',
+ \ '68': 'ff8b00',
+ \ '69': 'ff8b8b',
+ \ '70': 'ff8bcd',
+ \ '71': 'ff8bff',
+ \ '72': 'ffcd00',
+ \ '73': 'ffcd8b',
+ \ '74': 'ffcdcd',
+ \ '75': 'ffcdff',
+ \ '76': 'ffff00',
+ \ '77': 'ffff8b',
+ \ '78': 'ffffcd',
+ \ '79': 'ffffff',
+ \ '80': '2e2e2e',
+ \ '81': '5c5c5c',
+ \ '82': '737373',
+ \ '83': '8b8b8b',
+ \ '84': 'a2a2a2',
+ \ '85': 'b9b9b9',
+ \ '86': 'd0d0d0',
+ \ '87': 'e7e7e7'
+ \ }
+
+" ------------------------------------------------------------
+" Generate RGB_2_Int Dictionary: {{{2
+" ------------------------------------------------------------
+let s:RGB_2_Int = {}
+for key in sort(keys(s:Int_2_RGB))
+ let s:RGB_2_Int[s:Int_2_RGB[key]] = key
+endfor
+
+" xterm number to rgb string
+let s:ColorTable= []
+" TODO make into list of [r,g,b] values
+let cnt = 0
+while cnt < 88
+ let rgb = s:Int_2_RGB[cnt]
+ let r = rgb[0:1]
+ let g = rgb[2:3]
+ let b = rgb[4:5]
+ let rn = str2nr(r, 16)
+ let gn = str2nr(g, 16)
+ let bn = str2nr(b, 16)
+ call add(s:ColorTable, [rn,gn,bn])
+
+ let cnt += 1
+endwhile
+
+" intensities=[0, 139, 205, 255]
+" intensities = (0x00, 0x8b, 0xcd, 0xff)
+let s:intensities = [
+ \ str2nr("0x00",16),
+ \ str2nr("0x8b",16),
+ \ str2nr("0xcd",16),
+ \ str2nr("0xff",16)
+ \ ]
+
+
+" ------------------------------------------------------------
+" ConvertRGB_2_Int: {{{2
+" Converts an rgb String to a xterm 88 Number
+" Tried to make this fast.
+" Returns the xterm 88 Number
+" parameters:
+" rgb : Parameters accepted by ParseRGB
+" ------------------------------------------------------------
+
+" binary search over possible intensities
+function! s:GetPartial_Int(n)
+ " intensities=[0, 139, 205, 255]
+ " intensities = (0x00, 0x8b, 0xcd, 0xff)
+ let n = a:n
+ let n2 = n+n
+
+ if n <= 139
+ return (n2 <= 139) ? 0 : 139
+ elseif n <= 205
+ return (n2 <= 344) ? 139 : 205
+ else
+ return (n2 <= 460) ? 205 : 255
+ endif
+endfunction
+
+function! vimside#color#urxvt#ConvertRGB_2_Int(rn, gn, bn)
+"let start = reltime()
+ let rn = a:rn
+ let gn = a:gn
+ let bn = a:bn
+
+"call vimside#log("ConvertRGB_2_Int: in rn=". rn)
+"call vimside#log("ConvertRGB_2_Int: in gn=". gn)
+"call vimside#log("ConvertRGB_2_Int: in bn=". bn)
+
+ " special case
+ " '7': 'faebd7'
+ " '8': '404040',
+ if (rn == 250) && (gn == 235) && (bn == 215)
+ return 7
+ elseif (rn == 64) && (gn == 64) && (bn == 64)
+ return 8
+ endif
+
+ let rnx = s:GetPartial_Int(rn)
+ let gnx = s:GetPartial_Int(gn)
+ let bnx = s:GetPartial_Int(bn)
+"call vimside#log("ConvertRGB_2_Int: outjrnx=". rnx)
+"call vimside#log("ConvertRGB_2_Int: outjgnx=". gnx)
+"call vimside#log("ConvertRGB_2_Int: outjbnx=". bnx)
+
+ " must check grey levels which can be a closer match
+ " TODO how to tell if we are near a grey level and
+ " only do the following if we are near?
+ let diff = abs(rnx-rn) + abs(gnx-gn) + abs(bnx-bn)
+"call vimside#log("ConvertRGB_2_Int: diff=". diff)
+ let best_match = -1
+ let cnt = 80
+ while cnt < 88
+ let [rx,gx,bx] = s:ColorTable[cnt]
+ let d = abs(rx-rn) + abs(gx-gn) + abs(bx-bn)
+"call vimside#log("ConvertRGB_2_Int: d=". d)
+
+ " on equals, prefer gray to color
+ if d <= diff
+ let diff = d
+ let best_match = cnt
+ endif
+
+ let cnt += 1
+ endwhile
+
+ if best_match != -1
+"call vimside#log("ConvertRGB_2_Int: best_match=". best_match)
+ let n = best_match