[squeak-dev] The Trunk: ST80-nice.95.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Feb 8 11:35:48 UTC 2010
Nicolas Cellier uploaded a new version of ST80 to project The Trunk:
http://source.squeak.org/trunk/ST80-nice.95.mcz
==================== Summary ====================
Name: ST80-nice.95
Author: nice
Time: 8 February 2010, 12:35:33.95 pm
UUID: c0f59d7d-3015-5148-8a7c-c65867745c77
Ancestors: ST80-dtl.94
make cr-indentation work in case of LF
clean up dead code in inOutdent:delta:
Note: currently, shift+cmd+L will outdent even if line with min outdent is zero. his was the old behaviour, but we can change it by uncommenting the "^false"
=============== Diff against ST80-dtl.94 ===============
Item was changed:
----- Method: ParagraphEditor>>crWithIndent: (in category 'typing/selecting keys') -----
crWithIndent: characterStream
"Replace the current text selection with CR followed by as many tabs
as on the current line (+/- bracket count) -- initiated by Shift-Return."
| char s i tabCount |
sensor keyboard. "flush character"
s := paragraph string.
i := self stopIndex.
tabCount := 0.
+ [(i := i-1) > 0 and: [(char := s at: i) ~= Character cr and: [char ~= Character lf]]]
- [(i := i-1) > 0 and: [(char := s at: i) ~= Character cr]]
whileTrue: "Count tabs and brackets (but not a leading bracket)"
[(char = Character tab and: [i < s size and: [(s at: i+1) ~= $[ ]]) ifTrue: [tabCount := tabCount + 1].
char = $[ ifTrue: [tabCount := tabCount + 1].
char = $] ifTrue: [tabCount := tabCount - 1]].
characterStream crtab: tabCount. "Now inject CR with tabCount tabs"
^ false!
Item was changed:
----- Method: ParagraphEditor>>selectedSymbol (in category 'menu messages') -----
selectedSymbol
"Return the currently selected symbol, or nil if none. Spaces, tabs and returns are ignored"
| aString |
self hasCaret ifTrue: [^ nil].
aString := self selection string.
aString isOctetString ifTrue: [aString := aString asOctetString].
+ aString := self selection string copyWithoutAll: CharacterSet separators.
- aString := aString copyWithoutAll:
- {Character space. Character cr. Character lf. Character tab}.
aString size == 0 ifTrue: [^ nil].
Symbol hasInterned: aString ifTrue: [:sym | ^ sym].
^ nil!
Item was changed:
+ SystemOrganization addCategory: #'ST80-Controllers'!
SystemOrganization addCategory: #'ST80-Editors'!
SystemOrganization addCategory: #'ST80-Framework'!
- SystemOrganization addCategory: #'ST80-Controllers'!
SystemOrganization addCategory: #'ST80-Menus'!
SystemOrganization addCategory: #'ST80-Menus-Tests'!
SystemOrganization addCategory: #'ST80-Paths'!
SystemOrganization addCategory: #'ST80-Pluggable Views'!
SystemOrganization addCategory: #'ST80-Support'!
SystemOrganization addCategory: #'ST80-Support-Tests'!
SystemOrganization addCategory: #'ST80-Symbols'!
SystemOrganization addCategory: #'ST80-Views'!
Item was changed:
----- Method: ParagraphEditor>>inOutdent:delta: (in category 'editing keys') -----
inOutdent: characterStream delta: delta
"Add/remove a tab at the front of every line occupied by the selection. Flushes typeahead. Derived from work by Larry Tesler back in December 1985. Now triggered by Cmd-L and Cmd-R. 2/29/96 sw"
| realStart realStop lines startLine stopLine start stop adjustStart indentation size numLines inStream newString outStream |
-
sensor keyboard. "Flush typeahead"
"Operate on entire lines, but remember the real selection for re-highlighting later"
realStart := self startIndex.
realStop := self stopIndex - 1.
"Special case a caret on a line of its own, including weird case at end of paragraph"
(realStart > realStop and:
[realStart < 2 or: [(paragraph string at: realStart - 1) == Character cr or: [(paragraph string at: realStart - 1) == Character lf]]])
ifTrue:
[delta < 0
ifTrue:
[view flash]
ifFalse:
[self replaceSelectionWith: Character tab asSymbol asText.
self selectAt: realStart + 1].
+ ^true].
- ^ true].
lines := paragraph lines.
startLine := paragraph lineIndexOfCharacterIndex: realStart.
stopLine := paragraph lineIndexOfCharacterIndex: (realStart max: realStop).
start := (lines at: startLine) first.
stop := (lines at: stopLine) last.
"Pin the start of highlighting unless the selection starts a line"
adjustStart := realStart > start.
"Find the indentation of the least-indented non-blank line; never outdent more"
indentation := (startLine to: stopLine) inject: 1000 into:
[:m :l |
+ m min: (paragraph indentationOfLineIndex: l ifBlank: [:tabs | 1000])].
+ indentation + delta <= 0 ifTrue: ["^false"].
- m min: (paragraph indentationOfLineIndex: l ifBlank: [:tabs | 1000])].
size := stop + 1 - start.
numLines := stopLine + 1 - startLine.
inStream := ReadStream on: paragraph string from: start to: stop.
+ newString := String new: size + ((numLines * delta) max: 0).
+ outStream := WriteStream on: newString.
- newString := WideString new: size + ((numLines * delta) max: 0).
- outStream := ReadWriteStream on: newString.
"This subroutine does the actual work"
self indent: delta fromStream: inStream toStream: outStream.
+ newString := outStream contents.
"Adjust the range that will be highlighted later"
adjustStart ifTrue: [realStart := (realStart + delta) max: start].
+ realStop := realStop + newString size - size.
- realStop := realStop + outStream position - size.
+ "Replace selection"
+ self selectInvisiblyFrom: start to: stop.
+ self replaceSelectionWith: newString asText.
- "Prepare for another iteration"
- indentation := indentation + delta.
- size := outStream position.
- inStream := outStream setFrom: 1 to: size.
-
- outStream == nil
- ifTrue: "tried to outdent but some line(s) were already left flush"
- [view flash]
- ifFalse:
- [self selectInvisiblyFrom: start to: stop.
- size = newString size ifFalse: [newString := outStream contents].
- self replaceSelectionWith: newString asText].
self selectFrom: realStart to: realStop. "highlight only the original range"
^ true!
More information about the Squeak-dev
mailing list
|