[squeak-dev] The Inbox: Morphic-jar.1815.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Tue Dec 7 09:46:42 UTC 2021


Here is the discussion:
http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-December/217330.html


Best,
Marcel
Am 06.12.2021 20:57:07 schrieb commits at source.squeak.org <commits at source.squeak.org>:
A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-jar.1815.mcz

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

Name: Morphic-jar.1815
Author: jar
Time: 6 December 2021, 8:56:48.006443 pm
UUID: b73bc9c0-eec1-a645-80f7-39eb98778d2c
Ancestors: Morphic-ct.1814

Allow enclosing a selection with multiple levels of brackets with EncloseTextSelections preference on. Both opening and closing brackets on a selection enclose the selection with the first level of brackets; on higher levels opening brackets add and closing brackets remove one level...

Currently, enclosing a selection with only one level of brackets is supported; pressing an opening bracket for the second time removes the enclosing brackets; pressing a closing bracket replaces the selection altogether.

=============== Diff against Morphic-ct.1814 ===============

Item was changed:
----- Method: TextEditor>>enclose: (in category 'editing keys') -----
enclose: aKeyboardEvent
+ "Insert or remove bracket characters around the current selection.
+ Pressing a right bracket removes one level of brackets of the same kind if there are any."
- "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 := '([
+ closingBracket := true.
+ ')]>}|"''' indexOf: character ifAbsent: [^ false ]].
- which := '([
left := '([
right := ')]>}|"''' at: which.
t := self text.
((startIndex > 1 and: [stopIndex
+ 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 the pressed 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 the pressed character is an opening bracket; enclose by matching brackets"
- ["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!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211207/a3ac1f6c/attachment.html>


More information about the Squeak-dev mailing list