-
-
Notifications
You must be signed in to change notification settings - Fork 420
#19461 Rework Shout Preferences #19464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
belaroesener
wants to merge
5
commits into
pharo-project:Pharo14
Choose a base branch
from
belaroesener:improvement/rework-shout-preferences
base: Pharo14
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
df02498
Rework shout preferences
belaroesener bca4f74
Clean up
belaroesener f3bd8de
Update SettingBrowser when copying the Custom style from the current one
belaroesener 6a1969a
Fix emphasis 'bold italic'
belaroesener e4ea4e1
Correct typo
belaroesener File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| Extension { #name : 'SHCustomStyleElement' } | ||
|
|
||
| { #category : '*STON-Extensions' } | ||
| SHCustomStyleElement >> stonOn: stonWriter [ | ||
|
|
||
| stonWriter writeMap: { | ||
| (#group -> group). | ||
| (#color -> self color). | ||
| (#emphasis -> self emphasis) } asDictionary | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,190 @@ | ||
| " | ||
| I store all the style information associated with 'Custom' style | ||
| " | ||
| Class { | ||
| #name : 'SHCustomStyle', | ||
| #superclass : 'Object', | ||
| #classInstVars : [ | ||
| 'groups' | ||
| ], | ||
| #category : 'Shout-Styling', | ||
| #package : 'Shout', | ||
| #tag : 'Styling' | ||
| } | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyle class >> color: aColor forGroup: aGroupName [ | ||
|
|
||
| (groups at: aGroupName) at: #color put: aColor. | ||
| SHPreferences cutomStyleChanged | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyle class >> colorForGroup: groupName [ | ||
|
|
||
| ^ (groups at: groupName) at: #color | ||
| ] | ||
|
|
||
| { #category : 'class initialization' } | ||
| SHCustomStyle class >> copyFromCurrentStyle [ | ||
|
|
||
| SHRBTextStyler styleTable do: [ :row | | ||
| | token | | ||
| token := row first. | ||
| groups | ||
| detect: [ :entry | token = (entry at: #tokens) first ] | ||
| ifFound: [ :entry | | ||
| | colorDesc emphasis | | ||
| colorDesc := row second. | ||
| emphasis := #normal. | ||
| row size >= 3 ifTrue: [ emphasis := row third ]. | ||
| (emphasis isKindOf: Symbol) ifFalse: [ | ||
| emphasis := (' ' join: emphasis) asSymbol ]. | ||
| entry at: #color put: (Color colorFrom: colorDesc). | ||
| entry at: #emphasis put: emphasis ] ]. | ||
| SettingBrowser refreshAllSettingBrowsers | ||
| ] | ||
|
|
||
| { #category : 'private' } | ||
| SHCustomStyle class >> defaultColor [ | ||
|
|
||
| ^ Color r: 0.0 g: 0.75 b: 1.0 | ||
| ] | ||
|
|
||
| { #category : 'private' } | ||
| SHCustomStyle class >> defaultEmphasis [ | ||
|
|
||
| ^ #normal | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyle class >> emphasis: anEmphasis forGroup: aGroupName [ | ||
|
|
||
| (groups at: aGroupName) at: #emphasis put: anEmphasis. | ||
| SHPreferences cutomStyleChanged | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyle class >> emphasisForGroup: groupName [ | ||
|
|
||
| ^ (groups at: groupName) at: #emphasis | ||
| ] | ||
|
|
||
| { #category : 'private' } | ||
| SHCustomStyle class >> groupDefaults [ | ||
|
|
||
| ^ Dictionary newFrom: { | ||
| (#default -> { | ||
| (#name -> #default). | ||
| (#tokens -> #( #default )). | ||
| (#label -> 'Default'). | ||
| (#description -> 'Default style') } asDictionary). | ||
| (#reservedWords -> { | ||
| (#name -> #reservedWords). | ||
| (#tokens -> #( #self #super #true #false #nil #thisContext )). | ||
| (#label -> 'Reserved words'). | ||
| (#description -> 'Reserved words of the Smalltalk language') } | ||
| asDictionary). | ||
| (#primitiveTypes -> { | ||
| (#name -> #primitiveTypes). | ||
| (#description -> 'Literal data'). | ||
| (#tokens -> #( #character #number #symbol #string )). | ||
| (#label -> 'Primitive types') } asDictionary). | ||
| (#selectorPatterns -> { | ||
| (#name -> #selectorPatterns). | ||
| (#tokens -> #( #patternSelector )). | ||
| (#label -> 'Selector Patterns'). | ||
| (#description -> 'Selector patterns in method pane') } | ||
| asDictionary). | ||
| (#messageSends -> { | ||
| (#name -> #messageSends). | ||
| (#tokens -> #( selector #incompleteSelector )). | ||
| (#label -> 'Message sends') } asDictionary). | ||
| (#args -> { | ||
| (#name -> #args). | ||
| (#label -> 'Parameters'). | ||
| (#description | ||
| -> 'Parameters in patterns, message sends, and blocks'). | ||
| (#tokens | ||
| -> #( #patternArg #blockPatternArg #blockArg #argument )) } | ||
| asDictionary). | ||
| (#variable -> { | ||
| (#name -> #variable). | ||
| (#label -> 'Variable'). | ||
| (#description -> 'Temporary variable'). | ||
| (#tokens | ||
| -> | ||
| #( #blockTempVar #blockPatternTempVar #tempVar #patternTempVar | ||
| #incompleteIdentifier )) } asDictionary). | ||
| (#instanceVar -> { | ||
| (#name -> #instanceVar). | ||
| (#label -> 'Instance/class variables'). | ||
| (#description -> 'References to instance and class variables'). | ||
| (#tokens -> #( #instVar #classVar )) } asDictionary). | ||
| (#globalVar -> { | ||
| (#name -> #globalVar). | ||
| (#label -> 'Global variables'). | ||
| (#description | ||
| -> 'References to global variables, including classes'). | ||
| (#tokens -> #( #globalVar #poolConstant )) } asDictionary). | ||
| (#comment -> { | ||
| (#name -> #comment). | ||
| (#label -> 'Comments'). | ||
| (#descripiton -> 'Comments in code pane'). | ||
| (#tokens -> #( #comment )) } asDictionary). | ||
| (#error -> { | ||
| (#name -> #error). | ||
| (#label -> 'Syntactic error'). | ||
| (#description -> 'Invalid and undefined code'). | ||
| (#tokens | ||
| -> #( #invalid #undefinedSelector #undefinedIdentifier )) } | ||
| asDictionary). | ||
| (#syntax -> { | ||
| (#name -> #syntax). | ||
| (#label -> 'Syntax'). | ||
| (#description -> 'Any other syntactic element'). | ||
| (#tokens | ||
| -> | ||
| #( #return #blockArgColon #parenthesis #parenthesis1 | ||
| #parenthesis2 #parenthesis3 #parenthesis4 #parenthesis5 | ||
| #parenthesis6 #parenthesis7 #block #block1 #block2 #block3 | ||
| #block4 #block5 #block6 #block7 #byteArrayStart | ||
| #byteArrayEnd #byteArrayStart1 #byteArrayEnd1 | ||
| #brace #brace1 #brace2 #brace3 #brace4 #brace5 #brace6 | ||
| #brace7 #cascadeSeparator #statementSeparator | ||
| #methodTempBar #blockTempBar #blockArgsBar )) } | ||
| asDictionary) } | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyle class >> groups [ | ||
|
|
||
| ^ groups ifNil: [ | ||
| self initialize. | ||
| groups ] | ||
| ] | ||
|
|
||
| { #category : 'class initialization' } | ||
| SHCustomStyle class >> initialize [ | ||
|
|
||
| groups := self groupDefaults. | ||
| groups do: [ :entry | | ||
| entry at: #color put: self defaultColor. | ||
| entry at: #emphasis put: self defaultEmphasis ]. | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyle class >> styleTable [ | ||
|
|
||
| ^ groups flatCollect: [ :entry | | ||
| (entry at: #tokens) collect: [ :token | | ||
| | emphasis | | ||
| emphasis := entry at: #emphasis. | ||
| (emphasis includes: Character space) ifTrue: [ | ||
| emphasis := (emphasis substrings: ' ') collect: [ :str | | ||
| str asSymbol ] ]. | ||
| { | ||
| token. | ||
| (entry at: #color). | ||
| emphasis } ] ] | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| " | ||
| I am a style element of the custom style. | ||
|
|
||
| I am just a proxy object for one of the groups stored in `SHCustomStyleSettings` | ||
| " | ||
| Class { | ||
| #name : 'SHCustomStyleElement', | ||
| #superclass : 'Object', | ||
| #instVars : [ | ||
| 'group' | ||
| ], | ||
| #category : 'Shout-Styling', | ||
| #package : 'Shout', | ||
| #tag : 'Styling' | ||
| } | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyleElement class >> group: groupName [ | ||
|
|
||
| ^ self basicNew | ||
| group: groupName; | ||
| yourself | ||
| ] | ||
|
|
||
| { #category : 'instance creation' } | ||
| SHCustomStyleElement class >> new [ | ||
| "Please use #group: to create an instance" | ||
| self shouldNotImplement | ||
| ] | ||
|
|
||
| { #category : 'settings' } | ||
| SHCustomStyleElement class >> settingInputWidgetForNode: aSettingNode [ | ||
|
|
||
| | theme | | ||
| theme := UITheme builder. | ||
| ^ theme newRow: { | ||
| (theme | ||
| newColorChooserFor: aSettingNode realValue | ||
| getColor: #color | ||
| setColor: #color: | ||
| help: 'Choose token color'). | ||
| ((theme | ||
| newDropListFor: aSettingNode realValue | ||
| list: #( #bold #italic #normal #'bold italic' ) | ||
| getSelected: #emphasis | ||
| setSelected: #emphasis: | ||
| getEnabled: nil | ||
| useIndex: false | ||
| help: 'Choose token emphasis') | ||
| hResizing: #rigid; | ||
| width: 100) } | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyleElement >> color [ | ||
|
|
||
| ^ SHCustomStyle colorForGroup: group | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyleElement >> color: aColor [ | ||
|
|
||
| ^ SHCustomStyle color: aColor forGroup: group | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyleElement >> emphasis [ | ||
|
|
||
| ^ SHCustomStyle emphasisForGroup: group | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyleElement >> emphasis: anEmphasis [ | ||
|
|
||
| ^ SHCustomStyle emphasis: anEmphasis forGroup: group | ||
| ] | ||
|
|
||
| { #category : 'accessing' } | ||
| SHCustomStyleElement >> group: aString [ | ||
| group := aString | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like a typo