[Pkg] The Trunk: ST80-nice.134.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Aug 4 00:04:50 UTC 2011
Nicolas Cellier uploaded a new version of ST80 to project The Trunk:
http://source.squeak.org/trunk/ST80-nice.134.mcz
==================== Summary ====================
Name: ST80-nice.134
Author: nice
Time: 4 August 2011, 2:04:27.825 am
UUID: 64bde7ed-cd1c-4823-9cfe-384e95f4e770
Ancestors: ST80-nice.133
Let cmd+| insert/remove a pair of bars around the selection
Let clicking twice between bars select the range between bars.
=============== Diff against ST80-nice.133 ===============
Item was changed:
----- Method: ParagraphEditor 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"
"ParagraphEditor initialize"
| cmdMap |
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:].
cmdMap at: $, asciiValue + 1 put: #shiftEnclose:.
"triplet = {character. comment selector. novice appropiated}"
#(
($a #selectAll: true)
($b #browseIt: false)
($c #copySelection: true)
($d #doIt: false)
($e #exchange: true)
($f #find: true)
($g #findAgain: true)
($h #setSearchString: true)
($i #inspectIt: false)
($j #doAgainOnce: true)
($k #offerFontMenu: true)
($l #cancel: true)
($m #implementorsOfIt: false)
($n #sendersOfIt: false)
($o #spawnIt: false)
($p #printIt: false)
($q #querySymbol: false)
($s #save: true)
($t #tempCommand: false)
($u #align: true)
($v #paste: true)
($w #backWord: true)
($x #cut: true)
($y #swapChars: true)
($z #undo: true)
)
select:[:triplet | Preferences noviceMode not or:[triplet third]]
thenDo:[:triplet | cmdMap at: triplet first asciiValue + 1 put: triplet second].
CmdActions := cmdMap.
!
Item was changed:
----- Method: ParagraphEditor>>enclose: (in category 'editing keys') -----
enclose: characterStream
"Insert or remove bracket characters around the current selection.
Flushes typeahead."
| char left right startIndex stopIndex oldSelection which text |
char := sensor keyboard.
self closeTypeIn.
startIndex := self startIndex.
stopIndex := self stopIndex.
oldSelection := self selection.
+ which := '([<{|"''' indexOf: char ifAbsent: [ ^true ].
+ left := '([<{|"''' at: which.
+ right := ')]>}|"''' at: which.
- which := '([<{"''' indexOf: char ifAbsent: [ ^true ].
- 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)
emphasis: emphasisHere).
self selectFrom: startIndex+1 to: stopIndex].
^true!
Item was changed:
----- Method: ParagraphEditor>>selectWord (in category 'new selection') -----
selectWord
"Select delimited text or word--the result of double-clicking."
| openDelimiter closeDelimiter direction match level leftDelimiters rightDelimiters
string here hereChar start stop |
string := paragraph text string.
here := self pointIndex.
(here between: 2 and: string size)
ifFalse: ["if at beginning or end, select entire string"
^self selectFrom: 1 to: string size].
+ leftDelimiters := '([{<|''"
- leftDelimiters := '([{<''"
'.
+ rightDelimiters := ')]}>|''"
- rightDelimiters := ')]}>''"
'.
openDelimiter := string at: here - 1.
match := leftDelimiters indexOf: openDelimiter.
match > 0
ifTrue:
["delimiter is on left -- match to the right"
start := here.
direction := 1.
here := here - 1.
closeDelimiter := rightDelimiters at: match]
ifFalse:
[openDelimiter := string at: here.
match := rightDelimiters indexOf: openDelimiter.
match > 0
ifTrue:
["delimiter is on right -- match to the left"
stop := here - 1.
direction := -1.
closeDelimiter := leftDelimiters at: match]
ifFalse: ["no delimiters -- select a token"
direction := -1]].
level := 1.
[level > 0 and: [direction > 0
ifTrue: [here < string size]
ifFalse: [here > 1]]]
whileTrue:
[hereChar := string at: (here := here + direction).
match = 0
ifTrue: ["token scan goes left, then right"
hereChar tokenish
ifTrue: [here = 1
ifTrue:
[start := 1.
"go right if hit string start"
direction := 1]]
ifFalse: [direction < 0
ifTrue:
[start := here + 1.
"go right if hit non-token"
direction := 1]
ifFalse: [level := 0]]]
ifFalse: ["bracket match just counts nesting level"
hereChar = closeDelimiter
ifTrue: [level := level - 1"leaving nest"]
ifFalse: [hereChar = openDelimiter
ifTrue: [level := level + 1"entering deeper nest"]]]].
level > 0 ifTrue: ["in case ran off string end" here := here + direction].
direction > 0
ifTrue: [self selectFrom: start to: here - 1]
ifFalse: [self selectFrom: here + 1 to: stop]!
Item was changed:
----- Method: ParagraphEditor>>shiftEnclose: (in category 'editing keys') -----
shiftEnclose: characterStream
"Insert or remove bracket characters around the current selection.
Flushes typeahead."
| char left right startIndex stopIndex oldSelection which text |
char := sensor keyboard.
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)
emphasis: emphasisHere).
self selectFrom: startIndex+1 to: stopIndex].
^true!
More information about the Packages
mailing list