[squeak-dev] The Trunk: ShoutCore-mt.94.mcz
commits at source.squeak.org
commits at source.squeak.org
Sun Jul 3 09:58:31 UTC 2022
Marcel Taeumel uploaded a new version of ShoutCore to project The Trunk:
http://source.squeak.org/trunk/ShoutCore-mt.94.mcz
==================== Summary ====================
Name: ShoutCore-mt.94
Author: mt
Time: 3 July 2022, 11:58:30.475581 am
UUID: 6cf4d5f1-6ce3-1049-b8cd-08002edc3025
Ancestors: ShoutCore-mt.93
Adds preference to enforce italic typeset in comments. Enabled by default.
See http://lists.squeakfoundation.org/pipermail/squeak-dev/2022-May/220517.html
=============== Diff against ShoutCore-mt.93 ===============
Item was changed:
SHTextStyler subclass: #SHTextStylerST80
instanceVariableNames: 'classOrMetaClass workspace font parser formatAssignments environment sourceMap processedSourceMap pixelHeight attributesByPixelHeight parseAMethod context'
+ classVariableNames: 'EnforceItalicEmphasisInComments SyntaxHighlightingAsYouTypeAnsiAssignment SyntaxHighlightingAsYouTypeLeftArrowAssignment TextAttributesByPixelHeight'
- classVariableNames: '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 added:
+ ----- Method: SHTextStylerST80 class>>enforceItalicEmphasisInComments (in category 'preferences') -----
+ enforceItalicEmphasisInComments
+ <preference: 'Enforce Italic in Comments'
+ categoryList: #(browsing Accessibility)
+ description: 'When enabled, always typeset source-code comments in italic, regardless of the current UI theme. When disabled, depend on what the current UI theme prescribes as text attributes for such comments.'
+ type: #Boolean>
+
+ ^ EnforceItalicEmphasisInComments ifNil: [true]!
Item was added:
+ ----- Method: SHTextStylerST80 class>>enforceItalicEmphasisInComments: (in category 'preferences') -----
+ enforceItalicEmphasisInComments: aBooleanOrNil
+
+ EnforceItalicEmphasisInComments = aBooleanOrNil ifTrue: [^ self].
+ EnforceItalicEmphasisInComments := aBooleanOrNil.
+
+ self userInterfaceTheme apply. "Invalidate all styling caches."
+ !
Item was changed:
----- Method: SHTextStylerST80>>createTextAttributesForPixelHeight: (in category 'style table') -----
createTextAttributesForPixelHeight: aNumber
| result |
result := IdentityDictionary new.
result at: #default put: {}. "Required as fall-back for non-existing attributes."
self class themeProperties do: [:each |
| spec element emphasis font color |
element := each first.
spec := self userInterfaceTheme perform: element.
spec isArray ifFalse: [spec := {spec}]. "Support color-only hints."
color := spec first ifNotNil: [:colorSpec | Color colorFrom: colorSpec].
emphasis := spec at: 2 ifAbsent:[nil].
font := spec at: 3 ifAbsent: [nil].
+ (element == #comment and: [self class enforceItalicEmphasisInComments])
+ ifTrue: [
+ emphasis
+ ifNil: [emphasis := TextEmphasis italic]
+ ifNotNil: [
+ emphasis isArray
+ ifFalse: [emphasis := {emphasis}, {TextEmphasis italic}]
+ ifTrue: [emphasis := emphasis, {TextEmphasis italic}].
+ emphasis := emphasis asSet asArray "no double italic"]].
+
"Support for named text styles."
font isString ifTrue: [
| textStyle |
textStyle := TextStyle named: font.
font := textStyle ifNotNil: [textStyle fontOfSize: aNumber]].
(self createAttributeArrayForColor: color emphasis: emphasis font: font)
ifNotEmpty: [:attrArray | result at: element put: attrArray]].
+ ^ result!
- ^ result
- !
More information about the Squeak-dev
mailing list
|