[Cuis-dev] Editor cmd-"

Mark dev at virtualmdj.com
Mon Nov 22 12:11:41 PST 2021


Hi,

According to the Smalltalk Editor Help:

Cmd-"   			Enclose within double quotes, or remove enclosing double quotes

However, it surrounds my text with an apostrophe (“single-quote”) character instead of a quote (“double-quote”) character.

Specifically, if I have the following in the Workspace (or any other editor):

	Hello, world

And I highlight it and press <cmd-“>, the result is:

	‘Hello, world'

But, I would have expected it to result with:

	"Hello, world"

I used this as an opportunity to explore the system, and (after quite a while! 😉), I added a Transcript statement, as follows:

Texteditor>>>enclose: aKeyboardEvent
	"Insert or remove bracket characters around the current selection."
	"This is a user command, and generates undo"
	| left right startIndex stopIndex oldSelection which |
	Transcript show: ('kbd: [{1}]' format: {aKeyboardEvent keyCharacter }); newLine.
	startIndex _ self startIndex.
	stopIndex _ self stopIndex.
	oldSelection _ self selection.
	which _ '([<{"''`' indexOf: aKeyboardEvent keyCharacter ifAbsent: [ ^true ].
	left _ '([<{"''`' at: which.
	right _ ')]>}"''`' at: which.
	((startIndex > 1 and: [stopIndex <= model textSize])
			and: [ (model actualContents at: startIndex-1) = left and: [(model actualContents 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) attributes: emphasisHere),
				oldSelection,
				(Text string: (String with: right) attributes: emphasisHere).
			self selectFrom: startIndex+1 to: stopIndex].
	^ true

And discovered that this method never receives a <cmd-“> keyCharacter. By the time this code is executed, it seems like the <shift> key is ignored.

Further experimentation revealed that none of the “shift”-ed key commands work — at least, not on my setup. 🙄😉🙂

Any thoughts? Should this work?

TIA,

	— Mark


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20211122/6c15144a/attachment.htm>


More information about the Cuis-dev mailing list