[squeak-dev] The Trunk: Morphic-mt.1824.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Dec 15 16:16:04 UTC 2021
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1824.mcz
==================== Summary ====================
Name: Morphic-mt.1824
Author: mt
Time: 15 December 2021, 5:15:37.106892 pm
UUID: 9e2f47cd-4f46-864e-97d8-1251504f3ee5
Ancestors: Morphic-mt.1823
Via "enclose selection" preference, an opening bracket adds a level and a closer bracket removes a level. No toggling anymore.
Thanks to Jaromir (jar) for the idea!
See the discussion here: http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-December/217331.html
=============== Diff against Morphic-mt.1823 ===============
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 closingBracket t |
- | character left right startIndex stopIndex oldSelection which t |
character := aKeyboardEvent keyCharacter.
self closeTypeIn.
startIndex := self startIndex.
stopIndex := self stopIndex.
oldSelection := self selection.
+ closingBracket := false.
+ which := '([<{|"''' indexOf: character ifAbsent: [
+ closingBracket := true.
+ ')]>}|"''' indexOf: character ifAbsent: [ ^ false ]].
- which := '([<{|"''' indexOf: character ifAbsent: [ ^ false ].
left := '([<{|"''' at: which.
right := ')]>}|"''' at: which.
t := self text.
((startIndex > 1 and: [stopIndex <= t size])
+ and: [ (t at: startIndex-1) = left and: [(t at: stopIndex) = right]]
+ and: [ closingBracket ])
- and: [ (t at: startIndex-1) = left and: [(t at: stopIndex) = right]])
ifTrue:
+ ["already enclosed and character is a closing bracket; strip off brackets"
- ["already enclosed; strip off brackets"
self selectFrom: startIndex-1 to: stopIndex.
self replaceSelectionWith: oldSelection]
ifFalse:
+ ["not enclosed or character is an opening bracket; enclose by matching brackets"
+ closingBracket ifFalse:
+ [ self replaceSelectionWith:
- ["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] ].
- self selectFrom: startIndex+1 to: stopIndex].
^true!
More information about the Squeak-dev
mailing list
|