Created
August 17, 2021 09:50
-
-
Save ErikOnBike/7ed24759c63a045bd8ff8afbaeeb8a88 to your computer and use it in GitHub Desktop.
MacOS keybindings for cursor movement in Pharo Smalltalk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ClyNavigateBrowserBackCommand class compile: 'defaultShortcut | |
^Character arrowLeft control alt "fails for now"'. | |
ClyNavigateBrowserForwardCommand class compile: 'defaultShortcut | |
^Character arrowRight control alt "fails for now"'. | |
RubTextEditor compile: 'moveCursor: directionBlock forward: forward specialBlock: specialBlock event: aKeyboardEvent | |
"Private - Move cursor. | |
directionBlock is a one argument Block that computes the new Position from a given one. | |
specialBlock is a one argumentBlock that computes the new position from a given one under the alternate semantics. | |
Note that directionBlock always is evaluated first." | |
| shift isVertical indices position newPosition string | | |
shift := aKeyboardEvent shiftPressed. | |
isVertical := aKeyboardEvent keyCharacter | |
ifNotNil: [ :keyChar | | |
{ Character arrowUp . Character arrowDown . Character home . Character end } includes: keyChar ] | |
ifNil: [ false ]. | |
indices := self setIndices: shift forward: forward. | |
position := indices at: #moving. | |
string := self string. | |
newPosition := aKeyboardEvent altKeyPressed | |
ifTrue: [ specialBlock value: (directionBlock value: position) ] | |
ifFalse: [ | |
aKeyboardEvent commandKeyPressed | |
ifTrue: [ | |
isVertical | |
ifTrue: [ | |
forward | |
ifTrue: [ string size + 1 ] | |
ifFalse: [ 1 ] ] | |
ifFalse: [ | |
forward | |
ifTrue: [ string indexOf: Character cr startingAt: position ifAbsent: [ string size + 1 ] ] | |
ifFalse: [ (string lastIndexOf: Character cr startingAt: position - 1 ifAbsent: [ 0 ]) + 1 ] ] ] | |
ifFalse: [ directionBlock value: position ] ]. | |
shift | |
ifTrue: [self selectMark: (indices at: #fixed) point: newPosition - 1] | |
ifFalse: [self selectAt: newPosition]. | |
self setEmphasisHereFromTextForward: forward' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment