[squeak-dev] The Trunk: Tools-nice.242.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Jun 11 20:31:41 UTC 2010


Nicolas Cellier uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-nice.242.mcz

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

Name: Tools-nice.242
Author: nice
Time: 11 June 2010, 10:31:17.225 pm
UUID: ddbb024d-97d3-5b40-9214-b6dc15b51b0b
Ancestors: Tools-mtf.241

Use String>>lines to handle any case of in image LF leakage

=============== Diff against Tools-mtf.241 ===============

Item was changed:
  ----- Method: PopUpMenu>>readKeyboard (in category 'basic control sequence') -----
  readKeyboard
  	"Keyboard support for menus. ESC will abort the menu, Space or CR
  	will select an item. Cursor up and cursor down will change the
  	selection. Any other key will either select an item whose label starts
  	with that character or select the next matching label.
  	Answer true if the menu should be closed and false otherwise."
  
  	| ch labels occurences |
  	ch := Sensor keyboard asciiValue.
  	(ch = 13 or: [ch = 32]) ifTrue: [^ true].
  	ch = 27 ifTrue: [self setSelection: 0. ^ true].
  	ch = 30
  		ifTrue:
  			[self setSelection: (selection <= 1
  				ifTrue: [self nItems]
  				ifFalse: [selection - 1])].
  	ch = 31 ifTrue: [self setSelection: selection \\ self nItems + 1].
  	ch := ch asCharacter asLowercase.
+ 	labels := labelString lines.
- 	labels := labelString findTokens: Character cr asString.
  	occurences := 0.
  	1 + selection to: selection + labels size do:
  		[:index |
  		| i | i := index - 1 \\ labels size + 1.
  		(labels at: i) withBlanksTrimmed first asLowercase = ch
  			ifTrue: [(occurences := occurences + 1) = 1 ifTrue: [self setSelection: i]]].
  	^ occurences = 1!

Item was changed:
  ----- Method: PopUpMenu>>startUpSegmented:withCaption:at: (in category 'basic control sequence') -----
  startUpSegmented: segmentHeight withCaption: captionOrNil at: location
  	"This menu is too big to fit comfortably on the screen.
  	Break it up into smaller chunks, and manage the relative indices.
  	Inspired by a special-case solution by Reinier van Loon."
  "
  (PopUpMenu labels: (String streamContents: [:s | 1 to: 100 do: [:i | s print: i; cr]. s skip: -1])
  		lines: (5 to: 100 by: 5)) startUpWithCaption: 'Give it a whirl...'.
  "
  	| nLines nLinesPer allLabels from to subset subLines index |
  	frame ifNil: [self computeForm].
+ 	allLabels := labelString lines.
- 	allLabels := labelString findTokens: Character cr asString.
  	nLines := allLabels size.
  	lineArray ifNil: [lineArray := Array new].
  	nLinesPer := segmentHeight // marker height - 3.
  	from := 1.
  	[ true ] whileTrue:
  		[to := (from + nLinesPer) min: nLines.
  		subset := allLabels copyFrom: from to: to.
  		subset add: (to = nLines ifTrue: ['start over...' translated] ifFalse: ['more...' translated])
  			before: subset first.
  		subLines := lineArray select: [:n | n >= from] thenCollect: [:n | n - (from-1) + 1].
  		subLines := (Array with: 1) , subLines.
  		index := (PopUpMenu labels: subset asStringWithCr lines: subLines)
  					startUpWithCaption: captionOrNil at: location.
  		index = 1
  			ifTrue: [from := to + 1.
  					from > nLines ifTrue: [ from := 1 ]]
  			ifFalse: [index = 0 ifTrue: [^ 0].
  					^ from + index - 2]]!

Item was changed:
  ----- Method: CustomMenu>>labels:font:lines: (in category 'construction') -----
  labels: aString font: aFont lines: anArrayOrNil
  	"This method allows the receiver to accept old-style SelectionMenu creation messages. It should be used only for backward compatibility during the MVC-to-Morphic transition. New code should be written using the other menu construction protocol such as addList:."
  
  	| labelList linesArray |
+ 	labelList := aString lines asArray.
- 	labelList := (aString findTokens: String cr) asArray.
  	anArrayOrNil
  		ifNil: [linesArray := #()]
  		ifNotNil: [linesArray := anArrayOrNil].
  	1 to: labelList size do: [:i |
  		self add: (labelList at: i) action: (labelList at: i).
  		(linesArray includes: i) ifTrue: [self addLine]].
  	font ifNotNil: [font := aFont].
  !

Item was changed:
  ----- Method: PopUpMenu>>startUpSegmented:withCaption:at:allowKeyboard: (in category 'basic control sequence') -----
  startUpSegmented: segmentHeight withCaption: captionOrNil at: location allowKeyboard: aBoolean
  	"This menu is too big to fit comfortably on the screen.
  	Break it up into smaller chunks, and manage the relative indices.
  	Inspired by a special-case solution by Reinier van Loon.  The boolean parameter indicates whether the menu should be given keyboard focus (if in morphic)"
  
  "
  (PopUpMenu labels: (String streamContents: [:s | 1 to: 100 do: [:i | s print: i; cr]. s skip: -1])
  		lines: (5 to: 100 by: 5)) startUpWithCaption: 'Give it a whirl...'.
  "
  	| nLines nLinesPer allLabels from to subset subLines index |
  	frame ifNil: [self computeForm].
+ 	allLabels := labelString lines.
- 	allLabels := labelString findTokens: Character cr asString.
  	nLines := allLabels size.
  	lineArray ifNil: [lineArray := Array new].
  	nLinesPer := segmentHeight // marker height - 3.
  	from := 1.
  	[ true ] whileTrue:
  		[to := (from + nLinesPer) min: nLines.
  		subset := allLabels copyFrom: from to: to.
  		subset add: (to = nLines ifTrue: ['start over...' translated] ifFalse: ['more...' translated])
  			before: subset first.
  		subLines := lineArray select: [:n | n >= from] thenCollect: [:n | n - (from-1) + 1].
  		subLines := (Array with: 1) , subLines.
  		index := (PopUpMenu labels: subset asStringWithCr lines: subLines)
  					startUpWithCaption: captionOrNil at: location allowKeyboard: aBoolean.
  		index = 1
  			ifTrue: [from := to + 1.
  					from > nLines ifTrue: [ from := 1 ]]
  			ifFalse: [index = 0 ifTrue: [^ 0].
  					^ from + index - 2]]!

Item was changed:
  ----- Method: CustomMenu>>labels:lines:selections: (in category 'construction') -----
  labels: labelList lines: linesArray selections: selectionsArray
  	"This method allows the receiver to accept old-style SelectionMenu creation messages. It should be used only for backward compatibility during the MVC-to-Morphic transition. New code should be written using the other menu construction protocol such as addList:."
  	"Labels can be either a sting with embedded crs, or a collection of strings."
  
  	| labelArray |
  	labelList isString
+ 		ifTrue: [labelArray := labelList lines]
- 		ifTrue: [labelArray := labelList findTokens: String cr]
  		ifFalse: [labelArray := labelList].
  	1 to: labelArray size do: [:i |
  		self add: (labelArray at: i) action: (selectionsArray at: i).
  		(linesArray includes: i) ifTrue: [self addLine]].
  !




More information about the Squeak-dev mailing list