[squeak-dev] The Trunk: Morphic-eem.1322.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Feb 14 19:59:49 UTC 2017
Eliot Miranda uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-eem.1322.mcz
==================== Summary ====================
Name: Morphic-eem.1322
Author: eem
Time: 14 February 2017, 11:57:56.157607 am
UUID: 0e0bfc65-dd95-4b5f-a552-7bd3cb6b096a
Ancestors: Morphic-topa.1321
Preserve text emphasis when doing inOutdent: (tab/shift-tab). Comment out the unused guard against too much outdenting, insrtead of doing the search and then ignoring the result.
=============== Diff against Morphic-topa.1321 ===============
Item was changed:
----- Method: TextEditor>>inOutdent:delta: (in category 'editing keys') -----
inOutdent: aKeyboardEvent 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" numLines oldText newText newSize |
- | realStart realStop lines startLine stopLine start stop adjustStart indentation numLines oldString newString newSize |
"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:
[morph flash]
ifFalse:
[self replaceSelectionWith: Character tab asText.
self selectAt: realStart + 1].
^true].
lines := paragraph lines.
startLine := paragraph lineIndexOfCharacterIndex: realStart.
"start on a real line, not a wrapped line"
[startLine = 1 or: [CharacterSet crlf includes: (paragraph string at: (lines at: startLine-1) last)]] whileFalse: [startLine := startLine - 1].
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:
- indentation := (startLine to: stopLine) inject: 1000 into:
[:m :l |
m min: (paragraph indentationOfLineIndex: l ifBlank: [:tabs | 1000])].
+ indentation + delta <= 0 ifTrue: [^false]."
- indentation + delta <= 0 ifTrue: ["^false"].
numLines := stopLine + 1 - startLine.
+ oldText := paragraph text copyFrom: start to: stop.
+ newText := oldText species new: oldText size + ((numLines * delta) max: 0).
- oldString := paragraph string copyFrom: start to: stop.
- newString := oldString species new: oldString size + ((numLines * delta) max: 0).
"Do the actual work"
newSize := 0.
delta > 0
ifTrue: [| tabs |
+ tabs := oldText species new: delta withAll: Character tab.
+ oldText string lineIndicesDo: [:startL :endWithoutDelimiters :endL |
+ startL < endWithoutDelimiters ifTrue: [newText replaceFrom: 1 + newSize to: (newSize := newSize + delta) with: tabs startingAt: 1].
+ newText replaceFrom: 1 + newSize to: (newSize := 1 + newSize + endL - startL) with: oldText startingAt: startL]]
- tabs := oldString species new: delta withAll: Character tab.
- oldString lineIndicesDo: [:startL :endWithoutDelimiters :endL |
- startL < endWithoutDelimiters ifTrue: [newString replaceFrom: 1 + newSize to: (newSize := newSize + delta) with: tabs startingAt: 1].
- newString replaceFrom: 1 + newSize to: (newSize := 1 + newSize + endL - startL) with: oldString startingAt: startL]]
ifFalse: [| tab |
tab := Character tab.
+ oldText string lineIndicesDo: [:startL :endWithoutDelimiters :endL |
- oldString lineIndicesDo: [:startL :endWithoutDelimiters :endL |
| i |
i := 0.
+ [i + delta < 0 and: [ i + startL <= endWithoutDelimiters and: [(oldText at: i + startL) == tab]]] whileTrue: [i := i + 1].
+ newText replaceFrom: 1 + newSize to: (newSize := 1 + newSize + endL - (i + startL)) with: oldText startingAt: i + startL]].
+ newSize < newText size ifTrue: [newText := newText copyFrom: 1 to: newSize].
- [i + delta < 0 and: [ i + startL <= endWithoutDelimiters and: [(oldString at: i + startL) == tab]]] whileTrue: [i := i + 1].
- newString replaceFrom: 1 + newSize to: (newSize := 1 + newSize + endL - (i + startL)) with: oldString startingAt: i + startL]].
- newSize < newString size ifTrue: [newString := newString copyFrom: 1 to: newSize].
"Adjust the range that will be highlighted later"
adjustStart ifTrue: [realStart := (realStart + delta) max: start].
+ realStop := realStop + newSize - oldText size.
- realStop := realStop + newSize - oldString size.
"Replace selection"
self selectInvisiblyFrom: start to: stop.
+ self replaceSelectionWith: newText.
- self replaceSelectionWith: newString asText.
self selectFrom: realStart to: realStop. "highlight only the original range"
^ true!
More information about the Squeak-dev
mailing list
|