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

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Sat Mar 26 15:25:53 UTC 2022


Very nice revisions! I was a bit confused that the shortcut for the emphasis menu has changed - at least this is a breaking change and some of us may have internalized this shortcut -, but the new shortcut makes sense. :-)


> - No #narrow anymore (was [8])

Now it is still reachable through <opt>5 > "Custom attribute..." > "TextKern kern: -1", again. :P


Best,

Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Freitag, 11. März 2022 10:03:26
An: squeak-dev at lists.squeakfoundation.org; packages at lists.squeakfoundation.org
Betreff: [squeak-dev] The Trunk: Morphic-mt.1931.mcz

Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1931.mcz

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

Name: Morphic-mt.1931
Author: mt
Time: 11 March 2022, 10:03:20.148495 am
UUID: b4055ef5-466d-604e-be51-2affcbba4e6a
Ancestors: Morphic-mt.1930

Improves compromise for keyboard shortcuts in TextEditor and SmalltalkTextEditor regarding [CMD]+[0..9]:
- [1..5] No TextFontChange anymore in TextEditor bc. incompatible with scale factor and TrueType fonts
- [1..4] still argument name insert in SmalltalkEditor
- [5] opens emphasis menu (was [6])
- [6..9] add typical emphases: #bold #italic #underlined #struckOut
- No #narrow anymore (was [8])
- [0] still removes those emphases
- No support for US-only [=/-] anymore; was used for text kern +/- 1

Note that [CTRL]+[0..9] is not affected by this change.

=============== Diff against Morphic-mt.1930 ===============

Item was changed:
  ----- Method: SmalltalkEditor>>changeEmphasis: (in category 'editing keys') -----
  changeEmphasis: characterStream
+        "Change emphasis without styling if necessary. NOTE THAT [cmd]+[1..4] will insert the name of the method argument number n."
+
-        "Change emphasis without styling if necessary"
         self styler ifNil: [^super changeEmphasis: characterStream].
         ^ self styler evaluateWithoutStyling: [super changeEmphasis: characterStream].!

Item was changed:
  ----- Method: TextEditor class>>initializeCmdKeyShortcuts (in category 'keyboard shortcut tables') -----
  initializeCmdKeyShortcuts
         "Initialize the (unshifted) command-key (or alt-key) shortcut table."

         "NOTE: if you don't know what your keyboard generates, use Sensor kbdTest"

         "TextEditor initialize"

         | cmdMap cmds |
         cmdMap := Array new: 256 withAll: #noop:.               "use temp in case of a crash"
         cmdMap at: 1 + 1 put: #cursorHome:.                             "home key"
         cmdMap at: 4 + 1 put: #cursorEnd:.                              "end key"
         cmdMap at: 8 + 1 put: #backspace:.                              "ctrl-H or delete key"
         cmdMap at: 11 + 1 put: #cursorPageUp:.                  "page up key"
         cmdMap at: 12 + 1 put: #cursorPageDown:.                "page down key"
         cmdMap at: 13 + 1 put: #crWithIndent:.                  "cmd-Return"
         cmdMap at: 27 + 1 put: #offerMenuFromEsc:.              "escape key"
         cmdMap at: 28 + 1 put: #cursorLeft:.                            "left arrow key"
         cmdMap at: 29 + 1 put: #cursorRight:.                           "right arrow key"
         cmdMap at: 30 + 1 put: #cursorUp:.                              "up arrow key"
         cmdMap at: 31 + 1 put: #cursorDown:.                            "down arrow key"
         cmdMap at: 32 + 1 put: #selectWord:.                            "space bar key"
         cmdMap at: 127 + 1 put: #forwardDelete:.                "del key"

+        '0123456789'
-        '0123456789-='
                 do: [:char | cmdMap at: char asciiValue + 1 put: #changeEmphasis:].

         cmds := #($a #selectAll: $c #copySelection: $e #exchange: $f #find: $g #findAgain: $j #doAgain: $k #offerFontMenu: $u #align: $v #paste: $w #backWord: $x #cut: $y #swapChars: $z #undo:).
         1 to: cmds size
                 by: 2
                 do: [:i | cmdMap at: (cmds at: i) asciiValue + 1 put: (cmds at: i + 1)].

         cmdActions := cmdMap!

Item was changed:
  ----- Method: TextEditor>>changeEmphasis: (in category 'editing keys') -----
  changeEmphasis: aKeyboardEvent
         "Change the emphasis of the current selection or prepare to accept characters with the change in emphasis. Emphasis change amounts to a font change.  Keeps typeahead."

+        "[cmd]+[0..9]"
-        "control 0..9 -> 0..9"

         | keyCode attribute oldAttributes index thisSel colors extras |
+        keyCode := ('0123456789' indexOf: aKeyboardEvent keyCharacter ifAbsent: [1]) - 1.
-        keyCode := ('0123456789-=' indexOf: aKeyboardEvent keyCharacter ifAbsent: [1]) - 1.
         oldAttributes := paragraph text attributesAt: self pointIndex.
         thisSel := self selection.

+        "mt: Index-based font changes are not compatible with variable point sizes in text styles. Make room for other shortcuts.
+        (keyCode between: 1 and: 5) ifTrue: [attribute := TextFontChange fontNumber: keyCode]."
-        "Decipher keyCodes for Command 0-9..."
-        (keyCode between: 1 and: 5)
-                ifTrue: [attribute := TextFontChange fontNumber: keyCode].

+        keyCode = 5
-        keyCode = 6
                 ifTrue: [
                         colors := #(#black #magenta #red #yellow #green #blue #cyan #white).
                         extras := self emphasisExtras.
+                        index := Project uiManager chooseFrom: colors , #('choose color...' ), extras.
-                        index := UIManager default chooseFrom:colors , #('choose color...' ), extras
-                                                lines: (Array with: colors size + 1).
                         index = 0 ifTrue: [^true].
                         index <= colors size
                                 ifTrue: [attribute := TextColor color: (Color perform: (colors at: index))]
                                 ifFalse: [
                                         index := index - colors size - 1.       "Re-number!!!!!!"
                                         index = 0
                                                 ifTrue: [attribute := self chooseColor]
                                                 ifFalse:[^self handleEmphasisExtra: index with: aKeyboardEvent] "handle an extra"]].
+        (keyCode between: 6 and: 9)
-        (keyCode between: 7 and: 11)
                 ifTrue: [
                         aKeyboardEvent shiftPressed
+                                ifTrue: [ "Cannot be reached bc. method entry is #keyCharacter based and thus dependent on keyboard layout."
+                                        keyCode = 6 ifTrue: [attribute := TextKern kern: -1].
+                                        keyCode = 7 ifTrue: [attribute := TextKern kern: 1]]
-                                ifTrue: [
-                                        keyCode = 10 ifTrue: [attribute := TextKern kern: -1].
-                                        keyCode = 11 ifTrue: [attribute := TextKern kern: 1]]
                                 ifFalse: [
+                                        attribute := TextEmphasis
+                                                perform: (#(#bold #italic #underlined #struckOut) at: keyCode - 5).
+                                        oldAttributes
-                                        attribute := TextEmphasis
-                                                                perform: (#(#bold #italic #narrow #underlined #struckOut) at: keyCode - 6).
-                                        oldAttributes
                                                 do: [:att | (att dominates: attribute) ifTrue: [attribute turnOff]]]].
         keyCode = 0 ifTrue: [attribute := TextEmphasis normal].
         attribute ifNotNil: [
                 thisSel size = 0
                         ifTrue: [
                                 "only change emphasisHere while typing"
                                 self insertTypeAhead.
                                 emphasisHere := Text addAttribute: attribute toArray: oldAttributes ]
                         ifFalse: [
                                 self replaceSelectionWith: (thisSel asText addAttribute: attribute) ]].
         ^true!


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


More information about the Squeak-dev mailing list