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

commits at source.squeak.org commits at source.squeak.org
Wed Dec 22 09:09:01 UTC 2021

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

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

Name: Morphic-mt.1828
Author: mt
Time: 22 December 2021, 10:08:57.760053 am
UUID: e590bde6-a599-1044-81d1-a37f78271169
Ancestors: Morphic-mt.1827

Tweak enclose-selection feature to toggle symmetric quote characters such as "" '' and ||. Others are still open=add and close=remove.

Thanks to Christoph (ct) and Jaromir (jar) for the idea!

Update #autoEnclose default to match the settings in the ReleaseBuilder. Now that several US-only keyboard shortcuts are gone, we need this preference and #encloseSelection enabled to cover all the cases.

Sorry for any inconveniences.

=============== Diff against Morphic-mt.1827 ===============

Item was changed:
  ----- Method: TextEditor class>>autoEnclose (in category 'preferences') -----
  	<preference: 'Auto enclose brackets () {} []'
  		categoryList: #('Morphic' 'editing')
  		description: 'When true, typing an opening parenthesis, bracket or square-bracket will also add its corresponding closing character after the cursor so you can type within the bracket.'
  		type: #Boolean>
+ 	^ AutoEnclose ifNil: [ true ]!
- 	^ AutoEnclose ifNil: [ false ]!

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] ])
- 			and: [ closingBracket ])
  			["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 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