The Trunk: Morphic-mt.1117.mcz

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

The Trunk: Morphic-mt.1117.mcz

commits-2
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1117.mcz

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

Name: Morphic-mt.1117
Author: mt
Time: 19 April 2016, 11:43:17.879049 am
UUID: dfe3d794-df51-2f47-abef-00885c576f46
Ancestors: Morphic-mt.1116

Fixes return values of enclose feature. Only return true if you perfomed an edit operation.

=============== Diff against Morphic-mt.1116 ===============

Item was changed:
  ----- Method: TextEditor>>enclose: (in category 'editing keys') -----
  enclose: aKeyboardEvent
  "Insert or remove bracket characters around the current selection."
 
  | character left right startIndex stopIndex oldSelection which t |
  character := aKeyboardEvent shiftPressed
  ifTrue: ['{}|"<>' at: ('[]\'',.' indexOf: aKeyboardEvent keyCharacter) ifAbsent: [aKeyboardEvent keyCharacter]]
  ifFalse: [aKeyboardEvent keyCharacter].
  self closeTypeIn.
  startIndex := self startIndex.
  stopIndex := self stopIndex.
  oldSelection := self selection.
+ which := '([<{|"''9' indexOf: character ifAbsent: [ ^ false ].
- which := '([<{|"''9' indexOf: character ifAbsent: [ ^false ].
  "Allow Control key in lieu of Alt+Shift for (, {, and double-quote."
  left := ((Preferences cmdKeysInText and: [ aKeyboardEvent controlKeyPressed ])
  ifTrue: [ '({<{|""(' ]
  ifFalse: ['([<{|"''(']) at: which.
  right := ((Preferences cmdKeysInText and: [ aKeyboardEvent controlKeyPressed ])
  ifTrue: [ ')}>}|"")' ]
  ifFalse: [')]>}|"'')']) at: which.
  t := self text.
  ((startIndex > 1 and: [stopIndex <= t size])
  and: [ (t at: startIndex-1) = left and: [(t at: stopIndex) = right]])
  ifTrue: [
  "already enclosed; strip off brackets"
  self selectFrom: startIndex-1 to: stopIndex.
+ self replaceSelectionWith: oldSelection.
+ ^ true]
- self replaceSelectionWith: oldSelection]
  ifFalse: [
  "not enclosed; enclose by matching brackets"
  self replaceSelectionWith:
  (Text string: (String with: left), oldSelection string, (String with: right) attributes: emphasisHere).
+ self selectFrom: startIndex+1 to: stopIndex.
+ ^ true].
+ ^ false!
- self selectFrom: startIndex+1 to: stopIndex].
- ^true!