[squeak-dev] The Trunk: Morphic-nice.564.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Aug 4 00:01:29 UTC 2011
Nicolas Cellier uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-nice.564.mcz
==================== Summary ====================
Name: Morphic-nice.564
Author: nice
Time: 4 August 2011, 2:00:08.195 am
UUID: 53207bf1-76d6-494a-84ff-e151e65080cd
Ancestors: Morphic-nice.563
Let cmd+| insert/remove a pair of bars around the selection
=============== Diff against Morphic-nice.563 ===============
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-='
do: [:char | cmdMap at: char asciiValue + 1 put: #changeEmphasis:].
+ '([<{|"''' do: [:char | cmdMap at: char asciiValue + 1 put: #enclose:].
- '([{''"<' do: [:char | cmdMap at: char asciiValue + 1 put: #enclose:].
cmds := #($a #selectAll: $c #copySelection: $e #exchange: $f #find: $g #findAgain: $h #setSearchString: $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>>enclose: (in category 'editing keys') -----
enclose: aKeyboardEvent
"Insert or remove bracket characters around the current selection."
| left right startIndex stopIndex oldSelection which t |
self closeTypeIn.
startIndex := self startIndex.
stopIndex := self stopIndex.
oldSelection := self selection.
+ which := '([<{|"''' indexOf: aKeyboardEvent keyCharacter ifAbsent: [ ^true ].
+ left := '([<{|"''' at: which.
+ right := ')]>}|"''' at: which.
- which := '([<{"''' indexOf: aKeyboardEvent keyCharacter ifAbsent: [ ^true ].
- left := '([<{"''' at: which.
- right := ')]>}"''' 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!
Item was changed:
----- Method: TextEditor>>shiftEnclose: (in category 'editing keys') -----
shiftEnclose: aKeyboardEvent
"Insert or remove bracket characters around the current selection.
Flushes typeahead."
| char left right startIndex stopIndex oldSelection which text |
char := aKeyboardEvent keyCharacter.
char = $9 ifTrue: [ char := $( ].
char = $, ifTrue: [ char := $< ].
char = $[ ifTrue: [ char := ${ ].
char = $' ifTrue: [ char := $" ].
char asciiValue = 27 ifTrue: [ char := ${ ]. "ctrl-["
self closeTypeIn.
startIndex := self startIndex.
stopIndex := self stopIndex.
oldSelection := self selection.
+ which := '([<{|"''' indexOf: char ifAbsent: [1].
+ left := '([<{|"''' at: which.
+ right := ')]>}|"''' at: which.
- which := '([<{"''' indexOf: char ifAbsent: [1].
- left := '([<{"''' at: which.
- right := ')]>}"''' at: which.
text := paragraph text.
((startIndex > 1 and: [stopIndex <= text size])
and: [ (text at: startIndex-1) = left and: [(text 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
|