--- a/ListView.st Tue Jul 19 17:23:51 2016 +0200
+++ b/ListView.st Tue Jul 19 21:45:20 2016 +0200
@@ -9,6 +9,8 @@
other person. No title to or ownership of the software is
hereby transferred.
"
+'From Smalltalk/X, Version:7.1.0.0 on 15-07-2016 at 17:28:27' !
+
"{ Package: 'stx:libwidg' }"
"{ NameSpace: Smalltalk }"
@@ -87,10 +89,10 @@
(especially: attributed Text and labelAndIcon-like entities).
The internal version of the text has tabulators expanded to blanks. ListView is not prepared
- to deal with them. When text is exchanged with an external medium (i.e. reading/writing files),
- these are expanded/compressed assuming a tab-setting of 8.
+ to deal with them. When text is exchanged with an external medium (i.e. reading/writing files),
+ these are expanded/compressed assuming a tab-setting of 8.
This is done independent of the user's tab setting, which is used ONLY for positioning,
- while the text is edited.
+ while the text is edited.
Thus, even if the tab setting is multiple of 4's, tabs are
written in multiples of 8 when the text is saved. Since this is the default on all ascii
terminals and printers, this assures that the text looks correctly indented when finally printed.
@@ -104,11 +106,11 @@
views. The general scrolling code (in View) uses the transformation for transparent scrolling
using the viewOrigin (transparent means, that the code does not need to know - it simply draws
as if all of the text was visible).
- Here in ListView, the transformation is not used, instead it is done again, and different,
+ Here in ListView, the transformation is not used, instead it is done again, and different,
by keeping the firstLineShown (i.e. vertical offset) and leftOffset (horizontal offset).
- Even worse: the firstLineShown is a line-index, the most annoying consequence of this is that
- scrolling is done by lines here, whereas it is done in pixels in the View class.
- Thus, be very careful, when changing things (better: don't touch it ;-).
+ Even worse: the firstLineShown is a line-index, the most annoying consequence of this is that
+ scrolling is done by lines here, whereas it is done in pixels in the View class.
+ Thus, be very careful, when changing things (better: don't touch it ;-).
Also, the viewOrigin variable is only valid for the x coordinate. The viewOrigin's y is always 0 !!
Also, all controller functionality is completely performed by the listView
@@ -145,15 +147,15 @@
[Instance variables:]
list <aCollection> the text strings, a collection of lines.
- Nils may be used for empty lines.
+ Nils may be used for empty lines.
firstLineShown <Number> the index of the 1st visible line (1 ..)
leftOffset <Number> left offset for horizontal scroll
nFullLinesShown <Number> the number of unclipped lines in visible area
- (internal; updated on size changes)
+ (internal; updated on size changes)
nLinesShown <Number> the number of lines in visible area, incl. partial
- (internal; updated on size changes)
+ (internal; updated on size changes)
fgColor <Color> color to draw characters
bgColor <Color> the background
@@ -171,39 +173,39 @@
fontWidth <Number> width of space (internal)
lineSpacing <Number> pixels between lines
lastSearchPattern <String> last pattern for searching
- (kept to provide a default for next search)
+ (kept to provide a default for next search)
lastSearchIgnoredCase <Boolean> last search ignored case
- (kept to provide a default for next search)
+ (kept to provide a default for next search)
wordCheck <Block> rule used for check for word boundaries in word select
- The default rule is to return true for alphaNumeric characters.
- (can be changed to allow for underscore and other
- characters to be treated as alphaCharacters)
+ The default rule is to return true for alphaNumeric characters.
+ (can be changed to allow for underscore and other
+ characters to be treated as alphaCharacters)
autoScrollBlock <Block> block installed as timeoutBlock when doing an
- autoScroll (internal)
+ autoScroll (internal)
autoScrollDeltaT computed scroll time delta in seconds (internal)
includesNonStrings cached flag if any non-strings are in list
widthOfWidestLine cached width of widest line
listMsg if view has a model and listMsg is non-nil,
- this is sent to the model to acquired a new contents
- whenever a change of the aspect (aspectMsg) occurs.
+ this is sent to the model to acquired a new contents
+ whenever a change of the aspect (aspectMsg) occurs.
viewOrigin the current origin
backgroundAlreadyClearedColor internal; speedup by avoiding
- multiple fills when drawing
- internal lines
+ multiple fills when drawing
+ internal lines
scrollWhenUpdating
- <Symbol> defines how the view is scrolled if the
- model changes its value by some outside activity
- (i.e. not by user input).
- Can be one of:
- #keep / nil -> stay unchanged
- #endOfText -> scroll to the end
- #beginOfText -> scroll to the top
- The default is #beginOfText (i.e. scroll to top).
+ <Symbol> defines how the view is scrolled if the
+ model changes its value by some outside activity
+ (i.e. not by user input).
+ Can be one of:
+ #keep / nil -> stay unchanged
+ #endOfText -> scroll to the end
+ #beginOfText -> scroll to the top
+ The default is #beginOfText (i.e. scroll to top).
[StyleSheet parameters:]
@@ -213,10 +215,10 @@
textTabPositions defaults to #(1 9 17 25 ...)
[author:]
- Claus Gittinger
+ Claus Gittinger
[see also:]
- TextView EditTextView
+ TextView EditTextView
"
!
@@ -229,215 +231,215 @@
anyway, here are a few examples:
basic simple setup:
- [exBegin]
- |top l|
-
- top := StandardSystemView new.
- top extent:100@200.
-
- l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
- l list:#('one' 'two' 'three').
-
- top open
- [exEnd]
+ [exBegin]
+ |top l|
+
+ top := StandardSystemView new.
+ top extent:100@200.
+
+ l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
+ l list:#('one' 'two' 'three').
+
+ top open
+ [exEnd]
specifying textMargins (these have NOTHING to do with the viewInset):
- [exBegin]
- |top l|
-
- top := StandardSystemView new.
- top extent:100@200.
-
- l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
- l list:#('one' 'two' 'three').
- l topMargin:10.
- l leftMargin:20.
-
- top open
- [exEnd]
+ [exBegin]
+ |top l|
+
+ top := StandardSystemView new.
+ top extent:100@200.
+
+ l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
+ l list:#('one' 'two' 'three').
+ l topMargin:10.
+ l leftMargin:20.
+
+ top open
+ [exEnd]
globally set the fg/bg colors:
- [exBegin]
- |top l|
-
- top := StandardSystemView new.
- top extent:100@200.
-
- l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
- l list:#('one' 'two' 'three').
- l foregroundColor:(Color white).
- l backgroundColor:(Color blue).
-
- top open
- [exEnd]
+ [exBegin]
+ |top l|
+
+ top := StandardSystemView new.
+ top extent:100@200.
+
+ l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
+ l list:#('one' 'two' 'three').
+ l foregroundColor:(Color white).
+ l backgroundColor:(Color blue).
+
+ top open
+ [exEnd]
non-string (text) entries:
- [exBegin]
- |top list l|
-
- top := StandardSystemView new.
- top extent:100@200.
-
- l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
- list := #('all' 'of' 'your' 'preferred' 'colors')
- with:#(red green blue 'orange' cyan)
- collect:[:s :clr |
- Text string:s
- emphasis:(Array with:#bold
- with:(#color->(Color name:clr))) ].
- l list:list.
-
- top open
- [exEnd]
+ [exBegin]
+ |top list l|
+
+ top := StandardSystemView new.
+ top extent:100@200.
+
+ l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
+ list := #('all' 'of' 'your' 'preferred' 'colors')
+ with:#(red green blue 'orange' cyan)
+ collect:[:s :clr |
+ Text string:s
+ emphasis:(Array with:#bold
+ with:(#color->(Color name:clr))) ].
+ l list:list.
+
+ top open
+ [exEnd]
generic non-string entries:
(notice: ColoredListEntry is obsoleted by Text)
- [exBegin]
- |top list l|
-
- top := StandardSystemView new.
- top extent:100@200.
-
- l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
- list := #('all' 'of' 'your' 'preferred' 'colors')
- with:#(red green blue 'orange' cyan)
- collect:[:s :clr | ColoredListEntry string:s color:(Color name:clr) ].
- l list:list.
-
- top open
- [exEnd]
+ [exBegin]
+ |top list l|
+
+ top := StandardSystemView new.
+ top extent:100@200.
+
+ l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
+ list := #('all' 'of' 'your' 'preferred' 'colors')
+ with:#(red green blue 'orange' cyan)
+ collect:[:s :clr | ColoredListEntry string:s color:(Color name:clr) ].
+ l list:list.
+
+ top open
+ [exEnd]
using a model (default listMessage is aspectMessage):
- [exBegin]
- |top model l theModelsText|
-
- model := Plug new.
- model respondTo:#modelsAspect
- with:[ theModelsText ].
-
- top := StandardSystemView new.
- top extent:100@200.
-
- l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
- l model:model.
- l aspect:#modelsAspect.
-
- top open.
-
- Delay waitForSeconds:3.
- theModelsText := #('foo' 'bar' 'baz').
- model changed:#modelsAspect.
- [exEnd]
+ [exBegin]
+ |top model l theModelsText|
+
+ model := Plug new.
+ model respondTo:#modelsAspect
+ with:[ theModelsText ].
+
+ top := StandardSystemView new.
+ top extent:100@200.
+
+ l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
+ l model:model.
+ l aspect:#modelsAspect.
+
+ top open.
+
+ Delay waitForSeconds:3.
+ theModelsText := #('foo' 'bar' 'baz').
+ model changed:#modelsAspect.
+ [exEnd]
using a model with different aspects
for two listViews:
- [exBegin]
- |top model l1 l2 plainText|
-
- plainText := #('').
-
- model := Plug new.
- model respondTo:#modelsUppercaseText
- with:[ plainText asStringCollection
- collect:[:l | l asUppercase]].
- model respondTo:#modelsLowercaseText
- with:[ plainText asStringCollection
- collect:[:l | l asLowercase]].
-
- top := StandardSystemView extent:200@200.
-
- l1 := ListView origin:0.0 @ 0.0 corner:1.0 @ 0.5 in:top.
- l1 model:model.
- l1 aspect:#modelsAspect.
- l1 listMessage:#modelsUppercaseText.
-
- l2 := ListView origin:0.0 @ 0.5 corner:1.0 @ 1.0 in:top.
- l2 model:model.
- l2 aspect:#modelsAspect.
- l2 listMessage:#modelsLowercaseText.
-
- top open.
-
- Delay waitForSeconds:3.
- plainText := #('foo' 'bar' 'baz').
- model changed:#modelsAspect.
- [exEnd]
+ [exBegin]
+ |top model l1 l2 plainText|
+
+ plainText := #('').
+
+ model := Plug new.
+ model respondTo:#modelsUppercaseText
+ with:[ plainText asStringCollection
+ collect:[:l | l asUppercase]].
+ model respondTo:#modelsLowercaseText
+ with:[ plainText asStringCollection
+ collect:[:l | l asLowercase]].
+
+ top := StandardSystemView extent:200@200.
+
+ l1 := ListView origin:0.0 @ 0.0 corner:1.0 @ 0.5 in:top.
+ l1 model:model.
+ l1 aspect:#modelsAspect.
+ l1 listMessage:#modelsUppercaseText.
+
+ l2 := ListView origin:0.0 @ 0.5 corner:1.0 @ 1.0 in:top.
+ l2 model:model.
+ l2 aspect:#modelsAspect.
+ l2 listMessage:#modelsLowercaseText.
+
+ top open.
+
+ Delay waitForSeconds:3.
+ plainText := #('foo' 'bar' 'baz').
+ model changed:#modelsAspect.
+ [exEnd]
using a big list (100000 lines),
wrapping in a ScrollableView:
- [exBegin]
- |bigList top lv|
-
- bigList := (1 to:100000) collect:[:lineNr | 'List line Nr. ' , lineNr printString].
- bigList at:10 put:('Some Text ' asText , 'with Bold part' allBold).
- bigList at:20 put:('Some Text ' asText , 'with Italic part' allItalic).
-
- top := StandardSystemView extent:200@200.
-
- lv := HVScrollableView for:ListView in:top.
- lv origin:0.0 @ 0.0 corner:1.0 @ 1.0.
- lv list:bigList expandTabs:false scanForNonStrings:false includesNonStrings:false.
-
- top open.
- [exEnd]
+ [exBegin]
+ |bigList top lv|
+
+ bigList := (1 to:100000) collect:[:lineNr | 'List line Nr. ' , lineNr printString].
+ bigList at:10 put:('Some Text ' asText , 'with Bold part' allBold).
+ bigList at:20 put:('Some Text ' asText , 'with Italic part' allItalic).
+
+ top := StandardSystemView extent:200@200.
+
+ lv := HVScrollableView for:ListView in:top.
+ lv origin:0.0 @ 0.0 corner:1.0 @ 1.0.
+ lv list:bigList expandTabs:false scanForNonStrings:false includesNonStrings:false.
+
+ top open.
+ [exEnd]
using a huge virtual list (1 mio simulated lines),
wrapping in a ScrollableView:
- [exBegin]
- |virtualList top lv|
-
- virtualList := Plug new.
- virtualList inheritFrom:SequenceableCollection.
- virtualList respondTo:#size with:[ 1000000 ].
- virtualList respondTo:#at: with:[:lineNr | 'List line Nr. ' , lineNr printString ].
-
- top := StandardSystemView extent:200@200.
-
- lv := ScrollableView for:ListView in:top.
- lv origin:0.0 @ 0.0 corner:1.0 @ 1.0.
- lv list:virtualList expandTabs:false scanForNonStrings:false includesNonStrings:false.
-
- top open.
- [exEnd]
+ [exBegin]
+ |virtualList top lv|
+
+ virtualList := Plug new.
+ virtualList inheritFrom:SequenceableCollection.
+ virtualList respondTo:#size with:[ 1000000 ].
+ virtualList respondTo:#at: with:[:lineNr | 'List line Nr. ' , lineNr printString ].
+
+ top := StandardSystemView extent:200@200.
+
+ lv := ScrollableView for:ListView in:top.
+ lv origin:0.0 @ 0.0 corner:1.0 @ 1.0.
+ lv list:virtualList expandTabs:false scanForNonStrings:false includesNonStrings:false.
+
+ top open.
+ [exEnd]
using a huge virtual array (1 mio simulated lines),
wrapping in a ScrollableView.
To simulate an expensive computation, a delay is planted into the line generator;
Startup and display of page full of lines should not take longer than the number of lines shown:
- [exBegin]
- |virtualList top lv|
-
- virtualList := VirtualArray new.
- virtualList
- setSize:1000000;
- generator:[:index | Transcript showCR:index.
- Delay waitForSeconds:0.5.
- '%1 -> %2' bindWith:index with:index squared].
-
- top := StandardSystemView extent:200@200.
-
- lv := ScrollableView for:ListView in:top.
- lv origin:0.0 @ 0.0 corner:1.0 @ 1.0.
- lv expandTabsWhenUpdating:false.
- lv checkLineEndConventionWhenUpdating:false.
- lv checkedLinesForWidthOfContentsComputation:-1.
- lv list:virtualList.
-
- top open.
- [exEnd]
+ [exBegin]
+ |virtualList top lv|
+
+ virtualList := VirtualArray new.
+ virtualList
+ setSize:1000000;
+ generator:[:index | Transcript showCR:index.
+ Delay waitForSeconds:0.5.
+ '%1 -> %2' bindWith:index with:index squared].
+
+ top := StandardSystemView extent:200@200.
+
+ lv := ScrollableView for:ListView in:top.
+ lv origin:0.0 @ 0.0 corner:1.0 @ 1.0.
+ lv expandTabsWhenUpdating:false.
+ lv checkLineEndConventionWhenUpdating:false.
+ lv checkedLinesForWidthOfContentsComputation:-1.
+ lv list:virtualList.
+
+ top open.
+ [exEnd]
"
! !
@@ -482,11 +484,11 @@
"extract values from the styleSheet and cache them in class variables"
<resource: #style (#'text.foregroundColor' #'text.backgroundColor'
- #'text.tabPositions'
- #'text.font')>
-
- DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black.
- DefaultBackgroundColor := StyleSheet colorAt:'text.backgroundColor' default:White.
+ #'text.tabPositions'
+ #'text.font')>
+
+ DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Color black.
+ DefaultBackgroundColor := StyleSheet colorAt:'text.backgroundColor' default:Color white.
DefaultFont := StyleSheet fontAt:'text.font'.
"/ that's not style, but a personal setting
"/ DefaultTabPositions := StyleSheet at:'text.tabPositions'.
@@ -579,14 +581,14 @@
compareModelWhenUpdating
"return the compare when updating behavior.
- If true (the default), the list of lines as given due to a model update
- is processed and compared against the currently shown text.
+ If true (the default), the list of lines as given due to a model update
+ is processed and compared against the currently shown text.
If they are the same, no action is taken.
This behavior is ok in 99.99% of all applications.
However, you may turn this off iff:
- - it is very expensive to process the list (for example, because the list
- is defined by a virtual array, which computes the lines dynamically, on
- the fly).
+ - it is very expensive to process the list (for example, because the list
+ is defined by a virtual array, which computes the lines dynamically, on
+ the fly).
One use where this flag should be turned off is in the hex-memory display,
which is able to simulate texts with millions of lines, but they are actually
simulated by generating the presented lines dynamically, as they are displayed."
@@ -596,14 +598,14 @@
compareModelWhenUpdating:aBoolean
"define the compare when updating behavior.
- If true (the default), the list of lines as given due to a model update
- is processed and compared against the currently shown text.
+ If true (the default), the list of lines as given due to a model update
+ is processed and compared against the currently shown text.
If they are the same, no action is taken.
This behavior is ok in 99.99% of all applications.
However, you may turn this off iff:
- - it is very expensive to process the list (for example, because the list
- is defined by a virtual array, which computes the lines dynamically, on
- the fly).
+ - it is very expensive to process the list (for example, because the list
+ is defined by a virtual array, which computes the lines dynamically, on
+ the fly).
One use where this flag should be turned off is in the hex-memory display,
which is able to simulate texts with millions of lines, but they are actually
simulated by generating the presented lines dynamically, as they are displayed."
@@ -613,15 +615,15 @@
expandTabsWhenUpdating
"return the tab expansion behavior.
- If true (the default), the list of lines as given via #list: or
+ If true (the default), the list of lines as given via #list: or
due to a model update is processed and lines are replaced by lines with
tabs expanded.
This behavior is ok in 99.99% of all applications.
However, you may turn this off iff:
- - you are certain, that no tabs are in the passed in list
- - it is very expensive to process the list (for example, because the list
- is defined by a virtual array, which computes the lines dynamically, on
- the fly).
+ - you are certain, that no tabs are in the passed in list
+ - it is very expensive to process the list (for example, because the list
+ is defined by a virtual array, which computes the lines dynamically, on
+ the fly).
One use where this flag should be turned off is in the hex-memory display,
which is able to simulate texts with millions of lines, but they are actually
simulated by generating the presented lines dynamically, as they are displayed."
@@ -631,15 +633,15 @@
expandTabsWhenUpdating:aBoolean
"define the tab expansion behavior.
- If true (the default), the list of lines as given via #list: or
+ If true (the default), the list of lines as given via #list: or
due to a model update is processed and lines are replaced by lines with
tabs expanded.
This behavior is ok in 99.99% of all applications.
However, you may turn this off iff:
- - you are certain, that no tabs are in the passed in list
- - it is very expensive to process the list (for example, because the list
- is defined by a virtual array, which computes the lines dynamically, on
- the fly).
+ - you are certain, that no tabs are in the passed in list
+ - it is very expensive to process the list (for example, because the list
+ is defined by a virtual array, which computes the lines dynamically, on
+ the fly).
One use where this flag should be turned off is in the hex-memory display,
which is able to simulate texts with millions of lines, but they are actually
simulated by generating the presented lines dynamically, as they are displayed."
@@ -710,22 +712,22 @@
list add:aString.
includesNonStrings ifFalse:[
- includesNonStrings := (aString notNil and:[(aString isSingleByteString) not]).
- includesNonStrings ifTrue:[
- fontHeightBefore := fontHeight.
- self getFontParameters.
- fontHeightBefore ~~ fontHeight ifTrue:[
- self invalidate
- ].
- ].
+ includesNonStrings := (aString notNil and:[(aString isSingleByteString) not]).
+ includesNonStrings ifTrue:[
+ fontHeightBefore := fontHeight.
+ self getFontParameters.
+ fontHeightBefore ~~ fontHeight ifTrue:[
+ self invalidate
+ ].
+ ].
].
widthOfWidestLine notNil ifTrue:[
- self recomputeWidthOfWidestLineFor:aString old:nil.
+ self recomputeWidthOfWidestLineFor:aString old:nil.
].
shown ifTrue:[
- self redrawLine:(self size).
+ self redrawLine:(self size).
].
self enqueueDelayedContentsChangedNotification. "recompute scrollbars"
@@ -741,29 +743,29 @@
list add:aString beforeIndex:index.
widthOfWidestLine notNil ifTrue:[
- self recomputeWidthOfWidestLineFor:aString old:nil.
+ self recomputeWidthOfWidestLineFor:aString old:nil.
].
includesNonStrings ifFalse:[
- includesNonStrings := (aString notNil and:[(aString isSingleByteString) not]).
+ includesNonStrings := (aString notNil and:[(aString isSingleByteString) not]).
"/ includesNonStrings ifTrue:[self getFontParameters].
].
shown ifTrue:[
- lastShown := self lastLineShown.
- index <= 2 ifTrue:[
- self invalidate
- ] ifFalse:[
- index to:lastShown do:[:eachLine |
- self invalidateLine:eachLine
- ].
- ].
+ lastShown := self lastLineShown.
+ index <= 2 ifTrue:[
+ self invalidate
+ ] ifFalse:[
+ index to:lastShown do:[:eachLine |
+ self invalidateLine:eachLine
+ ].
+ ].
].
self enqueueDelayedContentsChangedNotification. "recompute scrollbars"
(scrollWhenUpdating == #end or:[scrollWhenUpdating == #endOfText]) ifTrue:[
- "/ self selection isNil ifTrue:[
- self scrollToBottom.
- "/ ]
+ "/ self selection isNil ifTrue:[
+ self scrollToBottom.
+ "/ ]
].
"Modified: / 25-07-2012 / 12:00:42 / cg"
@@ -776,43 +778,43 @@
list isNil ifTrue:[list := OrderedCollection new].
aCollectionOfLines do:[:eachLine |
- list addAll:aCollectionOfLines beforeIndex:index.
+ list addAll:aCollectionOfLines beforeIndex:index.
].
includesNonStrings ifFalse:[
- includesNonStrings :=
- aCollectionOfLines
- contains:[:someLine |
- someLine notNil and:[(someLine isSingleByteString) not].
- ]
+ includesNonStrings :=
+ aCollectionOfLines
+ contains:[:someLine |
+ someLine notNil and:[(someLine isSingleByteString) not].
+ ]
].
widthOfWidestLine notNil ifTrue:[
- aCollectionOfLines do:[:eachLine |
- self recomputeWidthOfWidestLineFor:eachLine old:nil.
- ].
+ aCollectionOfLines do:[:eachLine |
+ self recomputeWidthOfWidestLineFor:eachLine old:nil.
+ ].
].
"/ widthOfWidestLine := nil. "/ i.e. unknown
self textChanged.
shown ifTrue:[
- lastShown := self lastLineShown.
- ((index-1) <= lastShown) ifTrue:[
- index <= 2 ifTrue:[
- self invalidate
- ] ifFalse:[
- index-1 to:lastShown do:[:eachLine |
- self invalidateLine:eachLine
- ].
- "/ self redrawFromLine:index-1.
- ].
- ].
+ lastShown := self lastLineShown.
+ ((index-1) <= lastShown) ifTrue:[
+ index <= 2 ifTrue:[
+ self invalidate
+ ] ifFalse:[
+ index-1 to:lastShown do:[:eachLine |
+ self invalidateLine:eachLine
+ ].
+ "/ self redrawFromLine:index-1.
+ ].
+ ].
].
self enqueueDelayedContentsChangedNotification. "recompute scrollbars"
(scrollWhenUpdating == #end or:[scrollWhenUpdating == #endOfText]) ifTrue:[
- "/ self selection isNil ifTrue:[
- self scrollToBottom.
- "/ ]
+ "/ self selection isNil ifTrue:[
+ self scrollToBottom.
+ "/ ]
].
"Modified: / 25-07-2012 / 12:00:54 / cg"
@@ -837,12 +839,12 @@
self withoutRedrawAt:index put:aString.
shown ifTrue:[
- fontHeightBefore ~= fontHeight ifTrue:[
- "/ must redraw everything
- self invalidate.
- ^ self
- ].
- self redrawLine:index.
+ fontHeightBefore ~= fontHeight ifTrue:[
+ "/ must redraw everything
+ self invalidate.
+ ^ self
+ ].
+ self redrawLine:index.
"/ the code below is wrong - we really have to redraw everything, if the
"/ fontHeight changes (due to a labelAndIcon in the list).
@@ -860,16 +862,16 @@
"/ self redrawLine:index
"/ ].
- "/ asynchronous:
+ "/ asynchronous:
"/ visibleLine := self listLineToVisibleLine:index.
"/ visibleLine notNil ifTrue:[
"/ y := self yOfVisibleLine:visibleLine.
"/ self invalidate:((margin @ y) extent:(width@fontHeight))
"/ ].
- widthBefore ~~ widthOfWidestLine ifTrue:[
- self enqueueDelayedContentsChangedNotification
- ]
+ widthBefore ~~ widthOfWidestLine ifTrue:[
+ self enqueueDelayedContentsChangedNotification
+ ]
]
"Modified: / 25-07-2012 / 12:01:46 / cg"
@@ -918,17 +920,17 @@
list isNil ifTrue:[^ ''].
self lineEndCRLF ifTrue:[
- lineEnd := String crlf.
+ lineEnd := String crlf.
] ifFalse:[
- lineEnd := Character cr.
+ lineEnd := Character cr.
].
stringCollection := list asStringCollection.
- ^ stringCollection
- asStringWith:lineEnd
- from:1 to:stringCollection size
- compressTabs:false
- final:lineEnd
+ ^ stringCollection
+ asStringWith:lineEnd
+ from:1 to:stringCollection size
+ compressTabs:false
+ final:lineEnd
"Modified: / 04-07-2006 / 19:18:47 / fm"
!
@@ -1018,7 +1020,7 @@
(remembered to optimize later redraws)."
self
- list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nil
+ list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nil
"Modified: 5.6.1997 / 12:40:35 / cg"
!
@@ -1031,12 +1033,12 @@
otherwise, take the information from the nonStrings arg.
(the nonStrings information is remembered to optimize later redraws & height computations)."
- self
- list:aCollection
- expandTabs:expand
- scanForNonStrings:scan
- includesNonStrings:nonStringsIfNoScan
- redraw:true
+ self
+ list:aCollection
+ expandTabs:expand
+ scanForNonStrings:scan
+ includesNonStrings:nonStringsIfNoScan
+ redraw:true
!
list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStringsIfNoScan redraw:doRedraw
@@ -1056,61 +1058,61 @@
"/ notice, that it may be very expensive to ask aCollection for each line
"/ for example, iff the lines are generated on the fly by an algorithm
false ifTrue:[
- "/ see if there is a change at all.
- "/ use to compare using =, but that's not enough in case of emphasis change.
- aCollection size == list size ifTrue:[
- same := true.
- aCollection size > 0 ifTrue:[
- aCollection with:list do:[:eachNewLine :eachOldLine |
- (eachNewLine == eachOldLine)
- ifFalse:[
- same := false.
- ]
- ]
- ].
- same ifTrue:[^ self].
- ].
+ "/ see if there is a change at all.
+ "/ use to compare using =, but that's not enough in case of emphasis change.
+ aCollection size == list size ifTrue:[
+ same := true.
+ aCollection size > 0 ifTrue:[
+ aCollection with:list do:[:eachNewLine :eachOldLine |
+ (eachNewLine == eachOldLine)
+ ifFalse:[
+ same := false.
+ ]
+ ]
+ ].
+ same ifTrue:[^ self].
+ ].
].
scrollToTop := scrollWhenUpdating == #begin or:[scrollWhenUpdating == #beginOfText].
scrollToEnd := scrollWhenUpdating == #end or:[scrollWhenUpdating == #endOfText].
(aCollection isEmptyOrNil and:[list isEmptyOrNil]) ifTrue:[
- "no contents change"
- list := aCollection.
- scrollLocked ifFalse:[
- scrollToTop ifTrue:[
- self scrollToTop.
- ] ifFalse:[
- scrollToEnd ifTrue:[
- self scrollToBottom.
- ]
- ].
- self scrollToLeft.
- ].
- ^ self
+ "no contents change"
+ list := aCollection.
+ scrollLocked ifFalse:[
+ scrollToTop ifTrue:[
+ self scrollToTop.
+ ] ifFalse:[
+ scrollToEnd ifTrue:[
+ self scrollToBottom.
+ ]
+ ].
+ self scrollToLeft.
+ ].
+ ^ self
].
checkLineEndConventionWhenUpdating ifTrue:[
- "Check if the we use DOS/Windows line end convention with CR LF.
- The LF has already been consumed by the conversion to a StringCollection,
- now check for and remove the trailing left over CRs"
-
- lineEndCRLF := (aCollection size > 0
- and:[(firstLine := aCollection at:1) isString
- and:[firstLine notEmpty
- and:[firstLine string endsWith:Character return]]]).
+ "Check if the we use DOS/Windows line end convention with CR LF.
+ The LF has already been consumed by the conversion to a StringCollection,
+ now check for and remove the trailing left over CRs"
+
+ lineEndCRLF := (aCollection size > 0
+ and:[(firstLine := aCollection at:1) isString
+ and:[firstLine notEmpty
+ and:[firstLine string endsWith:Character return]]]).
].
lineEndCRLF ifTrue:[
- list := aCollection
- collect:[:eachLineWithCROrNil |
- eachLineWithCROrNil isNil
- ifTrue:nil
- ifFalse:[(eachLineWithCROrNil endsWith:Character return)
- ifTrue:[eachLineWithCROrNil copyButLast:1]
- ifFalse:[eachLineWithCROrNil]]].
+ list := aCollection
+ collect:[:eachLineWithCROrNil |
+ eachLineWithCROrNil isNil
+ ifTrue:nil
+ ifFalse:[(eachLineWithCROrNil endsWith:Character return)
+ ifTrue:[eachLineWithCROrNil copyButLast:1]
+ ifFalse:[eachLineWithCROrNil]]].
] ifFalse:[
- list := aCollection.
+ list := aCollection.
].
nonStringsBefore := includesNonStrings.
@@ -1118,18 +1120,18 @@
includesNonStrings := false.
list notNil ifTrue:[
- expand ifTrue:[
- self expandTabs
- ] ifFalse:[
- scan ifTrue:[
- includesNonStrings := list contains:[:e | e isString not].
- ] ifFalse:[
- includesNonStrings := nonStringsIfNoScan ? nonStringsBefore
- ]
- ].
+ expand ifTrue:[
+ self expandTabs
+ ] ifFalse:[
+ scan ifTrue:[
+ includesNonStrings := list contains:[:e | e isString not].
+ ] ifFalse:[
+ includesNonStrings := nonStringsIfNoScan ? nonStringsBefore
+ ]
+ ].
].
(includesNonStrings ~~ nonStringsBefore) ifTrue:[
- self getFontParameters.
+ self getFontParameters.
].
widthOfWidestLine := nil. "/ i.e. unknown
@@ -1137,49 +1139,49 @@
oldLeft := viewOrigin x.
(includesNonStrings ~~ nonStringsBefore) ifTrue:[
- self computeNumberOfLinesShown.
+ self computeNumberOfLinesShown.
].
scrollLocked ifFalse:[
- newLeftOffset := viewOrigin x.
- scrollToTop ifTrue:[
- firstLineShown := 1.
- newLeftOffset := 0.
- ] ifFalse:[
- scrollToEnd ifTrue:[
- firstLineShown := (list size - nFullLinesShown + 1) max:1.
- newLeftOffset := 0.
- ]
- ].
- newLeftOffset > 0 ifTrue:[
- wText := self widthOfContents.
- (viewOrigin x + self innerWidth) > wText ifTrue:[
- newLeftOffset := (wText - self innerWidth) max:0.
- ].
- ].
- newLeftOffset ~= oldLeft ifTrue:[
- viewOrigin := newLeftOffset @ viewOrigin y.
- ].
+ newLeftOffset := viewOrigin x.
+ scrollToTop ifTrue:[
+ firstLineShown := 1.
+ newLeftOffset := 0.
+ ] ifFalse:[
+ scrollToEnd ifTrue:[
+ firstLineShown := (list size - nFullLinesShown + 1) max:1.
+ newLeftOffset := 0.
+ ]
+ ].
+ newLeftOffset > 0 ifTrue:[
+ wText := self widthOfContents.
+ (viewOrigin x + self innerWidth) > wText ifTrue:[
+ newLeftOffset := (wText - self innerWidth) max:0.
+ ].
+ ].
+ newLeftOffset ~= oldLeft ifTrue:[
+ viewOrigin := newLeftOffset @ viewOrigin y.
+ ].
].
realized ifTrue:[
- self contentsChanged.
- scrollLocked ifFalse:[
- "
- don't use scroll here to avoid double redraw
- "
- viewOrigin := viewOrigin isNil ifTrue:[0@0] ifFalse:[(viewOrigin x) @ 0].
- transformation := nil.
-
- oldFirst ~~ firstLineShown ifTrue:[
- self originChanged:0 @ ((oldFirst - 1) * fontHeight negated).
- ].
- ].
- doRedraw ifTrue:[
- shown ifTrue:[
- self invalidate.
- ]
- ]
+ self contentsChanged.
+ scrollLocked ifFalse:[
+ "
+ don't use scroll here to avoid double redraw
+ "
+ viewOrigin := viewOrigin isNil ifTrue:[0@0] ifFalse:[(viewOrigin x) @ 0].
+ gc transformation:nil.
+
+ oldFirst ~~ firstLineShown ifTrue:[
+ self originChanged:0 @ ((oldFirst - 1) * fontHeight negated).
+ ].
+ ].
+ doRedraw ifTrue:[
+ shown ifTrue:[
+ self invalidate.
+ ]
+ ]
]
"Modified: / 30-08-1995 / 19:07:13 / claus"
@@ -1215,20 +1217,20 @@
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size).
widthOfWidestLine == widestLineRemoved ifTrue:[
- widthOfWidestLine := nil. "/ i.e. unknown
+ widthOfWidestLine := nil. "/ i.e. unknown
].
self textChanged.
((startLineNr <= self lastLineShown)
and:[endLineNr >= firstLineShown]) ifTrue:[
- startLineNr to:self lastLineShown do:[:eachLine |
- self invalidateLine:eachLine
- ].
+ startLineNr to:self lastLineShown do:[:eachLine |
+ self invalidateLine:eachLine
+ ].
].
nLines := list size.
(firstLineShown >= nLines) ifTrue:[
- self makeLineVisible:nLines
+ self makeLineVisible:nLines
].
self enqueueDelayedContentsChangedNotification.
@@ -1291,7 +1293,7 @@
list removeIndex:lineNr.
lineNr < firstLineShown ifTrue:[
- firstLineShown := firstLineShown - 1
+ firstLineShown := firstLineShown - 1
].
self enqueueDelayedContentsChangedNotification.
^ true
@@ -1303,7 +1305,7 @@
"replace some lines"
list isNil ifTrue:[
- list := OrderedCollection new.
+ list := OrderedCollection new.
].
list replaceFrom:startLineNr to:endLineNr with:aCollection startingAt:replStartIndex.
@@ -1312,7 +1314,7 @@
((startLineNr <= self lastLineShown)
and:[endLineNr >= firstLineShown]) ifTrue:[
- self invalidate.
+ self invalidate.
].
self enqueueDelayedContentsChangedNotification.
@@ -1366,9 +1368,9 @@
This can be used to update a self-changing list
(for example: a file list being shown, without disturbing the user too much)"
- self
- setList:aCollection expandTabs:expandTabs scanForNonStrings:true includesNonStrings:nil
- redraw:doRedraw
+ self
+ setList:aCollection expandTabs:expandTabs scanForNonStrings:true includesNonStrings:nil
+ redraw:doRedraw
!
setList:aCollection expandTabs:expandTabs scanForNonStrings:scan includesNonStrings:nonStringsIfNoScan redraw:doRedraw
@@ -1377,24 +1379,24 @@
This can be used to update a self-changing list
(for example: a file list being shown, without disturbing the user too much).
TODO: this stinks: most of the code is the same as in #list:expandTabs:...
- needs a refactoring"
+ needs a refactoring"
|prev|
prev := scrollLocked.
[
- scrollLocked := false.
- self
- list:aCollection
- expandTabs:expandTabs
- scanForNonStrings:scan
- includesNonStrings:nonStringsIfNoScan
- redraw:doRedraw
+ scrollLocked := false.
+ self
+ list:aCollection
+ expandTabs:expandTabs
+ scanForNonStrings:scan
+ includesNonStrings:nonStringsIfNoScan
+ redraw:doRedraw
] ensure:[
- scrollLocked := prev
+ scrollLocked := prev
].
"/
-"/
+"/
"/"/ scrollLocked ifTrue:[
"/"/ self setList:newText expandTabs:expandTabsWhenUpdating
"/"/ ] ifFalse:[
@@ -1517,10 +1519,10 @@
endLine isNil ifTrue:[^ nil].
(startLine == endLine) ifTrue:[
- "part of a line"
- ^ StringCollection with:(self listAt:startLine from:startCol to:endCol)
+ "part of a line"
+ ^ StringCollection with:(self listAt:startLine from:startCol to:endCol)
].
-
+
sz := endLine - startLine + 1.
sz < 1 ifTrue:[^ ''].
@@ -1529,17 +1531,17 @@
"get 1st and last (possibly) partial lines"
text at:1 put:(self listAt:startLine from:startCol).
endCol == 0 ifTrue:[
- last := ''
+ last := ''
] ifFalse:[
- last := self listAt:endLine to:endCol.
+ last := self listAt:endLine to:endCol.
].
text at:sz put:last.
"get bulk of text"
index := 2.
(startLine + 1) to:(endLine - 1) do:[:lineNr |
- text at:index put:(self listAt:lineNr).
- index := index + 1
+ text at:index put:(self listAt:lineNr).
+ index := index + 1
].
^ text
@@ -1559,25 +1561,25 @@
oldLine := self listAt:index.
list at:index put:aString.
oldLine ~= aString ifTrue:[
- self textChanged
+ self textChanged
].
didIncludeNonStrings := includesNonStrings.
includesNonStrings ifFalse:[
- includesNonStrings := (aString notNil and:[(aString isSingleByteString) not]).
+ includesNonStrings := (aString notNil and:[(aString isSingleByteString) not]).
] ifTrue:[
- (aString isNil or:[(aString isSingleByteString)]) ifTrue:[
- includesNonStrings := list contains:[:l | l notNil and:[(l isSingleByteString) not]].
- ]
+ (aString isNil or:[(aString isSingleByteString)]) ifTrue:[
+ includesNonStrings := list contains:[:l | l notNil and:[(l isSingleByteString) not]].
+ ]
].
includesNonStrings ~~ didIncludeNonStrings ifTrue:[
- self getFontParameters.
- self computeNumberOfLinesShown
+ self getFontParameters.
+ self computeNumberOfLinesShown
].
widthOfWidestLine notNil ifTrue:[
- self recomputeWidthOfWidestLineFor:aString old:oldLine.
+ self recomputeWidthOfWidestLineFor:aString old:oldLine.
].
"Modified: / 26.7.1998 / 13:00:14 / cg"
@@ -1614,13 +1616,13 @@
aFont isNil ifTrue:[
^ self error:'nil font' mayProceed:true
].
- font ~~ aFont ifTrue:[
- super font:(aFont onDevice:device).
+ gc font ~~ aFont ifTrue:[
preferredExtent := nil.
widthOfWidestLine := nil. "/ i.e. unknown
+ super font:aFont.
self getFontParameters.
realized ifTrue:[
- (font graphicsDevice == device) ifTrue:[
+ (gc font graphicsDevice == device) ifTrue:[
self computeNumberOfLinesShown.
shown ifTrue:[
self redrawFromVisibleLine:1 to:nLinesShown
@@ -1638,7 +1640,7 @@
by which lines are vertically separated."
fontHeight ~~ pixels ifTrue:[
- fontHeight := pixels.
+ fontHeight := pixels.
]
"Created: 17.4.1997 / 01:41:33 / cg"
@@ -1735,8 +1737,8 @@
by which lines are vertically separated."
lineSpacing ~~ pixels ifTrue:[
- lineSpacing := pixels.
- self getFontParameters.
+ lineSpacing := pixels.
+ self getFontParameters.
]
"Modified: 22.5.1996 / 12:22:29 / cg"
@@ -1817,10 +1819,10 @@
"ST-80 compatibility"
aspectSymbol notNil ifTrue:[
- aspectMsg := aspectSymbol.
- listMsg isNil ifTrue:[
- listMsg := aspectSymbol
- ]
+ aspectMsg := aspectSymbol.
+ listMsg isNil ifTrue:[
+ listMsg := aspectSymbol
+ ]
].
listSymbol notNil ifTrue:[listMsg := listSymbol].
changeSymbol notNil ifTrue:[changeMsg := changeSymbol].
@@ -1916,11 +1918,11 @@
sH := lineSpacing // 2.
backgroundAlreadyClearedColor == bg ifFalse:[
- self paint:bg.
- self fillRectangleX:margin
- y:y-sH
- width:(width - (margin * 2))
- height:(endVisLineNr - startVisLineNr + 1) * fontHeight + (lineSpacing - sH).
+ self paint:bg.
+ self fillRectangleX:margin
+ y:y-sH
+ width:(width - (margin * 2))
+ height:(endVisLineNr - startVisLineNr + 1) * fontHeight + (lineSpacing - sH).
].
list isNil ifTrue:[^ self].
@@ -1930,29 +1932,29 @@
startLine := startVisLineNr + firstLineShown - 1.
endLine := endVisLineNr + firstLineShown - 1.
(startLine == 0) ifTrue:[
- y := y + fontHeight.
- startLine := startLine + 1
+ y := y + fontHeight.
+ startLine := startLine + 1
].
(endLine > listSize) ifTrue:[
- e := listSize
+ e := listSize
] ifFalse:[
- e := endLine
+ e := endLine
].
(startLine <= e) ifTrue:[
- x := textStartLeft - viewOrigin x.
- self paint:fg on:bg.
- "/ don't use list from:to:do:, to allow for subclasses to redefine the enumeration (TableView)
- self from:startLine to:e do:[:line |
- line notNil ifTrue:[
- "/ remove line's color emphasis, to enforce color.
- "/ otherwise blue text is not visible if selection-bg is blue
- l := self withoutColorEmphasis:line ifFg:fg andBg:bg.
- self displayOpaqueString:l x:x y:y
- ].
- y := y + fontHeight
- ]
+ x := textStartLeft - viewOrigin x.
+ self paint:fg on:bg.
+ "/ don't use list from:to:do:, to allow for subclasses to redefine the enumeration (TableView)
+ self from:startLine to:e do:[:line |
+ line notNil ifTrue:[
+ "/ remove line's color emphasis, to enforce color.
+ "/ otherwise blue text is not visible if selection-bg is blue
+ l := self withoutColorEmphasis:line ifFg:fg andBg:bg.
+ self displayOpaqueString:l x:x y:y
+ ].
+ y := y + fontHeight
+ ]
]
"Modified: / 15.12.1999 / 23:19:39 / cg"
@@ -1967,28 +1969,28 @@
y := self yOfVisibleLine:visLineNr.
backgroundAlreadyClearedColor == bg ifFalse:[
- self paint:bg.
- halfSpacing := (lineSpacing//2).
- extraBelow := 0.
- self highlightLineSpacing ifTrue:[
- extraBelow := halfSpacing.
- ].
- self fillRectangleX:margin y:y - halfSpacing
- width:(width - (2 * margin))
- height:fontHeight+extraBelow.
+ self paint:bg.
+ halfSpacing := (lineSpacing//2).
+ extraBelow := 0.
+ self highlightLineSpacing ifTrue:[
+ extraBelow := halfSpacing.
+ ].
+ self fillRectangleX:margin y:y - halfSpacing
+ width:(width - (2 * margin))
+ height:fontHeight+extraBelow.
].
line notNil ifTrue:[
- self paint:fg on:bg.
-
- "/ remove lines color emphasis, to enforce color.
- "/ otherwise blue text is not visible if selection-bg is blue.
- "/ this is only done in EditTextViews and subClasses.
- self suppressEmphasisInSelection ifTrue:[
- l := self withoutColorEmphasis:line ifFg:fg andBg:bg.
- ] ifFalse:[
- l := line
- ].
- self displayOpaqueString:l x:x y:(y + fontAscent)
+ self paint:fg on:bg.
+
+ "/ remove lines color emphasis, to enforce color.
+ "/ otherwise blue text is not visible if selection-bg is blue.
+ "/ this is only done in EditTextViews and subClasses.
+ self suppressEmphasisInSelection ifTrue:[
+ l := self withoutColorEmphasis:line ifFg:fg andBg:bg.
+ ] ifFalse:[
+ l := line
+ ].
+ self displayOpaqueString:l x:x y:(y + fontAscent)
].
"Modified: / 15.12.1999 / 23:19:46 / cg"
@@ -2031,7 +2033,7 @@
(lineString notNil and:[lineString isString not]) ifTrue:[
w := lineString widthFrom:col to:(col min:len) on:self.
w <= 0 ifTrue:[
- w := font width.
+ w := gc font width.
self fillRectangleX:x y:yf width:w height:fontHeight.
self paint:fg
].
@@ -2042,7 +2044,7 @@
].
(lineString isNil or:[col > len]) ifTrue:[
- self fillRectangleX:x y:yf width:(font width) height:fontHeight.
+ self fillRectangleX:x y:yf width:(gc font width) height:fontHeight.
self paint:fg
] ifFalse:[
characterString := lineString copyFrom:col to:col.
@@ -2128,7 +2130,7 @@
fontIsFixedWidth ifTrue:[
w := (eCol - sCol + 1) * fontWidth
] ifFalse:[
- w := font widthOf:lineString from:sCol to:eCol
+ w := gc font widthOf:lineString from:sCol to:eCol
]
] ifFalse:[
w := lineString widthFrom:sCol to:endCol on:self
@@ -2147,7 +2149,7 @@
]
] ifFalse:[
"/ self displayOpaqueString:lineString from:sCol to:eCol x:x y:(y + fontAscent)
- self displayString:lineString from:sCol to:eCol x:x y:(y + fontAscent)
+ self displayString:lineString from:sCol to:eCol x:x y:(y + fontAscent) opaque:false maxWidth:self width
].
]
]
@@ -2161,31 +2163,31 @@
|y x index1 index2 lineWithoutColor|
(startCol < 1) ifTrue:[
- index1 := 1
+ index1 := 1
] ifFalse:[
- index1 := startCol
+ index1 := startCol
].
y := self yOfVisibleLine:visLineNr.
x := (self xOfCol:index1 inVisibleLine:visLineNr) - viewOrigin x.
backgroundAlreadyClearedColor == bg ifFalse:[
- self paint:bg.
- self fillRectangleX:x y:y - (lineSpacing // 2)
- width:(width + viewOrigin x - x)
- height:fontHeight.
- ].
+ self paint:bg.
+ self fillRectangleX:x y:y - (lineSpacing // 2)
+ width:(width + viewOrigin x - x)
+ height:fontHeight.
+ ].
lineString notNil ifTrue:[
- lineString isString ifFalse:[
- self drawLine:lineString inVisible:visLineNr from:startCol to:nil with:fg and:bg.
- ] ifTrue:[
- lineWithoutColor := self withoutColorEmphasis:lineString ifFg:fg andBg:bg.
- index2 := lineWithoutColor size.
- (index2 < index1) ifTrue:[^ self].
- (index1 <= index2) ifTrue:[
- self paint:fg on:bg.
- "/ self displayOpaqueString:lineWithoutColor from:index1 to:index2 x:x y:(y + fontAscent)
- self displayString:lineWithoutColor from:index1 to:index2 x:x y:(y + fontAscent)
- ]
- ]
+ lineString isString ifFalse:[
+ self drawLine:lineString inVisible:visLineNr from:startCol to:nil with:fg and:bg.
+ ] ifTrue:[
+ lineWithoutColor := self withoutColorEmphasis:lineString ifFg:fg andBg:bg.
+ index2 := lineWithoutColor size.
+ (index2 < index1) ifTrue:[^ self].
+ (index1 <= index2) ifTrue:[
+ self paint:fg on:bg.
+ "/ self displayOpaqueString:lineWithoutColor from:index1 to:index2 x:x y:(y + fontAscent)
+ self displayString:lineWithoutColor from:index1 to:index2 x:x y:(y + fontAscent)
+ ]
+ ]
]
"Modified: / 15.12.1999 / 23:24:40 / cg"
@@ -2242,13 +2244,11 @@
fillRectangleX:x y:y width:w height:h
"fill rectangle; checks whether the rectangle already is filled with
- the current paint (#redrawX:y:w:h).
- "
- backgroundAlreadyClearedColor ~~ paint ifTrue:[
- super fillRectangleX:x y:y width:w height:h
+ the current paint (#redrawX:y:w:h)."
+
+ backgroundAlreadyClearedColor ~~ self paint ifTrue:[
+ super fillRectangleX:x y:y width:w height:h
]
-
-
!
invalidateLine:line
@@ -2263,14 +2263,14 @@
visLineNr := self listLineToVisibleLine:line.
visLineNr notNil ifTrue:[
- yTop := self yOfVisibleLine:visLineNr.
- yTop isNil ifTrue:[^ self]. "/ not visible
- (yTop + fontHeight) < 0 ifTrue:[^ self]. "/ not visible
- self
- invalidateDeviceRectangle:(Rectangle
- left:margin top:yTop-(lineSpacing//2)
- width:(width - (2 * margin)) height:fontHeight)
- repairNow:false.
+ yTop := self yOfVisibleLine:visLineNr.
+ yTop isNil ifTrue:[^ self]. "/ not visible
+ (yTop + fontHeight) < 0 ifTrue:[^ self]. "/ not visible
+ self
+ invalidateDeviceRectangle:(Rectangle
+ left:margin top:yTop-(lineSpacing//2)
+ width:(width - (2 * margin)) height:fontHeight)
+ repairNow:false.
]
"Created: / 5.3.1998 / 01:24:19 / cg"
@@ -2285,24 +2285,24 @@
|listSize newOrigin|
shown ifTrue:[
- list notNil ifTrue:[
- listSize := self numberOfLines.
-
- listSize == 0 ifTrue:[
- widthOfWidestLine := 0.
- ].
-
- "
- if we are beyond the end, scroll up a bit
- "
- ((firstLineShown + nFullLinesShown) > listSize) ifTrue:[
- newOrigin := listSize - nFullLinesShown + 1.
- newOrigin < 1 ifTrue:[
- newOrigin := 1
- ].
- self scrollToLine: newOrigin.
- ].
- ].
+ list notNil ifTrue:[
+ listSize := self numberOfLines.
+
+ listSize == 0 ifTrue:[
+ widthOfWidestLine := 0.
+ ].
+
+ "
+ if we are beyond the end, scroll up a bit
+ "
+ ((firstLineShown + nFullLinesShown) > listSize) ifTrue:[
+ newOrigin := listSize - nFullLinesShown + 1.
+ newOrigin < 1 ifTrue:[
+ newOrigin := 1
+ ].
+ self scrollToLine: newOrigin.
+ ].
+ ].
].
^ super contentsChanged
@@ -2347,7 +2347,7 @@
mouseWheelZoom:amount
"CTRL-wheel action"
- |oldSize newSize delta mul|
+ |oldSize newSize delta mul font|
amount > 0 ifTrue:[
"/ delta := 1. mul := 1.
@@ -2357,7 +2357,8 @@
delta := 0. mul := 0.8.
].
- font sizeUnit == #px ifFalse:[
+ font := gc font.
+ font sizeUnit ~~ #px ifTrue:[
oldSize := font size.
newSize := ((oldSize + delta)* mul) max:2.
newSize ~= oldSize ifTrue:[
@@ -2379,47 +2380,47 @@
startLine := self visibleLineOfY:y.
stopLine := self visibleLineOfY:(y + h).
- saveClip := clipRect.
+ saveClip := gc clippingBoundsOrNil.
self clippingRectangle:(Rectangle left:x top:y width:w height:h).
self paint:bgColor.
self fillRectangleX:x y:y width:w height:h.
backgroundAlreadyClearedColor := bgColor.
(includesNonStrings or:[w > (width // 4 * 3)]) ifTrue:[
- "includes non strings or area is big enough: redraw whole lines"
- self redrawFromVisibleLine:startLine to:stopLine
+ "includes non strings or area is big enough: redraw whole lines"
+ self redrawFromVisibleLine:startLine to:stopLine
] ifFalse:[
- line := self visibleAt:startLine.
-
- (fontIsFixedWidth and:[line isSingleByteString]) ifFalse:[
- "start/end col has to be computed for each line"
-
- startLine to:stopLine do:[:i |
- startCol := self colOfX:x inVisibleLine:i.
- endCol := self colOfX:(x + w) inVisibleLine:i.
- startCol > 0 ifTrue:[
- endCol > 0 ifTrue:[
- self redrawVisibleLine:i from:startCol to:endCol
- ]
- ]
- ]
- ] ifTrue:[
- "start/end col is the same for all lines"
- startCol := self colOfX:x inVisibleLine:startLine.
- endCol := self colOfX:(x + w) inVisibleLine:startLine.
- startCol > 0 ifTrue:[
- endCol > 0 ifTrue:[
- startLine to:stopLine do:[:i |
- line := self visibleAt:i.
- (line isSingleByteString) ifTrue:[
- self redrawVisibleLine:i from:startCol to:endCol
- ] ifFalse:[
- self redrawVisibleLine:i
- ]
- ]
- ]
- ]
- ]
+ line := self visibleAt:startLine.
+
+ (fontIsFixedWidth and:[line isSingleByteString]) ifFalse:[
+ "start/end col has to be computed for each line"
+
+ startLine to:stopLine do:[:i |
+ startCol := self colOfX:x inVisibleLine:i.
+ endCol := self colOfX:(x + w) inVisibleLine:i.
+ startCol > 0 ifTrue:[
+ endCol > 0 ifTrue:[
+ self redrawVisibleLine:i from:startCol to:endCol
+ ]
+ ]
+ ]
+ ] ifTrue:[
+ "start/end col is the same for all lines"
+ startCol := self colOfX:x inVisibleLine:startLine.
+ endCol := self colOfX:(x + w) inVisibleLine:startLine.
+ startCol > 0 ifTrue:[
+ endCol > 0 ifTrue:[
+ startLine to:stopLine do:[:i |
+ line := self visibleAt:i.
+ (line isSingleByteString) ifTrue:[
+ self redrawVisibleLine:i from:startCol to:endCol
+ ] ifFalse:[
+ self redrawVisibleLine:i
+ ]
+ ]
+ ]
+ ]
+ ]
].
backgroundAlreadyClearedColor := nil.
self clippingRectangle:saveClip.
@@ -2494,21 +2495,21 @@
n := DefaultTopMargin.
n isInteger ifFalse:[
- n := (self verticalPixelPerMillimeter:n) rounded.
+ n := (self verticalPixelPerMillimeter:n) rounded.
].
self topMargin:n.
n := DefaultLeftMargin.
n isInteger ifFalse:[
- n := (self verticalPixelPerMillimeter:n) rounded.
+ n := (self verticalPixelPerMillimeter:n) rounded.
].
self leftMargin:n.
lineSpacing := 2.
"/ q&d temporary hack.
"/ X11 fonts are currently so ugly... add more spacing.
- device platformName == #X11 ifTrue:[
- lineSpacing := lineSpacing + 3.
+ device isX11Platform ifTrue:[
+ lineSpacing := lineSpacing + 3.
].
fgColor := DefaultForegroundColor.
bgColor := DefaultBackgroundColor.
@@ -2531,7 +2532,7 @@
partialLines := true.
tabPositions := UserDefaultTabPositions ? self class defaultTabPositions.
includesNonStrings := false.
- lineEndCRLF := false.
+ lineEndCRLF := false.
checkedLinesForWidthOfContentsComputation := nil."/ i.e. all
self getFontParameters.
self initializeWordCheckAction.
@@ -2661,34 +2662,34 @@
"
(fontIsFixedWidth
and:[lineString isNil
- or:[lineString hasChangeOfEmphasis not]]) ifTrue:[
- ^ (xRel // fontWidth) + 1
+ or:[lineString hasChangeOfEmphasis not]]) ifTrue:[
+ ^ (xRel // fontWidth) + 1
].
"
for variable fonts, more work is required ...
"
lineString notNil ifTrue:[
- lineString := self visibleStringFrom:lineString.
- (hasEmphasis := lineString hasChangeOfEmphasis) ifTrue:[
- linePixelWidth := lineString widthOn:self
- ] ifFalse:[
- lineString := lineString string.
- linePixelWidth := font widthOf:lineString.
- ]
+ lineString := self visibleStringFrom:lineString.
+ (hasEmphasis := lineString hasChangeOfEmphasis) ifTrue:[
+ linePixelWidth := lineString widthOn:self
+ ] ifFalse:[
+ lineString := lineString string.
+ linePixelWidth := gc font widthOf:lineString.
+ ]
] ifFalse:[
- linePixelWidth := 0
+ linePixelWidth := 0
].
(linePixelWidth <= xRel) ifTrue:[
- fontWidth == 0 ifTrue:[
- "
- although this 'cannot happen',
- it seems that X reports this width for some strange fonts ...
- "
- ^ lineString size
- ].
- ^ lineString size + ((xRel - linePixelWidth) // fontWidth) + 1
+ fontWidth == 0 ifTrue:[
+ "
+ although this 'cannot happen',
+ it seems that X reports this width for some strange fonts ...
+ "
+ ^ lineString size
+ ].
+ ^ lineString size + ((xRel - linePixelWidth) // fontWidth) + 1
].
"/ cannot simply count individual characters,
@@ -2696,53 +2697,53 @@
"/ use a binary search, initialized with some guess.
"/ a guess: take some 'average' character's width and compute an initial guess
- runCol := x // (font widthOf:'e').
+ runCol := x // (gc font widthOf:'e').
runCol := runCol min:lineString size.
"/ runCol := lineString size // 2.
"/ (runCol == 0) ifTrue:[runCol := 1].
hasEmphasis ifTrue:[
- posLeft := (lineString copyFrom:1 to:(runCol - 1)) widthOn:self.
- posRight := (lineString copyFrom:1 to:runCol) widthOn:self.
+ posLeft := (lineString copyFrom:1 to:(runCol - 1)) widthOn:self.
+ posRight := (lineString copyFrom:1 to:runCol) widthOn:self.
] ifFalse:[
- posLeft := font widthOf:lineString from:1 to:(runCol - 1).
- posRight := font widthOf:lineString from:1 to:runCol.
+ posLeft := gc font widthOf:lineString from:1 to:(runCol - 1).
+ posRight := gc font widthOf:lineString from:1 to:runCol.
].
done := (posLeft <= xRel) and:[posRight > xRel].
[done] whileFalse:[
- oPosRight := posRight.
- oPosLeft := posLeft.
-
- (posRight <= xRel) ifTrue:[
- runCol := runCol + 1.
- posLeft := posRight.
- hasEmphasis ifTrue:[
- posRight := (lineString copyFrom:1 to:runCol) widthOn:self.
- ] ifFalse:[
- posRight := font widthOf:lineString from:1 to:runCol
- ]
- ] ifFalse:[
- (posLeft > xRel) ifTrue:[
- runCol := runCol - 1.
- (runCol == 0) ifTrue:[^ 0].
- posRight := posLeft.
- hasEmphasis ifTrue:[
- posLeft := (lineString copyFrom:1 to:(runCol - 1)) widthOn:self.
- ] ifFalse:[
- posLeft := font widthOf:lineString from:1 to:(runCol - 1)
- ]
- ]
- ].
- done := (posLeft <= xRel) and:[posRight > xRel].
+ oPosRight := posRight.
+ oPosLeft := posLeft.
+
+ (posRight <= xRel) ifTrue:[
+ runCol := runCol + 1.
+ posLeft := posRight.
+ hasEmphasis ifTrue:[
+ posRight := (lineString copyFrom:1 to:runCol) widthOn:self.
+ ] ifFalse:[
+ posRight := gc font widthOf:lineString from:1 to:runCol
+ ]
+ ] ifFalse:[
+ (posLeft > xRel) ifTrue:[
+ runCol := runCol - 1.
+ (runCol == 0) ifTrue:[^ 0].
+ posRight := posLeft.
+ hasEmphasis ifTrue:[
+ posLeft := (lineString copyFrom:1 to:(runCol - 1)) widthOn:self.
+ ] ifFalse:[
+ posLeft := gc font widthOf:lineString from:1 to:(runCol - 1)
+ ]
+ ]
+ ].
+ done := (posLeft <= xRel) and:[posRight > xRel].
"234567890123456789012345678901234567890"
- ((oPosRight == posRight) and:[oPosLeft == posLeft]) ifTrue:[
- "/ paranoia: just in case there are unprintable characters
- "/ (avoid endless loop if the binary search does not make progress)
- done := true.
- ]
+ ((oPosRight == posRight) and:[oPosLeft == posLeft]) ifTrue:[
+ "/ paranoia: just in case there are unprintable characters
+ "/ (avoid endless loop if the binary search does not make progress)
+ done := true.
+ ]
].
"/self paint:Color red.
"/self displayRectangleX:posLeft+textStartLeft-viewOrigin x y:(self yOfVisibleLine:visLineNr)
@@ -2834,7 +2835,7 @@
sensor := self sensor.
(sensor hasUserEvent:#contentsChanged for:self) ifFalse:[
- sensor pushUserEvent:#contentsChanged for:self
+ sensor pushUserEvent:#contentsChanged for:self
].
"/ used to be syncronous:
"/ self contentsChanged. "recompute scrollbars"
@@ -2849,36 +2850,36 @@
Therefore, this method should be redefined in views which will be used
with national characters (i.e. editTextViews)."
- |hMax|
-
- font := font onDevice:device.
- hMax := font height.
+ |hMax newDeviceFont|
+
+ newDeviceFont := gc createFontOnDevice.
+ hMax := newDeviceFont height.
includesNonStrings == true ifTrue:[
- "/
- "/ find maximum height of lines
- "/
- hMax := list inject:hMax into:[:maxSoFar :thisLine |
- thisLine isNil ifTrue:[
- maxSoFar
- ] ifFalse:[
- (thisLine isSingleByteString) ifTrue:[
- maxSoFar
- ] ifFalse:[
- maxSoFar max:(thisLine heightOn:self)
- ]
- ]
- ].
+ "/
+ "/ find maximum height of lines
+ "/
+ hMax := list inject:hMax into:[:maxSoFar :thisLine |
+ thisLine isNil ifTrue:[
+ maxSoFar
+ ] ifFalse:[
+ (thisLine isSingleByteString) ifTrue:[
+ maxSoFar
+ ] ifFalse:[
+ maxSoFar max:(thisLine heightOn:self)
+ ]
+ ]
+ ].
].
- fontHeight := font maxHeight.
+ fontHeight := newDeviceFont maxHeight.
"/ fontHeight := font height.
fontHeight := fontHeight max:(hMax + lineSpacing).
- fontAscent := font ascent. "/ maxAscent. -- see SelectionInListViews selection in motif style
+ fontAscent := newDeviceFont ascent. "/ maxAscent. -- see SelectionInListViews selection in motif style
"/ fontAscent := font maxAscent "ascent". "/ maxAscent. -- see SelectionInListViews selection in motif style
"/ fontAscent := (font maxAscent + font ascent) // 2. "/ maxAscent. -- see SelectionInListViews selection in motif style
- fontWidth := font width.
- fontIsFixedWidth := font isFixedWidth.
+ fontWidth := newDeviceFont width.
+ fontIsFixedWidth := newDeviceFont isFixedWidth.
"Modified: 3.7.1997 / 12:24:25 / cg"
!
@@ -2890,55 +2891,55 @@
|newText msg doCompareIfUnchanged|
model notNil ifTrue:[
- msg := listMsg ? aspectMsg.
-
- msg notNil ifTrue:[
- doCompareIfUnchanged := compareModelOnUpdate.
-
- newText := model perform:msg.
- "/ cg: this makes many optimizations (virtualArray) useless;
- "/ I do not think that this is a good idea:
- "/ text notNil ifTrue:[
- "/ so I changed it to:
- (newText notNil and:[newText isString]) ifTrue:[
- newText := newText asStringCollection.
- ] ifFalse:[
- newText == model ifTrue:[
- "/ I must operate on a copy
- newText := model asNewOrderedCollection.
- "/ doCompareIfUnchanged := false.
- ].
- ].
-
- doCompareIfUnchanged ifTrue:[
- "/ see if there is a change at all.
- "/ use to compare using =, but that's not enough in case of emphasis change.
- newText size == list size ifTrue:[
- |same|
-
- same := true.
- newText size > 0 ifTrue:[
- newText with:list do:[:eachNewLine :eachOldLine |
- (eachNewLine == eachOldLine) ifFalse:[
- same := false.
- ]
- ]
- ].
- same ifTrue:[^ self].
- ].
- ].
-
- "/ SV: this compare does not work, if model uses (i.e. updates)
- "/ the same stringCollection as the view!!
- true "text ~= list" ifTrue:[
- "/ changed #list to care for scrollLocked
+ msg := listMsg ? aspectMsg.
+
+ msg notNil ifTrue:[
+ doCompareIfUnchanged := compareModelOnUpdate.
+
+ newText := model perform:msg.
+ "/ cg: this makes many optimizations (virtualArray) useless;
+ "/ I do not think that this is a good idea:
+ "/ text notNil ifTrue:[
+ "/ so I changed it to:
+ (newText notNil and:[newText isString]) ifTrue:[
+ newText := newText asStringCollection.
+ ] ifFalse:[
+ newText == model ifTrue:[
+ "/ I must operate on a copy
+ newText := model asNewOrderedCollection.
+ "/ doCompareIfUnchanged := false.
+ ].
+ ].
+
+ doCompareIfUnchanged ifTrue:[
+ "/ see if there is a change at all.
+ "/ use to compare using =, but that's not enough in case of emphasis change.
+ newText size == list size ifTrue:[
+ |same|
+
+ same := true.
+ newText size > 0 ifTrue:[
+ newText with:list do:[:eachNewLine :eachOldLine |
+ (eachNewLine == eachOldLine) ifFalse:[
+ same := false.
+ ]
+ ]
+ ].
+ same ifTrue:[^ self].
+ ].
+ ].
+
+ "/ SV: this compare does not work, if model uses (i.e. updates)
+ "/ the same stringCollection as the view!!
+ true "text ~= list" ifTrue:[
+ "/ changed #list to care for scrollLocked
"/ scrollLocked ifTrue:[
"/ self setList:newText expandTabs:expandTabsWhenUpdating
"/ ] ifFalse:[
- self list:newText expandTabs:expandTabsWhenUpdating scanForNonStrings:expandTabsWhenUpdating
+ self list:newText expandTabs:expandTabsWhenUpdating scanForNonStrings:expandTabsWhenUpdating
"/ ]
- ].
- ].
+ ].
+ ].
].
"Modified: 26.4.1996 / 14:09:42 / cg"
@@ -2955,9 +2956,9 @@
prev := scrollLocked.
scrollLocked := aBoolean not.
[
- self getListFromModel
+ self getListFromModel
] ensure:[
- scrollLocked := prev.
+ scrollLocked := prev.
].
!
@@ -2999,14 +3000,14 @@
lineLen := line size.
(line isNil or:[startCol > lineLen]) ifTrue:[
- (nCols > 0) ifTrue:[
- ^ (String new:nCols)
- ].
- ^ nil
+ (nCols > 0) ifTrue:[
+ ^ (String new:nCols)
+ ].
+ ^ nil
].
(endCol > lineLen) ifTrue:[
- ^ (line copyFrom:startCol to:lineLen) , (String new:(endCol-lineLen))
+ ^ (line copyFrom:startCol to:lineLen) , (String new:(endCol-lineLen))
].
^ line copyFrom:startCol to:endCol
!
@@ -3018,16 +3019,16 @@
line := self listAt:lineNr.
line isNil ifTrue:[
- (endCol > 0) ifTrue:[
- ^ (String new:endCol)
- ].
- ^ nil
+ (endCol > 0) ifTrue:[
+ ^ (String new:endCol)
+ ].
+ ^ nil
].
lineSize := line size.
(endCol > lineSize) ifTrue:[
- ^ (line copyTo:lineSize) , (String new:(endCol - lineSize)).
+ ^ (line copyTo:lineSize) , (String new:(endCol - lineSize)).
].
^ line copyTo:endCol
!
@@ -3064,47 +3065,47 @@
recomputeWidthOfWidestLineFor:newEntry old:oldEntry
"a new line was added (oldEntry == nil) or replaced oldEntry.
- Update the widthOfWidestLine cache or flush it, if we cannot easily
+ Update the widthOfWidestLine cache or flush it, if we cannot easily
figure out the overall text width"
|newW oldW|
widthOfWidestLine notNil ifTrue:[
- newEntry isNil ifTrue:[
- newW := 0
- ] ifFalse:[
- (newEntry isSingleByteString) ifTrue:[
- newW := font widthOf:newEntry
- ] ifFalse:[
- newW := newEntry widthOn:self
- ].
- ].
-
- newW >= widthOfWidestLine ifTrue:[
- widthOfWidestLine := newW.
- ] ifFalse:[
- oldEntry isNil ifTrue:[
- oldW := 0
- ] ifFalse:[
- (oldEntry isSingleByteString) ifTrue:[
- oldW := font widthOf:oldEntry
- ] ifFalse:[
- oldW := oldEntry widthOn:self
- ].
- ].
- newW > oldW ifTrue:[
- "/ no change; new entries width is between this width and amx width
- ] ifFalse:[
- "/ new entry is smaller than oldEntry; if the oldEntry was the previos max,
- "/ we don't know the new max
- oldW = widthOfWidestLine ifTrue:[
- widthOfWidestLine := nil "/ means: unknown
- ] ifFalse:[
- "/ old line was not the widest, and new line is shorter;
- "/ no change
- ]
- ]
- ].
+ newEntry isNil ifTrue:[
+ newW := 0
+ ] ifFalse:[
+ (newEntry isSingleByteString) ifTrue:[
+ newW := gc font widthOf:newEntry
+ ] ifFalse:[
+ newW := newEntry widthOn:self
+ ].
+ ].
+
+ newW >= widthOfWidestLine ifTrue:[
+ widthOfWidestLine := newW.
+ ] ifFalse:[
+ oldEntry isNil ifTrue:[
+ oldW := 0
+ ] ifFalse:[
+ (oldEntry isSingleByteString) ifTrue:[
+ oldW := gc font widthOf:oldEntry
+ ] ifFalse:[
+ oldW := oldEntry widthOn:self
+ ].
+ ].
+ newW > oldW ifTrue:[
+ "/ no change; new entries width is between this width and amx width
+ ] ifFalse:[
+ "/ new entry is smaller than oldEntry; if the oldEntry was the previos max,
+ "/ we don't know the new max
+ oldW = widthOfWidestLine ifTrue:[
+ widthOfWidestLine := nil "/ means: unknown
+ ] ifFalse:[
+ "/ old line was not the widest, and new line is shorter;
+ "/ no change
+ ]
+ ]
+ ].
].
^ widthOfWidestLine
!
@@ -3210,7 +3211,7 @@
entry isNil ifTrue:[^ 0].
(entry isSingleByteString) ifTrue:[
- ^ font widthOf:entry
+ ^ gc font widthOf:entry
].
^ entry widthOn:self
@@ -3229,11 +3230,11 @@
listSize "{ Class: SmallInteger }" |
includesNonStrings ifTrue:[
- ^ width
+ ^ width
].
fontIsFixedWidth ifTrue:[
- ^ (self lengthOfLongestLineBetween:firstLine and:lastLine) * fontWidth
+ ^ (self lengthOfLongestLineBetween:firstLine and:lastLine) * fontWidth
].
listSize := self size.
max := 0.
@@ -3242,27 +3243,27 @@
(first > listSize) ifTrue:[^ max].
(last > listSize) ifTrue:[
- last := listSize
+ last := listSize
].
self from:first to:last do:[:line |
- line notNil ifTrue:[
- (line isSingleByteString) ifTrue:[
- thisLen := font widthOf:line
- ] ifFalse:[
- thisLen := line widthOn:self
- ].
- (thisLen > max) ifTrue:[
- max := thisLen
- ]
- ]
+ line notNil ifTrue:[
+ (line isSingleByteString) ifTrue:[
+ thisLen := gc font widthOf:line
+ ] ifFalse:[
+ thisLen := line widthOn:self
+ ].
+ (thisLen > max) ifTrue:[
+ max := thisLen
+ ]
+ ]
].
^ max
!
withoutAnyColorEmphasis:line
(line notNil and:[line isText]) ifTrue:[
- ^ line withoutAnyColorEmphasis
+ ^ line withoutAnyColorEmphasis
].
^ line
@@ -3277,14 +3278,14 @@
withoutBackgroundColorEmphasis:line
(line notNil and:[line isText]) ifTrue:[
- ^ line withoutBackgroundColorEmphasis
+ ^ line withoutBackgroundColorEmphasis
].
^ line
!
withoutColorEmphasis:line
(line notNil and:[line isText]) ifTrue:[
- ^ line withoutForegroundColorEmphasis
+ ^ line withoutForegroundColorEmphasis
].
^ line
!
@@ -3296,7 +3297,7 @@
(line notNil
and:[line isText
and:[fg ~= fgColor or:[bg ~= bgColor]]]) ifTrue:[
- ^ line withoutAnyColorEmphasis
+ ^ line withoutAnyColorEmphasis
].
^ line
@@ -3309,35 +3310,35 @@
|line lineSize tcol lText|
col == 1 ifTrue:[
- lText := 0
+ lText := 0
] ifFalse:[
- tcol := col - 1.
-
- line := self visibleAt:visLineNr.
- (fontIsFixedWidth
- and:[line isNil or:[line isSingleByteString]])
- ifTrue:[
- lText := (tcol * fontWidth)
- ] ifFalse:[
- line notNil ifTrue:[
- lineSize := line string size
- ] ifFalse:[
- lineSize := 0
- ].
- (lineSize == 0) ifTrue:[
- lText := (tcol * fontWidth)
- ] ifFalse:[
- (lineSize < col) ifTrue:[
- lText := (line widthOn:self) + (fontWidth * (tcol - lineSize))
- ] ifFalse:[
- (line isSingleByteString) ifTrue:[
- lText := (font widthOf:line from:1 to:tcol)
- ] ifFalse:[
- lText := line widthFrom:1 to:tcol on:self.
- ]
- ]
- ]
- ]
+ tcol := col - 1.
+
+ line := self visibleAt:visLineNr.
+ (fontIsFixedWidth
+ and:[line isNil or:[line isSingleByteString]])
+ ifTrue:[
+ lText := (tcol * fontWidth)
+ ] ifFalse:[
+ line notNil ifTrue:[
+ lineSize := line string size
+ ] ifFalse:[
+ lineSize := 0
+ ].
+ (lineSize == 0) ifTrue:[
+ lText := (tcol * fontWidth)
+ ] ifFalse:[
+ (lineSize < col) ifTrue:[
+ lText := (line widthOn:self) + (fontWidth * (tcol - lineSize))
+ ] ifFalse:[
+ (line isSingleByteString) ifTrue:[
+ lText := (gc font widthOf:line from:1 to:tcol)
+ ] ifFalse:[
+ lText := line widthFrom:1 to:tcol on:self.
+ ]
+ ]
+ ]
+ ]
].
^ lText + textStartLeft
@@ -3352,7 +3353,7 @@
visLine := self listLineToVisibleLine:lineNr.
visLine isNil ifTrue:[
- ^ nil
+ ^ nil
].
^ self yOfVisibleLine:visLine
@@ -3390,18 +3391,18 @@
self checkForExistingLine:lineNr.
charPos := 1.
1 to:(lineNr - 1) do:[:lnr |
- lineString := self at:lnr.
- lineString notNil ifTrue:[
- charPos := charPos + (lineString string) size
- ].
- charPos := charPos + lineEndCharSize "the return-character"
+ lineString := self at:lnr.
+ lineString notNil ifTrue:[
+ charPos := charPos + (lineString string) size
+ ].
+ charPos := charPos + lineEndCharSize "the return-character"
].
- "/ NEW: expand that line, so that characterAtCharacterPosition returns the correct character
-"/ wrong: will modify!!
+ "/ NEW: expand that line, so that characterAtCharacterPosition returns the correct character
+"/ wrong: will modify!!
"/ (lineString := self at:lineNr) size < colArg ifTrue:[
"/ "/ expand this line
-"/ self at:lineNr put:((lineString ? ''),(String new:colArg-lineString size)).
+"/ self at:lineNr put:((lineString ? ''),(String new:colArg-lineString size)).
"/ ].
"/ OLD: if beyond end of line, be careful to not advance into next line.
@@ -3445,9 +3446,11 @@
heightForLines:numberOfLines
"return the height of the receiver, if numberOfLines are to be displayed"
+ |font|
+
"need a device font for query"
- font := font onDevice:device.
- ^ numberOfLines * fontHeight + topMargin + font descent + (lineSpacing) + (margin * 2)
+ font := gc createFontOnDevice.
+ ^ numberOfLines * fontHeight + topMargin + font descent + lineSpacing + (margin * 2)
"Created: 27.1.1996 / 16:55:39 / cg"
!
@@ -3456,7 +3459,7 @@
"return the height of the contents in pixels
- used for scrollbar interface"
- | numLines |
+ |numLines font|
numLines := self numberOfLines.
numLines == 0 ifTrue:[^ 0].
@@ -3470,12 +3473,11 @@
"
need device-font for query
"
- font := font onDevice:device.
- ^ numLines * fontHeight "don't take font height here - think of LabelAndIcons"
+ font := gc createFontOnDevice.
+ ^ numLines * fontHeight "dont take font height here - think of LabelAndIcons"
"/ + textStartTop
- (lineSpacing // 2)
+ (font descent)
-"/ + (font descent)
"/ + (font descent * 2) "makes it look better"
.
@@ -3580,12 +3582,12 @@
sum := 0.
lastLine := self size.
[(sum < charPos) and:[lineNr <= lastLine]] whileTrue:[
- l := (self at:lineNr) ? ''.
- sum := sum + (l string "withoutTrailingSeparators" size) + lineEndCharSize.
- lineNr := lineNr + 1
+ l := (self at:lineNr) ? ''.
+ sum := sum + (l string "withoutTrailingSeparators" size) + lineEndCharSize.
+ lineNr := lineNr + 1
].
sum == charPos ifTrue:[
- ^ lineNr
+ ^ lineNr
].
^ (lineNr - 1) max:1
@@ -3605,9 +3607,9 @@
!
preferredExtentForLines:numLines cols:numCols
- ^ (((font widthOf:'x') * numCols + margin + margin)
+ ^ (((gc font widthOf:'x') * numCols + margin + margin)
@
- (fontHeight * numLines + margin + margin + font descent + lineSpacing + topMargin)).
+ (fontHeight * numLines + margin + margin + gc font descent + lineSpacing + topMargin)).
"Modified: 26.5.1996 / 12:26:41 / cg"
!
@@ -3622,8 +3624,7 @@
"return the width of the contents in pixels
- used for scrollbar interface"
- |f d
- start "{ Class: SmallInteger }"
+ |font start "{ Class: SmallInteger }"
stop "{ Class: SmallInteger }"
lengthOfLongestString "{ Class: SmallInteger }"
lengthOfLongestLine "{ Class: SmallInteger }"
@@ -3635,12 +3636,7 @@
^ widthOfWidestLine + (leftMargin * 2)
].
- (d := device) isNil ifTrue:[
- "/ mhmh - really dont know yet
- d := Screen current
- ].
- f := font := font onDevice:d.
-
+ font := gc createFontOnDevice.
checkedLinesForWidthOfContentsComputation isNil ifTrue:[
start := 1.
stop := list size
@@ -3662,7 +3658,7 @@
entry := list at:lineNr.
entry notNil ifTrue:[
(entry isSingleByteString) ifTrue:[
- w := f widthOf:entry
+ w := font widthOf:entry
] ifFalse:[
w := entry widthOn:self
].
@@ -3717,21 +3713,16 @@
widthOfLine:lineNr
"return the width of a line in pixels"
- |line f d|
+ |line font|
list isNil ifTrue:[^ 0].
lineNr > list size ifTrue:[^ 0].
line := list at:lineNr.
list isNil ifTrue:[^ 0].
- (d := device) isNil ifTrue:[
- "/ mhmh - really dont know yet
- d := Screen current
- ].
- f := font := font onDevice:d.
-
+ font := gc createFontOnDevice.
(line isSingleByteString) ifTrue:[
- ^ f widthOf:line
+ ^ font widthOf:line
].
^ line widthOn:self
@@ -3966,7 +3957,7 @@
"return the amount to scroll when stepping up/down.
Here, the scrolling unit is characters."
- ^ font width
+ ^ gc font width
"Created: / 21.5.1999 / 15:55:06 / cg"
!
@@ -3996,7 +3987,7 @@
no, the above does not look good, if you click / select at the
far right - makes selecting so difficult ...
"
- (xVis >= 0 and:[xVis < (width - font width)]) ifTrue:[^ self].
+ (xVis >= 0 and:[xVis < (width - gc font width)]) ifTrue:[^ self].
self scrollHorizontalTo:(xWant - (width // 2)).
!
@@ -4209,7 +4200,7 @@
^ self
].
- pxlOffset := font width * (aColNr - 1).
+ pxlOffset := gc font width * (aColNr - 1).
pxlOffset < leftOffset ifTrue:[
self scrollLeft:(leftOffset - pxlOffset)
@@ -4300,8 +4291,8 @@
Return true, to tell caller that scrolling is allowed (redefined in editField)"
self
- startAutoScrollVertical:yDistance
- scrollSelector:#scrollSelectDown.
+ startAutoScrollVertical:yDistance
+ scrollSelector:#scrollSelectDown.
^ true
!
@@ -4330,8 +4321,8 @@
- timeDelta for scroll is computed from distance"
self
- startAutoScrollHorizontal:xDistance negated
- scrollSelector:#scrollSelectLeft.
+ startAutoScrollHorizontal:xDistance negated
+ scrollSelector:#scrollSelectLeft.
^ true
!
@@ -4340,8 +4331,8 @@
- timeDelta for scroll is computed from distance"
self
- startAutoScrollHorizontal:xDistance
- scrollSelector:#scrollSelectRight.
+ startAutoScrollHorizontal:xDistance
+ scrollSelector:#scrollSelectRight.
^ true
!
@@ -4351,8 +4342,8 @@
Return true, to tell caller that scrolling is allowed (redefined in editField)"
self
- startAutoScrollVertical:yDistance negated
- scrollSelector:#scrollSelectUp.
+ startAutoScrollVertical:yDistance negated
+ scrollSelector:#scrollSelectUp.
^ true
!
@@ -4364,15 +4355,15 @@
autoScroll ifFalse:[^ self].
- mm := (yDistance abs // self verticalIntegerPixelPerMillimeter) + 1.
+ mm := (yDistance abs // self verticalIntegerPixelPerMillimeter) + 1.
deltaT := 0.5 / mm.
(deltaT = autoScrollDeltaT) ifFalse:[
- autoScrollDeltaT := deltaT.
- autoScrollBlock isNil ifTrue:[
- autoScrollBlock := [self realized ifTrue:[self perform:scrollSelector]].
- Processor addTimedBlock:autoScrollBlock afterSeconds:deltaT
- ]
+ autoScrollDeltaT := deltaT.
+ autoScrollBlock isNil ifTrue:[
+ autoScrollBlock := [self realized ifTrue:[self perform:scrollSelector]].
+ Processor addTimedBlock:autoScrollBlock afterSeconds:deltaT
+ ]
]
"Modified: / 08-08-2010 / 11:26:26 / cg"
@@ -4415,7 +4406,7 @@
to be visible if it is positioned right behind the longest line of text.
The default returned here is the width of a blank (to beautify italic text)"
- ^ font width
+ ^ gc font width
!
scrollTo:anOrigin redraw:doRedraw
@@ -4444,42 +4435,42 @@
"/ compute valid horizontal offset x
(x := dltOrg x) ~~ 0 ifTrue:[
- tmp := viewOrigin x + x.
-
- x < 0 ifTrue:[ "/ scrolling left
- tmp < 0 ifTrue:[x := 0 - viewOrigin x]
- ] ifFalse:[ "/ scrolling right
- "/ allows scrolling to the right of widest line
- max := self widthOfContents + (self additionalMarginForHorizontalScroll).
-
- tmp + width > max ifTrue:[
- x := (max - viewOrigin x - width) max:0
- ]
- ]
+ tmp := viewOrigin x + x.
+
+ x < 0 ifTrue:[ "/ scrolling left
+ tmp < 0 ifTrue:[x := 0 - viewOrigin x]
+ ] ifFalse:[ "/ scrolling right
+ "/ allows scrolling to the right of widest line
+ max := self widthOfContents + (self additionalMarginForHorizontalScroll).
+
+ tmp + width > max ifTrue:[
+ x := (max - viewOrigin x - width) max:0
+ ]
+ ]
].
"/ compute valid vertical offset measured in lines
(y := dltOrg y // fontHeight) ~~ 0 ifTrue:[
- tmp := firstLineShown + y.
-
- y < 0 ifTrue:[ "/ scrolling up
- tmp < 1 ifTrue:[y := 1 - firstLineShown]
- ] ifFalse:[ "/ scrolling down
- max := self size.
-
- tmp + nFullLinesShown > max ifTrue:[
- y := (max - firstLineShown - nFullLinesShown + 1) max:0
- ]
- ]
+ tmp := firstLineShown + y.
+
+ y < 0 ifTrue:[ "/ scrolling up
+ tmp < 1 ifTrue:[y := 1 - firstLineShown]
+ ] ifFalse:[ "/ scrolling down
+ max := self size.
+
+ tmp + nFullLinesShown > max ifTrue:[
+ y := (max - firstLineShown - nFullLinesShown + 1) max:0
+ ]
+ ]
].
(x == 0 and:[y == 0]) ifTrue:[ "/ has viewOrigin changed ?
- ^ self
+ ^ self
].
(noLn := y) ~~ 0 ifTrue:[
- y := y * fontHeight
+ y := y * fontHeight
].
delta := (x @ y).
@@ -4487,11 +4478,11 @@
newViewOrigin := viewOrigin + delta.
(shown and:[doRedraw]) ifFalse:[
- self originWillChange.
- firstLineShown := newFirstLine.
- viewOrigin := newViewOrigin.
- self assert:(viewOrigin x >= 0).
- ^ self originChanged:delta
+ self originWillChange.
+ firstLineShown := newFirstLine.
+ viewOrigin := newViewOrigin.
+ self assert:(viewOrigin x >= 0).
+ ^ self originChanged:delta
].
"/ (self sensor notNil and: [self sensor hasExposeEventFor:self]) ifTrue:[ "/ outstanding expose events
@@ -4504,18 +4495,18 @@
or:[(noLn abs) >= nLinesShown "/ at least one area is
or:[(x abs) > (width // 4 * 3)]] "/ big enough to redraw all
) ifTrue:[
- self originWillChange.
- firstLineShown := newFirstLine.
- viewOrigin := newViewOrigin.
- self invalidate.
- ^ self originChanged:delta
+ self originWillChange.
+ firstLineShown := newFirstLine.
+ viewOrigin := newViewOrigin.
+ self invalidate.
+ ^ self originChanged:delta
].
"/ OLD:
"/ self repairDamage.
(wg := self windowGroup) notNil ifTrue:[
- wg processRealExposeEventsFor:self.
+ wg processRealExposeEventsFor:self.
].
self originWillChange.
@@ -4526,61 +4517,61 @@
self catchExpose.
x == 0 ifTrue:[
- "/ scrolling vertical
-
- y0 := textStartTop + (y abs).
- h := hBefore - margin - y0.
- w := wBefore - margin.
- y > 0 ifTrue:[ "/ copy down
- "/ kludge: if the selection highlighting draws into the textStartTop area,
- "/ the copy below leaves some selection depris in the top area.
- "/ Therefore, clear the top area.
- "/ (should avoid this, in case we know there cannot be anything
- "/ there - selection is nil or >= firstLineShown).
- self clearDeviceRectangleX:margin y:margin width:width-margin-margin height:(textStartTop-margin).
+ "/ scrolling vertical
+
+ y0 := textStartTop + (y abs).
+ h := hBefore - margin - y0.
+ w := wBefore - margin.
+ y > 0 ifTrue:[ "/ copy down
+ "/ kludge: if the selection highlighting draws into the textStartTop area,
+ "/ the copy below leaves some selection depris in the top area.
+ "/ Therefore, clear the top area.
+ "/ (should avoid this, in case we know there cannot be anything
+ "/ there - selection is nil or >= firstLineShown).
+ self clearDeviceRectangleX:margin y:margin width:width-margin-margin height:(textStartTop-margin).
"/ self invalidateDeviceRectangle:((margin@margin) corner:(width-margin@textStartTop)) repairNow:false.
- self copyFrom:self
- x:0 y:y0 toX:0 y:textStartTop
- width:w height:h async:true.
- y1 := h - 1.
- y0 := y0 + 1.
- ] ifFalse:[ "/ copy up
- self copyFrom:self
- x:margin y:textStartTop toX:margin y:y0
- width:w height:h async:true.
- y1 := 0.
- ].
-
- inv := (margin@y1) extent:(w@y0+margin).
+ self copyFrom:self
+ x:0 y:y0 toX:0 y:textStartTop
+ width:w height:h async:true.
+ y1 := h - 1.
+ y0 := y0 + 1.
+ ] ifFalse:[ "/ copy up
+ self copyFrom:self
+ x:margin y:textStartTop toX:margin y:y0
+ width:w height:h async:true.
+ y1 := 0.
+ ].
+
+ inv := (margin@y1) extent:(w@y0+margin).
] ifFalse:[
- "/ scrolling horizontal
-
- x > 0 ifTrue:[ "/ scrolling right
- y0 := margin + x.
- y1 := wBefore - y0.
- ] ifFalse:[ "/ scrolling left
- y0 := margin - x.
- y1 := 0.
- ].
- h := hBefore - margin - margin.
- w := wBefore - margin - y0.
-
- x > 0 ifTrue:[ "/ copy right
- self copyFrom:self x:y0 y:margin toX:margin y:margin
- width:w height:h async:true.
- ] ifFalse:[ "/ copy left
- "/ self copyFrom:self x:textStartLeft y:margin toX:y0 y:margin
+ "/ scrolling horizontal
+
+ x > 0 ifTrue:[ "/ scrolling right
+ y0 := margin + x.
+ y1 := wBefore - y0.
+ ] ifFalse:[ "/ scrolling left
+ y0 := margin - x.
+ y1 := 0.
+ ].
+ h := hBefore - margin - margin.
+ w := wBefore - margin - y0.
+
+ x > 0 ifTrue:[ "/ copy right
+ self copyFrom:self x:y0 y:margin toX:margin y:margin
+ width:w height:h async:true.
+ ] ifFalse:[ "/ copy left
+ "/ self copyFrom:self x:textStartLeft y:margin toX:y0 y:margin
"/ viewOrigin x > margin ifTrue:[
"/ self copyFrom:self x:0 y:margin toX:y0-margin y:margin
"/ width:w height:h async:true.
"/ ] ifFalse:[
- self copyFrom:self x:margin y:margin toX:y0 y:margin
- width:w height:h async:true.
+ self copyFrom:self x:margin y:margin toX:y0 y:margin
+ width:w height:h async:true.
"/ ].
- ].
-
- inv := (y1@margin) extent:(y0@h).
+ ].
+
+ inv := (y1@margin) extent:(y0@h).
].
firstLineShown := newFirstLine.
@@ -4588,14 +4579,14 @@
self invalidateDeviceRectangle:inv repairNow:false.
viewOrigin x <= margin ifTrue:[
- self invalidateDeviceRectangle:((0@margin) extent:(margin@h)) repairNow:false.
+ self invalidateDeviceRectangle:((0@margin) extent:(margin@h)) repairNow:false.
].
self originChanged:delta.
self waitForExpose.
(wg := self windowGroup) notNil ifTrue:[
- wg processRealExposeEventsFor:self.
+ wg processRealExposeEventsFor:self.
].
"/ (hBefore ~= height or:[wBefore ~= width]) ifTrue:[
@@ -4694,13 +4685,13 @@
found evaluate block2.
Sorry, but pattern is no regular expression pattern (yet)"
- ^ self
- searchBackwardUsingSpec:(SearchSpec new
- pattern:pattern
- ignoreCase:ignCase
- match:false)
- startingAtLine:startLine col:startCol
- ifFound:block1 ifAbsent:block2
+ ^ self
+ searchBackwardUsingSpec:(SearchSpec new
+ pattern:pattern
+ ignoreCase:ignCase
+ match:false)
+ startingAtLine:startLine col:startCol
+ ifFound:block1 ifAbsent:block2
!
searchBackwardFor:pattern startingAtLine:startLine col:startCol ifFound:block1 ifAbsent:block2
@@ -4745,82 +4736,82 @@
and:[startLine > 0
and:[patternSize ~~ 0]])
ifTrue:[
- self withCursor:Cursor questionMark do:[
- col := startCol - 1.
- firstChar1 := pattern at:1.
- ignCase ifTrue:[
- firstChar1 := firstChar1 asLowercase.
- firstChar2 := firstChar1 asUppercase.
- ] ifFalse:[
- firstChar2 := firstChar1
- ].
-
- line1 := startLine.
- line1 > list size ifTrue:[
- line1 := list size.
- col := -999
- ] ifFalse:[
- col > (list at:line1) size ifTrue:[
- col := -999
- ]
- ].
- line1 to:1 by:-1 do:[:lnr |
- lineString := list at:lnr.
- lineString notNil ifTrue:[
- lineString := lineString asString.
- lineString isString ifTrue:[
- "/ quick check if pattern is present
- col1 := lineString
- findString:pattern startingAt:1
- ifAbsent:0 caseSensitive: ignCase not.
- col1 ~~ 0 ifTrue:[
- lineSize := lineString size.
- col == -999 ifTrue:[col := lineSize - patternSize + 1].
- [(col > 0)
- and:[(c := lineString at:col) ~= firstChar1
- and:[c ~= firstChar2]]] whileTrue:[
- col := col - 1
- ].
- [col > 0] whileTrue:[
- cc := col.
- found := true.
- 1 to:patternSize do:[:cnr |
- cc > lineSize ifTrue:[
- found := false
- ] ifFalse:[
- pc := pattern at:cnr.
- c := lineString at:cc.
- pc ~= c ifTrue:[
- (ignCase not or:[pc asLowercase ~= c asLowercase]) ifTrue:[
- found := false
- ]
- ]
- ].
- cc := cc + 1
- ].
- found ifTrue:[
- (fullWord not
- or:[ (self findBeginOfWordAtLine:lnr col:col) == col
- and:[ (self findEndOfWordAtLine:lnr col:col) == (col + patternSize - 1) ]]
- ) ifTrue:[
- (atBeginOfLineOnly not or:[col == 1]) ifTrue:[
- ^ block1 value:lnr value:col optionalArgument:nil.
- ]
- ]
- ].
- col := col - 1.
- [(col > 0)
- and:[(c := lineString at:col) ~= firstChar1
- and:[c ~= firstChar2]]] whileTrue:[
- col := col - 1
- ]
- ]
- ]
- ].
- ].
- col := -999.
- ]
- ]
+ self withCursor:Cursor questionMark do:[
+ col := startCol - 1.
+ firstChar1 := pattern at:1.
+ ignCase ifTrue:[
+ firstChar1 := firstChar1 asLowercase.
+ firstChar2 := firstChar1 asUppercase.
+ ] ifFalse:[
+ firstChar2 := firstChar1
+ ].
+
+ line1 := startLine.
+ line1 > list size ifTrue:[
+ line1 := list size.
+ col := -999
+ ] ifFalse:[
+ col > (list at:line1) size ifTrue:[
+ col := -999
+ ]
+ ].
+ line1 to:1 by:-1 do:[:lnr |
+ lineString := list at:lnr.
+ lineString notNil ifTrue:[
+ lineString := lineString asString.
+ lineString isString ifTrue:[
+ "/ quick check if pattern is present
+ col1 := lineString
+ findString:pattern startingAt:1
+ ifAbsent:0 caseSensitive: ignCase not.
+ col1 ~~ 0 ifTrue:[
+ lineSize := lineString size.
+ col == -999 ifTrue:[col := lineSize - patternSize + 1].
+ [(col > 0)
+ and:[(c := lineString at:col) ~= firstChar1
+ and:[c ~= firstChar2]]] whileTrue:[
+ col := col - 1
+ ].
+ [col > 0] whileTrue:[
+ cc := col.
+ found := true.
+ 1 to:patternSize do:[:cnr |
+ cc > lineSize ifTrue:[
+ found := false
+ ] ifFalse:[
+ pc := pattern at:cnr.
+ c := lineString at:cc.
+ pc ~= c ifTrue:[
+ (ignCase not or:[pc asLowercase ~= c asLowercase]) ifTrue:[
+ found := false
+ ]
+ ]
+ ].
+ cc := cc + 1
+ ].
+ found ifTrue:[
+ (fullWord not
+ or:[ (self findBeginOfWordAtLine:lnr col:col) == col
+ and:[ (self findEndOfWordAtLine:lnr col:col) == (col + patternSize - 1) ]]
+ ) ifTrue:[
+ (atBeginOfLineOnly not or:[col == 1]) ifTrue:[
+ ^ block1 value:lnr value:col optionalArgument:nil.
+ ]
+ ]
+ ].
+ col := col - 1.
+ [(col > 0)
+ and:[(c := lineString at:col) ~= firstChar1
+ and:[c ~= firstChar2]]] whileTrue:[
+ col := col - 1
+ ]
+ ]
+ ]
+ ].
+ ].
+ col := -999.
+ ]
+ ]
].
"not found"
@@ -4835,12 +4826,12 @@
found evaluate block2."
^ self
- searchForwardUsingSpec:(SearchSpec new
- pattern:pattern
- ignoreCase:ignCase
- match:match)
- startingAtLine:startLine col:startCol
- ifFound:block1 ifAbsent:block2
+ searchForwardUsingSpec:(SearchSpec new
+ pattern:pattern
+ ignoreCase:ignCase
+ match:match)
+ startingAtLine:startLine col:startCol
+ ifFound:block1 ifAbsent:block2
!
searchForwardFor:pattern ignoreCase:ignCase startingAtLine:startLine col:startCol ifFound:block1 ifAbsent:block2
@@ -4865,12 +4856,12 @@
!
searchForwardUsingSpec:searchSpec startingAtLine:startLine col:startCol ifFound:block1 ifAbsent:block2
- "search for a pattern, if found evaluate block1 with row/col as arguments,
- if not found evaluate block2.
+ "search for a pattern, if found evaluate block1 with row/col as arguments,
+ if not found evaluate block2.
If the block is a three-arg block, it gets the end-col (or nil, if not known)"
|lineString col pattern match regexMatch ignCase fullWord atBeginOfLineOnly
- wrapAtEndOfText patternSize matcher lnr "{Class: SmallInteger}"
+ wrapAtEndOfText patternSize matcher lnr "{Class: SmallInteger}"
line1 "{Class: SmallInteger}"
line2 "{Class: SmallInteger}"
p realPattern runner foundCol endCol|
@@ -4879,9 +4870,9 @@
match := searchSpec match.
regexMatch := searchSpec regexMatch.
(match and:[regexMatch not]) ifTrue:[
- pattern := pattern globPatternAsRegexPattern.
- regexMatch := true.
- ].
+ pattern := pattern globPatternAsRegexPattern.
+ regexMatch := true.
+ ].
ignCase := searchSpec ignoreCase.
fullWord := searchSpec fullWord.
atBeginOfLineOnly := searchSpec atBeginOfLineOnly.
@@ -4889,106 +4880,106 @@
patternSize := pattern size.
(list notNil and:[patternSize ~~ 0]) ifTrue:[
- self withCursor:Cursor questionMark do:[
-
- col := startCol + 1.
- line1 := startLine.
- line2 := list size.
-
- "/ call searchBlock with lnr, col, and line. Cares for wrap
- runner :=
- [:searchBlock |
- |didWrap|
-
- lnr := line1.
- didWrap := false.
- [lnr <= line2] whileTrue:[
- lineString := list at:lnr.
- lineString notNil ifTrue:[
- lineString := lineString asString string.
- lineString isString ifTrue:[
- searchBlock value:lnr value:col value:lineString
- ]
- ].
- col := 1.
- lnr := lnr + 1.
- lnr > line2 ifTrue:[
- (wrapAtEndOfText and:[didWrap not]) ifTrue:[
- didWrap := true.
- lnr := 1.
- line2 := line1-1.
- ].
- ].
- ].
-
- ].
-
- (match and:[regexMatch]) ifTrue:[
- "perform a findMatchString (regex matching)"
- Regex::RxParser isNil ifTrue:[
- Smalltalk loadPackage:'stx:goodies/regex'
- ].
- matcher := ignCase ifTrue:[pattern asRegexIgnoringCase] ifFalse:[pattern asRegex].
- runner
- value:[:lnr :col :lineString |
- "/ first a crude check ...
- (matcher hasMatchesIn:lineString) ifTrue:[
- "/ find which match to show
- 1 to:matcher subexpressionCount do:[:i |
- foundCol := matcher subBeginning:i.
- endCol := matcher subEnd:i.
- (foundCol notNil and: [endCol notNil]) ifTrue: [
- foundCol := foundCol + 1. "/ regex uses 0-based indexes (sigh)
- foundCol >= col ifTrue:[
- (atBeginOfLineOnly not or:[foundCol == 1]) ifTrue:[
- ^ block1 value:lnr value:foundCol optionalArgument:endCol.
- ]]]]]].
- ] ifFalse:[
- (match and:[pattern includesUnescapedMatchCharacters]) ifTrue:[
- "perform a findMatchString (glob matching)"
- p := pattern species new:0.
- (pattern startsWith:$*) ifFalse:[p := p , '*'].
- p := p , pattern.
- (pattern endsWith:$*) ifFalse:[p := p , '*'].
- realPattern := pattern.
- (realPattern startsWith:$*) ifTrue:[
- realPattern := realPattern copyFrom:2
- ].
- runner
- value:[:lnr :col :lineString |
- (p match:lineString caseSensitive:ignCase not) ifTrue:[
- "/ ok, there it is; look at which position
- foundCol := lineString
- findMatchString:realPattern startingAt:col
- caseSensitive:ignCase not ifAbsent:0.
- foundCol ~~ 0 ifTrue:[
- (atBeginOfLineOnly not or:[foundCol == 1]) ifTrue:[
- ^ block1 value:lnr value:foundCol optionalArgument:nil.
- ]]]].
- ] ifFalse:[
- "perform a findString (no matching)"
- p := pattern.
- (match and:[pattern includesMatchCharacters]) ifTrue:[
- p := pattern withoutMatchEscapes
- ].
- runner
- value:[:lnr :col :lineString |
- foundCol := lineString
- findString:p startingAt:col ifAbsent:0 caseSensitive: ignCase not.
- foundCol ~~ 0 ifTrue:[
- (fullWord not
- or:[ (self findBeginOfWordAtLine:lnr col:foundCol) == foundCol
- and:[ (self findEndOfWordAtLine:lnr col:foundCol) == (foundCol + patternSize - 1) ]]
- ) ifTrue:[
- (atBeginOfLineOnly not or:[foundCol == 1]) ifTrue:[
- ^ block1 value:lnr value:foundCol optionalArgument:nil.
- ]
- ]
- ]
- ].
- ].
- ].
- ]
+ self withCursor:Cursor questionMark do:[
+
+ col := startCol + 1.
+ line1 := startLine.
+ line2 := list size.
+
+ "/ call searchBlock with lnr, col, and line. Cares for wrap
+ runner :=
+ [:searchBlock |
+ |didWrap|
+
+ lnr := line1.
+ didWrap := false.
+ [lnr <= line2] whileTrue:[
+ lineString := list at:lnr.
+ lineString notNil ifTrue:[
+ lineString := lineString asString string.
+ lineString isString ifTrue:[
+ searchBlock value:lnr value:col value:lineString
+ ]
+ ].
+ col := 1.
+ lnr := lnr + 1.
+ lnr > line2 ifTrue:[
+ (wrapAtEndOfText and:[didWrap not]) ifTrue:[
+ didWrap := true.
+ lnr := 1.
+ line2 := line1-1.
+ ].
+ ].
+ ].
+
+ ].
+
+ (match and:[regexMatch]) ifTrue:[
+ "perform a findMatchString (regex matching)"
+ Regex::RxParser isNil ifTrue:[
+ Smalltalk loadPackage:'stx:goodies/regex'
+ ].
+ matcher := ignCase ifTrue:[pattern asRegexIgnoringCase] ifFalse:[pattern asRegex].
+ runner
+ value:[:lnr :col :lineString |
+ "/ first a crude check ...
+ (matcher hasMatchesIn:lineString) ifTrue:[
+ "/ find which match to show
+ 1 to:matcher subexpressionCount do:[:i |
+ foundCol := matcher subBeginning:i.
+ endCol := matcher subEnd:i.
+ (foundCol notNil and: [endCol notNil]) ifTrue: [
+ foundCol := foundCol + 1. "/ regex uses 0-based indexes (sigh)
+ foundCol >= col ifTrue:[
+ (atBeginOfLineOnly not or:[foundCol == 1]) ifTrue:[
+ ^ block1 value:lnr value:foundCol optionalArgument:endCol.
+ ]]]]]].
+ ] ifFalse:[
+ (match and:[pattern includesUnescapedMatchCharacters]) ifTrue:[
+ "perform a findMatchString (glob matching)"
+ p := pattern species new:0.
+ (pattern startsWith:$*) ifFalse:[p := p , '*'].
+ p := p , pattern.
+ (pattern endsWith:$*) ifFalse:[p := p , '*'].
+ realPattern := pattern.
+ (realPattern startsWith:$*) ifTrue:[
+ realPattern := realPattern copyFrom:2
+ ].
+ runner
+ value:[:lnr :col :lineString |
+ (p match:lineString caseSensitive:ignCase not) ifTrue:[
+ "/ ok, there it is; look at which position
+ foundCol := lineString
+ findMatchString:realPattern startingAt:col
+ caseSensitive:ignCase not ifAbsent:0.
+ foundCol ~~ 0 ifTrue:[
+ (atBeginOfLineOnly not or:[foundCol == 1]) ifTrue:[
+ ^ block1 value:lnr value:foundCol optionalArgument:nil.
+ ]]]].
+ ] ifFalse:[
+ "perform a findString (no matching)"
+ p := pattern.
+ (match and:[pattern includesMatchCharacters]) ifTrue:[
+ p := pattern withoutMatchEscapes
+ ].
+ runner
+ value:[:lnr :col :lineString |
+ foundCol := lineString
+ findString:p startingAt:col ifAbsent:0 caseSensitive: ignCase not.
+ foundCol ~~ 0 ifTrue:[
+ (fullWord not
+ or:[ (self findBeginOfWordAtLine:lnr col:foundCol) == foundCol
+ and:[ (self findEndOfWordAtLine:lnr col:foundCol) == (foundCol + patternSize - 1) ]]
+ ) ifTrue:[
+ (atBeginOfLineOnly not or:[foundCol == 1]) ifTrue:[
+ ^ block1 value:lnr value:foundCol optionalArgument:nil.
+ ]
+ ]
+ ]
+ ].
+ ].
+ ].
+ ]
].
"not found"
@@ -5008,12 +4999,12 @@
|prefs|
(prefs := UserPreferences current) whitespaceWordSelectMode ifTrue:[
- "an extremely simple mode, where every non-space is treated as part of the word"
- ^ char isSeparator not
+ "an extremely simple mode, where every non-space is treated as part of the word"
+ ^ char isSeparator not
].
prefs extendedWordSelectMode ifTrue:[
- "the typical mode, useful for text and code"
- ^ char isNationalAlphaNumeric or:[char == $_]
+ "the typical mode, useful for text and code"
+ ^ char isNationalAlphaNumeric or:[char == $_]
].
"another typical mode, also useful for text and code"
^ char isNationalAlphaNumeric
@@ -5032,20 +5023,20 @@
includesNonStrings := false.
list notNil ifTrue:[
- nLines := self size.
- 1 to:nLines do:[:index |
- line := self at:index.
- line notNil ifTrue:[
- (line isString) ifTrue:[
- newLine := line withTabsExpanded.
- newLine ~~ line ifTrue:[
- list at:index put:newLine
- ].
- ] ifFalse:[
- includesNonStrings := true.
- ]
- ]
- ]
+ nLines := self size.
+ 1 to:nLines do:[:index |
+ line := self at:index.
+ line notNil ifTrue:[
+ (line isString) ifTrue:[
+ newLine := line withTabsExpanded.
+ newLine ~~ line ifTrue:[
+ list at:index put:newLine
+ ].
+ ] ifFalse:[
+ includesNonStrings := true.
+ ]
+ ]
+ ]
]
"Modified: 30.8.1995 / 19:06:37 / claus"
@@ -5311,7 +5302,7 @@
^ pattern
!
-pattern:patternString
+pattern:patternString
pattern := patternString.
!
@@ -5333,11 +5324,11 @@
forward := forwardBoolean
!
-pattern:patternString ignoreCase:ignoredCaseBoolean
- match:matchBoolean regexMatch:regexMatchBoolean
- variable:variableBoolen
- fullWord:fullWordBoolen forward:forwardBoolean
- atBeginOfLineOnly:atBeginOfLineOnlyArg
+pattern:patternString ignoreCase:ignoredCaseBoolean
+ match:matchBoolean regexMatch:regexMatchBoolean
+ variable:variableBoolen
+ fullWord:fullWordBoolen forward:forwardBoolean
+ atBeginOfLineOnly:atBeginOfLineOnlyArg
pattern := patternString.
ignoreCase := ignoredCaseBoolean.
match := matchBoolean.
@@ -5348,12 +5339,12 @@
atBeginOfLineOnly := atBeginOfLineOnlyArg
!
-pattern:patternString ignoreCase:ignoredCaseBoolean
- match:matchBoolean regexMatch:regexMatchBoolean
- variable:variableBoolen
- fullWord:fullWordBoolen forward:forwardBoolean
- atBeginOfLineOnly:atBeginOfLineOnlyArg
- wrapAtEnd:wrapAtEndOfTextArg
+pattern:patternString ignoreCase:ignoredCaseBoolean
+ match:matchBoolean regexMatch:regexMatchBoolean
+ variable:variableBoolen
+ fullWord:fullWordBoolen forward:forwardBoolean
+ atBeginOfLineOnly:atBeginOfLineOnlyArg
+ wrapAtEnd:wrapAtEndOfTextArg
pattern := patternString.
ignoreCase := ignoredCaseBoolean.
match := matchBoolean.
@@ -5382,9 +5373,9 @@
forward := forwardBoolean
!
-pattern:patternString ignoreCase:ignoredCaseBoolean match:matchBoolean variable:variableBoolen
- fullWord:fullWordBoolen forward:forwardBoolean
- atBeginOfLineOnly:atBeginOfLineOnlyArg
+pattern:patternString ignoreCase:ignoredCaseBoolean match:matchBoolean variable:variableBoolen
+ fullWord:fullWordBoolen forward:forwardBoolean
+ atBeginOfLineOnly:atBeginOfLineOnlyArg
pattern := patternString.
ignoreCase := ignoredCaseBoolean.
match := matchBoolean.