[squeak-dev] The Trunk: ShoutCore-mt.90.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Nov 25 15:45:50 UTC 2021

Marcel Taeumel uploaded a new version of ShoutCore to project The Trunk:

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

Name: ShoutCore-mt.90
Author: mt
Time: 25 November 2021, 4:45:49.823354 pm
UUID: b976028e-e63c-5c40-b0d6-1ae06b21ca6a
Ancestors: ShoutCore-ct.88, ShoutCore-ct.89

Uses TextStyler abstraction to control #syntaxHighlightingAsYouType. This makes this preference actually functional again. :-)

Thanks to Christoph (ct) for the idea!

When the preference is toggled, try to update all open code tools automatically.

Also merges ShoutCore-ct.89, which fixes #unload in Shout.

=============== Diff against ShoutCore-mt.85 ===============

Item was changed:
  SHTextStyler subclass: #SHTextStylerST80
  	instanceVariableNames: 'classOrMetaClass workspace font parser formatAssignments environment sourceMap processedSourceMap pixelHeight attributesByPixelHeight parseAMethod context'
+ 	classVariableNames: 'SyntaxHighlightingAsYouTypeAnsiAssignment SyntaxHighlightingAsYouTypeLeftArrowAssignment TextAttributesByPixelHeight'
- 	classVariableNames: 'SyntaxHighlightingAsYouType SyntaxHighlightingAsYouTypeAnsiAssignment SyntaxHighlightingAsYouTypeLeftArrowAssignment TextAttributesByPixelHeight'
  	poolDictionaries: ''
  	category: 'ShoutCore-Styling'!
  !SHTextStylerST80 commentStamp: 'tween 8/27/2004 10:55' prior: 0!
  I style Smalltalk methods and expressions.
  My 'styleTable' class instance var holds an array ofArrays which control how each token is styled/coloured. See my defaultStyleTable class method for its structure.
  My styleTable can be changed by either modifying the defaultStyleTable class method and then executing SHTextStylerST80 initialize ; or by giving me a new styleTable through my #styleTable: class method.
  My 'textAttributesByPixelSize' class instance var contains a dictionary of dictionaries.
  	The key is a pixelSize and the value a Dictionary from token type Symbol to TextAttribute array.
  	It is created/maintained automatically.
  I also install these 3 preferences when my class initialize method is executed....
  	#syntaxHighlightingAsYouType  - controls whether methods are styled in browsers
  	#syntaxHighlightingAsYouTypeAnsiAssignment - controls whether assignments are formatted to be :=
  	#syntaxHighlightingAsYouTypeLeftArrowAssignment - controls whether assignments are formatted to be _
  I reimplement #unstyledTextFrom: so that TextActions are preserved in the unstyled text 

Item was changed:
  ----- Method: SHTextStylerST80 class>>syntaxHighlightingAsYouType (in category 'preferences') -----
  	<preference: 'syntaxHighlightingAsYouType'
  		category: 'browsing'
  		description: 'Enable, or disable, Shout - Syntax Highlighting As You Type. When enabled, code in Browsers and Workspaces is styled to reveal its syntactic structure. When the code is changed (by typing some characters, for example), the styling is changed so that it remains in sync with the modified code.'
  		type: #Boolean>
+ 	^ (TextStyler for: #Smalltalk) = self!
- 	^SyntaxHighlightingAsYouType ifNil: [true]!

Item was changed:
  ----- Method: SHTextStylerST80 class>>syntaxHighlightingAsYouType: (in category 'preferences') -----
  syntaxHighlightingAsYouType: aBoolean
+ 	self syntaxHighlightingAsYouType = aBoolean ifTrue: [^ self].
+ 	TextStyler
+ 		default: (aBoolean ifTrue: [self] ifFalse: [nil])
+ 		for: #Smalltalk.
+ 	"Update known tools that show Smalltalk source code."
+ 	(self environment classNamed: #PluggableTextMorphPlus) ifNotNil: [:widgetClass |
+ 			| stylerClass toolClass workspaceClass |
+ 			stylerClass := TextStyler for: #Smalltalk.
+ 			toolClass := self environment classNamed: #CodeHolder.
+ 			workspaceClass := self environment classNamed: #Workspace. "Actually a StringHolder but a code tool."
+ 			widgetClass allInstancesDo: [:widget |
+ 				(((widget model isKindOf: toolClass) or: [widget model isKindOf: workspaceClass])
+ 					and: [widget getTextSelector ~= #annotation])
+ 						ifTrue: [
+ 							widget styler: (stylerClass ifNotNil: [:c | c new view: widget]).
+ 							widget setText: widget text asString "drop text attributes" ]]].!
- 	SyntaxHighlightingAsYouType := aBoolean.!

Item was added:
+ ----- Method: SHTextStylerST80 class>>unload (in category 'class initialization') -----
+ unload
+ 	TextStyler unregister: self for: #Smalltalk.!

More information about the Squeak-dev mailing list