[squeak-dev] The Trunk: Morphic-mt.1832.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Dec 29 10:32:31 UTC 2021

Marcel Taeumel uploaded a new version of Morphic to project The Trunk:

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

Name: Morphic-mt.1832
Author: mt
Time: 29 December 2021, 11:32:30.143561 am
UUID: 21c85275-501f-a94c-a3b2-4e13efd3c145
Ancestors: Morphic-ct.1831

If you cannot stip off a pair of brackets, just allow the user to type that bracket, replacing the current text selection.

=============== Diff against Morphic-ct.1831 ===============

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 := 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 ]].
  	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 or: [left = right] ])
  			["already enclosed and character is a closing bracket; strip off brackets"
  			self selectFrom: startIndex-1 to: stopIndex.
  			self replaceSelectionWith: oldSelection]
  			["not enclosed or character is an opening bracket; enclose by matching brackets"
+ 			closingBracket ifTrue: [ ^ false ] ifFalse:
- 			closingBracket ifFalse:
  			[ self replaceSelectionWith:
  				(Text string: (String with: left), oldSelection string, (String with: right) attributes: emphasisHere).
  			self selectFrom: startIndex+1 to: stopIndex] ].

More information about the Squeak-dev mailing list