[squeak-dev] The Inbox: Morphic-ct.1717.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Jan 24 16:04:56 UTC 2021


A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1717.mcz

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

Name: Morphic-ct.1717
Author: ct
Time: 24 January 2021, 5:04:52.512273 pm
UUID: c5d26f4c-059d-c54b-8c78-a7c9c06fc6db
Ancestors: Morphic-mt.1710

Editor: Fixes the 9-enclosing bug, the inability to enclose a text into single quotes, and cleans up the #enclose: implementation.

Pressing 9 while some text is selected now con{sist,veni}ently replaces the selection with a 9 as it is usual for every other digit key as well. If you would like to enclose the current selection within brackets, just enter the bracket (i.e. shift + 9 on a qwerty keyboard) as you would do for square brackets, quotes etc. too.

Reuploaded again to replace Morphic-ct.1588, with the following changes applied:
* Removed the entire keyboard-layout specific logic which was only needed for a VM hack from older times and apparently is not needed any longer
* Eliminated Collections-ct.860 dependency, which will not be merged
* Resolved merge conflicts
* Minor refactoring, documentation, and stability improvements to the previous version
* Compressed diff

See also: http://forum.world.st/When-did-it-become-a-good-idea-for-selected-text-to-be-enclosed-by-instead-of-replaced-by-9-td4936276.html | http://forum.world.st/The-Inbox-Morphic-ct-1588-mcz-td5106961.html.

Depends on Collections-ct.921. Please review! I'm really looking forward to see this in a Trunk soon because the Nine Bug bothers me every time I make some experiments in a fresh image ... ;-)

=============== Diff against Morphic-mt.1710 ===============

Item was changed:
  Object subclass: #Editor
  	instanceVariableNames: 'morph'
+ 	classVariableNames: 'BlinkingCursor DestructiveBackWord DumbbellCursor EnclosingCharacterMap KeystrokeActions SelectionsMayShrink'
- 	classVariableNames: 'BlinkingCursor DestructiveBackWord DumbbellCursor KeystrokeActions SelectionsMayShrink'
  	poolDictionaries: ''
  	category: 'Morphic-Text Support'!
  
  !Editor commentStamp: 'hjh 9/28/2017 11:37' prior: 0!
  New text editors.
  TextEditor provides most of the functionality that used to be in TextMorphEditor.
  SmalltalkEditor is has Smalltalk code specific features.
  !

Item was added:
+ ----- Method: Editor class>>enclosingCharacterMap (in category 'keyboard shortcut tables') -----
+ enclosingCharacterMap
+ 	"Maps opening bracket characters to their closing equivalent. Used for encloseSelection preference. See senders."
+ 
+ 	^ EnclosingCharacterMap ifNil: [EnclosingCharacterMap :=
+ 		Dictionary newFromKeys: '([<{|"''' values: ')]>}|"''']!

Item was added:
+ ----- Method: Editor>>enclosingCharacterFor:ifNone: (in category 'private') -----
+ enclosingCharacterFor: openingCharacter ifNone: aBlock
+ 
+ 	^ self enclosingCharacterMap
+ 		at: openingCharacter
+ 		ifAbsent: aBlock!

Item was added:
+ ----- Method: Editor>>enclosingCharacterMap (in category 'accessing') -----
+ enclosingCharacterMap
+ 
+ 	^ self class enclosingCharacterMap!

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 text |
- 	| character left right startIndex stopIndex oldSelection which t |
- 	character := aKeyboardEvent shiftPressed
- 					ifTrue: ['{}|"<>' at: ('[]\'',.' indexOf: aKeyboardEvent keyCharacter) ifAbsent: [aKeyboardEvent keyCharacter]]
- 					ifFalse: [aKeyboardEvent keyCharacter].
  	self closeTypeIn.
+ 	
+ 	character := aKeyboardEvent keyCharacter.
  	startIndex := self startIndex.
  	stopIndex := self stopIndex.
  	oldSelection := self selection.
+ 	left := character.
+ 	right := self enclosingCharacterFor: left ifNone: [^ false].
+ 	
+ 	text := self text.
+ 	((startIndex > 1 and: [stopIndex <= text size])
+ 			and: [ (text at: startIndex - 1) = left and: [(text at: stopIndex) = right]])
- 	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]
  		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!



More information about the Squeak-dev mailing list