TextView.st
changeset 77 565b052f5277
parent 70 14443a9ea4ec
child 81 0c97b2905d5b
equal deleted inserted replaced
76:81e3409404d2 77:565b052f5277
    32 
    32 
    33 TextView comment:'
    33 TextView comment:'
    34 COPYRIGHT (c) 1989 by Claus Gittinger
    34 COPYRIGHT (c) 1989 by Claus Gittinger
    35 	     All Rights Reserved
    35 	     All Rights Reserved
    36 
    36 
    37 $Header: /cvs/stx/stx/libwidg/TextView.st,v 1.13 1994-11-28 21:05:24 claus Exp $
    37 $Header: /cvs/stx/stx/libwidg/TextView.st,v 1.14 1995-02-06 00:53:24 claus Exp $
    38 '!
    38 '!
    39 
    39 
    40 !TextView class methodsFor:'documentation'!
    40 !TextView class methodsFor:'documentation'!
    41 
    41 
    42 copyright
    42 copyright
    53 "
    53 "
    54 !
    54 !
    55 
    55 
    56 version
    56 version
    57 "
    57 "
    58 $Header: /cvs/stx/stx/libwidg/TextView.st,v 1.13 1994-11-28 21:05:24 claus Exp $
    58 $Header: /cvs/stx/stx/libwidg/TextView.st,v 1.14 1995-02-06 00:53:24 claus Exp $
    59 "
    59 "
    60 !
    60 !
    61 
    61 
    62 documentation
    62 documentation
    63 "
    63 "
    80     selectionBgColor        <Color>                 color used to draw selections
    80     selectionBgColor        <Color>                 color used to draw selections
    81     fileBox                 <FileSelectionBox>      box for save
    81     fileBox                 <FileSelectionBox>      box for save
    82     searchBox               <EnterBox2>             box to enter searchpattern
    82     searchBox               <EnterBox2>             box to enter searchpattern
    83     lineNumberBox           <EnterBox>              box to enter linenumber
    83     lineNumberBox           <EnterBox>              box to enter linenumber
    84     selectStyle             <Symbol>                how words are selected
    84     selectStyle             <Symbol>                how words are selected
       
    85 
       
    86     StyleSheet parameters:
       
    87 
       
    88     textViewBackground                 defaults to viewBackground
       
    89     textSelectionForegroundColor       defaults to textBackgroundColor
       
    90     textSelectionBackgroundColor       defaults to textForegroundColor
       
    91     textViewFont                       defaults to textFont
    85 "
    92 "
    86 ! !
    93 ! !
    87 
    94 
    88 !TextView class methodsFor:'startup'!
    95 !TextView class methodsFor:'startup'!
    89 
    96 
   157 
   164 
   158 updateStyleCache
   165 updateStyleCache
   159     DefaultViewBackground := StyleSheet colorAt:'textViewBackground' default:White.
   166     DefaultViewBackground := StyleSheet colorAt:'textViewBackground' default:White.
   160     DefaultSelectionForegroundColor := StyleSheet colorAt:'textSelectionForegroundColor'.
   167     DefaultSelectionForegroundColor := StyleSheet colorAt:'textSelectionForegroundColor'.
   161     DefaultSelectionBackgroundColor := StyleSheet colorAt:'textSelectionBackgroundColor'.
   168     DefaultSelectionBackgroundColor := StyleSheet colorAt:'textSelectionBackgroundColor'.
   162     DefaultFont := StyleSheet fontAt:'textFont'.
   169     DefaultFont := StyleSheet fontAt:'textViewFont'.
   163 ! !
   170 ! !
   164 
   171 
   165 !TextView methodsFor:'initialize & release'!
   172 !TextView methodsFor:'initialize & release'!
   166 
   173 
   167 initialize
   174 initialize
   532 
   539 
   533     |text|
   540     |text|
   534 
   541 
   535     text := self selection.
   542     text := self selection.
   536     text notNil ifTrue:[
   543     text notNil ifTrue:[
   537 	Smalltalk at:#CopyBuffer put:text.
   544 	self unselect.
   538 	self unselect
   545 	self setTextSelection:text
   539     ]
   546     ]
   540 !
   547 !
   541 
   548 
   542 changeFont
   549 changeFont
   543     "pop up a fontPanel to change font"
   550     "pop up a fontPanel to change font"
   544 
   551 
   545     MyFontPanel isNil ifTrue:[
   552     |panel|
   546 	MyFontPanel := FontPanel new
   553 
   547     ].
   554     panel := FontPanel new.
   548     MyFontPanel action:[:family :face :style :size |
   555     panel action:[:family :face :style :size |
   549 	self font:(Font family:family
   556 	self font:(Font family:family
   550 			  face:face
   557 			  face:face
   551 			 style:style
   558 			 style:style
   552 			  size:size)
   559 			  size:size)
   553     ].
   560     ].
   554     MyFontPanel initialFont:font.
   561     panel initialFont:font.
   555     MyFontPanel showAtPointer
   562     panel showAtPointer
   556 !
   563 !
   557 
   564 
   558 defaultForGotoLine
   565 defaultForGotoLine
   559     "return a default value to show in the gotoLine box"
   566     "return a default value to show in the gotoLine box"
   560 
   567 
   921      (used to be: tell user by changing cursor for a while)"
   928      (used to be: tell user by changing cursor for a while)"
   922 
   929 
   923     |savedCursor|
   930     |savedCursor|
   924 
   931 
   925     device beep.
   932     device beep.
       
   933 
   926 "
   934 "
   927     uncomment if you want a CROSS cursor to be shown for a while ..
   935     uncomment if you want a CROSS cursor to be shown for a while ..
   928 "
   936 "
   929 
   937 
   930 " "
   938 " "
  1167 		(selectionStartCol ~~ 1) ifTrue:[
  1175 		(selectionStartCol ~~ 1) ifTrue:[
  1168 		    self clearMarginOfVisible:visLine with:bgColor.
  1176 		    self clearMarginOfVisible:visLine with:bgColor.
  1169 		    super redrawVisibleLine:visLine
  1177 		    super redrawVisibleLine:visLine
  1170 				       from:1
  1178 				       from:1
  1171 					 to:(selectionStartCol - 1)
  1179 					 to:(selectionStartCol - 1)
       
  1180 		] ifFalse:[
       
  1181 		    leftOffset == 0 ifTrue:[
       
  1182 			self clearMarginOfVisible:visLine with:selectionBgColor.
       
  1183 		    ]
  1172 		].
  1184 		].
  1173 		self drawVisibleLine:visLine from:selectionStartCol
  1185 		self drawVisibleLine:visLine from:selectionStartCol
  1174 				with:selectionFgColor and:selectionBgColor.
  1186 				with:selectionFgColor and:selectionBgColor.
  1175 		^ self
  1187 		^ self
  1176 	    ].
  1188 	    ].