Permalink
Browse files

Added support for 8 and 16 color terminals.

Works with non-unicode characters sets (there is some degradation).
  • Loading branch information...
1 parent 42edec9 commit c0b29160a1cac0df4f94b9bd9e67f961c6ea3abe megaannum committed Aug 29, 2012
View
@@ -222,7 +222,8 @@ The Forms library ought to work on any platform where Vim has 256 colors
(or full RGB as with GVim) and a fixed width UTF-8 font which implements
the box drawing and block characters in a reasonable manner.
-## Linux Xterm & Vim
+## Linux Vim
+### Xterm
Forms was developed and extensively tested on a Linux Xterm platform.
As long as the Xterm is using the correct font, such as
@@ -236,45 +237,59 @@ works to launch an Xterm appropriately configured:
/usr/bin/xterm -g 80x30 -bg lightgrey -sl 1000 +si -fn \
'-misc-fixed-medium-r-normal-*-20-*-*-*-*-*-iso10646-*'
-The Xterm must also have 256 color support and such support is
-declared in the .vimrc file with:
+If with say, the font 10x20, then you may not be able to render all of
+the unicode characters, but it ought to still work.
- set t_Co=256
+There is support for 256, 88, 16 and 8 color Xterms though
+the 256 looks best. In your .vimrc file add one of:
-then, there ought not be a problem.
+ if ($TERM == 'xterm')
+ let &t_Co=256
+or
+ let &t_Co=88
+or
+ let &t_Co=16
+or
+ let &t_Co=8
+ endif
-## Linux urxvt256c & Vim
+if you need help in getting the correct number of colors in Vim.
+
+
+### urxvt256c
Forms simply works on the version of rxvt that supports Unicode and 256
-colors, urxvt256c. Add to .vimrc file:
+colors, urxvt256c.
+Vim knows that &t_Co == 256.
- set t_Co=256
+### urxvt
-## Linux urxvt & Vim
+Forms works with 88 color verion of rxvt that supports Unicode, urxvt.
+Vim knows that &t_Co == 88.
-Forms works with 88 colore rxvt that supports Unicode urxvt.
-Add to .vimrc file:
+### rxvt
- set t_Co=88
+Forms works with non-Unicode, 8 color rxvt.
+Vim knows that &t_Co == 8.
-## Linux Konsole & Vim
+### Konsole
Forms works kconsole (though kconsole's UTF-8 9608 2588 FULL BLOCK
does not render correctly).
Add to .vimrc file:
- set t_Co=256
+ let &t_Co=256
let g:FORMS_COLOR_TERM_KONSOLE = 1
-## Linux Eterm & Vim
+### Eterm
Forms works eterm (well, I hope it works, no access to ETerm so could not test).
Add to .vimrc file:
- set t_Co=256
+ let &t_Co=256
let g:FORMS_COLOR_TERM_ETERM = 1
-## Linux GVim
+### GVim
Some testing has been done on the Linux GVim platform and all of the
demonstration forms seem to work as expected.
View
@@ -5,8 +5,8 @@
" File: forms.vim
" Summary: Vim Form Library
" Author: Richard Emberson <richard.n.embersonATgmailDOTcom>
-" Last Modified: 08/30/2012
-" Version: 1.5
+" Last Modified: 06/30/2012
+" Version: 1.6
" Modifications:
" 1.0 : initial public release.
"
@@ -383,24 +383,13 @@ else
execute "hi BackgroundHi cterm=NONE ctermbg=" . backgroundNumber
-"let g:forms_log_enabled = g:self#IS_TRUE
-"call forms#log("FRAME")
-"call forms#log("backgroundNumber=".backgroundNumber)
let framefgNumber = forms#color#term#ConvertRGBTxt_2_Int(framefgColor)
-"call forms#log("framefgNumber=".framefgNumber)
let framebgNumber = forms#color#term#ConvertRGBTxt_2_Int(framebgColor)
-"call forms#log("framebgNumber=".framebgNumber)
execute "hi FrameHi cterm=NONE ctermfg=".framefgNumber." ctermbg=" . framebgNumber
-"let g:forms_log_enabled = g:self#IS_FALSE
-"let g:forms_log_enabled = g:self#IS_TRUE
-"call forms#log("DROPSHADOW")
-"call forms#log("backgroundNumber=".backgroundNumber)
let dropshadowfgNumber = forms#color#term#ConvertRGBTxt_2_Int(dropshadowfgColor)
let dropshadowbgNumber = forms#color#term#ConvertRGBTxt_2_Int(dropshadowbgColor)
-"call forms#log("dropshadowfgNumber=".dropshadowfgNumber)
execute "hi DropShadowHi cterm=NONE ctermbg=".dropshadowbgNumber." ctermfg=" . dropshadowfgNumber
-"let g:forms_log_enabled = g:self#IS_FALSE
let disableNumber = forms#color#term#ConvertRGBTxt_2_Int(disableColor)
@@ -6030,12 +6019,15 @@ function! forms#loadSliderPrototype()
endif
endif
- if self.__resolution < 0
+ if self.__resolution < 1
throw "Slider: resolution must 1, 2, 3 or 4: " . self.__resolution
endif
if self.__resolution > 4
throw "Slider: resolution must 1, 2, 3 or 4: " . self.__resolution
endif
+if &encoding != 'utf-8'
+let self.__resolution = 1
+endif
return self
endfunction
@@ -6400,7 +6392,11 @@ function! forms#loadHSliderPrototype()
let size = self.__size
let resolution = self.__resolution
- let full = b:forms_FullB
+ if &encoding == 'utf-8'
+ let full = b:forms_FullB
+ else
+ let full = 'X'
+ endif
" call forms#log("g:forms#HSlider.draw resolution=" . resolution)
" nos possible positions = resolution * (size-1) + 1
@@ -6412,9 +6408,9 @@ function! forms#loadHSliderPrototype()
call forms#SetHCharsAt(' ', (size-1), line, column)
call forms#SetCharAt(full, line, column+size-1)
else
- call forms#SetHCharsAt(' ', (pos-1), line, column)
+ call forms#SetHCharsAt(' ', pos, line, column)
call forms#SetCharAt(full, line, column+pos)
- call forms#SetHCharsAt(' ', (size-pos=1), line, column+pos+1)
+ call forms#SetHCharsAt(' ', (size-pos-1), line, column+pos+1)
endif
elseif resolution == 2
@@ -6425,27 +6421,18 @@ function! forms#loadHSliderPrototype()
let offset = value * nosoffsets/(upper-lower+1)
let p = (offset/el_per_cell) * el_per_cell
let i = offset - p
-" call forms#log("g:forms#HSlider.draw nosoffsets=" . nosoffsets)
-" call forms#log("g:forms#HSlider.draw value=" . value)
-" call forms#log("g:forms#HSlider.draw offset=" . offset)
-" call forms#log("g:forms#HSlider.draw p=" . p)
-" call forms#log("g:forms#HSlider.draw i=" . i)
let pp = p / el_per_cell
-" call forms#log("g:forms#HSlider.draw pp=" . pp)
if i == 0
if pp == 0
-" call forms#log("g:forms#HSlider.draw A")
call forms#SetCharAt(full, line, column)
call forms#SetHCharsAt(' ', (size-1), line, column+1)
elseif pp == size-1
-" call forms#log("g:forms#HSlider.draw B")
call forms#SetHCharsAt(' ', (size-1), line, column)
call forms#SetCharAt(full, line, column+size-1)
else
-" call forms#log("g:forms#HSlider.draw C")
call forms#SetHCharsAt(' ', (pp), line, column)
" call forms#SetCharAt(' ', line, column+pp-1)
call forms#SetCharAt(full, line, column+pp)
@@ -6454,7 +6441,6 @@ function! forms#loadHSliderPrototype()
endif
else
-" call forms#log("g:forms#HSlider.draw D")
if pp > 0
call forms#SetHCharsAt(' ', (pp), line, column)
endif
@@ -6744,7 +6730,11 @@ function! forms#loadVSliderPrototype()
let size = self.__size
let resolution = self.__resolution
- let full = b:forms_FullB
+ if &encoding == 'utf-8'
+ let full = b:forms_FullB
+ else
+ let full = 'X'
+ endif
" call forms#log("g:forms#VSlider.draw resolution=" . resolution)
" nos possible positions = resolution * (size-1) + 1
@@ -6756,9 +6746,9 @@ function! forms#loadVSliderPrototype()
call forms#SetVCharsAt(' ', (size-1), line, column)
call forms#SetCharAt(full, line+size-1, column)
else
- call forms#SetVCharsAt(' ', (pos-1), line, column)
+ call forms#SetVCharsAt(' ', pos, line, column)
call forms#SetCharAt(full, line+pos, column)
- call forms#SetVCharsAt(' ', (size-pos=1), line+pos+1, column)
+ call forms#SetVCharsAt(' ', (size-pos-1), line+pos+1, column)
endif
elseif resolution == 2
@@ -7164,7 +7154,6 @@ function! forms#loadBoxPrototype()
if self.__status != g:IS_INVISIBLE
let m = 1
-
call forms#DrawBox(self.__mode, a.line, a.column, a.width, a.height)
" call forms#log("g:forms#Box.draw calling body")
@@ -7402,7 +7391,9 @@ function! forms#loadDropShadowPrototype()
let hi = self.__highlight
+if &encoding == 'utf-8'
call forms#DrawDropShadow(c, line, column, width-1, height-1)
+endif
if c == 'ul'
call GlyphHilight(self, hi, {
@@ -7585,7 +7576,9 @@ function! forms#loadFramePrototype()
let hi = self.__highlight
"call forms#log("g:forms#Frame.draw c=".c)
+if &encoding == 'utf-8'
call forms#DrawFrame(c, line, column, width, height)
+endif
call GlyphHilight(self, hi, {
\ 'line': line,
@@ -14616,15 +14609,19 @@ function! forms#addBoxDrawingCharacterSet(name, dr, uh, dl, rv, ul, lh, ur, lv,)
endfunction
function! forms#LookupBoxDrawingCharacterSet(name)
- if has_key(s:boxDrawingCharacterSets, a:name)
- return s:boxDrawingCharacterSets[a:name]
- else
- call forms#log("LookupBoxDrawingCharacterSet: unknown box drawing character set: " . a:name)
- if &encoding == 'utf-8'
- return s:boxDrawingCharacterSets['light']
+ if &encoding == 'utf-8'
+ if has_key(s:boxDrawingCharacterSets, a:name)
+ return s:boxDrawingCharacterSets[a:name]
else
- return s:boxDrawingCharacterSets['default']
+ call forms#log("LookupBoxDrawingCharacterSet: unknown box drawing character set: " . a:name)
+ if &encoding == 'utf-8'
+ return s:boxDrawingCharacterSets['light']
+ else
+ return s:boxDrawingCharacterSets['default']
+ endif
endif
+ else
+ return s:boxDrawingCharacterSets['default']
endif
endfunction
@@ -298,7 +298,7 @@ endwhile
" 6 intensity RGB
" intensities = [0, 42, 85, 127, 170, 212]
" intensities = (0x00, 0x2a, 0x55, 0x7f, 0xaa, 0xd4)
-let forms#color#eterm#intensities256 = [
+let s:intensities = [
\ str2nr("0x00",16),
\ str2nr("0x2a",16),
\ str2nr("0x55",16),
@@ -298,7 +298,7 @@ endwhile
" 6 intensity RGB
" intensities = [0, 51, 102, 153, 204, 255]
" intensities = (0x00, 0x33, 0x66, 0x99, 0xcc, 0xff )
-let forms#color#konsole#intensities256 = [
+let s:intensities = [
\ str2nr("0x00",16),
\ str2nr("0x33",16),
\ str2nr("0x66",16),
@@ -316,7 +316,7 @@ let forms#color#konsole#intensities256 = [
" rgb : Parameters accepted by ParseRGB
" ------------------------------------------------------------
-" binary search over possible intensities256
+" binary search over possible intensities
function! s:GetPartial_Int256(n)
" intensities = [0, 51, 102, 153, 204, 255]
" intensities = (0x00, 0x33, 0x66, 0x99, 0xcc, 0xff )
Oops, something went wrong.

0 comments on commit c0b2916

Please sign in to comment.