--- a/TextView.st Mon Jun 16 10:44:36 2014 +0100
+++ b/TextView.st Mon Sep 08 17:09:06 2014 +0100
@@ -337,6 +337,9 @@
#searchFullWord
'Search only for full words (ignore occurrences as substring)'
+#searchAtBeginOfLineOnly
+'Search only for the string at the beginning if a line'
+
#searchPattern
'String or match-pattern to be searched'
@@ -367,191 +370,201 @@
<resource: #canvas>
- ^
+ ^
#(FullSpec
name: searchDialogSpec
- window:
+ window:
(WindowSpec
- label: 'String search'
- name: 'String search'
- min: (Point 10 10)
- max: (Point 1280 1024)
- bounds: (Rectangle 0 0 302 242)
+ label: 'String search'
+ name: 'String search'
+ min: (Point 10 10)
+ max: (Point 1280 1024)
+ bounds: (Rectangle 0 0 319 266)
)
- component:
+ component:
(SpecCollection
- collection: (
- (LabelSpec
- label: 'SearchPattern:'
- name: 'label'
- layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
- level: 0
- translateLabel: true
- adjust: left
- )
- (ComboBoxSpec
- name: 'patternComboBox'
- layout: (LayoutFrame 2 0.0 26 0 -2 1.0 48 0)
- activeHelpKey: searchPattern
- tabable: true
- model: searchPattern
- immediateAccept: false
- acceptOnLeave: true
- acceptOnReturn: true
- acceptOnTab: true
- acceptOnLostFocus: true
- acceptOnPointerLeave: false
- autoSelectInitialText: true
- comboList: patternList
- )
- (VerticalPanelViewSpec
- name: 'VerticalPanel1'
- layout: (LayoutFrame 0 0.0 52 0 0 1.0 -30 1)
- horizontalLayout: fit
- verticalLayout: top
- component:
- (SpecCollection
- collection: (
- (CheckBoxSpec
- label: 'Case Sensitive'
- name: 'ignoreCaseCheckBox'
- activeHelpKey: searchCaseSensitive
- level: 0
- tabable: true
- model: caseSensitive
- translateLabel: true
- extent: (Point 302 24)
- )
- (CheckBoxSpec
- label: 'Match (forward only)'
- name: 'matchCheckBox'
- activeHelpKey: matchSearch
- level: 0
- tabable: true
- model: match
- translateLabel: true
- extent: (Point 302 24)
- )
- (CheckBoxSpec
- label: 'Search Full Words'
- name: 'CheckBox2'
- activeHelpKey: searchFullWord
- level: 0
- enableChannel: searchFullWordEnabled
- tabable: true
- model: searchFullWord
- translateLabel: true
- extent: (Point 302 24)
- )
- (CheckBoxSpec
- label: 'Variable Only'
- name: 'CheckBox1'
- activeHelpKey: searchVariable
- level: 0
- visibilityChannel: searchVariableVisible
- enableChannel: searchVariableEnabled
- tabable: true
- model: searchVariable
- translateLabel: true
- labelChannel: stringWithVariableUnderCursorHolder
- extent: (Point 302 24)
+ collection: (
+ (LabelSpec
+ label: 'SearchPattern:'
+ name: 'label'
+ layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
+ level: 0
+ translateLabel: true
+ adjust: left
+ )
+ (ComboBoxSpec
+ name: 'patternComboBox'
+ layout: (LayoutFrame 2 0.0 26 0 -2 1.0 48 0)
+ activeHelpKey: searchPattern
+ tabable: true
+ model: searchPattern
+ immediateAccept: false
+ acceptOnLeave: true
+ acceptOnReturn: true
+ acceptOnTab: true
+ acceptOnLostFocus: true
+ acceptOnPointerLeave: false
+ autoSelectInitialText: true
+ comboList: patternList
+ )
+ (VerticalPanelViewSpec
+ name: 'VerticalPanel1'
+ layout: (LayoutFrame 0 0.0 52 0 0 1.0 -30 1)
+ horizontalLayout: fit
+ verticalLayout: top
+ component:
+ (SpecCollection
+ collection: (
+ (CheckBoxSpec
+ label: 'Case Sensitive'
+ name: 'ignoreCaseCheckBox'
+ activeHelpKey: searchCaseSensitive
+ level: 0
+ tabable: true
+ model: caseSensitive
+ translateLabel: true
+ extent: (Point 319 24)
+ )
+ (CheckBoxSpec
+ label: 'Match (forward only)'
+ name: 'matchCheckBox'
+ activeHelpKey: matchSearch
+ level: 0
+ tabable: true
+ model: match
+ translateLabel: true
+ extent: (Point 319 24)
+ )
+ (CheckBoxSpec
+ label: 'Search Full Words'
+ name: 'CheckBox2'
+ activeHelpKey: searchFullWord
+ level: 0
+ enableChannel: searchFullWordEnabled
+ tabable: true
+ model: searchFullWord
+ translateLabel: true
+ extent: (Point 319 24)
)
(CheckBoxSpec
- label: 'Select Lines'
- name: 'CheckBox3'
- activeHelpKey: selectLines
+ label: 'At Begin of Line Only'
+ name: 'CheckBox5'
+ activeHelpKey: searchAtBeginOfLineOnly
level: 0
- initiallyInvisible: true
tabable: true
- model: selectLines
+ model: searchAtBeginOfLineOnly
translateLabel: true
- extent: (Point 302 24)
- )
- (ViewSpec
- name: 'Box1'
- component:
- (SpecCollection
- collection: (
- (CheckBoxSpec
- label: 'Global Replace With:'
- name: 'CheckBox4'
- layout: (LayoutFrame 0 0 0 0 162 0 23 0)
- activeHelpKey: replaceText
- level: 0
- enableChannel: replaceEnabled
- tabable: true
- model: replaceBoolean
- translateLabel: true
- )
- (InputFieldSpec
- name: 'ReplaceEntryField'
- layout: (LayoutFrame 164 0 0 0 -2 1 22 0)
- activeHelpKey: replaceText
- visibilityChannel: replaceBoolean
- enableChannel: replaceBoolean
- model: replaceTextHolder
- acceptOnReturn: true
- acceptOnTab: true
- acceptOnPointerLeave: true
- )
- )
-
- )
- extent: (Point 302 24)
- )
- )
-
- )
- )
- (HorizontalPanelViewSpec
- name: 'horizontalPanelView'
- layout: (LayoutFrame 0 0.0 -30 1.0 -16 1.0 0 1.0)
- level: 0
- horizontalLayout: fitSpace
- verticalLayout: center
- horizontalSpace: 3
- verticalSpace: 3
- ignoreInvisibleComponents: true
- reverseOrderIfOKAtLeft: true
- component:
- (SpecCollection
- collection: (
- (ActionButtonSpec
- label: 'Cancel'
- name: 'cancelButton'
- level: 2
- translateLabel: true
- tabable: true
- model: cancel
- extent: (Point 91 21)
- )
- (ActionButtonSpec
- label: 'Prev'
- name: 'prevButton'
- level: 2
- translateLabel: true
- tabable: true
- model: prevAction
- extent: (Point 91 21)
- )
- (ActionButtonSpec
- label: 'Next'
- name: 'nextButton'
- level: 2
- borderWidth: 1
- translateLabel: true
- tabable: true
- model: nextAction
- isDefault: true
- extent: (Point 90 21)
- )
- )
-
- )
- keepSpaceForOSXResizeHandleH: true
- )
- )
-
+ extent: (Point 319 24)
+ )
+ (CheckBoxSpec
+ label: 'Variable Only'
+ name: 'CheckBox1'
+ activeHelpKey: searchVariable
+ level: 0
+ visibilityChannel: searchVariableVisible
+ enableChannel: searchVariableEnabled
+ tabable: true
+ model: searchVariable
+ translateLabel: true
+ labelChannel: stringWithVariableUnderCursorHolder
+ extent: (Point 319 24)
+ )
+ (CheckBoxSpec
+ label: 'Select Lines'
+ name: 'CheckBox3'
+ activeHelpKey: selectLines
+ level: 0
+ initiallyInvisible: true
+ tabable: true
+ model: selectLines
+ translateLabel: true
+ extent: (Point 302 24)
+ )
+ (ViewSpec
+ name: 'Box1'
+ component:
+ (SpecCollection
+ collection: (
+ (CheckBoxSpec
+ label: 'Global Replace With:'
+ name: 'CheckBox4'
+ layout: (LayoutFrame 0 0 0 0 162 0 23 0)
+ activeHelpKey: replaceText
+ level: 0
+ enableChannel: replaceEnabled
+ tabable: true
+ model: replaceBoolean
+ translateLabel: true
+ )
+ (InputFieldSpec
+ name: 'ReplaceEntryField'
+ layout: (LayoutFrame 164 0 0 0 -2 1 22 0)
+ activeHelpKey: replaceText
+ visibilityChannel: replaceBoolean
+ enableChannel: replaceBoolean
+ model: replaceTextHolder
+ acceptOnReturn: true
+ acceptOnTab: true
+ acceptOnPointerLeave: true
+ )
+ )
+
+ )
+ extent: (Point 319 24)
+ )
+ )
+
+ )
+ )
+ (HorizontalPanelViewSpec
+ name: 'horizontalPanelView'
+ layout: (LayoutFrame 0 0.0 -30 1.0 -16 1.0 0 1.0)
+ level: 0
+ horizontalLayout: fitSpace
+ verticalLayout: center
+ horizontalSpace: 3
+ verticalSpace: 3
+ ignoreInvisibleComponents: true
+ reverseOrderIfOKAtLeft: true
+ component:
+ (SpecCollection
+ collection: (
+ (ActionButtonSpec
+ label: 'Cancel'
+ name: 'cancelButton'
+ level: 2
+ translateLabel: true
+ tabable: true
+ model: cancel
+ extent: (Point 96 21)
+ )
+ (ActionButtonSpec
+ label: 'Prev'
+ name: 'prevButton'
+ level: 2
+ translateLabel: true
+ tabable: true
+ model: prevAction
+ extent: (Point 97 21)
+ )
+ (ActionButtonSpec
+ label: 'Next'
+ name: 'nextButton'
+ level: 2
+ borderWidth: 1
+ translateLabel: true
+ tabable: true
+ model: nextAction
+ isDefault: true
+ extent: (Point 96 21)
+ )
+ )
+
+ )
+ keepSpaceForOSXResizeHandleH: true
+ )
+ )
+
)
)
! !
@@ -819,10 +832,10 @@
"/ TODO: reencode contents if required.
(list size ~~ 0
and:[ list contains:[:line | line size > 0]]) ifTrue:[
- (self confirm:'Your text may need to be re-coded - this is not yet supported.\\Proceed ?')
+ (self confirm:(resources stringWithCRs:'Your text may need to be re-coded - this is not yet supported.\\Proceed ?'))
ifFalse:[^ self].
].
- super characterEncoding:encodingSymOrNil.
+ super characterEncoding:encodingSymOrNil.
].
"Modified (format): / 25-01-2012 / 00:28:27 / cg"
@@ -1279,27 +1292,27 @@
"mouse-move while button was pressed - handle selection changes"
(clickLine isNil or:[clickPos isNil]) ifTrue:[
- dragIsActive := false.
- ^ self
+ dragIsActive := false.
+ ^ self
].
dragIsActive ifTrue:[
- (clickPos dist:(x@y)) >= 5.0 ifTrue:[
- dragIsActive := false.
-
- self hasSelection ifTrue:[
- dropSource startDragIn:self at:(x@y)
- ]
- ].
- ^ self
+ (clickPos dist:(x@y)) >= 5.0 ifTrue:[
+ dragIsActive := false.
+
+ self hasSelection ifTrue:[
+ dropSource startDragIn:self at:(x@y)
+ ]
+ ].
+ ^ self
].
"is it the select or 1-button ?"
buttonState == 0 ifTrue:[^ self].
self sensor leftButtonPressed ifFalse:[
- "/ self setPrimarySelection.
- "/ self selectionChanged.
- ^ self
+ "/ self setPrimarySelection.
+ "/ self selectionChanged.
+ ^ self
].
"/ (device buttonMotionMask:buttonState includesButton:#select) ifFalse:[
"/ (device buttonMotionMask:buttonState includesButton:1) ifFalse:[
@@ -1310,29 +1323,33 @@
"if moved outside of view, start autoscroll"
((y < 0) and:[firstLineShown ~~ 0]) ifTrue:[
- self compressMotionEvents:false.
- self startAutoScrollUp:y negated.
- ^ self
+ self compressMotionEvents:false.
+ (self startAutoScrollUp:y negated) ifTrue:[
+ ^ self
+ ].
].
(y > height) ifTrue:[
- self compressMotionEvents:false.
- self startAutoScrollDown:(y - height).
- ^ self
+ self compressMotionEvents:false.
+ (self startAutoScrollDown:(y - height)) ifTrue:[
+ ^ self
+ ].
].
((x < 0) and:[viewOrigin x ~~ 0]) ifTrue:[
- self compressMotionEvents:false.
- self startAutoScrollLeft:x.
- ^ self
+ self compressMotionEvents:false.
+ (self startAutoScrollLeft:x) ifTrue:[
+ ^ self
+ ].
].
(x > width) ifTrue:[
- self compressMotionEvents:false.
- self startAutoScrollRight:(x - width).
- ^ self
+ self compressMotionEvents:false.
+ (self startAutoScrollRight:(x - width)) ifTrue:[
+ ^ self
+ ].
].
"move inside - stop autoscroll if any"
autoScrollBlock notNil ifTrue:[
- self stopScrollSelect
+ self stopScrollSelect
].
self extendSelectionToX:x y:y setPrimarySelection:false.
@@ -1412,20 +1429,20 @@
"mouse- button release - turn off autoScroll if any"
(button == 1) ifTrue:[
- self hasSelection ifTrue:[
- self setPrimarySelection.
- self selectionChanged.
- ].
-
- autoScrollBlock notNil ifTrue:[
- self stopScrollSelect
- ].
- dragIsActive ifTrue:[
- self unselect
- ].
- clickPos := nil.
+ self hasSelection ifTrue:[
+ self setPrimarySelection.
+ self selectionChanged.
+ ].
+
+ autoScrollBlock notNil ifTrue:[
+ self stopScrollSelect
+ ].
+ dragIsActive ifTrue:[
+ self unselect
+ ].
+ clickPos := nil.
] ifFalse:[
- super buttonRelease:button x:x y:y
+ super buttonRelease:button x:x y:y
].
dragIsActive := false.
@@ -1447,153 +1464,153 @@
"
((sel := self selection) size == 1
and:[(sel := sel at:1) size == 1]) ifTrue:[
- ch := sel at:1.
-
- ((self isOpeningParenthesis:ch)
- or:[ (self isClosingParenthesis:ch) ]) ifTrue:[
- self
- searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol
- ifFound:[:line :col |
- |prevLine prevCol moveBack pos1|
-
- prevLine := firstLineShown.
- prevCol := viewOrigin x.
- self selectFromLine:selectionStartLine col:selectionStartCol
- toLine:line col:col.
-
- self sensor ctrlDown ifFalse:[
- "/ undo scroll operation ...
- self withCursor:Cursor eye do:[
- |delayCount|
-
- moveBack := false.
- (self isClosingParenthesis:ch) ifTrue:[
- (firstLineShown ~~ prevLine or:[prevCol ~~ viewOrigin x]) ifTrue:[
- moveBack := true
- ]
- ] ifFalse:[
- selectionEndLine > (firstLineShown + nFullLinesShown) ifTrue:[
- self makeLineVisible:selectionEndLine.
- moveBack := true
- ]
- ].
- moveBack ifTrue:[
- delayCount := 0.
- pos1 := x@y.
- self invalidateRepairNow:true.
- Delay waitForSeconds:MatchDelayTime.
- delayCount := delayCount + MatchDelayTime.
- [self sensor hasUserEventFor:self] whileFalse:[
- Delay waitForSeconds:MatchDelayTime / 2.
- delayCount := delayCount + (MatchDelayTime / 2).
- delayCount > 2 ifTrue:[
- self cursor:Cursor eyeClosed.
- ].
- delayCount >= 2.3 ifTrue:[
- self cursor:Cursor eye.
- delayCount := 0.
- ]
- ].
- self scrollToLine:prevLine; scrollToCol:prevCol.
- ].
- ]
- ].
- ^ self.
- ]
- ifNotFound:[self showNotFound]
- onError:[self beep]
- openingCharacters:((parenthesisSpecification at:#open) ", '([{'")
- closingCharacters:((parenthesisSpecification at:#close) ", ')]}'").
- selectStyle := nil
- ]
+ ch := sel at:1.
+
+ ((self isOpeningParenthesis:ch)
+ or:[ (self isClosingParenthesis:ch) ]) ifTrue:[
+ self
+ searchForMatchingParenthesisFromLine:selectionStartLine col:selectionStartCol
+ ifFound:[:line :col |
+ |prevLine prevCol moveBack pos1|
+
+ prevLine := firstLineShown.
+ prevCol := viewOrigin x.
+ self selectFromLine:selectionStartLine col:selectionStartCol
+ toLine:line col:col.
+
+ self sensor ctrlDown ifFalse:[
+ "/ undo scroll operation ...
+ self withCursor:Cursor eye do:[
+ |delayCount|
+
+ moveBack := false.
+ (self isClosingParenthesis:ch) ifTrue:[
+ (firstLineShown ~~ prevLine or:[prevCol ~~ viewOrigin x]) ifTrue:[
+ moveBack := true
+ ]
+ ] ifFalse:[
+ selectionEndLine > (firstLineShown + nFullLinesShown) ifTrue:[
+ self makeLineVisible:selectionEndLine.
+ moveBack := true
+ ]
+ ].
+ moveBack ifTrue:[
+ delayCount := 0.
+ pos1 := x@y.
+ self invalidateRepairNow:true.
+ Delay waitForSeconds:MatchDelayTime.
+ delayCount := delayCount + MatchDelayTime.
+ [self sensor hasUserEventFor:self] whileFalse:[
+ Delay waitForSeconds:MatchDelayTime / 2.
+ delayCount := delayCount + (MatchDelayTime / 2).
+ delayCount > 2 ifTrue:[
+ self cursor:Cursor eyeClosed.
+ ].
+ delayCount >= 2.3 ifTrue:[
+ self cursor:Cursor eye.
+ delayCount := 0.
+ ]
+ ].
+ self scrollToLine:prevLine; scrollToCol:prevCol.
+ ].
+ ]
+ ].
+ ^ self.
+ ]
+ ifNotFound:[self showNotFound]
+ onError:[self beep]
+ openingCharacters:((parenthesisSpecification at:#open) ", '([{'")
+ closingCharacters:((parenthesisSpecification at:#close) ", ')]}'").
+ selectStyle := nil
+ ]
].
(self st80SelectMode or:[ self sensor ctrlDown]) ifTrue:[
- "/ st80 selects:
- "/ - if clicked right after a parenthesis -> select to matching parenthesis
- "/ - if clicked right after a quote -> select to matching quote (unless escaped ;-)
- "/ - if clicked at beginning of the line -> select that line
- "/ - if clicked at the top of the text -> select all
- "/ however, do none of the above, if clicked on a parenthesis
- clickCol == 1 ifTrue:[
- clickLine == 1 ifTrue:[
- self selectAll.
- ^ self.
- ].
- self selectLineAtY:y.
- selectStyle := #line.
- ^ self
- ].
-
- matchCol := nil.
- "/ see what is to the left of that character ...
- clickCol > 1 ifTrue:[
- ch := self characterAtLine:clickLine col:clickCol-1.
- (self isOpeningParenthesis:ch) ifTrue:[
- matchCol := clickCol - 1
- ] ifFalse:[
- ('"''|' includes:ch) ifTrue:[
- scanCol := clickCol - 1.
- fwdScan := true.
- scanCh := ch.
- ]
- ]
- ].
- fwdSelect := true.
- (matchCol isNil and:[scanCol isNil]) ifTrue:[
- clickCol < (self listAt:clickLine) size ifTrue:[
- ch := self characterAtLine:clickLine col:clickCol+1.
- (self isClosingParenthesis:ch) ifTrue:[
- matchCol := clickCol + 1.
- fwdSelect := false.
- ] ifFalse:[
- ('"''|' includes:ch) ifTrue:[
- scanCol := clickCol + 1.
- fwdScan := false.
- scanCh := ch.
- ]
- ]
- ].
- ].
- matchCol notNil ifTrue:[
- self
- searchForMatchingParenthesisFromLine:clickLine col:matchCol
- ifFound:[:line :col |
- self selectFromLine:clickLine col:matchCol+(fwdSelect ifTrue:1 ifFalse:-1)
- toLine:line col:col-(fwdSelect ifTrue:1 ifFalse:-1)]
- ifNotFound:[self showNotFound]
- onError:[self beep]
- openingCharacters:((parenthesisSpecification at:#open) , '([{')
- closingCharacters:((parenthesisSpecification at:#close) , ')]}').
- ^ self
- ].
- scanCol notNil ifTrue:[
- "/ if its an EOL comment, do it differently
- ch := self characterAtLine:clickLine col:clickCol.
- ch == $/ ifTrue:[
- self selectFromLine:clickLine col:clickCol+1 toLine:clickLine+1 col:0.
- ^ self
- ].
-
- self
- scanFor:scanCh fromLine:clickLine col:scanCol forward:fwdScan
- ifFound:[:line :col |
- |selStart selEnd|
-
- fwdScan ifTrue:[
- selStart := scanCol+1.
- selEnd := col-1.
- ] ifFalse:[
- selStart := scanCol-1.
- selEnd := col+1.
- ].
- self selectFromLine:clickLine col:selStart
- toLine:line col:selEnd.
- ^ self
- ]
- ifNotFound:[self showNotFound].
- ^ self
- ]
+ "/ st80 selects:
+ "/ - if clicked right after a parenthesis -> select to matching parenthesis
+ "/ - if clicked right after a quote -> select to matching quote (unless escaped ;-)
+ "/ - if clicked at beginning of the line -> select that line
+ "/ - if clicked at the top of the text -> select all
+ "/ however, do none of the above, if clicked on a parenthesis
+ clickCol == 1 ifTrue:[
+ clickLine == 1 ifTrue:[
+ self selectAll.
+ ^ self.
+ ].
+ self selectLineAtY:y.
+ selectStyle := #line.
+ ^ self
+ ].
+
+ matchCol := nil.
+ "/ see what is to the left of that character ...
+ clickCol > 1 ifTrue:[
+ ch := self characterAtLine:clickLine col:clickCol-1.
+ (self isOpeningParenthesis:ch) ifTrue:[
+ matchCol := clickCol - 1
+ ] ifFalse:[
+ ('"''|' includes:ch) ifTrue:[
+ scanCol := clickCol - 1.
+ fwdScan := true.
+ scanCh := ch.
+ ]
+ ]
+ ].
+ fwdSelect := true.
+ (matchCol isNil and:[scanCol isNil]) ifTrue:[
+ clickCol < (self listAt:clickLine) size ifTrue:[
+ ch := self characterAtLine:clickLine col:clickCol+1.
+ (self isClosingParenthesis:ch) ifTrue:[
+ matchCol := clickCol + 1.
+ fwdSelect := false.
+ ] ifFalse:[
+ ('"''|' includes:ch) ifTrue:[
+ scanCol := clickCol + 1.
+ fwdScan := false.
+ scanCh := ch.
+ ]
+ ]
+ ].
+ ].
+ matchCol notNil ifTrue:[
+ self
+ searchForMatchingParenthesisFromLine:clickLine col:matchCol
+ ifFound:[:line :col |
+ self selectFromLine:clickLine col:matchCol+(fwdSelect ifTrue:1 ifFalse:-1)
+ toLine:line col:col-(fwdSelect ifTrue:1 ifFalse:-1)]
+ ifNotFound:[self showNotFound]
+ onError:[self beep]
+ openingCharacters:((parenthesisSpecification at:#open) , '([{')
+ closingCharacters:((parenthesisSpecification at:#close) , ')]}').
+ ^ self
+ ].
+ scanCol notNil ifTrue:[
+ "/ if its an EOL comment, do it differently
+ ch := self characterAtLine:clickLine col:clickCol.
+ ch == $/ ifTrue:[
+ self selectFromLine:clickLine col:clickCol+1 toLine:clickLine+1 col:0.
+ ^ self
+ ].
+
+ self
+ scanFor:scanCh fromLine:clickLine col:scanCol forward:fwdScan
+ ifFound:[:line :col |
+ |selStart selEnd|
+
+ fwdScan ifTrue:[
+ selStart := scanCol+1.
+ selEnd := col-1.
+ ] ifFalse:[
+ selStart := scanCol-1.
+ selEnd := col+1.
+ ].
+ self selectFromLine:clickLine col:selStart
+ toLine:line col:selEnd.
+ ^ self
+ ]
+ ifNotFound:[self showNotFound].
+ ^ self
+ ]
].
"
@@ -1602,14 +1619,14 @@
wordStartLine := selectionStartLine.
wordEndLine := selectionEndLine.
selectStyle == #wordLeft ifTrue:[
- wordStartCol := selectionStartCol + 1
+ wordStartCol := selectionStartCol + 1
] ifFalse:[
- wordStartCol := selectionStartCol.
+ wordStartCol := selectionStartCol.
].
selectStyle == #wordRight ifTrue:[
- wordEndCol := selectionEndCol - 1
+ wordEndCol := selectionEndCol - 1
] ifFalse:[
- wordEndCol := selectionEndCol
+ wordEndCol := selectionEndCol
]
"Created: / 11-09-1997 / 04:12:55 / cg"
@@ -1633,156 +1650,156 @@
movedLine := self visibleLineToAbsoluteLine:movedVisibleLine.
(x < leftMargin) ifTrue:[
- movedCol := 0
+ movedCol := 0
] ifFalse:[
- movedCol := self colOfX:x inVisibleLine:movedVisibleLine
+ movedCol := self colOfX:x inVisibleLine:movedVisibleLine
].
y < 0 ifTrue:[
- movedCol := 0
+ movedCol := 0
].
((movedLine == clickLine) and:[movedCol == clickCol]) ifTrue:[
- selectionStartLine notNil ifTrue:[
- ^ self
- ].
- (clickPos isNil
- or:[(clickPos x - x) abs < 3
- and:[(clickPos y - y) abs < 3]]) ifTrue:[
- ^ self
- ].
- selectionStartLine := clickLine.
- selectionStartCol := clickCol.
- selectionEndLine := selectionStartLine.
- selectionEndCol := selectionStartCol.
-
- oldStartLine := selectionStartLine.
- oldEndLine := selectionEndLine.
- oldStartCol := selectionStartCol.
- oldEndCol := selectionEndCol-1.
+ selectionStartLine notNil ifTrue:[
+ ^ self
+ ].
+ (clickPos isNil
+ or:[(clickPos x - x) abs < 3
+ and:[(clickPos y - y) abs < 3]]) ifTrue:[
+ ^ self
+ ].
+ selectionStartLine := clickLine.
+ selectionStartCol := clickCol.
+ selectionEndLine := selectionStartLine.
+ selectionEndCol := selectionStartCol.
+
+ oldStartLine := selectionStartLine.
+ oldEndLine := selectionEndLine.
+ oldStartCol := selectionStartCol.
+ oldEndCol := selectionEndCol-1.
] ifFalse:[
- selectionStartLine isNil ifTrue:[
- selectionStartLine := selectionEndLine := clickLine.
- selectionStartCol := selectionEndCol := clickCol.
- ].
- oldStartLine := selectionStartLine.
- oldEndLine := selectionEndLine.
- oldStartCol := selectionStartCol.
- oldEndCol := selectionEndCol.
+ selectionStartLine isNil ifTrue:[
+ selectionStartLine := selectionEndLine := clickLine.
+ selectionStartCol := selectionEndCol := clickCol.
+ ].
+ oldStartLine := selectionStartLine.
+ oldEndLine := selectionEndLine.
+ oldStartCol := selectionStartCol.
+ oldEndCol := selectionEndCol.
].
oldEndLine isNil ifTrue:[
- oldEndLine := selectionEndLine ? clickLine ? movedLine.
+ oldEndLine := selectionEndLine ? clickLine ? movedLine.
].
oldEndCol isNil ifTrue:[
- oldEndCol := selectionEndCol ? clickCol.
+ oldEndCol := selectionEndCol ? clickCol.
].
"find out if we are before or after initial click"
movedUp := false.
clickStartLine isNil ifTrue:[
- clickStartLine := movedLine.
+ clickStartLine := movedLine.
].
clickStartCol isNil ifTrue:[
- clickStartCol := movedCol.
+ clickStartCol := movedCol.
].
(movedLine < clickStartLine) ifTrue:[
- movedUp := true
+ movedUp := true
] ifFalse:[
- (movedLine == clickStartLine) ifTrue:[
- (movedCol < clickStartCol) ifTrue:[
- movedUp := true
- ]
- ]
+ (movedLine == clickStartLine) ifTrue:[
+ (movedCol < clickStartCol) ifTrue:[
+ movedUp := true
+ ]
+ ]
].
movedUp ifTrue:[
- "change selectionStart"
- selectionStartCol := movedCol.
- selectionStartLine := movedLine.
- selectionEndCol := clickStartCol.
- selectionEndLine := clickStartLine.
- selectStyle notNil ifTrue:[
- selectionEndCol := wordEndCol.
- selectionEndLine := wordEndLine.
- ]
+ "change selectionStart"
+ selectionStartCol := movedCol.
+ selectionStartLine := movedLine.
+ selectionEndCol := clickStartCol.
+ selectionEndLine := clickStartLine.
+ selectStyle notNil ifTrue:[
+ selectionEndCol := wordEndCol.
+ selectionEndLine := wordEndLine.
+ ]
] ifFalse:[
- "change selectionEnd"
- selectionEndCol := movedCol.
- selectionEndLine := movedLine.
- selectionStartCol := clickStartCol.
- selectionStartLine := clickStartLine.
- selectStyle notNil ifTrue:[
- selectionStartCol := wordStartCol.
- selectionStartLine := wordStartLine.
- ]
+ "change selectionEnd"
+ selectionEndCol := movedCol.
+ selectionEndLine := movedLine.
+ selectionStartCol := clickStartCol.
+ selectionStartLine := clickStartLine.
+ selectStyle notNil ifTrue:[
+ selectionStartCol := wordStartCol.
+ selectionStartLine := wordStartLine.
+ ]
].
selectionStartLine isNil ifTrue:[^ self].
(selectionStartCol == 0) ifTrue:[
- selectionStartCol := 1
+ selectionStartCol := 1
].
"
if in word-select, just catch the rest of the word
"
(selectStyle notNil and:[selectStyle startsWith:'word']) ifTrue:[
- movedUp ifTrue:[
- selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol
- ] ifFalse:[
- selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol.
- selectionEndCol == 0 ifTrue:[
- selectionEndLine := selectionEndLine + 1
- ]
- ].
+ movedUp ifTrue:[
+ selectionStartCol := self findBeginOfWordAtLine:selectionStartLine col:selectionStartCol
+ ] ifFalse:[
+ selectionEndCol := self findEndOfWordAtLine:selectionEndLine col:selectionEndCol.
+ selectionEndCol == 0 ifTrue:[
+ selectionEndLine := selectionEndLine + 1
+ ]
+ ].
].
selectStyle == #line ifTrue:[
- movedUp ifTrue:[
- selectionStartCol := 1.
- ] ifFalse:[
- selectionEndCol := 0.
- selectionEndLine := selectionEndLine + 1
- ]
+ movedUp ifTrue:[
+ selectionStartCol := 1.
+ ] ifFalse:[
+ selectionEndCol := 0.
+ selectionEndLine := selectionEndLine + 1
+ ]
].
self validateNewSelection.
aBoolean ifTrue:[
- self setPrimarySelection.
- self selectionChanged.
+ self setPrimarySelection.
+ self selectionChanged.
].
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done
"/ self clearSearchAction.
(oldStartLine == selectionStartLine) ifTrue:[
- (oldStartCol ~~ selectionStartCol) ifTrue:[
- self
- redrawLine:oldStartLine
- from:((selectionStartCol min:oldStartCol) max:1)
- to:((selectionStartCol max:oldStartCol) max:1)
- ]
+ (oldStartCol ~~ selectionStartCol) ifTrue:[
+ self
+ redrawLine:oldStartLine
+ from:((selectionStartCol min:oldStartCol) max:1)
+ to:((selectionStartCol max:oldStartCol) max:1)
+ ]
] ifFalse:[
- self
- redrawFromLine:(oldStartLine?selectionStartLine min:selectionStartLine)
- to:(oldStartLine?selectionStartLine max:selectionStartLine)
+ self
+ redrawFromLine:(oldStartLine?selectionStartLine min:selectionStartLine)
+ to:(oldStartLine?selectionStartLine max:selectionStartLine)
].
(oldEndLine == selectionEndLine) ifTrue:[
- (oldEndCol notNil and:[oldEndCol ~~ selectionEndCol]) ifTrue:[
- self redrawLine:oldEndLine
- from:((selectionEndCol min:oldEndCol) max:1)
- to:((selectionEndCol max:oldEndCol) max:1)
- ]
+ (oldEndCol notNil and:[oldEndCol ~~ selectionEndCol]) ifTrue:[
+ self redrawLine:oldEndLine
+ from:((selectionEndCol min:oldEndCol) max:1)
+ to:((selectionEndCol max:oldEndCol) max:1)
+ ]
] ifFalse:[
- selectionEndLine isNil ifTrue:[
- selectionStartLine := nil.
- self redraw.
- ] ifFalse:[
- (selectionStartLine notNil) ifTrue:[
- self redrawFromLine:(oldEndLine min:selectionEndLine)
- to:(oldEndLine max:selectionEndLine)
- ]
- ]
+ selectionEndLine isNil ifTrue:[
+ selectionStartLine := nil.
+ self redraw.
+ ] ifFalse:[
+ (selectionStartLine notNil) ifTrue:[
+ self redrawFromLine:(oldEndLine min:selectionEndLine)
+ to:(oldEndLine max:selectionEndLine)
+ ]
+ ]
].
clickLine := movedLine.
clickCol := movedCol
@@ -1884,17 +1901,17 @@
selectionFgColor isNil ifTrue:[selectionFgColor := bgColor].
selectionBgColor := DefaultSelectionBackgroundColor.
selectionBgColor isNil ifTrue:[
- self graphicsDevice hasColors ifTrue:[
+ self graphicsDevice hasColors ifTrue:[
DefaultSelectionForegroundColor isNil ifTrue:[
selectionFgColor := fgColor
].
selectionBgColor := Color green
] ifFalse:[
- self graphicsDevice hasGrayscales ifTrue:[
+ self graphicsDevice hasGrayscales ifTrue:[
DefaultSelectionForegroundColor isNil ifTrue:[
selectionFgColor := fgColor
].
- selectionBgColor := Color grey
+ selectionBgColor := Color gray
] ifFalse:[
selectionBgColor := fgColor
]
@@ -1914,7 +1931,7 @@
lastSearchIgnoredCase := true.
parenthesisSpecification isNil ifTrue:[
- parenthesisSpecification := DefaultParenthesisSpecification.
+ parenthesisSpecification := DefaultParenthesisSpecification.
].
"I handle menus myself"
@@ -1965,10 +1982,10 @@
|newFont|
self withWaitCursorDo:[
- newFont := FontPanel fontFromUserInitial:gc font.
+ newFont := FontPanel fontFromUserInitial:gc font.
].
newFont notNil ifTrue:[
- self font:newFont.
+ self font:newFont.
]
"Modified: 27.2.1996 / 00:53:51 / cg"
@@ -2068,8 +2085,8 @@
|newFont|
newFont := gc font asSize:(largerBoolean
- ifTrue:[gc font size + 1]
- ifFalse:[(gc font size-1) max:4]).
+ ifTrue:[gc font size + 1]
+ ifFalse:[(gc font size-1) max:4]).
self font:newFont.
"Modified: / 27-02-1996 / 00:53:51 / cg"
@@ -2146,12 +2163,13 @@
"
|searchBox patternHolder caseHolder matchHolder fwd ign match initialString
bindings bldr doSearch modal searchVariableHolder selectedVariable searchFullWordHolder
- replaceBooleanEnabledHolder replaceBooleanHolder replaceTextHolder|
+ replaceBooleanEnabledHolder replaceBooleanHolder replaceTextHolder
+ searchAtBeginOfLineOnlyHolder|
searchBarActionBlock notNil ifTrue:[
- self resetVariablesBeforeNewSearch.
- searchBarActionBlock value:#search value:self.
- ^ self
+ self resetVariablesBeforeNewSearch.
+ searchBarActionBlock value:#search value:self.
+ ^ self
].
modal := (UserPreferences current searchDialogIsModal). "/ thats experimental
@@ -2163,6 +2181,7 @@
matchHolder := match asValue.
searchVariableHolder := (lastSearchWasVariableSearch ? false) asValue.
searchFullWordHolder := false asValue.
+ searchAtBeginOfLineOnlyHolder := false asValue.
replaceBooleanHolder := false asValue.
replaceTextHolder := '' asValue.
replaceBooleanEnabledHolder := self isReadOnly not asValue.
@@ -2172,137 +2191,139 @@
self setSearchPatternWithMatchEscapes: match.
lastSearchPattern notNil ifTrue:[
- initialString := lastSearchPattern.
+ initialString := lastSearchPattern.
].
"/ No longer force the current selection to be the initialString
"/ self hasSelectionWithinSingleLine ifTrue:[
"/ initialString := self selection asString.
"/ ].
initialString isNil ifTrue:[
- LastSearchPatterns size > 0 ifTrue:[
- initialString := LastSearchPatterns first.
- ]
+ LastSearchPatterns size > 0 ifTrue:[
+ initialString := LastSearchPatterns first.
+ ]
].
initialString notNil ifTrue:[
- patternHolder value:initialString.
+ patternHolder value:initialString.
].
fwd := true.
doSearch := [:fwd |
- |isVariableSearch pattern searchAction|
-
- self resetVariablesBeforeNewSearch.
-
- isVariableSearch := self searchVariableVisible
- and:[searchVariableHolder value
- and:[selectedVariable notNil]].
-
- isVariableSearch ifTrue:[
- searchAction := [self searchVariableWithSyntaxElement:selectedVariable forward:fwd].
- ] ifFalse:[
- lastSearchWasVariableSearch := false.
- LastSearchIgnoredCase := lastSearchIgnoredCase := (caseHolder value not).
- LastSearchWasMatch := lastSearchWasMatch := matchHolder value.
- pattern := patternHolder value.
- pattern notEmptyOrNil ifTrue:[
- searchAction := [
- self searchUsingSpec:(
- ListView::SearchSpec new
- pattern:pattern
- ignoreCase:lastSearchIgnoredCase
- match: lastSearchWasMatch
- variable: searchVariableHolder value
- fullWord: searchFullWordHolder value
- forward:fwd).
- ]
- ]
- ].
-
- replaceBooleanHolder value ifTrue:[
- |selStart|
-
- isVariableSearch ifTrue:[
- "/ must replace from the end towards beginning,
- "/ because syntax-elements do not update their position, when
- "/ the text is changed (in replace).
-
- selectedVariable := selectedVariable lastElementInChain.
- self selectFromCharacterPosition:selectedVariable start to:selectedVariable stop.
- searchAction := [selectedVariable := selectedVariable previousElement.
- selectedVariable notNil ifTrue:[
- self selectFromCharacterPosition:selectedVariable start to:selectedVariable stop.
- ].
- "/ self searchVariableWithSyntaxElement:selectedVariable forward:false
- ].
- ].
-
- selStart := self characterPositionOfSelection.
- self replace:(replaceTextHolder value).
-
- searchAction value.
- [self characterPositionOfSelection ~= selStart] whileTrue:[
- selStart := self characterPositionOfSelection.
- self replace:(replaceTextHolder value).
- searchAction value.
- ]
- ] ifFalse:[
- searchAction value.
- ].
+ |isVariableSearch pattern searchAction|
+
+ self resetVariablesBeforeNewSearch.
+
+ isVariableSearch := self searchVariableVisible
+ and:[searchVariableHolder value
+ and:[selectedVariable notNil]].
+
+ isVariableSearch ifTrue:[
+ searchAction := [self searchVariableWithSyntaxElement:selectedVariable forward:fwd].
+ ] ifFalse:[
+ lastSearchWasVariableSearch := false.
+ LastSearchIgnoredCase := lastSearchIgnoredCase := (caseHolder value not).
+ LastSearchWasMatch := lastSearchWasMatch := matchHolder value.
+ pattern := patternHolder value.
+ pattern notEmptyOrNil ifTrue:[
+ searchAction := [
+ self searchUsingSpec:(
+ ListView::SearchSpec new
+ pattern:pattern
+ ignoreCase:lastSearchIgnoredCase
+ match: lastSearchWasMatch
+ variable: searchVariableHolder value
+ fullWord: searchFullWordHolder value
+ forward:fwd
+ atBeginOfLineOnly:searchAtBeginOfLineOnlyHolder value).
+ ]
+ ]
+ ].
+
+ replaceBooleanHolder value ifTrue:[
+ |selStart|
+
+ isVariableSearch ifTrue:[
+ "/ must replace from the end towards beginning,
+ "/ because syntax-elements do not update their position, when
+ "/ the text is changed (in replace).
+
+ selectedVariable := selectedVariable lastElementInChain.
+ self selectFromCharacterPosition:selectedVariable start to:selectedVariable stop.
+ searchAction := [selectedVariable := selectedVariable previousElement.
+ selectedVariable notNil ifTrue:[
+ self selectFromCharacterPosition:selectedVariable start to:selectedVariable stop.
+ ].
+ "/ self searchVariableWithSyntaxElement:selectedVariable forward:false
+ ].
+ ].
+
+ selStart := self characterPositionOfSelection.
+ self replace:(replaceTextHolder value).
+
+ searchAction value.
+ [self characterPositionOfSelection ~= selStart] whileTrue:[
+ selStart := self characterPositionOfSelection.
+ self replace:(replaceTextHolder value).
+ searchAction value.
+ ]
+ ] ifFalse:[
+ searchAction value.
+ ].
].
bindings := IdentityDictionary new.
bindings at:#searchPattern put:patternHolder.
modal ifTrue:[
- bindings at:#nextAction put:[searchBox doAccept.].
- bindings at:#prevAction put:[fwd := false. searchBox doAccept.].
+ bindings at:#nextAction put:[searchBox doAccept.].
+ bindings at:#prevAction put:[fwd := false. searchBox doAccept.].
] ifFalse:[
- bindings at:#nextAction put:[doSearch value:true. "searchBox doAccept."].
- bindings at:#prevAction put:[doSearch value:false. "fwd := false. searchBox doAccept."].
+ bindings at:#nextAction put:[doSearch value:true. "searchBox doAccept."].
+ bindings at:#prevAction put:[doSearch value:false. "fwd := false. searchBox doAccept."].
].
bindings at:#caseSensitive put:caseHolder.
bindings at:#match put:matchHolder.
bindings at:#patternList put:LastSearchPatterns.
self supportsSyntaxElements ifFalse:[
- bindings at:#searchVariableVisible put:false.
+ bindings at:#searchVariableVisible put:false.
] ifTrue:[
- bindings at:#searchVariableVisible put:true.
- selectedVariable := self syntaxElementForSelectedVariable.
- bindings at:#searchVariableEnabled put:(selectedVariable notNil).
- selectedVariable notNil ifTrue:[
- bindings
- at:#stringWithVariableUnderCursorHolder
- put:('Variable ("%1")' bindWith:selectedVariable value).
- searchVariableHolder value:true.
- ] ifFalse:[
- bindings
- at:#stringWithVariableUnderCursorHolder
- put:('Variable (none selected)').
- ].
+ bindings at:#searchVariableVisible put:true.
+ selectedVariable := self syntaxElementForSelectedVariable.
+ bindings at:#searchVariableEnabled put:(selectedVariable notNil).
+ selectedVariable notNil ifTrue:[
+ bindings
+ at:#stringWithVariableUnderCursorHolder
+ put:('Variable ("%1")' bindWith:selectedVariable value).
+ searchVariableHolder value:true.
+ ] ifFalse:[
+ bindings
+ at:#stringWithVariableUnderCursorHolder
+ put:('Variable (none selected)').
+ ].
].
bindings at:#searchVariable put:searchVariableHolder.
bindings at:#searchFullWord put:searchFullWordHolder.
bindings at:#searchFullWordEnabled put:true.
+ bindings at:#searchAtBeginOfLineOnly put:searchAtBeginOfLineOnlyHolder.
bindings at:#replaceEnabled put:replaceBooleanEnabledHolder.
bindings at:#replaceBoolean put:replaceBooleanHolder.
bindings at:#replaceTextHolder put:replaceTextHolder.
replaceBooleanHolder onChangeEvaluate:
- [
- replaceBooleanHolder value ifTrue:[
- (bldr componentAt:#ReplaceEntryField) requestFocus
- ] ifFalse:[
- (bldr componentAt:#patternComboBox) requestFocus
- ].
- ].
+ [
+ replaceBooleanHolder value ifTrue:[
+ (bldr componentAt:#ReplaceEntryField) requestFocus
+ ] ifFalse:[
+ (bldr componentAt:#patternComboBox) requestFocus
+ ].
+ ].
modal ifTrue:[
- searchBox := SimpleDialog new.
+ searchBox := SimpleDialog new.
] ifFalse:[
- searchBox := ApplicationModel new.
- searchBox createBuilder.
+ searchBox := ApplicationModel new.
+ searchBox createBuilder.
].
searchBox resources:(self resources).
@@ -2316,21 +2337,21 @@
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown).
modal ifTrue:[
- searchBox openDialog.
- searchBox accepted ifTrue:[ doSearch value:fwd ].
+ searchBox openDialog.
+ searchBox accepted ifTrue:[ doSearch value:fwd ].
] ifFalse:[
- (bldr componentAt:#nextButton) isReturnButton:false.
- (bldr componentAt:#cancelButton)
- label:(resources string:'Close');
- action:[searchBox closeRequest].
- "/ searchBox masterApplication:self application.
- self topView beMaster.
- searchBox window
- beSlave;
- openInGroup:(self windowGroup).
-
- "/ searchBox window open.
- searchBox window assignKeyboardFocusToFirstInputField.
+ (bldr componentAt:#nextButton) isReturnButton:false.
+ (bldr componentAt:#cancelButton)
+ label:(resources string:'Close');
+ action:[searchBox closeRequest].
+ "/ searchBox masterApplication:self application.
+ self topView beMaster.
+ searchBox window
+ beSlave;
+ openInGroup:(self windowGroup).
+
+ "/ searchBox window open.
+ searchBox window assignKeyboardFocusToFirstInputField.
]
"Modified: / 11-07-2006 / 11:18:38 / fm"
@@ -2345,59 +2366,71 @@
!
saveAs:fileName
- "save the contents into a file named fileName"
+ "save the contents into a file named fileName.
+ On error return false otherwise return true"
^ self saveAs:fileName doAppend:false
!
saveAs:aFilename doAppend:doAppend
"save the contents into a file named fileName;
- if doAppend is true, the views contents is appended to the existing
+ if doAppend is true, the view's contents is appended to the existing
contents - otherwise, it overwrites any previous file contents.
- on error return false otherwise return true"
+ On error return false otherwise return true"
^ self saveAs:aFilename doAppend:doAppend compressTabs:true
!
saveAs:aFilename doAppend:doAppend compressTabs:compressTabs
"save the contents into a file named fileName;
- if doAppend is true, the views contents is appended to the existing
+ if doAppend is true, the view's contents is appended to the existing
contents - otherwise, it overwrites any previous file contents.
- on error return false otherwise return true"
+ On error return false otherwise return true"
+
+ ^ self saveAs:aFilename doAppend:doAppend compressTabs:compressTabs eolMode:nil
+!
+
+saveAs:aFilename doAppend:doAppend compressTabs:compressTabs eolMode:eolMode
+ "save the contents into a file named fileName;
+ if doAppend is true, the view's contents is appended to the existing
+ contents - otherwise, it overwrites any previous file contents.
+ eolMode is one of #cr, #nl or #crlf.
+ On error return false otherwise return true."
|filename msg|
filename := aFilename asFilename.
self withWriteCursorDo:[
- |aStream|
-
- (FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[
- msg := resources
- stringWithCRs:'Refused to write file ''%1'' !!\(ST/X internal permission check)'
- with:filename name.
- ] ifTrue:[
- [
- doAppend ifTrue:[
- aStream := filename appendingWriteStream.
- ] ifFalse:[
- aStream := filename newReadWriteStream.
- ].
- self fileOutContentsOn:aStream compressTabs:compressTabs encoding:externalEncoding.
- aStream syncData; close.
- contentsWasSaved := true.
- defaultFileNameForFileDialog := filename.
- ] on:FileStream openErrorSignal do:[:ex|
- msg := resources stringWithCRs:'Cannot write file ''%1'' !!\(%2)'
- with:filename name
- with:FileStream lastErrorString.
- ].
- ].
+ |aStream|
+
+ (FileStream userInitiatedFileSaveQuerySignal queryWith:filename) ifFalse:[
+ msg := resources
+ stringWithCRs:'Refused to write file ''%1'' !!\(ST/X internal permission check)'
+ with:filename name.
+ ] ifTrue:[
+ [
+ doAppend ifTrue:[
+ aStream := filename appendingWriteStream.
+ ] ifFalse:[
+ aStream := filename newReadWriteStream.
+ ].
+ aStream eolMode:eolMode.
+ self fileOutContentsOn:aStream compressTabs:compressTabs encoding:externalEncoding.
+ aStream syncData; close.
+ contentsWasSaved := true.
+ defaultFileNameForFileDialog := filename.
+ ] on:FileStream openErrorSignal do:[:ex|
+ msg := resources stringWithCRs:'Cannot write file ''%1'' !!\(%2)'
+ with:filename name
+ with:FileStream lastErrorString.
+ ].
+ ].
].
msg notNil ifTrue:[
- Dialog warn:msg.
- ^ false
+ Dialog warn:msg.
+ ^ false
].
^ true
@@ -2514,6 +2547,17 @@
"Created: / 08-03-2012 / 12:45:26 / cg"
! !
+!TextView methodsFor:'native widget support'!
+
+nativeWindowType
+ "return a symbol describing my native window type
+ (may be used internally by the device as a native window creation hint)"
+
+ ^ #TextView
+
+ "Created: 2.5.1997 / 14:41:00 / cg"
+! !
+
!TextView methodsFor:'private'!
currentSelectionBgColor
@@ -2552,44 +2596,55 @@
encoder := CharacterEncoder encoderToEncodeFrom:gc characterEncoding into:encodingSymOrNil.
encoder isNullEncoder ifTrue:[
- (list contains:[:lineOrNil|
- |s|
- lineOrNil notNil
- and:[(s := lineOrNil string string) isWideString
- and:[s asSingleByteStringIfPossible isWideString]]
- ]
- ) ifTrue:[
- (Dialog confirm:'The text contains non-8bit characters. Encode as UTF8?') ifFalse:[
- ^ self
- ]
- ].
- encoder := CharacterEncoder encoderToEncodeFrom:#unicode into:#utf8
+ (list contains:[:lineOrNil|
+ |s|
+ lineOrNil notNil
+ and:[(s := lineOrNil string string) isWideString
+ and:[s asSingleByteStringIfPossible isWideString]]
+ ]
+ ) ifTrue:[
+ (Dialog confirm:'The text contains non-8bit characters. Encode as UTF8?') ifFalse:[
+ ^ self
+ ]
+ ].
+ encoder := CharacterEncoder encoderToEncodeFrom:#unicode into:#utf8
].
aStream isFileStream ifTrue:[
- "on some systems, writing linewise is very slow (via NFS)
- therefore we convert to a string and write it in big chunks.
- To avoid creating huge strings, we do it in blocks of 1000 lines,
- limiting temporary string creation to about 50-80k.
- "
- startNr := 1.
- nLines := list size.
- [startNr <= nLines] whileTrue:[
- string := list
- asStringWithCRsFrom:startNr
- to:((startNr + 1000) min:nLines)
- compressTabs:compressTabs.
- aStream nextPutAll:(encoder encodeString:string string).
- startNr := startNr + 1000 + 1.
+ "on some systems, writing linewise is very slow (via NFS)
+ therefore we convert to a string and write it in big chunks.
+ To avoid creating huge strings, we do it in blocks of 1000 lines,
+ limiting temporary string creation to about 50-80k.
+ "
+ startNr := 1.
+ nLines := list size.
+ (aStream eolMode notNil
+ and:[aStream eolMode ~= #nl]) ifTrue:[
+ "/ must do it lineWise ...
+ list do:[:line |
+ line notNil ifTrue:[
+ aStream nextPutAll:(encoder encodeString:line withTabs)
+ ].
+ aStream cr
+ ].
+ ] ifFalse:[
+ [startNr <= nLines] whileTrue:[
+ string := list
+ asStringWithCRsFrom:startNr
+ to:((startNr + 1000) min:nLines)
+ compressTabs:compressTabs.
+ aStream nextPutAll:(encoder encodeString:string string).
+ startNr := startNr + 1000 + 1.
+ ].
].
] ifFalse:[
- list do:[:aLine |
- aLine notNil ifTrue:[
- aStream nextPutLine:(encoder encodeString:aLine).
- ] ifFalse:[
- aStream cr.
- ]
- ]
+ list do:[:aLine |
+ aLine notNil ifTrue:[
+ aStream nextPutLine:(encoder encodeString:aLine).
+ ] ifFalse:[
+ aStream cr.
+ ]
+ ]
]
"Modified: 8.6.1996 / 11:50:46 / cg"
@@ -2609,8 +2664,8 @@
fontHeight := currentDeviceFont height max:(italicFont height max:(boldFont height)).
includesNonStrings == true ifTrue:[
- "/ for now, we do not support variable height entries ...
- fontHeight := fontHeight max:(list first heightOn:self).
+ "/ for now, we do not support variable height entries ...
+ fontHeight := fontHeight max:(list first heightOn:self).
].
fontHeight := fontHeight + lineSpacing.
fA := currentDeviceFont ascent.
@@ -2785,6 +2840,15 @@
]
!
+textChanged
+ self isNativeWidget ifTrue:[
+ gc drawableId notNil ifTrue:[
+ gc device changeText:self contents in:gc drawableId
+ ]
+ ].
+ super textChanged
+!
+
widthForScrollBetween:firstLine and:lastLine
"return the width in pixels for a scroll between firstLine and lastLine"
@@ -2824,13 +2888,13 @@
"if there is a margin, clear it - a helper for selection drawing"
(leftMargin ~~ 0) ifTrue:[
- viewOrigin x <= margin ifTrue:[
- self paint:color.
- self fillRectangleX:margin-viewOrigin x
- y:(self yOfVisibleLine:visLine)- (lineSpacing//2)
- width:leftMargin
- height:fontHeight
- ]
+ viewOrigin x <= margin ifTrue:[
+ self paint:color.
+ self fillRectangleX:margin-viewOrigin x
+ y:(self yOfVisibleLine:visLine)- (lineSpacing//2)
+ width:leftMargin
+ height:fontHeight
+ ]
]
"Created: 6.3.1996 / 14:22:55 / cg"
@@ -2967,50 +3031,50 @@
(selectionStartLine notNil and:[selectionEndLine notNil
and:[ selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[
- line := self visibleLineToAbsoluteLine:visLineNr.
- (line between:selectionStartLine and:selectionEndLine) ifTrue:[
- (line == selectionStartLine) ifTrue:[
- (line == selectionEndLine) ifTrue:[
- "it's part-of-single-line selection"
- self clearMarginOfVisibleLine:visLineNr with:bgColor.
- (selectionStartCol > 1) ifTrue:[
- super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1)
- ].
- self drawVisibleLineSelected:visLineNr from:selectionStartCol to:selectionEndCol.
- super redrawVisibleLine:visLineNr from:(selectionEndCol + 1).
- ^ self
- ].
-
- "it's the first line of a multi-line selection"
- (selectionStartCol ~~ 1) ifTrue:[
- self clearMarginOfVisibleLine:visLineNr with:bgColor.
- super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1)
- ] ifFalse:[
- viewOrigin x == 0 ifTrue:[
- self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
- ]
- ].
- self drawVisibleLineSelected:visLineNr from:selectionStartCol.
- ^ self
- ].
-
- (line == selectionEndLine) ifTrue:[
- "it's the last line of a multi-line selection"
- (selectionEndCol == 0) ifTrue:[
- ^ super redrawVisibleLine:visLineNr
- ].
-
- self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
- self drawVisibleLineSelected:visLineNr from:1 to:selectionEndCol.
- super redrawVisibleLine:visLineNr from:(selectionEndCol + 1).
- ^ self
- ].
-
- "it's a full line in a multi-line selection"
- self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
- self drawVisibleLineSelected:visLineNr.
- ^ self
- ]
+ line := self visibleLineToAbsoluteLine:visLineNr.
+ (line between:selectionStartLine and:selectionEndLine) ifTrue:[
+ (line == selectionStartLine) ifTrue:[
+ (line == selectionEndLine) ifTrue:[
+ "it's part-of-single-line selection"
+ self clearMarginOfVisibleLine:visLineNr with:bgColor.
+ (selectionStartCol > 1) ifTrue:[
+ super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1)
+ ].
+ self drawVisibleLineSelected:visLineNr from:selectionStartCol to:selectionEndCol.
+ super redrawVisibleLine:visLineNr from:(selectionEndCol + 1).
+ ^ self
+ ].
+
+ "it's the first line of a multi-line selection"
+ (selectionStartCol ~~ 1) ifTrue:[
+ self clearMarginOfVisibleLine:visLineNr with:bgColor.
+ super redrawVisibleLine:visLineNr from:1 to:(selectionStartCol - 1)
+ ] ifFalse:[
+ viewOrigin x == 0 ifTrue:[
+ self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
+ ]
+ ].
+ self drawVisibleLineSelected:visLineNr from:selectionStartCol.
+ ^ self
+ ].
+
+ (line == selectionEndLine) ifTrue:[
+ "it's the last line of a multi-line selection"
+ (selectionEndCol == 0) ifTrue:[
+ ^ super redrawVisibleLine:visLineNr
+ ].
+
+ self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
+ self drawVisibleLineSelected:visLineNr from:1 to:selectionEndCol.
+ super redrawVisibleLine:visLineNr from:(selectionEndCol + 1).
+ ^ self
+ ].
+
+ "it's a full line in a multi-line selection"
+ self clearMarginOfVisibleLine:visLineNr with:self currentSelectionBgColor.
+ self drawVisibleLineSelected:visLineNr.
+ ^ self
+ ]
].
super redrawVisibleLine:visLineNr
@@ -3027,18 +3091,18 @@
"/
(selectionStartLine notNil and:[selectionEndLine notNil
and:[ selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[
- line := self visibleLineToAbsoluteLine:visLine.
- (line between:selectionStartLine and:selectionEndLine) ifTrue:[
- ((line == selectionStartLine)
- and: [col < selectionStartCol]) ifFalse:[
- ((line == selectionEndLine)
- and: [col > selectionEndCol]) ifFalse:[
- "its in the selection"
- self drawVisibleLineSelected:visLine col:col.
- ^ self.
- ]
- ]
- ]
+ line := self visibleLineToAbsoluteLine:visLine.
+ (line between:selectionStartLine and:selectionEndLine) ifTrue:[
+ ((line == selectionStartLine)
+ and: [col < selectionStartCol]) ifFalse:[
+ ((line == selectionEndLine)
+ and: [col > selectionEndCol]) ifFalse:[
+ "its in the selection"
+ self drawVisibleLineSelected:visLine col:col.
+ ^ self.
+ ]
+ ]
+ ]
].
self drawVisibleLine:visLine col:col with:fgColor and:bgColor
@@ -3085,75 +3149,75 @@
allOut := false.
(selectionStartLine isNil or:[selectionEndLine isNil
or:[selectionStartCol isNil or:[selectionEndCol isNil]]]) ifTrue:[
- allOut := true
+ allOut := true
] ifFalse:[
- (line between:selectionStartLine and:selectionEndLine) ifFalse:[
- allOut := true
- ] ifTrue:[
- (selectionStartLine == selectionEndLine) ifTrue:[
- ((endCol < selectionStartCol)
- or:[startCol > selectionEndCol]) ifTrue:[
- allOut := true
- ] ifFalse:[
- ((startCol >= selectionStartCol)
- and:[endCol <= selectionEndCol]) ifTrue:[
- allIn := true
- ]
- ]
- ] ifFalse:[
- (line == selectionStartLine) ifTrue:[
- (endCol < selectionStartCol) ifTrue:[
- allOut := true
- ] ifFalse:[
- (startCol >= selectionStartCol) ifTrue:[
- allIn := true
- ]
- ]
- ] ifFalse:[
- (line == selectionEndLine) ifTrue:[
- (startCol > selectionEndCol) ifTrue:[
- allOut := true
- ] ifFalse:[
- (endCol <= selectionEndCol) ifTrue:[
- allIn := true
- ]
- ]
- ] ifFalse:[
- allIn := true
- ]
- ]
- ]
- ]
+ (line between:selectionStartLine and:selectionEndLine) ifFalse:[
+ allOut := true
+ ] ifTrue:[
+ (selectionStartLine == selectionEndLine) ifTrue:[
+ ((endCol < selectionStartCol)
+ or:[startCol > selectionEndCol]) ifTrue:[
+ allOut := true
+ ] ifFalse:[
+ ((startCol >= selectionStartCol)
+ and:[endCol <= selectionEndCol]) ifTrue:[
+ allIn := true
+ ]
+ ]
+ ] ifFalse:[
+ (line == selectionStartLine) ifTrue:[
+ (endCol < selectionStartCol) ifTrue:[
+ allOut := true
+ ] ifFalse:[
+ (startCol >= selectionStartCol) ifTrue:[
+ allIn := true
+ ]
+ ]
+ ] ifFalse:[
+ (line == selectionEndLine) ifTrue:[
+ (startCol > selectionEndCol) ifTrue:[
+ allOut := true
+ ] ifFalse:[
+ (endCol <= selectionEndCol) ifTrue:[
+ allIn := true
+ ]
+ ]
+ ] ifFalse:[
+ allIn := true
+ ]
+ ]
+ ]
+ ]
].
allOut ifTrue:[
- super redrawVisibleLine:visLine from:startCol to:endCol.
- ^ self
+ super redrawVisibleLine:visLine from:startCol to:endCol.
+ ^ self
].
allIn ifTrue:[
- self drawVisibleLineSelected:visLine from:startCol to:endCol
+ self drawVisibleLineSelected:visLine from:startCol to:endCol
] ifFalse:[
- "redraw part before selection"
- ((line == selectionStartLine)
- and:[startCol <= selectionStartCol]) ifTrue:[
- super redrawVisibleLine:visLine from:startCol
- to:(selectionStartCol - 1).
- leftCol := selectionStartCol
- ] ifFalse:[
- leftCol := startCol
- ].
- "redraw selected part"
- (selectionEndLine > line) ifTrue:[
- rightCol := endCol
- ] ifFalse:[
- rightCol := selectionEndCol min:endCol
- ].
- self drawVisibleLineSelected:visLine from:leftCol to:rightCol.
-
- "redraw part after selection"
- (rightCol < endCol) ifTrue:[
- super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol
- ]
+ "redraw part before selection"
+ ((line == selectionStartLine)
+ and:[startCol <= selectionStartCol]) ifTrue:[
+ super redrawVisibleLine:visLine from:startCol
+ to:(selectionStartCol - 1).
+ leftCol := selectionStartCol
+ ] ifFalse:[
+ leftCol := startCol
+ ].
+ "redraw selected part"
+ (selectionEndLine > line) ifTrue:[
+ rightCol := endCol
+ ] ifFalse:[
+ rightCol := selectionEndCol min:endCol
+ ].
+ self drawVisibleLineSelected:visLine from:leftCol to:rightCol.
+
+ "redraw part after selection"
+ (rightCol < endCol) ifTrue:[
+ super redrawVisibleLine:visLine from:(rightCol + 1) to:endCol
+ ]
].
"special care for first and last line of selection:
@@ -3163,14 +3227,14 @@
and:[(startCol == 1)
and:[selectionStartLine < selectionEndLine]])
ifTrue:[
- self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor.
+ self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor.
].
((line == selectionStartLine)
and:[(startCol == 1)
and:[selectionStartLine < selectionEndLine]])
ifTrue:[
- self clearMarginOfVisibleLine:visLine with:bgColor.
+ self clearMarginOfVisibleLine:visLine with:bgColor.
].
((line > selectionStartLine)
@@ -3178,7 +3242,7 @@
and:[selectionStartLine < selectionEndLine
and:[line < selectionEndLine]]])
ifTrue:[
- self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor.
+ self clearMarginOfVisibleLine:visLine with:self currentSelectionBgColor.
]
"Modified: 6.3.1996 / 14:23:26 / cg"
@@ -4266,16 +4330,16 @@
realPattern := pattern.
isMatch ifTrue: [
- (realPattern startsWith:$*) ifTrue:[
- realPattern := realPattern copyFrom:2
- ].
- (realPattern endsWith:$*) ifTrue:[
- realPattern := realPattern copyButLast:1
- ].
+ (realPattern startsWith:$*) ifTrue:[
+ realPattern := realPattern copyButFirst
+ ].
+ (realPattern endsWith:$*) ifTrue:[
+ realPattern := realPattern copyButLast
+ ].
].
self selectFromLine:line col:col
- toLine:line col:(col + realPattern size - 1).
+ toLine:line col:(col + realPattern size - 1).
self makeLineVisible:line
!
@@ -4339,31 +4403,31 @@
|l t|
selectionStartLine notNil ifTrue:[
- expandingTop == true ifTrue:[
- l := selectionStartLine.
- selectionStartLine := selectionStartLine + 1.
- (selectionStartLine > clickLine
- or:[selectionStartLine == clickLine and:[selectionStartCol > clickCol]])
- ifTrue:[
- t := selectionStartLine.
- selectionStartLine := selectionEndLine.
- selectionEndLine := t.
- t := selectionStartCol.
- selectionStartCol := selectionEndCol.
- selectionEndCol := t.
- expandingTop := false
- ].
- ] ifFalse:[
- l := selectionEndLine.
- selectionEndLine := selectionEndLine + 1.
- ].
+ expandingTop == true ifTrue:[
+ l := selectionStartLine.
+ selectionStartLine := selectionStartLine + 1.
+ (selectionStartLine > clickLine
+ or:[selectionStartLine == clickLine and:[selectionStartCol > clickCol]])
+ ifTrue:[
+ t := selectionStartLine.
+ selectionStartLine := selectionEndLine.
+ selectionEndLine := t.
+ t := selectionStartCol.
+ selectionStartCol := selectionEndCol.
+ selectionEndCol := t.
+ expandingTop := false
+ ].
+ ] ifFalse:[
+ l := selectionEndLine.
+ selectionEndLine := selectionEndLine + 1.
+ ].
"/ self redrawLine:l.
"/ self redrawLine:l+1.
- self validateNewSelection.
- self setPrimarySelection.
- self selectionChanged.
- self redrawFromLine:l to:l+1.
- self makeSelectionVisible.
+ self validateNewSelection.
+ self setPrimarySelection.
+ self selectionChanged.
+ self redrawFromLine:l to:l+1.
+ self makeSelectionVisible.
].
"Created: / 01-03-1996 / 23:35:08 / cg"
@@ -4375,34 +4439,34 @@
|c l t c1 c2|
selectionStartLine notNil ifTrue:[
- expandingTop == true ifTrue:[
- selectionStartCol == 0 ifTrue:[^ self].
- l := selectionStartLine.
- selectionStartCol := (selectionStartCol - 1) max:1.
- c := selectionStartCol.
- ] ifFalse:[
- l := selectionEndLine.
- selectionEndCol := (selectionEndCol - 1) max:0.
- c := selectionEndCol.
- selectionEndLine == selectionStartLine ifTrue:[
- selectionEndCol <= selectionStartCol ifTrue:[
- t := selectionStartCol. selectionStartCol := selectionEndCol.
- selectionEndCol := t.
- expandingTop := true.
- c := selectionStartCol.
- ]
- ].
- ].
- c1 := c.
- c2 := c1 + 1.
- c1 == 0 ifTrue:[
- c1 := 1
- ].
- self validateNewSelection.
- self setPrimarySelection.
- self selectionChanged.
- self redrawLine:l from:c1 to:c2.
- self makeSelectionVisible.
+ expandingTop == true ifTrue:[
+ selectionStartCol == 0 ifTrue:[^ self].
+ l := selectionStartLine.
+ selectionStartCol := (selectionStartCol - 1) max:1.
+ c := selectionStartCol.
+ ] ifFalse:[
+ l := selectionEndLine.
+ selectionEndCol := (selectionEndCol - 1) max:0.
+ c := selectionEndCol.
+ selectionEndLine == selectionStartLine ifTrue:[
+ selectionEndCol <= selectionStartCol ifTrue:[
+ t := selectionStartCol. selectionStartCol := selectionEndCol.
+ selectionEndCol := t.
+ expandingTop := true.
+ c := selectionStartCol.
+ ]
+ ].
+ ].
+ c1 := c.
+ c2 := c1 + 1.
+ c1 == 0 ifTrue:[
+ c1 := 1
+ ].
+ self validateNewSelection.
+ self setPrimarySelection.
+ self selectionChanged.
+ self redrawLine:l from:c1 to:c2.
+ self makeSelectionVisible.
].
"Modified: / 18-03-1996 / 17:05:46 / cg"
@@ -4413,29 +4477,29 @@
|l c t|
selectionStartLine notNil ifTrue:[
- expandingTop == true ifTrue:[
- l := selectionStartLine.
- c := selectionStartCol.
- selectionStartCol := selectionStartCol + 1.
- l == selectionEndLine ifTrue:[
- c >= selectionEndCol ifTrue:[
- expandingTop := false.
- t := selectionStartCol. selectionStartCol := selectionEndCol.
- selectionEndCol := t.
- c := selectionStartCol.
- ]
- ]
- ] ifFalse:[
- l := selectionEndLine.
- c := selectionEndCol.
- selectionEndCol := selectionEndCol + 1.
- ].
-
- self validateNewSelection.
- self setPrimarySelection.
- self selectionChanged.
- self redrawLine:l from:(c max:1) to:c+1.
- self makeSelectionVisible.
+ expandingTop == true ifTrue:[
+ l := selectionStartLine.
+ c := selectionStartCol.
+ selectionStartCol := selectionStartCol + 1.
+ l == selectionEndLine ifTrue:[
+ c >= selectionEndCol ifTrue:[
+ expandingTop := false.
+ t := selectionStartCol. selectionStartCol := selectionEndCol.
+ selectionEndCol := t.
+ c := selectionStartCol.
+ ]
+ ]
+ ] ifFalse:[
+ l := selectionEndLine.
+ c := selectionEndCol.
+ selectionEndCol := selectionEndCol + 1.
+ ].
+
+ self validateNewSelection.
+ self setPrimarySelection.
+ self selectionChanged.
+ self redrawLine:l from:(c max:1) to:c+1.
+ self makeSelectionVisible.
].
"Created: / 01-03-1996 / 23:33:17 / cg"
@@ -4447,33 +4511,33 @@
|l t|
selectionStartLine notNil ifTrue:[
- expandingTop == true ifTrue:[
- selectionStartLine := (selectionStartLine - 1) max:1.
- l := selectionStartLine.
- ] ifFalse:[
- selectionEndLine := (selectionEndLine - 1) max:0.
-
- l := selectionEndLine.
- (selectionEndLine < clickLine
- or:[(selectionEndLine == clickLine and:[selectionEndCol < clickCol])])
- ifTrue:[
- t := selectionStartLine.
- selectionStartLine := selectionEndLine.
- selectionEndLine := t.
- t := selectionStartCol.
- selectionStartCol := selectionEndCol.
- selectionEndCol := t.
- l := selectionStartLine.
- expandingTop := true
- ].
- ].
- self validateNewSelection.
- self setPrimarySelection.
- self selectionChanged.
- "/ self redrawLine:l.
- "/ self redrawLine:l+1.
- self redrawFromLine:l to:l+1.
- self makeSelectionVisible.
+ expandingTop == true ifTrue:[
+ selectionStartLine := (selectionStartLine - 1) max:1.
+ l := selectionStartLine.
+ ] ifFalse:[
+ selectionEndLine := (selectionEndLine - 1) max:0.
+
+ l := selectionEndLine.
+ (selectionEndLine < clickLine
+ or:[(selectionEndLine == clickLine and:[selectionEndCol < clickCol])])
+ ifTrue:[
+ t := selectionStartLine.
+ selectionStartLine := selectionEndLine.
+ selectionEndLine := t.
+ t := selectionStartCol.
+ selectionStartCol := selectionEndCol.
+ selectionEndCol := t.
+ l := selectionStartLine.
+ expandingTop := true
+ ].
+ ].
+ self validateNewSelection.
+ self setPrimarySelection.
+ self selectionChanged.
+ "/ self redrawLine:l.
+ "/ self redrawLine:l+1.
+ self redrawFromLine:l to:l+1.
+ self makeSelectionVisible.
].
"Modified: / 06-03-1996 / 14:12:06 / cg"
@@ -4503,9 +4567,9 @@
!
hasSingleFullLineSelected
- ^ (selectionStartLine notNil
+ ^ (selectionStartLine notNil
and:[selectionEndLine notNil
- and:[selectionEndLine == (selectionStartLine+1)
+ and:[selectionEndLine == (selectionStartLine+1)
and:[selectionStartCol == 1
and:[selectionEndCol == 0
]]]])
@@ -4576,7 +4640,7 @@
|line1 col1 line2 col2|
pos1 > pos2 ifTrue:[
- ^ self unselect
+ ^ self unselect
].
line1 := self lineOfCharacterPosition:pos1.
col1 := pos1 - (self characterPositionOfLine:line1 col:1) + 1.
@@ -4600,29 +4664,29 @@
self unselectWithoutRedraw.
startLine notNil ifTrue:[
- "new:"
- endLine < startLine ifTrue:[
- ^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol
- ].
- (endLine == startLine and:[endCol < startCol]) ifTrue:[
- endCol ~~ 0 ifTrue:[
- self selectFromLine:endLine col:endCol toLine:startLine col:startCol.
- ].
- ^ self
- ].
+ "new:"
+ endLine < startLine ifTrue:[
+ ^ self selectFromLine:endLine col:endCol toLine:startLine col:startCol
+ ].
+ (endLine == startLine and:[endCol < startCol]) ifTrue:[
+ endCol ~~ 0 ifTrue:[
+ self selectFromLine:endLine col:endCol toLine:startLine col:startCol.
+ ].
+ ^ self
+ ].
" old:
- endLine < startLine ifTrue:[^ self].
- (startLine == endLine and:[endCol < startCol]) ifTrue:[^ self].
+ endLine < startLine ifTrue:[^ self].
+ (startLine == endLine and:[endCol < startCol]) ifTrue:[^ self].
"
- selectionStartLine := startLine.
- selectionStartCol := startCol.
- selectionEndLine := endLine.
- selectionEndCol := endCol.
- self validateNewSelection.
- self setPrimarySelection.
- self selectionChanged.
+ selectionStartLine := startLine.
+ selectionStartCol := startCol.
+ selectionEndLine := endLine.
+ selectionEndCol := endCol.
+ self validateNewSelection.
+ self setPrimarySelection.
+ self selectionChanged.
(selectionStartLine == selectionEndLine
and:[oldStartLine == selectionStartLine
@@ -4630,12 +4694,12 @@
self redrawLine:selectionStartLine
from:(selectionStartCol min: oldStartCol)
to:(selectionEndCol max: oldEndCol)
- ] ifFalse:[
+ ] ifFalse:[
(selectionStartLine min: oldStartLine) to: (selectionEndLine max: oldEndLine) do:[:lineNr |
- self redrawLine:lineNr
- ]
- ].
- selectStyle := nil.
+ self redrawLine:lineNr
+ ]
+ ].
+ selectStyle := nil.
]
"
@@ -4751,8 +4815,8 @@
selectionStartLine isNil ifTrue:[^ nil].
sel := self textFromLine:selectionStartLine col:(selectionStartCol max:1) toLine:selectionEndLine col:selectionEndCol.
sel notNil ifTrue:[
- (gc characterEncoding ? #'iso10646-1' "eg unicode") ~~ #'iso10646-1' ifTrue:[
- sel := sel encodeFrom:gc characterEncoding into:#'iso10646-1'
+ (gc characterEncoding ? #'iso10646-1' "eg unicode") ~~ #'iso10646-1' ifTrue:[
+ sel := sel encodeFrom:gc characterEncoding into:#'iso10646-1'
].
].
^ sel
@@ -4798,7 +4862,7 @@
self graphicsDevice notNil ifTrue:[
"On X11, be nice and set the PRIMARY selection.
(#setPrimaryText:ownerView: is void in DeviceWorkstation)"
- self graphicsDevice setPrimaryText: self selectionAsString ownerView: self.
+ self graphicsDevice setPrimaryText: self selectionAsString ownerView: self.
].
"Created: / 17-04-2012 / 20:59:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -4885,11 +4949,11 @@
!TextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.375 2014-06-10 10:05:46 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.384 2014-08-03 12:27:00 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.375 2014-06-10 10:05:46 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.384 2014-08-03 12:27:00 cg Exp $'
!
version_HG