VT100TerminalView.st
changeset 4297 da54726fd311
parent 4296 c52538ab6102
child 4298 c9c174303f4e
--- a/VT100TerminalView.st	Tue Jul 23 23:08:35 2013 +0200
+++ b/VT100TerminalView.st	Wed Jul 24 11:49:45 2013 +0200
@@ -144,6 +144,24 @@
 
 !VT100TerminalView methodsFor:'defaults'!
 
+colorAtIndex:idx
+    |colorName colorModifier clr|
+
+    colorName := #(black red green yellow blue magenta cyan white) at:idx.
+    self backgroundColor brightness < 0.5 ifTrue:[
+        "/ dark backgrounds
+        colorModifier := #(nil nil nil nil lightened nil nil nil) at:idx.
+    ] ifFalse:[
+        "/ bright backgrounds
+        colorModifier := #(nil nil darkened darkened nil darkened darkened nil) at:idx.
+    ].
+    clr := Color perform:colorName.
+    colorModifier notNil ifTrue:[
+        clr := clr perform:colorModifier
+    ].
+    ^ clr
+!
+
 vt100AlternativeKeyCodes
     "return the alternative vt100 keyCode table"
 
@@ -274,10 +292,12 @@
 displayMode:p1
     "Set the current display mode (emphasis) as specified by param 1."
 
-    |clrName|
+"/    self endEntry.    -- not needed (does not affect characters on screen or buffered or cursor position
+    p1 == 0 ifTrue:[
+        self normal.
+        ^ self.
+    ].
 
-
-"/    self endEntry.
     p1 == 1 ifTrue:[
         "/ ESC-[-1-m  -> bold
 
@@ -318,8 +338,7 @@
         "/ ESC-[-31-m  -> red   fg color
         "/ ...
         "/ ESC-[-37-m  -> white fg color
-        clrName := #(black red green yellow blue magenta cyan white) at:(p1-30+1).
-        self color:(Color perform:clrName).
+        self color:(self colorAtIndex:(p1-30+1)).
         ^ self.
     ].
     p1 == 39 ifTrue:[
@@ -331,8 +350,7 @@
         "/ ESC-[-40-m  -> black bg color
         "/ ...
         "/ ESC-[-47-m  -> white bg color
-        clrName := #(black red green yellow blue magenta cyan white) at:(p1-40+1).
-        self bgColor:(Color perform:clrName).
+        self bgColor:(self colorAtIndex:(p1-40+1)).
         ^ self.
     ].
     p1 == 49 ifTrue:[
@@ -342,13 +360,11 @@
     ].
 
     (p1 between:90 and:97) ifTrue:[
-        clrName := #(black red green yellow blue magenta cyan white) at:(p1-30+1).
-        self color:(Color perform:clrName) lightened.
+        self color:(self colorAtIndex:(p1-90+1)) lightened.
         ^ self.
     ].
     (p1 between:100 and:107) ifTrue:[
-        clrName := #(black red green yellow blue magenta cyan white) at:(p1-30+1).
-        self bgColor:(Color perform:clrName) lightened.
+        self bgColor:(self colorAtIndex:(p1-100+1)) lightened.
         ^ self.
     ].
 
@@ -975,7 +991,9 @@
     ].
     char == $m ifTrue: [
         "/ character attributes (SGR)
-        self displayMode:(self getParameter:1 withDefault:0).
+        1 to:currentParam do:[:pI |
+            self displayMode:(self getParameter:pI withDefault:0).
+        ].
         ^ #sequenceComplete
     ].
     char == $r ifTrue: [
@@ -1169,10 +1187,10 @@
 !VT100TerminalView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/VT100TerminalView.st,v 1.54 2013-07-23 21:08:35 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/VT100TerminalView.st,v 1.55 2013-07-24 09:49:45 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/VT100TerminalView.st,v 1.54 2013-07-23 21:08:35 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/VT100TerminalView.st,v 1.55 2013-07-24 09:49:45 cg Exp $'
 ! !