[squeak-dev] The Trunk: ST80-nice.96.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Feb 8 16:49:17 UTC 2010

Nicolas Cellier uploaded a new version of ST80 to project The Trunk:

==================== Summary ====================

Name: ST80-nice.96
Author: nice
Time: 8 February 2010, 5:48:45.026 pm
UUID: 7a5e9f47-34ed-5347-9d93-15207baf9b66
Ancestors: ST80-nice.95

Let outdent work when selection starts on a wrapped line.
Do not let indent insert a tab in the middle of a line when selection starts on a wrapped line.

=============== Diff against ST80-nice.95 ===============

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]]])
  			[delta < 0
  					[view flash]
  					[self replaceSelectionWith: Character tab asSymbol asText.
  					self selectAt: realStart + 1].
  	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:
  		[:m :l |
  		m min: (paragraph indentationOfLineIndex: l ifBlank: [:tabs | 1000])].
  	indentation + delta <= 0 ifTrue: ["^false"].
  	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.
  	"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.
  	"Replace selection"
  	self selectInvisiblyFrom: start to: stop.
  	self replaceSelectionWith: newString asText.
  	self selectFrom: realStart to: realStop. 	"highlight only the original range"
  	^ true!

More information about the Squeak-dev mailing list