The Trunk: ST80-nice.221.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: ST80-nice.221.mcz

commits-2
Nicolas Cellier uploaded a new version of ST80 to project The Trunk:
http://source.squeak.org/trunk/ST80-nice.221.mcz

==================== Summary ====================

Name: ST80-nice.221
Author: nice
Time: 27 October 2016, 4:25:19.895229 am
UUID: 138427de-a05b-4320-be9e-16051a9e81a5
Ancestors: ST80-nice.220

While at reviewing text selection code, do these minor cleanups that a bot could do:
- remove dead code (commented out)
- don't assign a variable outside the sole block where it's used
- factor out identical code in both ifTrue:ifFalse: branch

=============== Diff against ST80-nice.220 ===============

Item was changed:
  ----- Method: Paragraph>>hiliteRect: (in category 'selecting') -----
  hiliteRect: rect
 
- | highlightColor |
- highlightColor := Color quickHighLight: destinationForm depth.
  rect ifNotNil: [
+ | highlightColor |
+ highlightColor := Color quickHighLight: destinationForm depth.
  destinationForm
  fill: rect
  rule: Form reverse
+ fillColor: highlightColor].
- fillColor: highlightColor.
- "destinationForm
- fill: (rect translateBy: 1@1)
- rule: Form reverse
- fillColor: highlightColor" ].
  !

Item was changed:
  ----- Method: Paragraph>>reverseFrom:to: (in category 'selecting') -----
  reverseFrom: characterBlock1 to: characterBlock2
  "Reverse area between the two character blocks given as arguments."
  | visibleRectangle initialRectangle interiorRectangle finalRectangle lineNo baseline caret |
  characterBlock1 = characterBlock2 ifTrue:
  [lineNo := self lineIndexOfCharacterIndex: characterBlock1 stringIndex.
  baseline := lineNo = 0 ifTrue: [textStyle baseline]
  ifFalse: [(lines at: lineNo) baseline].
  caret := self caretFormForDepth: Display depth.
  ^ caret  "Use a caret to indicate null selection"
  displayOn: destinationForm
  at: characterBlock1 topLeft + (-3 @ baseline)
  clippingBox: clippingRectangle
  rule: (false "Display depth>8" ifTrue: [9 "not-reverse"]
  ifFalse: [Form reverse])
  fillColor: nil].
  visibleRectangle :=
  (clippingRectangle intersect: compositionRectangle)
  "intersect: destinationForm boundingBox" "not necessary".
  characterBlock1 top = characterBlock2 top
  ifTrue: [characterBlock1 left < characterBlock2 left
  ifTrue:
  [initialRectangle :=
  (characterBlock1 topLeft corner: characterBlock2 bottomLeft)
  intersect: visibleRectangle]
  ifFalse:
  [initialRectangle :=
  (characterBlock2 topLeft corner: characterBlock1 bottomLeft)
  intersect: visibleRectangle]]
  ifFalse: [characterBlock1 top < characterBlock2 top
+ ifTrue:
+ [initialRectangle :=
+ (characterBlock1 topLeft
+ corner: visibleRectangle right @ characterBlock1 bottom)
+ intersect: visibleRectangle.
+ finalRectangle :=
+ (visibleRectangle left @ characterBlock2 top
+ corner: characterBlock2 bottomLeft)
+ intersect: visibleRectangle.
+ characterBlock1 bottom = characterBlock2 top
+ ifFalse:
+ [interiorRectangle :=
+ (visibleRectangle left @ characterBlock1 bottom
+ corner: visibleRectangle right @ characterBlock2 top)
+ intersect: visibleRectangle]]
- ifTrue:
- [initialRectangle :=
- (characterBlock1 topLeft
- corner: visibleRectangle right @ characterBlock1 bottom)
- intersect: visibleRectangle.
- characterBlock1 bottom = characterBlock2 top
- ifTrue:
- [finalRectangle :=
- (visibleRectangle left @ characterBlock2 top
- corner: characterBlock2 bottomLeft)
- intersect: visibleRectangle]
- ifFalse:
- [interiorRectangle :=
- (visibleRectangle left @ characterBlock1 bottom
- corner: visibleRectangle right
- @ characterBlock2 top)
- intersect: visibleRectangle.
- finalRectangle :=
- (visibleRectangle left @ characterBlock2 top
- corner: characterBlock2 bottomLeft)
- intersect: visibleRectangle]]
  ifFalse:
  [initialRectangle :=
  (visibleRectangle left @ characterBlock1 top
  corner: characterBlock1 bottomLeft)
  intersect: visibleRectangle.
+ finalRectangle :=
+ (characterBlock2 topLeft
+ corner: visibleRectangle right @ characterBlock2 bottom)
+ intersect: visibleRectangle.
  characterBlock1 top = characterBlock2 bottom
- ifTrue:
- [finalRectangle :=
- (characterBlock2 topLeft
- corner: visibleRectangle right
- @ characterBlock2 bottom)
- intersect: visibleRectangle]
  ifFalse:
  [interiorRectangle :=
  (visibleRectangle left @ characterBlock2 bottom
  corner: visibleRectangle right @ characterBlock1 top)
- intersect: visibleRectangle.
- finalRectangle :=
- (characterBlock2 topLeft
- corner: visibleRectangle right
- @ characterBlock2 bottom)
  intersect: visibleRectangle]]].
  self hiliteRect: initialRectangle.
  self hiliteRect: interiorRectangle.
  self hiliteRect: finalRectangle.!