UserPreferences.st
author fm
Mon, 26 Oct 2009 17:19:51 +0100
changeset 12357 0d668fb50783
parent 12348 0b5b83521c0c
child 12391 35ee0cb7fd56
permissions -rw-r--r--
added: #additionalClassAttributesFor: changed: #classNamesAndAttributes_code_ignoreOldEntries:ignoreOldDefinition:

"
 COPYRIGHT (c) 1998 by eXept Software AG
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libbasic' }"

IdentityDictionary subclass:#UserPreferences
	instanceVariableNames:''
	classVariableNames:'CurrentPreferences DefaultPreferences'
	poolDictionaries:''
	category:'System-Support'
!

!UserPreferences class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1998 by eXept Software AG
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

!

documentation
"
    A Dictionary for user preference values.
    For non-existing keys, either a defaultValue (false),
    or the value from a defaultDictionary is returned.

    This will eventually keep track of ALL user preferences.
    For now, not all preferences are found here -
    (some of them are currently spread over the system - especially, in Class-Variables)
    - but this will change over time.

    If more prefs are added, think about adding a corresponding UI to the SystemSettingsDialog too.

    UserPreferences current at:#foo
"
! !

!UserPreferences class methodsFor:'initialization'!

initializeDefaultPreferences
    DefaultPreferences := self new.

    Color isNil "Smalltalk isStandAloneApp" ifTrue:[
        ^ self.
    ].

    #(
        #useNewChangesBrowser           false
        #useNewInspector                false
        #showClockInLauncher            true

        #autoFormatting                 false
        #syntaxColoring                 true
        #fullSelectorCheck              false

        #defaultSyntaxColor             (Color black)
        #defaultSyntaxEmphasis          normal

        #errorColor                     (Color red)

        "/ #commentColor                   (Color 12.5 12.5 100)
        "/ #constantColor                  (Color 25 0 0)
        #commentEmphasis                normal

        #methodSelectorEmphasis         bold
        #selectorEmphasis               bold
        #unimplementedSelectorColor     (Color red)
        #unimplementedSelectorEmphasis  normal

"/ I prefer red-underwave over red identifier ...
"/        #badIdentifierColor             (Color red)
        #instVarIdentifierColor         (Color 33 0 33)


"/        #jsKeywordColor                 (Color black)
        #jsKeywordEmphasis              bold
        #jsKeywordColor                 (Color 33 33 0)

        #controlFlowSelectorColor       (Color 0 0 100)
        #commentColor                   (Color 0 50 0)
        #constantColor                  (Color 64 8 8)

     ) pairWiseDo:[:k :v |
        DefaultPreferences at:k put:(v decodeAsLiteralArray).
    ].

    "/ I prefer red-underwave over red identifier ...
    DefaultPreferences at:#badIdentifierEmphasis put:(Array with:#underwave with:(#underlineColor->Color red)).

    "
     self initializeDefaultPreferences
    "

    "Modified: / 07-12-2006 / 17:08:38 / cg"
! !

!UserPreferences class methodsFor:'accessing'!

current
    CurrentPreferences isNil ifTrue:[
	CurrentPreferences := self new.
	CurrentPreferences addAll:self default.
	CurrentPreferences flyByHelpSettingChanged.
    ].
    ^ CurrentPreferences.

    "
     CurrentPreferences := nil
    "
!

default
    DefaultPreferences isNil ifTrue:[
	self initializeDefaultPreferences
    ].
    ^ DefaultPreferences.

    "
     DefaultPreferences := nil.
    "
!

reset
    "resets the CurrentPreferences to its default values"

    CurrentPreferences := nil
!

syntaxColorKeys
    "returns the keys of syntax color items"

    ^#(
	argumentIdentifierColor
	  argumentIdentifierEmphasis
	booleanConstantColor
	  booleanConstantEmphasis
	bracketColor
	  bracketEmphasis
	classVariableIdentifierColor
	  classVariableIdentifierEmphasis
	constantColor
	  constantEmphasis
	controlFlowSelectorColor
	  controlFlowSelectorEmphasis
	commentColor
	  commentEmphasis
	defaultSyntaxColor
	  defaultSyntaxEmphasis
	errorColor
	globalIdentifierColor
	  globalIdentifierEmphasis
	globalClassIdentifierColor
	  globalClassIdentifierEmphasis
	hereColor
	  hereEmphasis
	identifierColor
	  identifierEmphasis
	instVarIdentifierColor
	  instVarIdentifierEmphasis
	localIdentifierColor
	  localIdentifierEmphasis
	methodSelectorColor
	  methodSelectorEmphasis
	poolVariableIdentifierColor
	  poolVariableIdentifierEmphasis
	returnColor
	  returnEmphasis
	selectorColor
	  selectorEmphasis
	selfColor
	  selfEmphasis
	stringColor
	  stringEmphasis
	superColor
	  superEmphasis
	symbolColor
	  symbolEmphasis
	thisContextColor
	  thisContextEmphasis
	unknownIdentifierColor
	  unknownIdentifierEmphasis
	unimplementedSelectorColor
	  unimplementedSelectorEmphasis
    )

    "Modified: / 08-09-2006 / 16:06:54 / cg"
!

syntaxColorNames
    "returns the syntax colors for the settings in the launcher"

"/ warning, the strings below are presented to the user
"/ as the syntax-color boxes comboList - however, they are
"/ also used (without separators) as key into myself.
"/ Therefore, do not change the strings below.
"/ I know - this is bad coding ....

^#(
'Argument Identifier Color'
'Boolean Constant Color'
'Bracket Color'
'Class Variable Identifier Color'
'Constant Color'
'Control Flow Selector Color'
'Comment Color'
'Global Identifier Color'
'Global Class Identifier Color'
'Here Color'
'Identifier Color'
'InstVar Identifier Color'
'Local Identifier Color'
'Method Selector Color'
'Pool Variable Identifier Color'
'Return Color'
'Selector Color'
'Self Color'
'String Color'
'Super Color'
'Symbol Color'
'This Context Color'
'Unknown Identifier Color'
'Unimplemented Selector Color'
)

    "Modified: / 08-09-2006 / 16:07:36 / cg"
! !

!UserPreferences class methodsFor:'accessing defaultPrefs'!

defaultSettingsFilename
    ^ 'settings.stx'
!

fileBrowserClass
    ^ self current fileBrowserClass

    "
     UserPreferences fileBrowserClass
    "
!

systemBrowserClass
    ^ self current systemBrowserClass

    "
     UserPreferences systemBrowserClass
    "
!

versionDiffViewerClass
    ^ self current versionDiffViewerClass

    "
     UserPreferences versionDiffViewerClass
    "
! !

!UserPreferences class methodsFor:'saving'!

saveSettings:userPrefs in:fileName
    "save settings to a settings-file."

    "a temporary kludge for old classVariable-based settings
     - all of those MUST go into the user-preferences dictionary eventually"

    |s screen|

    s := fileName asFilename writeStream.

    screen := Screen current.

    s nextPutLine:'"/ ST/X saved settings';
      nextPutLine:'"/ DO NOT MODIFY MANUALLY';
      nextPutLine:'"/ (modifications would be lost with next save-settings)';
      nextPutLine:'"/';
      nextPutLine:'"/ this file was automatically generated by the';
      nextPutLine:'"/ ''save settings'' function of the SettingsDialog';
      nextPutLine:'"/'.
    s cr.

    s nextPutLine:'"/'.
    s nextPutLine:'"/ saved by ' , OperatingSystem getLoginName , '@' , OperatingSystem getHostName , ' at ' , Timestamp now printString.
    s nextPutLine:'"/'.
    s cr.

    s nextPutLine:'"/'.
    s nextPutLine:'"/ Display settings:'.
    s nextPutLine:'"/'.
    s nextPutLine:'"/ only restore the display settings, if on the same Display ...'.
    s nextPutLine:'Display notNil ifTrue:['.
    s nextPutLine:' Display displayName = ' , (screen displayName storeString) , ' ifTrue:['.
      screen fixColors notNil ifTrue:[
        s nextPutLine:'  Image flushDeviceImages.'.
        s nextPutLine:'  Color colorAllocationFailSignal catch:['.
        s nextPutLine:'    Color getColorsRed:6 green:6 blue:4 on:Display'.
        s nextPutLine:'  ].'.
      ] ifFalse:[
        s nextPutLine:'  Display releaseFixColors.'.
      ].
      s nextPutLine:'  Display hasColors: ' , (screen hasColors storeString) , '.'.
      s nextPutLine:'  Display widthInMillimeter: ' , (screen widthInMillimeter storeString) , '.'.
      s nextPutLine:'  Display heightInMillimeter: ' , (screen heightInMillimeter storeString) , '.'.
      s nextPutLine:'  Display supportsDeepIcons: ' , (screen supportsDeepIcons storeString) , '.'.
      s nextPutLine:'  Image ditherAlgorithm: ' , (Image ditherAlgorithm storeString) , '.'.
      s nextPutLine:'  View defaultStyle:' , View defaultStyle storeString , '.'.
    s nextPutLine:' ].'.
    s nextPutLine:'].'.
    s cr.

    s nextPutLine:'"/'.
    s nextPutLine:'"/ Parser/Compiler settings:'.
    s nextPutLine:'"/'.
    s nextPutLine:'ParserFlags warnSTXSpecials: ' , (ParserFlags warnSTXSpecials storeString) , '.';
      nextPutLine:'ParserFlags warnings: ' , (ParserFlags warnings storeString) , '.';
      nextPutLine:'ParserFlags warnUnderscoreInIdentifier: ' , (ParserFlags warnUnderscoreInIdentifier storeString) , '.';
      nextPutLine:'ParserFlags warnOldStyleAssignment: ' , (ParserFlags warnOldStyleAssignment storeString) , '.';
      nextPutLine:'ParserFlags warnCommonMistakes: ' , (ParserFlags warnCommonMistakes storeString) , '.';
      nextPutLine:'ParserFlags warnPossibleIncompatibilities: ' , (ParserFlags warnPossibleIncompatibilities storeString) , '.';
      nextPutLine:'ParserFlags allowUnderscoreInIdentifier: ' , (ParserFlags allowUnderscoreInIdentifier storeString) , '.';
      nextPutLine:'ParserFlags allowSqueakExtensions: ' , (ParserFlags allowSqueakExtensions storeString) , '.';
      nextPutLine:'ParserFlags allowDolphinExtensions: ' , (ParserFlags allowDolphinExtensions storeString) , '.';
      nextPutLine:'ParserFlags allowQualifiedNames: ' , (ParserFlags allowQualifiedNames storeString) , '.';
      nextPutLine:'ParserFlags arraysAreImmutable: ' , (ParserFlags arraysAreImmutable storeString) , '.';
      nextPutLine:'Compiler lineNumberInfo: ' , (Compiler lineNumberInfo storeString) , '.';

      nextPutLine:'Compiler foldConstants: ' , (Compiler foldConstants storeString) , '.';
      nextPutLine:'ParserFlags stcCompilation: ' , (ParserFlags stcCompilation storeString) , '.';
      nextPutLine:'OperatingSystem getOSType = ' , (OperatingSystem getOSType storeString) , ' ifTrue:[';
      nextPutLine:'  ParserFlags stcCompilationIncludes: ' , (ParserFlags stcCompilationIncludes storeString) , '.';
      nextPutLine:'  ParserFlags stcCompilationDefines: ' , (ParserFlags stcCompilationDefines storeString) , '.';
      nextPutLine:'  ParserFlags stcCompilationOptions: ' , (ParserFlags stcCompilationOptions storeString) , '.';
      nextPutLine:'  ' , (ParserFlags stcModulePath storeString) , ' asFilename exists ifTrue:[';
      nextPutLine:'    ParserFlags stcModulePath: ' , (ParserFlags stcModulePath storeString) , '.';
      nextPutLine:'  ].';
      nextPutLine:'  ParserFlags stcPath: ' , (ParserFlags stcPath storeString) , '.';
      nextPutLine:'  ParserFlags ccCompilationOptions: ' , (ParserFlags ccCompilationOptions storeString) , '.';
      nextPutLine:'  ParserFlags ccPath: ' , (ParserFlags ccPath storeString) , '.';
      nextPutLine:'  ParserFlags linkArgs: ' , (ParserFlags linkArgs storeString) , '.';
      nextPutLine:'  ParserFlags linkSharedArgs: ' , (ParserFlags linkSharedArgs storeString) , '.';
      nextPutLine:'  ParserFlags linkCommand: ' , (ParserFlags linkCommand storeString) , '.';
      nextPutLine:'  ParserFlags makeCommand: ' , (ParserFlags makeCommand storeString) , '.';
      nextPutLine:'  ParserFlags libPath: ' , (ParserFlags libPath storeString) , '.';
      nextPutLine:'  ParserFlags searchedLibraries: ' , (ParserFlags searchedLibraries storeString) , '.';
      nextPutLine:'].';

      nextPutLine:'ObjectMemory justInTimeCompilation: ' , (ObjectMemory justInTimeCompilation storeString) , '.';
      nextPutLine:'ObjectMemory fullSingleStepSupport: ' , (ObjectMemory fullSingleStepSupport storeString) , '.'.

    HistoryManager notNil ifTrue:[
        HistoryManager isActive ifTrue:[
            s nextPutLine:'HistoryManager notNil ifTrue:[HistoryManager activate].'.
            s nextPutLine:'HistoryManager notNil ifTrue:[HistoryManager fullHistoryUpdate:' , HistoryManager fullHistoryUpdate storeString , '].'.
        ] ifFalse:[
            s nextPutLine:'HistoryManager notNil ifTrue:[HistoryManager deactivate].'.
        ].
    ].

    s nextPutLine:'Class catchMethodRedefinitions: ' , (Class catchMethodRedefinitions storeString) , '.'.
    s nextPutLine:'ClassCategoryReader sourceMode: ' , (ClassCategoryReader sourceMode storeString) , '.'.

    s cr.
    s nextPutLine:'"/'.
    s nextPutLine:'"/ Info & Debug Messages:'.
    s nextPutLine:'"/'.
    s nextPutLine:'Smalltalk hasNoConsole ifFalse:[ ObjectMemory infoPrinting: ' , (ObjectMemory infoPrinting storeString) , '].';
      nextPutLine:'ObjectMemory debugPrinting: ' , (ObjectMemory debugPrinting storeString) , '.';
      nextPutLine:'Smalltalk hasNoConsole ifFalse:[ Object infoPrinting: ' , (Object infoPrinting storeString) , '].';
      nextPutLine:'DeviceWorkstation errorPrinting: ' , (DeviceWorkstation errorPrinting storeString) , '.'.

"/    FlyByHelp isActive ifTrue:[
"/        s nextPutLine:'FlyByHelp start.'
"/    ].

    s cr.
    s nextPutLine:'"/'.
    s nextPutLine:'"/ Edit settings:'.
    s nextPutLine:'"/'.
    "/ s nextPutLine:'EditTextView st80Mode: ' , (EditTextView st80Mode storeString) , '.'.
    s nextPutLine:'TextView st80SelectMode: ' , (TextView st80SelectMode storeString) , '.'.
    s nextPutLine:'UserPreferences current syntaxColoring: ' , (userPrefs syntaxColoring storeString) , '.'.
    (ListView userDefaultTabPositions = ListView tab4Positions) ifTrue:[
        s nextPutLine:'ListView userDefaultTabPositions:(ListView tab4Positions).'.
    ] ifFalse:[
        s nextPutLine:'ListView userDefaultTabPositions:(ListView tab8Positions).'.
    ].

    s nextPutLine:'"/'.
    s nextPutLine:'"/ User preference values:'.
    s nextPutLine:'"/'.
    userPrefs keysAndValuesDo:[:k :v |
        (UserPreferences includesSelector:(k , ':') asSymbol) ifTrue:[
            s nextPutLine:'UserPreferences current ' , k , ':' , v storeString , '.'.
        ] ifFalse:[
            s nextPutLine:'UserPreferences current at:' , k storeString , ' put:' , v storeString , '.'.
        ]
    ].

    s cr.
    s nextPutLine:'"/'.
    s nextPutLine:'"/ GC settings:'.
    s nextPutLine:'"/'.
    s nextPutLine:'ObjectMemory newSpaceSize: ' , (ObjectMemory newSpaceSize storeString) , '.';
      nextPutLine:'ObjectMemory dynamicCodeGCTrigger: ' , (ObjectMemory dynamicCodeGCTrigger storeString) , '.';
      nextPutLine:'ObjectMemory freeSpaceGCAmount: ' , (ObjectMemory freeSpaceGCAmount storeString) , '.';
      nextPutLine:'ObjectMemory freeSpaceGCLimit: ' , (ObjectMemory freeSpaceGCLimit storeString) , '.';
      nextPutLine:'ObjectMemory incrementalGCLimit: ' , (ObjectMemory incrementalGCLimit storeString) , '.';
      nextPutLine:'ObjectMemory oldSpaceCompressLimit: ' , (ObjectMemory oldSpaceCompressLimit storeString) , '.';
      nextPutLine:'ObjectMemory oldSpaceIncrement: ' , (ObjectMemory oldSpaceIncrement storeString) , '.'.

    s cr.
    s nextPutLine:'"/'.
    s nextPutLine:'"/ Misc settings:'.
    s nextPutLine:'"/'.
    s nextPutLine:'Class keepMethodHistory: ' , (Class methodHistory notNil storeString) , '.';
      nextPutLine:'Smalltalk logDoits: ' , (Smalltalk logDoits storeString) , '.';
      nextPutLine:'Autoload compileLazy: ' , (Autoload compileLazy storeString) , '.';
      nextPutLine:'Smalltalk loadBinaries: ' , (Smalltalk loadBinaries storeString) , '.';
      nextPutLine:'StandardSystemView includeHostNameInLabel: ' , (StandardSystemView includeHostNameInLabel storeString) , '.';

      "/ claus - I dont think its a good idea to save those ...
"/      nextPutLine:'"/ Class updateChanges: ' , (Class updatingChanges storeString) , '.';
"/      nextPutLine:'"/ ObjectMemory nameForChanges: ' , (ObjectMemory nameForChanges storeString) , '.';

      nextPutLine:'StandardSystemView returnFocusWhenClosingModalBoxes: ' , (StandardSystemView returnFocusWhenClosingModalBoxes storeString) , '.';
      nextPutLine:'StandardSystemView takeFocusWhenMapped: ' , (StandardSystemView takeFocusWhenMapped storeString) , '.';
      nextPutLine:'Display notNil ifTrue:[';
      nextPutLine:' Display activateOnClick: ' , ((screen activateOnClick:nil) storeString) , '.';
      nextPutLine:'].';
      nextPutLine:'MenuView showAcceleratorKeys: ' , (MenuView showAcceleratorKeys storeString) , '.';
      nextPutLine:'Class tryLocalSourceFirst: ' , (Class tryLocalSourceFirst storeString) , '.'.
    (NoHandlerError emergencyHandler == AbstractLauncherApplication notifyingEmergencyHandler) ifTrue:[
        s nextPutLine:'NoHandlerError emergencyHandler:(AbstractLauncherApplication notifyingEmergencyHandler).'.
    ].
    Processor isTimeSlicing ifTrue:[
        s nextPutLine:'Processor startTimeSlicing.'.
        s nextPutLine:('Processor supportDynamicPriorities:' , (Processor supportDynamicPriorities ? false) storeString , '.').
    ] ifFalse:[
        s nextPutLine:'Processor stopTimeSlicing.'.
    ].

    s cr.
    s nextPutLine:'"/'.
    s nextPutLine:'"/ Printer settings:'.
    s nextPutLine:'"/'.
    Printer notNil ifTrue:[
        s nextPutLine:'Printer := ' , (Printer name) , '.'.
        Printer supportsPrintingToCommand ifTrue:[
            s nextPutLine:'Printer printCommand: ' , (Printer printCommand storeString) , '.'.
        ].
        Printer supportsPageSizes ifTrue:[
            s nextPutLine:'Printer pageFormat: ' , (Printer pageFormat storeString) , '.'.
            s nextPutLine:'Printer landscape: ' , (Printer landscape storeString) , '.'.
        ].
        Printer supportsMargins ifTrue:[
            s nextPutLine:'Printer topMargin: ' , (Printer topMargin storeString) , '.'.
            s nextPutLine:'Printer leftMargin: ' , (Printer leftMargin storeString) , '.'.
            s nextPutLine:'Printer rightMargin: ' , (Printer rightMargin storeString) , '.'.
            s nextPutLine:'Printer bottomMargin: ' , (Printer bottomMargin storeString) , '.'.
        ].
        Printer supportsPostscript ifTrue:[
            s nextPutLine:'Printer supportsColor: ' , (Printer supportsColor storeString) , '.'.
        ].
    ].
    s cr.
    s nextPutLine:'"/'.
    s nextPutLine:'"/ Font settings:'.
    s nextPutLine:'"/ (only restored, if image is restarted on the same display)'.
    s nextPutLine:'"/'.
    s nextPutLine:'Display notNil ifTrue:['.
    s nextPutLine:' Display displayName = ' , (screen displayName storeString) , ' ifTrue:['.
    s nextPutLine:'  View defaultFont: ' , (View defaultFont storeString) , '.'.
    s nextPutLine:'  Label defaultFont: ' , (Label defaultFont storeString) , '.'.
    s nextPutLine:'  Button defaultFont: ' , (Button defaultFont storeString) , '.'.
    s nextPutLine:'  Toggle defaultFont: ' , (Toggle defaultFont storeString) , '.'.
    s nextPutLine:'  SelectionInListView defaultFont: ' , (SelectionInListView defaultFont storeString) , '.'.
    s nextPutLine:'  MenuView defaultFont: ' , (MenuView defaultFont storeString) , '.'.
    s nextPutLine:'  MenuPanel defaultFont: ' , (MenuPanel defaultFont storeString) , '.'.
    s nextPutLine:'  NoteBookView defaultFont: ' , (NoteBookView defaultFont storeString) , '.'.
    s nextPutLine:'  PullDownMenu defaultFont: ' , (PullDownMenu defaultFont storeString) , '.'.
    s nextPutLine:'  TextView defaultFont: ' , (TextView defaultFont storeString) , '.'.
    s nextPutLine:'  EditTextView defaultFont: ' , (EditTextView defaultFont storeString) , '.'.
    s nextPutLine:'  CodeView defaultFont: ' , (CodeView defaultFont storeString) , '.'.
    s nextPutLine:' ].'.
    s nextPutLine:'].'.

    s cr.
    s nextPutLine:'"/'.
    s nextPutLine:'"/ Language setting:'.
    s nextPutLine:'"/'.
    s nextPutLine:'"/ Notice:'.
    s nextPutLine:'"/   Language should be taken from the Environment Variable LANG'.
    s nextPutLine:'"/   To use the previous seting, uncomment the following:'.
    s nextPutLine:'"/ Smalltalk language: ' , (Smalltalk language storeString) , '.'.
    s nextPutLine:'"/ Smalltalk languageTerritory: ' , (Smalltalk languageTerritory storeString) , '.'.

    s cr.
    s nextPutLine:'"/'.
    s nextPutLine:'"/ SourceCodeManager settings:'.
    s nextPutLine:'"/ (only restored, if image is restarted on the same host)'.
    s nextPutLine:'"/'.
    s nextPutLine:'OperatingSystem getHostName = ' , (OperatingSystem getHostName storeString) , ' ifTrue:['.
    s nextPutLine:'  Class tryLocalSourceFirst:' , Class tryLocalSourceFirst storeString , '.'.
    s nextPutLine:'  AbstractSourceCodeManager cacheDirectoryName:' , AbstractSourceCodeManager cacheDirectoryName storeString , '.'.
    CVSSourceCodeManager notNil ifTrue:[
        CVSSourceCodeManager savePreferencesOn:s
    ].
    (StoreSourceCodeManager notNil and:[StoreSourceCodeManager isExperimental not]) ifTrue:[
        StoreSourceCodeManager savePreferencesOn:s
    ].
    (SmallTeamSourceCodeManager notNil and:[SmallTeamSourceCodeManager isExperimental not]) ifTrue:[
        SmallTeamSourceCodeManager savePreferencesOn:s
    ].
    s nextPutLine:'].'.

    s close.

    "
     Transcript topView application saveSettings
    "

    "Modified: / 09-08-2006 / 18:52:14 / fm"
    "Modified: / 09-11-2006 / 15:12:07 / cg"
! !

!UserPreferences methodsFor:'acccesing-locale'!

dateInputFormat
    "return a format used when tools read a date from the user"

    ^ self 
        at:#dateInputFormat 
        ifAbsentPut:[
            (self language == #en and:[ self languageTerritory ~= #en])
                ifTrue:[ '%m %d %y' ]
                ifFalse:[ '%d %m %y' ]
        ]
!

dateInputFormat:aFormatString
    "return a format used when tools read a date from the user"

    ^ self 
        at:#dateInputFormat 
        ifAbsentPut:[
            (self language == #en and:[ self languageTerritory ~= #en])
                ifTrue:[ '%m %d %y' ]
                ifFalse:[ '%d %m %y' ]
        ]

    "
     UserPreferences current dateInputFormat:'%d %m %y'  -- european
     UserPreferences current dateInputFormat:'%m %d %y'  -- us
    "
!

decimalPointCharacter
    "toDo: migrate from ClassVar in Number;
     use this for new applications"

    ^ $.
!

thousandsSeparatorCharacter
    "toDo: migrate from ClassVar elsewhere;
     use this for new applications"

    ^ $'
! !

!UserPreferences methodsFor:'accessing'!

at:key put:value
    |classNameToCheck classToCheck|

    value == true ifTrue:[
	key == #useNewVersionDiffBrowser ifTrue:[
	    classNameToCheck := #'VersionDiffBrowser'.
	].
	key == #useNewChangesBrowser ifTrue:[
	    classNameToCheck := #'NewChangesBrowser'.
	].
	key == #useNewFileBrowser ifTrue:[
	    classNameToCheck := #'FileBrowserV2'.
	].
	key == #useNewSystemBrowser ifTrue:[
	    classNameToCheck := #'Tools::NewSystemBrowser'.
	].
	key == #useNewInspector ifTrue:[
	    classNameToCheck := #'NewInspector::NewInspectorView'.
	].
    ].

    classNameToCheck notNil ifTrue:[
	classToCheck := Smalltalk at:classNameToCheck.
	classToCheck isNil ifTrue:[
	    ('UserPreferences [warning]: no class ' , classNameToCheck , ' class in system.') errorPrintCR.
	] ifFalse:[
	    Autoload autoloadFailedSignal handle:[:ex |
		'UserPreferences [warning]: autoload of ' , classNameToCheck , ' failed.' errorPrintCR.
	    ] do:[
		classToCheck autoload.
	    ]
	]
    ].

    ^ super at:key put:value
! !

!UserPreferences methodsFor:'accessing-misc-communication'!

dotNetBridgeRunsInIDE
    "a debugging flag: if true, the dotNetBridge is assumed to be
     already running and the bridge-exe will not be started by st/x"

    ^ self at:#dotNetBridgeRunsInIDE ifAbsent:false
!

dotNetBridgeRunsInIDE:aBoolean
    "a debugging flag: if true, the dotNetBridge is assumed to be
     already running and the bridge-exe will not be started by st/x"

    ^ self at:#dotNetBridgeRunsInIDE put:aBoolean
!

dotNetBridgeVerbose
    ^ self at:#dotNetBridgeVerbose ifAbsent:false

    "
     UserPreferences current dotNetBridgeVerbose
    "
!

dotNetBridgeVerbose:aBoolean
    ^ self at:#dotNetBridgeVerbose put:aBoolean
!

javaBridgeRunsInIDE
    "a debugging flag: if true, the javaBridge is assumed to be
     already running and the bridge-exe will not be started by st/x"

    ^ self at:#javaBridgeRunsInIDE ifAbsent:false
!

javaBridgeRunsInIDE:aBoolean
    "a debugging flag: if true, the javaBridge is assumed to be
     already running and the bridge-exe will not be started by st/x"

    ^ self at:#javaBridgeRunsInIDE put:aBoolean
!

smtpServerName
    ^ self at:#smtpServerName ifAbsent:nil

    "Created: / 20-09-2007 / 15:59:20 / cg"
!

smtpServerName:aHostnameString
    ^ self at:#smtpServerName put:aHostnameString

    "
     UserPreferences current smtpServerName
     UserPreferences current smtpServerName:'mailhost'
    "

    "Created: / 20-09-2007 / 15:59:58 / cg"
! !

!UserPreferences methodsFor:'accessing-pref''d tools'!

changesBrowserClass
    self useNewChangesBrowser ifTrue:[
	^ (NewChangesBrowser ? ChangesBrowser)
    ].
    ^ ChangesBrowser

    "Created: / 17.10.1998 / 14:37:46 / cg"
!

fileBrowserClass
    self useNewFileBrowser ifTrue:[
	^ (FileBrowserV2 ? FileBrowser)
    ].
    ^ FileBrowser

    "
     UserPreferences current fileBrowserClass
    "
!

flyByHelpActive

    ^ self at:#flyByHelpActive ifAbsent:true "(FlyByHelp notNil and:[FlyByHelp isActive])"
!

flyByHelpActive:aBoolean
    aBoolean ~~ self flyByHelpActive ifTrue:[
	self at:#flyByHelpActive put:aBoolean.
	self flyByHelpSettingChanged.
    ].
!

inspectorClassSetting
    self useNewInspector ifTrue:[
	^ (NewInspector::NewInspectorView ? InspectorView)
    ].
    ^ InspectorView

    "Modified: / 12.11.2001 / 15:47:35 / cg"
    "Created: / 12.11.2001 / 15:49:00 / cg"
!

showTipOfTheDayAtStartup
    ^ self at:#showTipOfTheDayAtStartup ifAbsent:false
!

showTipOfTheDayAtStartup:aBoolean
    self at:#showTipOfTheDayAtStartup put:aBoolean.
!

systemBrowserClass
    self useNewSystemBrowser ifTrue:[
	^ ((Tools::NewSystemBrowser ? NewSystemBrowser) ? SystemBrowser)
    ].
    ^ SystemBrowser
!

useNativeFileDialog
    "using native file dialog"

    ^ self at:#useNativeFileDialog ifAbsent:false
!

useNativeFileDialog:aBoolean
    "using native file dialog (if available)"

    self at:#useNativeFileDialog put:aBoolean

    "
     UserPreferences current useNativeFileDialog:true
     UserPreferences current useNativeFileDialog:false
     UserPreferences current useNativeFileDialog
    "
!

useNewChangesBrowser
    "using new or old change browser"

    ^ self at:#useNewChangesBrowser ifAbsent:false

    "Modified: / 13.10.1998 / 15:53:05 / cg"
!

useNewChangesBrowser:aBoolean
    "using new or old changeBrowser"

    self at:#useNewChangesBrowser put:aBoolean

    "
     UserPreferences current useNewChangesBrowser
    "

    "Modified: / 13.10.1998 / 15:53:21 / cg"
!

useNewFileBrowser
    "using new or old version diff viewer"

    ^ self at:#useNewFileBrowser ifAbsent:(FileBrowserV2 notNil and:[FileBrowserV2 isLoaded])

    "Modified: / 13.10.1998 / 15:53:05 / cg"
!

useNewFileBrowser:aBoolean
    "using new or old file browser"

    self at:#useNewFileBrowser put:aBoolean

    "
     UserPreferences current useNewFileBrowser
    "

    "Modified: / 13.10.1998 / 15:53:21 / cg"
!

useNewFileDialog
    "using new or old file dialog"

    ^ self at:#useNewFileDialog ifAbsent:true
!

useNewFileDialog:aBoolean
    "using new or old file dialog"

    self at:#useNewFileDialog put:aBoolean

    "
     UserPreferences current useNewFileDialog:true
    "
!

useNewInspector
    "using new or old inspector"

    ^ self at:#useNewInspector ifAbsent:false

    "
     UserPreferences current useNewInspector
    "

    "Modified: / 17.10.1998 / 14:45:12 / cg"
!

useNewInspector:aBoolean
    "using new or old inspector"

    self at:#useNewInspector put:aBoolean

    "
     UserPreferences current useNewInspector
    "
!

useNewSettingsApplication
    "using one application for the settings"

    ^ self at:#useNewSettingsApplication ifAbsent:true
!

useNewSettingsApplication:aBoolean
    "using one application for the settings"

    self at:#useNewSettingsApplication put:aBoolean

    "
     UserPreferences current useNewSettingsApplication:true
    "

    "Modified: / 13.10.1998 / 15:53:21 / cg"
!

useNewSystemBrowser
    "using new or old system browser"

    |newSystemBrowserClass useIt|

    newSystemBrowserClass := (Tools::NewSystemBrowser ? NewSystemBrowser).
    useIt := self at:#useNewSystemBrowser ifAbsent:nil.
    useIt isNil ifTrue:[
	useIt := (newSystemBrowserClass notNil and:[ newSystemBrowserClass isLoaded]).
	useIt ifTrue:[
	    self at:#useNewSystemBrowser put:true.
	].
    ].
    ^ useIt
!

useNewSystemBrowser:aBoolean
    "using new or old systemBrowser"

    self at:#useNewSystemBrowser put:aBoolean

    "
     UserPreferences current useNewSystemBrowser:true
    "

    "Modified: / 13.10.1998 / 15:53:21 / cg"
!

useNewVersionDiffBrowser
    "using new or old version diff viewer"

    ^ self at:#useNewVersionDiffBrowser ifAbsent:true

    "Modified: / 13.10.1998 / 15:53:05 / cg"
!

useNewVersionDiffBrowser:aBoolean
    "using new or old versionDiffBrowser"

    self at:#useNewVersionDiffBrowser put:aBoolean

    "
     UserPreferences current useNewVersionDiffBrowser
    "

    "Modified: / 13.10.1998 / 15:53:21 / cg"
!

useProcessMonitorV2
    "using ProcessMonitorV2 application for display Processes"

    ^ self at:#useProcessMonitorV2 ifAbsent:(ProcessMonitorV2 notNil)
!

useProcessMonitorV2:aBoolean
    "using ProcessMonitorV2 application for display Processes"

    self at:#useProcessMonitorV2 put:aBoolean

    "
     UserPreferences current useProcessMonitorV2:true
    "

    "Modified: / 13.10.1998 / 15:53:21 / cg"
!

useSmalltalkDocumentViewer
    "using the smalltalk-DocumentViewer (as opposed to the native systems Browser)
     to display documentation"

    ^ self at:#useSmalltalkDocumentViewer ifAbsent:true

    "
     UserPreferences current useSmalltalkDocumentViewer
     UserPreferences current useSmalltalkDocumentViewer:false
    "
!

useSmalltalkDocumentViewer:aBoolean
    "using the smalltalk-DocumentViewer (as opposed to the native systems Browser)
     to display documentation"

    ^ self at:#useSmalltalkDocumentViewer put:aBoolean
!

versionDiffViewerClass
    self useNewVersionDiffBrowser ifTrue:[
	^ (VersionDiffBrowser ? DiffTextView)
    ].
    ^ DiffCodeView
! !

!UserPreferences methodsFor:'accessing-prefs-UI'!

allowMouseWheelZoom
    "return the flag which controls if text can be magnified via the ALT-wheel-action"

    ^ self at:#allowMouseWheelZoom ifAbsent:[ true ]

    "
     UserPreferences current allowMouseWheelZoom
    "
!

allowMouseWheelZoom:aBooleanOrNil
    "set/clear the flag which controls if text can be magnified via the ALT-wheel-action"

    ^ self at:#allowMouseWheelZoom put:aBooleanOrNil

    "
     UserPreferences current allowMouseWheelZoom:true
     UserPreferences current allowMouseWheelZoom:false
     UserPreferences current allowMouseWheelZoom
    "
!

avoidSlowDrawingOperationsUnderWindows
    ^ OperatingSystem isMSWINDOWSlike
!

beepEnabled
    "return the flag which controls the beeper"

    ^ self at:#beepEnabled ifAbsentPut:true

    "
     UserPreferences current beepEnabled
    "

    "Modified: / 11.9.1998 / 00:09:59 / cg"
    "Created: / 3.12.1999 / 17:09:49 / ps"
!

beepEnabled:aBoolean
    "set/clear the flag which controls the beeper"

    ^ self at:#beepEnabled put:aBoolean

    "
     UserPreferences current beepEnabled:false
    "

    "Modified: / 11.9.1998 / 00:09:59 / cg"
    "Created: / 3.12.1999 / 17:10:27 / ps"
!

beepForErrorDialog
    "return the flag which controls beeping for error dialogs"

    ^ self at:#beepForErrorDialog ifAbsent:true

    "
     UserPreferences current beepForErrorDialog
    "
!

beepForErrorDialog:aBoolean
    "set/clear the flag which controls beeping for error dialogs"

    ^ self at:#beepForErrorDialog put:aBoolean

    "
     UserPreferences current beepForErrorDialog:true
    "
!

beepForInfoDialog
    "return the flag which controls beeping for info dialogs"

    ^ self at:#beepForInfoDialog ifAbsent:false

    "
     UserPreferences current beepForInfoDialog
    "
!

beepForInfoDialog:aBoolean
    "set/clear the flag which controls beeping for info dialogs"

    ^ self at:#beepForInfoDialog put:aBoolean

    "
     UserPreferences current beepForInfoDialog:true
    "
!

beepForWarningDialog
    "return the flag which controls beeping for warning dialogs"

    ^ self at:#beepForWarningDialog ifAbsent:true

    "
     UserPreferences current beepForWarningDialog
    "
!

beepForWarningDialog:aBoolean
    "set/clear the flag which controls beeping for warning dialogs"

    ^ self at:#beepForWarningDialog put:aBoolean

    "
     UserPreferences current beepForWarningDialog:true
    "
!

beepInEditor
    "return the flag which controls the beeper"

    ^ self at:#beepInEditor ifAbsentPut:true

    "
     UserPreferences current beepInEditor
    "
!

closePopUpMenuChainOnEscape
    "if true, the whole chain of popUpMenus is closed when escape is pressed.
     if false (the default), only the last popup-view is closed.
     The first corresponds to X-behavior, the later is how windows does it - sigh."

    ^ self at:#closePopUpMenuChainOnEscape ifAbsent:false

    "
     UserPreferences current closePopUpMenuChainOnEscape:false
     UserPreferences current closePopUpMenuChainOnEscape:true
    "
!

closePopUpMenuChainOnEscape:aBoolean
    "if true, the whole chain of popUpMenus is closed when escape is pressed.
     if false (the default), only the last popup-view is closed.
     The first corresponds to X-behavior, the later is how windows does it - sigh."

    ^ self at:#closePopUpMenuChainOnEscape put:aBoolean

    "
     UserPreferences current closePopUpMenuChainOnEscape:true
     UserPreferences current closePopUpMenuChainOnEscape:false
    "
!

expandSelectionOnMouseMoveWithButtonPressed
    "expand the selection in a selectionInListView if the mouse is pressed while moving over
     more lines. Default is not FALSE !!"

    ^ self at:#expandSelectionOnMouseMoveWithButtonPressed ifAbsent:false

    "
     UserPreferences current expandSelectionOnMouseMoveWithButtonPressed
    "
!

expandSelectionOnMouseMoveWithButtonPressed:aBoolean
    "expand the selection in a selectionInListView if the mouse is pressed while moving over
     more lines. Default is not FALSE !!"

    ^ self at:#expandSelectionOnMouseMoveWithButtonPressed put:aBoolean

    "
     UserPreferences current expandSelectionOnMouseMoveWithButtonPressed
    "
!

focusFollowsMouse
    "return the flag which controls if the keyboard focus should
     follow the mouse (as in X) - as opposed to click mode (as in MS-win).
     This only affects certain widgets (EditFields, EditTextViews and SelectionInListViews).
     The returned value has 3 states: true/false and nil, which means: as defined in styleSheet."

    ^ self at:#focusFollowsMouse ifAbsent:[ Screen current platformName ~= 'WIN32' ]

    "
     UserPreferences current focusFollowsMouse
    "
    "Modified: / 11.9.1998 / 00:09:59 / cg"
!

focusFollowsMouse:aBooleanOrNil
    "set/clear the flag which controls if the keyboard focus should
     follow the mouse (as in X) - as opposed to click mode (as in MS-win).
     This only affects certain widgets (EditFields, EditTextViews and SelectionInListViews).
     Allowed are: true/false and nil, which means: as defined in styleSheet."

    ^ self at:#focusFollowsMouse put:aBooleanOrNil

    "
     UserPreferences current focusFollowsMouse:true
     UserPreferences current focusFollowsMouse:false
     UserPreferences current focusFollowsMouse
    "

    "Modified: / 11.9.1998 / 00:09:59 / cg"
!

motionDistanceToStartDrag
    "the motion distance (in pixel) to start drag (as opposed to adding to the selection)"

    ^ "DragMotionDistance ?" 10
!

mouseWheelFocusFollowsMouse
    "return the flag which controls if the mouseWheel focus should
     follow the mouse (as in X) - as opposed to click mode (as in MS-win)"

    self focusFollowsMouse ifTrue:[^ true].
    ^ self at:#mouseWheelFocusFollowsMouse ifAbsent:[ Screen current platformName ~= 'WIN32' ]

    "
     UserPreferences current mouseWheelFocusFollowsMouse
    "
!

opaqueTableColumnResizing
    "return the flag which controls if table column resizing should be done
     animated (opaque)"

    ^ self at:#opaqueTableColumnResizing ifAbsent:false

    "
     UserPreferences current opaqueTableColumnResizing
    "
!

opaqueTableColumnResizing:aBoolean
    "change the flag which controls if table column resizing should be done
     animated (opaque)"

    ^ self at:#opaqueTableColumnResizing put:aBoolean

    "
     UserPreferences current opaqueTableColumnResizing:true
    "

    "Modified: / 11.9.1998 / 00:09:59 / cg"
!

opaqueVariablePanelResizing
    "return the flag which controls if variable panel resizing should be done
     animated (opaque)"

    ^ self at:#opaqueVariablePanelResizing ifAbsent:false

    "
     UserPreferences current opaqueVariablePanelResizing
    "

    "Modified: / 11.9.1998 / 00:09:59 / cg"
!

opaqueVariablePanelResizing:aBoolean
    "change the flag which controls if variable panel resizing should be done
     animated (opaque)"

    ^ self at:#opaqueVariablePanelResizing put:aBoolean

    "
     UserPreferences current opaqueVariablePanelResizing:true
    "

    "Modified: / 11.9.1998 / 00:09:59 / cg"
!

searchDialogIsModal
    "true if the search dialog (in textViews) shall be modal (the default)"

    ^ self at:#searchDialogIsModal ifAbsent:true

    "
     UserPreferences current searchDialogIsModal
    "
!

searchDialogIsModal:aBooleanOrNil
    "true if the search dialog (in textViews) shall be modal (the default)"

    ^ self at:#searchDialogIsModal put:aBooleanOrNil

    "
     UserPreferences current searchDialogIsModal:true
     UserPreferences current searchDialogIsModal:false
     UserPreferences current searchDialogIsModal
    "
!

selectOnRightClick
    "the Windows behavior of selecting on a right-click"

    ^ self at:#selectOnRightClick ifAbsent:false
!

selectOnRightClick:aBoolean
    "the Windows behavior of selecting on a right-click"

    ^ self at:#selectOnRightClick put:aBoolean

    "
     UserPreferences current selectOnRightClick:true.
     UserPreferences current selectOnRightClick:false.
    "
!

showRightButtonMenuOnRelease
    "the Windows behavior of showing the right-button menu on a release.
     Not yet fully implemented."

    ^ self at:#showRightButtonMenuOnRelease ifAbsent:true
!

showRightButtonMenuOnRelease:aBoolean
    "the Windows behavior of showing the right-button menu on a release.
     Not yet fully implemented."

    ^ self at:#showRightButtonMenuOnRelease put:aBoolean

    "
     UserPreferences current showRightButtonMenuOnRelease:true.
     UserPreferences current showRightButtonMenuOnRelease:false.
    "
!

startTextDragWithControl
    "if true, textDrag is only started when the CTRL-key is down"

    ^ self at:#startTextDragWithControl ifAbsent:true

    "
     UserPreferences current startTextDragWithControl
    "
!

startTextDragWithControl:aBooleanOrNil
    "if true, textDrag is only started when the CTRL-key is down"

    ^ self at:#startTextDragWithControl put:aBooleanOrNil

    "
     UserPreferences current startTextDragWithControl:true
     UserPreferences current startTextDragWithControl:false
     UserPreferences current startTextDragWithControl
    "
! !

!UserPreferences methodsFor:'accessing-prefs-browser'!

autoFormatting
    "return the flag which controls automatic formatting of code (in some browsers)
     Notice, the regular browser does not (yet) do automatic formating."

    ^ self at:#autoFormatting ifAbsent:false

    "
     UserPreferences current autoFormatting
    "

    "Created: / 4.2.2000 / 20:08:08 / cg"
    "Modified: / 5.2.2000 / 15:38:33 / cg"
!

autoFormatting:aBoolean
    "turn on/off automatic formatting of code (in some browsers);
     Notice, the regular browser does not (yet) do automatic formating."

    ^ self at:#autoFormatting put:aBoolean

    "
     UserPreferences current autoFormatting:true
     UserPreferences current autoFormatting:false
    "

    "Created: / 4.2.2000 / 20:08:26 / cg"
    "Modified: / 5.2.2000 / 15:38:20 / cg"
!

enforceCodeStyle
    "return the flag which controls enforcing a certain code style (in some browsers)"

    ^ self at:#enforceCodeStyle ifAbsent:false

    "
     UserPreferences current enforceCodeStyle
     UserPreferences current enforceCodeStyle:true
     UserPreferences current enforceCodeStyle:false
    "

    "Modified: / 27-03-2007 / 21:51:42 / cg"
!

generateComments
    "return true; comments shall be generated (by the codeGenerator tool)"

    ^ self at:#generateComments ifAbsent:true.

    "
     UserPreferences current generateComments
    "
!

generateCommentsForGetters
    "return true if comments for simple getters are to be generated (by the codeGenerator tool).
     The default is now false, as these look stupid in the browser and were only generated
     for the HTMLDocumentGenerator, which is not able  to generate these comments on the fly."

    ^ self generateComments and:[self at:#generateCommentsForGetters ifAbsent:false].

    "
     UserPreferences current generateCommentsForGetters
    "
!

generateCommentsForSetters
    "return true if comments for simple setters are to be generated (by the codeGenerator tool).
     The default is now false, as these look stupid in the browser and were only generated
     for the HTMLDocumentGenerator, which is not able  to generate these comments on the fly."

    ^ self generateComments and:[self at:#generateCommentsForSetters ifAbsent:false].

    "
     UserPreferences current generateCommentsForSetters
    "
!

showAcceptCancelBarInBrowser
    "experimental."

    ^ self at:#showAcceptCancelBarInBrowser ifAbsent:true

    "
     UserPreferences current showAcceptCancelBarInBrowser
     UserPreferences current showAcceptCancelBarInBrowser:true
     UserPreferences current showAcceptCancelBarInBrowser:false
    "
!

showAcceptCancelBarInBrowser:aBoolean
    "experimental."

    ^ self at:#showAcceptCancelBarInBrowser put:aBoolean

    "
     UserPreferences current showAcceptCancelBarInBrowser:true
     UserPreferences current showAcceptCancelBarInBrowser:false
    "
!

syntaxColoring
    "return the flag which controls syntax coloring (in the browsers)"

    ^ self at:#syntaxColoring ifAbsent:true

    "
     UserPreferences current syntaxColoring
    "

    "Modified: / 11.9.1998 / 00:09:59 / cg"
!

syntaxColoring:aBoolean
    "turn on/off syntaxColoring (in the browsers)."

    ^ self at:#syntaxColoring put:aBoolean

    "
     UserPreferences current syntaxColoring:true
     UserPreferences current syntaxColoring:false
    "

    "Created: / 31.3.1998 / 13:44:00 / cg"
    "Modified: / 1.4.1998 / 13:23:03 / cg"
!

useSearchBarInBrowser
    "true, if the search-entry fields are initially shown in the browser itself
     (like in firefox). False if a dialog is to be opened."

    "/ cg: disabled for now, until fixed.
    "/ does not initially select the searchString.
    "/ thereby interrupting the workflow...

    ^ self at:#useSearchBarInBrowser ifAbsent:false

    "
     UserPreferences current useSearchBarInBrowser
     UserPreferences current useSearchBarInBrowser:true
     UserPreferences current useSearchBarInBrowser:false
    "
!

useSearchBarInBrowser:aBoolean
    "true, if the search-entry fields are initially shown in the browser itself
     (like in firefox). False if a dialog is to be opened."

    ^ self at:#useSearchBarInBrowser put:aBoolean

    "
     UserPreferences current useSearchBarInBrowser:true
     UserPreferences current useSearchBarInBrowser:false
    "
! !

!UserPreferences methodsFor:'accessing-prefs-browser-colors'!

emphasisForChangedCode
    "the emphasis for changed code (in changeSet) in the browser"

    |emp|

    emp := self at:#emphasisForChangedCode ifAbsent:nil.
    emp isNil ifTrue:[
	emp := #color->Color red darkened.
	emp := Array with:#bold with:emp.
	"/ emp := #color->Color blue darkened.
	self at:#emphasisForChangedCode put:emp.
    ].
    ^ emp

    "
     self allInstancesDo:[:pref |pref at:#emphasisForChangedCode put:nil].
     UserPreferences current emphasisForChangedCode.
     UserPreferences current at:#emphasisForChangedCode put:nil.
    "

    "Modified: / 10-11-2006 / 17:27:23 / cg"
!

emphasisForChangedCodeInSmallTeam
    "the emphasis for changed code (in a remote changeSet) in the browser.
     You need the SmallTeam extension to be present for this to work."

    |emp|

    emp := self at:#emphasisForChangedCodeInSmallTeam ifAbsent:nil.
    emp isNil ifTrue:[
	emp := #color->Color yellow darkened.
	emp := Array with:#bold with:emp.
	self at:#emphasisForChangedCodeInSmallTeam put:emp.
    ].
    ^ emp

    "
     self allInstancesDo:[:pref |pref at:#emphasisForChangedCodeInSmallTeam put:nil].
     UserPreferences current emphasisForChangedCodeInSmallTeam.
     UserPreferences current at:#emphasisForChangedCodeInSmallTeam put:nil.
    "

    "Created: / 10-11-2006 / 16:31:00 / cg"
!

emphasisForDifferentPackage
    |emp|

    emp := self at:#emphasisForDifferentPackage ifAbsent:nil.
    emp isNil ifTrue:[
	emp := #color->Color green darkened.
	"/ emp := Array with:#bold with:emp.
	self at:#emphasisForDifferentPackage put:emp.
    ].
    ^ emp

    "
     self allInstancesDo:[:pref |pref at:#emphasisForDifferentPackage put:nil].
    "
!

emphasisForModifiedBuffer
    |emp|

    emp := self at:#emphasisForModifiedBuffer ifAbsent:nil.
    emp isNil ifTrue:[
	emp := #color->Color red darkened.
	emp := Array with:#bold with:emp.
	self at:#emphasisForModifiedBuffer put:emp.
    ].
    ^ emp

    "
     self allInstancesDo:[:pref |pref at:#emphasisForModifiedBuffer put:nil].
    "
!

emphasisForObsoleteCode
    |emp|

    emp := self at:#emphasisForObsoleteCode ifAbsent:nil.
    emp isNil ifTrue:[
	emp := #color->Color red.
	emp := Array with:#bold with:emp.
	self at:#emphasisForObsoleteCode put:emp.
    ].
    ^ emp

    "
     self allInstancesDo:[:pref |pref at:#emphasisForObsoleteCode put:nil].
    "
!

emphasisForReadVariable
    |emp|

    emp := self at:#emphasisForReadVariable ifAbsent:nil.
    emp isNil ifTrue:[
	emp := #underline.
	self at:#emphasisForReadVariable put:emp.
    ].
    ^ emp
!

emphasisForWrittenVariable
    |emp|

    emp := self at:#emphasisForWrittenVariable ifAbsent:nil.
    emp isNil ifTrue:[
	emp := Array with:#underline with:#underlineColor->Color red.
	self at:#emphasisForWrittenVariable put:emp.
    ].
    ^ emp
! !

!UserPreferences methodsFor:'accessing-prefs-browser-syntaxColoring'!

argumentIdentifierColor
    "the color used for argument identifiers;
     If syntaxColoring is turned on."

    ^ self at:#argumentIdentifierColor ifAbsentPut:[self identifierColor]

    "Created: / 31.3.1998 / 15:08:20 / cg"
    "Modified: / 1.4.1998 / 13:19:58 / cg"
!

argumentIdentifierEmphasis
    "the emphasis used for argument identifiers;
     If syntaxColoring is turned on."

    ^ self at:#argumentIdentifierEmphasis ifAbsentPut:[self identifierEmphasis]

    "Created: / 31.3.1998 / 15:16:40 / cg"
    "Modified: / 1.4.1998 / 13:19:55 / cg"
!

badIdentifierColor
    "the color used for illegal identifiers;
     If syntaxColoring is turned on."

    ^ self at:#badIdentifierColor ifAbsentPut:[self identifierColor]

!

badIdentifierEmphasis
    "the emphasis used for illegal identifiers;
     If syntaxColoring is turned on."

    ^ self at:#badIdentifierEmphasis ifAbsentPut:[UserPreferences default at:#badIdentifierEmphasis]

    "Modified: / 7.7.1999 / 00:30:00 / cg"
!

booleanConstantColor
    "the color used for boolean constants;
     If syntaxColoring is turned on."

    ^ self at:#booleanConstantColor ifAbsentPut:[self constantColor]

    "Created: / 31.3.1998 / 18:12:06 / cg"
    "Modified: / 1.4.1998 / 13:20:07 / cg"
!

booleanConstantEmphasis
    "the emphasis used for boolean constants;
     If syntaxColoring is turned on."

    ^ self at:#booleanConstantEmphasis ifAbsentPut:[self constantEmphasis]

    "Created: / 31.3.1998 / 18:12:46 / cg"
    "Modified: / 1.4.1998 / 13:26:01 / cg"
!

bracketColor
    "the color used for brackets;
     If syntaxColoring is turned on."

    ^ self at:#bracketColor ifAbsentPut:[self defaultSyntaxColor]

    "
     self current at:#bracketColor  put:Color red.
     self current at:#bracketEmphasis  put:#bold

     self current bracketColor
     self current bracketEmphasis
    "

    "Created: / 31.3.1998 / 19:11:38 / cg"
    "Modified: / 1.4.1998 / 13:22:33 / cg"
!

bracketEmphasis
    "the emphasis used for brackets;
     If syntaxColoring is turned on."

    ^ self at:#bracketEmphasis ifAbsentPut:[self defaultSyntaxEmphasis]

    "
     self current at:#bracketEmphasis  put:#bold
     self current bracketEmphasis
    "

    "Created: / 31.3.1998 / 19:11:38 / cg"
    "Modified: / 1.4.1998 / 13:22:33 / cg"
!

classVariableIdentifierColor
    "the color used for classVar/classInstVar identifiers
     If syntaxColoring is turned on."

    ^ self at:#classVariableIdentifierColor ifAbsentPut:[self globalIdentifierColor]

    "Modified: / 1.4.1998 / 13:20:47 / cg"
    "Created: / 4.3.1999 / 12:50:31 / cg"
!

classVariableIdentifierEmphasis
    "the color used for classVar/classInstVar identifiers
     If syntaxColoring is turned on."

    ^ self at:#classVariableIdentifierEmphasis ifAbsentPut:[self globalIdentifierEmphasis]

    "Modified: / 1.4.1998 / 13:20:47 / cg"
    "Created: / 4.3.1999 / 12:50:31 / cg"
!

commentColor
    "the color used for comments;
     If syntaxColoring is turned on."

    ^ self at:#commentColor ifAbsentPut:[UserPreferences default at:#commentColor]

    "Created: / 31.3.1998 / 15:10:23 / cg"
    "Modified: / 11.9.1998 / 19:24:04 / cg"
!

commentEmphasis
    "the emphasis used for comments;
     If syntaxColoring is turned on."

    ^ self at:#commentEmphasis ifAbsentPut:[UserPreferences default at:#commentEmphasis]

    "Created: / 31.3.1998 / 15:09:59 / cg"
    "Modified: / 1.4.1998 / 13:25:53 / cg"
!

commentEmphasisAndColor
    ^ Text addEmphasis:(self commentEmphasis) to:(#color->self commentColor).


!

constantColor
    "the color used for constants;
     If syntaxColoring is turned on."

    ^ self at:#constantColor ifAbsentPut:[UserPreferences default at:#constantColor]

    "Created: / 31.3.1998 / 18:13:15 / cg"
    "Modified: / 1.4.1998 / 13:20:37 / cg"
!

constantEmphasis
    "the emphasis used for constants;
     If syntaxColoring is turned on."

    ^ self at:#constantEmphasis ifAbsentPut:[self identifierEmphasis]

    "Created: / 31.3.1998 / 18:13:23 / cg"
    "Modified: / 1.4.1998 / 13:25:43 / cg"
!

controlFlowSelectorColor
    "the color used for some selected controlFlow selectors (such as if, while etc.);
     If syntaxColoring is turned on."

    ^ self at:#controlFlowSelectorColor
	    ifAbsentPut:[UserPreferences default
			    at:#controlFlowSelectorColor ifAbsent:[self selectorColor]]

    "Created: / 08-09-2006 / 15:51:20 / cg"
!

controlFlowSelectorEmphasis
    "the emphasis used for some selected controlFlow selectors (such as if, while etc.);
     If syntaxColoring is turned on."

    ^ self at:#controlFlowSelectorEmphasis
	    ifAbsentPut:[UserPreferences default
			    at:#controlFlowSelectorEmphasis ifAbsent:[self selectorEmphasis]]

    "Created: / 08-09-2006 / 15:51:04 / cg"
!

defaultSyntaxColor
    "the color used for anything else;
     If syntaxColoring is turned on."

    ^ self at:#defaultSyntaxColor ifAbsentPut:[UserPreferences default at:#defaultSyntaxColor]

!

defaultSyntaxEmphasis
    "the emphasis used for anything else;
     If syntaxColoring is turned on."

    ^ self at:#defaultSyntaxEmphasis ifAbsentPut:[UserPreferences default at:#defaultSyntaxEmphasis]

!

doesNotUnderstand:aMessage
    |k def|

    k := aMessage selector.
    aMessage numArgs == 0 ifTrue:[
	(self includesKey:k) ifTrue:[
	    ^ self at:k
	].
	((def := self class default) includesKey:k) ifTrue:[
	    ^ def at:k
	].
	^ self defaultValue
    ].
"/    ((aMessage numArgs == 1)
"/    and:[ (k endsWith:$:)])
"/    ifTrue:[
"/        k := (k copyWithoutLast:1) asSymbol.
"/        ((self includesKey:k)
"/        or:[ self class default includesKey:k ]) ifTrue:[
"/            ^ self at:k put:(aMessage arg1)
"/        ].
"/    ].

    aMessage numArgs == 1 ifTrue:[
	('UserPreferences [info]: obsolete settings key: ' , aMessage selector , ' - ignored.') infoPrintCR.
	^ nil
    ].

    ^ super doesNotUnderstand:aMessage
!

emphasizeParenthesisLevel
    ^ self at:#emphasizeParenthesisLevel ifAbsent:true

    "
     UserPreferences current emphasizeParenthesisLevel
     UserPreferences current emphasizeParenthesisLevel:true
     UserPreferences current emphasizeParenthesisLevel:false
    "
!

emphasizeParenthesisLevel:aBoolean
    self at:#emphasizeParenthesisLevel put:aBoolean

    "
     UserPreferences current emphasizeParenthesisLevel
     UserPreferences current emphasizeParenthesisLevel:true
     UserPreferences current emphasizeParenthesisLevel:false
    "
!

errorColor
    "the color used for illegal identifiers;
     If syntaxColoring is turned on."

    ^ self at:#errorColor ifAbsentPut:[UserPreferences default at:#errorColor]

!

fullSelectorCheck
    "with fullSelector check, selectors are searched immediately for
     being implemented in the system. This may not be useful on slow machines"

    ^ self at:#fullSelectorCheck ifAbsentPut:[UserPreferences default at:#fullSelectorCheck]

    "Created: / 31.3.1998 / 15:09:41 / cg"
    "Modified: / 1.4.1998 / 13:25:06 / cg"
!

globalClassIdentifierColor
    "the color used for global identifiers which are known to be classes;
     If syntaxColoring is turned on."

    ^ self at:#globalClassIdentifierColor ifAbsentPut:[self globalIdentifierColor]

    "Modified: / 1.4.1998 / 13:20:47 / cg"
    "Created: / 4.3.1999 / 12:50:31 / cg"
!

globalClassIdentifierEmphasis
    "the emphasis used for global variable identifiers which are known to be classes;
     If syntaxColoring is turned on."

    ^ self at:#globalClassIdentifierEmphasis ifAbsentPut:[self globalIdentifierEmphasis]

    "Modified: / 1.4.1998 / 13:25:31 / cg"
    "Created: / 4.3.1999 / 12:51:00 / cg"
!

globalIdentifierColor
    "the color used for global identifiers;
     If syntaxColoring is turned on."

    ^ self at:#globalIdentifierColor ifAbsentPut:[self identifierColor]

    "Created: / 31.3.1998 / 15:18:49 / cg"
    "Modified: / 1.4.1998 / 13:20:47 / cg"
!

globalIdentifierEmphasis
    "the emphasis used for global variable identifiers;
     If syntaxColoring is turned on."

    ^ self at:#globalIdentifierEmphasis ifAbsentPut:[self identifierEmphasis]

    "Created: / 31.3.1998 / 15:18:29 / cg"
    "Modified: / 1.4.1998 / 13:25:31 / cg"
!

hereColor
    "the color used for the here pseudoVariable;
     If syntaxColoring is turned on."

    ^ self at:#hereColor ifAbsentPut:[self selfColor]

    "Created: / 31.3.1998 / 17:38:09 / cg"
    "Modified: / 1.4.1998 / 13:20:57 / cg"
!

hereEmphasis
    "the emphasis used for the hre special variable;
     If syntaxColoring is turned on."

    ^ self at:#hereEmphasis ifAbsentPut:[self selfEmphasis]

    "Created: / 31.3.1998 / 17:35:13 / cg"
    "Modified: / 1.4.1998 / 13:25:17 / cg"
!

identifierColor
    "the color used for other identifiers;
     If syntaxColoring is turned on."

    ^ self at:#identifierColor ifAbsentPut:[self defaultSyntaxColor]

    "
     UserPreferences current at:#identifierColor put:Color green darkened darkened.
     UserPreferences current at:#identifierColor put:Color black.
    "

    "Created: / 31.3.1998 / 17:35:55 / cg"
    "Modified: / 2.4.1998 / 10:39:42 / cg"
!

identifierEmphasis
    "the emphasis used for other identifiers;
     If syntaxColoring is turned on."

    ^ self at:#identifierEmphasis ifAbsentPut:[self defaultSyntaxEmphasis]

    "Created: / 31.3.1998 / 15:09:41 / cg"
    "Modified: / 1.4.1998 / 13:25:06 / cg"
!

instVarIdentifierColor
    "the color used for instance variable identifiers;
     If syntaxColoring is turned on."

    ^ self at:#instVarIdentifierColor ifAbsentPut:[self identifierColor]

    "
     UserPreferences current at:#instVarIdentifierColor put:Color green darkened.
     UserPreferences current at:#instVarIdentifierColor put:Color black.
     UserPreferences current instVarIdentifierColor
    "

    "Created: / 16.4.1998 / 18:31:29 / cg"
    "Modified: / 16.4.1998 / 18:57:06 / cg"
!

instVarIdentifierEmphasis
    "the emphais used for instance variable identifiers;
     If syntaxColoring is turned on."

    ^ self at:#instVarIdentifierEmphasis ifAbsentPut:[self identifierEmphasis]

    "Modified: / 1.4.1998 / 13:24:42 / cg"
    "Created: / 16.4.1998 / 18:40:05 / cg"
!

jsKeywordColor
    ^ self at:#jsKeywordColor ifAbsentPut:[self defaultSyntaxColor]
!

jsKeywordEmphasis
    ^ self at:#jsKeywordEmphasis ifAbsentPut:[self defaultSyntaxEmphasis]
!

localIdentifierColor
    "the color used for local variable identifiers;
     If syntaxColoring is turned on."

    ^ self at:#localIdentifierColor ifAbsent:[self identifierColor]

    "
     UserPreferences current at:#localIdentifierColor put:Color green darkened.
     UserPreferences current at:#localIdentifierColor put:Color black.
    "

    "Created: / 31.3.1998 / 15:18:07 / cg"
    "Modified: / 2.4.1998 / 10:40:05 / cg"
!

localIdentifierEmphasis
    "the emphais used for local variable identifiers;
     If syntaxColoring is turned on."

    ^ self at:#localIdentifierEmphasis ifAbsent:[self identifierEmphasis]

    "Created: / 31.3.1998 / 15:16:56 / cg"
    "Modified: / 1.4.1998 / 13:24:42 / cg"
!

methodSelectorColor
    "the color used for a methods selector pattern;
     If syntaxColoring is turned on."

    ^ self at:#methodSelectorColor ifAbsentPut:[self defaultSyntaxColor]

    "Created: / 31.3.1998 / 15:11:24 / cg"
    "Modified: / 1.4.1998 / 13:24:26 / cg"
!

methodSelectorEmphasis
    "the emphasis used for a methods selector pattern;
     If syntaxColoring is turned on."

    ^ self at:#methodSelectorEmphasis ifAbsentPut:[UserPreferences default at:#methodSelectorEmphasis]

    "Created: / 31.3.1998 / 15:11:16 / cg"
    "Modified: / 1.4.1998 / 13:24:20 / cg"
!

numberConstantColor
    "the color used for number constants;
     If syntaxColoring is turned on."

    ^ self at:#numberConstantColor ifAbsent:[ self constantColor ]
!

numberConstantEmphasis
    "the emphasis used for number constants;
     If syntaxColoring is turned on."

    ^ self at:#numberConstantEmphasis ifAbsent:[ self constantEmphasis ]
!

poolVariableIdentifierColor
    "the color used for pool variable identifiers
     If syntaxColoring is turned on."

    ^ self at:#poolVariableIdentifierColor ifAbsentPut:[self globalIdentifierColor]
!

poolVariableIdentifierEmphasis
    "the color used for pool variable identifiers
     If syntaxColoring is turned on."

    ^ self at:#poolVariableIdentifierEmphasis ifAbsentPut:[self globalIdentifierEmphasis]
!

returnColor
    "the color used for the return expression;
     If syntaxColoring is turned on."

    ^ self at:#returnColor ifAbsentPut:[self defaultSyntaxColor]

    "Modified: / 5.1.1980 / 00:43:52 / cg"
!

returnEmphasis
    "the emphasis used for returns;
     If syntaxColoring is turned on."

    ^ self at:#returnEmphasis ifAbsentPut:[self defaultSyntaxEmphasis]

    "Created: / 5.1.1980 / 00:43:39 / cg"
!

selectorColor
    "the color used for message selectors;
     If syntaxColoring is turned on."

    ^ self at:#selectorColor ifAbsentPut:[self defaultSyntaxColor]

    "Created: / 31.3.1998 / 15:19:19 / cg"
    "Modified: / 1.4.1998 / 13:24:04 / cg"
!

selectorEmphasis
    "the emphasis used for message selectors;
     If syntaxColoring is turned on."

    ^ self at:#selectorEmphasis ifAbsentPut:[UserPreferences default at:#selectorEmphasis]

    "Created: / 31.3.1998 / 15:19:09 / cg"
    "Modified: / 1.4.1998 / 13:23:59 / cg"
!

selfColor
    "the color used for the self pseudoVariable;
     If syntaxColoring is turned on."

    ^ self at:#selfColor ifAbsentPut:[self identifierColor]

    "Created: / 31.3.1998 / 17:35:45 / cg"
    "Modified: / 1.4.1998 / 13:21:07 / cg"
!

selfEmphasis
    "the emphasis used for the self pseudoVariable;
     If syntaxColoring is turned on."

    ^ self at:#selfEmphasis ifAbsentPut:[self identifierEmphasis]

    "Created: / 31.3.1998 / 17:34:57 / cg"
    "Modified: / 1.4.1998 / 13:21:51 / cg"
!

stringColor
    "the color used for string constants;
     If syntaxColoring is turned on."

    ^ self at:#stringColor ifAbsentPut:[self constantColor]

    "Created: / 31.3.1998 / 15:19:50 / cg"
    "Modified: / 1.4.1998 / 13:22:06 / cg"
!

stringEmphasis
    "the emphasis used for string constants;
     If syntaxColoring is turned on."

    ^ self at:#stringEmphasis ifAbsentPut:[self constantEmphasis]

    "Created: / 31.3.1998 / 15:19:09 / cg"
    "Modified: / 1.4.1998 / 13:22:00 / cg"
!

superColor
    "the color used for the super pseudoVariable;
     If syntaxColoring is turned on."

    ^ self at:#superColor ifAbsentPut:[self selfColor]

    "Created: / 31.3.1998 / 17:37:56 / cg"
    "Modified: / 1.4.1998 / 13:21:15 / cg"
!

superEmphasis
    "the emphasis used for the super pseudoVariable;
     If syntaxColoring is turned on."

    ^ self at:#superEmphasis ifAbsentPut:[self selfEmphasis]

    "Created: / 31.3.1998 / 17:35:08 / cg"
    "Modified: / 1.4.1998 / 13:21:41 / cg"
!

symbolColor
    "the color used for symbol constants;
     If syntaxColoring is turned on."

    ^ self at:#symbolColor ifAbsentPut:[self constantColor]

    "Created: / 1.4.1998 / 12:57:35 / cg"
    "Modified: / 1.4.1998 / 13:22:16 / cg"
!

symbolEmphasis
    "the emphasis used for symbol constants;
     If syntaxColoring is turned on."

    ^ self at:#symbolEmphasis ifAbsentPut:[self constantEmphasis]

    "Created: / 1.4.1998 / 12:57:43 / cg"
    "Modified: / 1.4.1998 / 13:23:43 / cg"
!

thisContextColor
    "the color used for the thisContext pseudoVariable;
     If syntaxColoring is turned on."

    ^ self at:#thisContextColor ifAbsentPut:[self identifierColor]

    "Created: / 31.3.1998 / 17:37:49 / cg"
    "Modified: / 1.4.1998 / 13:21:24 / cg"
!

thisContextEmphasis
    "the emphasis used for the thisContext pseudoVariable;
     If syntaxColoring is turned on."

    ^ self at:#thisContextEmphasis ifAbsentPut:[self identifierEmphasis]

    "Created: / 31.3.1998 / 17:35:27 / cg"
    "Modified: / 1.4.1998 / 13:21:30 / cg"
!

unimplementedSelectorColor
    "the color used for bad message selectors;
     If syntaxColoring is turned on."

    ^ self at:#unimplementedSelectorColor ifAbsentPut:[UserPreferences default at:#unimplementedSelectorColor]
!

unimplementedSelectorEmphasis
    "the emphasis used for bad message selectors;
     If syntaxColoring is turned on."

    ^ self at:#unimplementedSelectorEmphasis ifAbsentPut:[UserPreferences default at:#unimplementedSelectorEmphasis]

    "Created: / 31.3.1998 / 15:19:09 / cg"
    "Modified: / 1.4.1998 / 13:23:59 / cg"
!

unknownIdentifierColor
    "the color used for unknown identifiers;
     If syntaxColoring is turned on."

    ^ self at:#unknownIdentifierColor ifAbsentPut:[self badIdentifierColor]

    "
     self current at:#unknownIdentifierColor  put:Color red.
     self current at:#unknownIdentifierEmphasis  put:#bold

     self current unknownIdentifierColor
     self current unknownIdentifierEmphasis
    "

    "Created: / 31.3.1998 / 19:11:38 / cg"
    "Modified: / 1.4.1998 / 13:22:33 / cg"
!

unknownIdentifierEmphasis
    "the emphasis used for unknown identifiers;
     If syntaxColoring is turned on."

    ^ self at:#unknownIdentifierEmphasis ifAbsentPut:[self badIdentifierEmphasis]

    "Created: / 31.3.1998 / 19:11:55 / cg"
    "Modified: / 1.4.1998 / 13:22:45 / cg"
! !

!UserPreferences methodsFor:'accessing-prefs-code'!

categoryForMenuActionsMethods
    ^ 'menu actions'.
!

numberOfLinesForLongMethod
    "how many lines for a method's source to be considered as 'long'"

    ^ self at:#numberOfLinesForLongMethod ifAbsent:30

    "
     UserPreferences current numberOfLinesForLongMethod
    "
! !

!UserPreferences methodsFor:'accessing-prefs-editor'!

deleteSetsClipboardText
    "if true, a delete also updates the clipboard with the deleted text"

    ^ self at:#deleteSetsClipboardText ifAbsent:false

    "
     UserPreferences current deleteSetsClipboardText
    "
!

deleteSetsClipboardText:aBooleanOrNil
    "if true, a delete also updates the clipboard with the deleted text"

    ^ self at:#deleteSetsClipboardText put:aBooleanOrNil

    "
     UserPreferences current deleteSetsClipboardTextdeleteSetsClipboardText:true
     UserPreferences current deleteSetsClipboardText:false
     UserPreferences current deleteSetsClipboardText
    "
!

enforcedDropModeForFiles
    "when dropping a file, paste the name, the contents or ask ?
     (default is nil, for ask)"

    ^ self at:#enforcedDropModeForFiles ifAbsent:nil

    "
     UserPreferences current enforcedDropModeForFiles
    "
!

enforcedDropModeForFiles:aSymbolOrNil
    "when dropping a file, paste the name, the contents or ask ?
     (default is nil, for ask)"

    ^ self at:#enforcedDropModeForFiles put:aSymbolOrNil

    "
     UserPreferences current enforcedDropModeForFiles
    "
!

extendedWordSelectMode
    "when double clicking, include underscore, dollar and at-character as word-characters ?
     (default is on)"

    ^ self at:#extendedWordSelectMode ifAbsent:true

    "
     UserPreferences current extendedWordSelectMode
    "

    "Created: / 03-07-2006 / 16:49:58 / cg"
!

extendedWordSelectMode:aBoolean
    "when double clicking, include underscore, dollar and at-character as word-characters ?
     (default is on)"

    ^ self at:#extendedWordSelectMode put:aBoolean

    "
     UserPreferences current extendedWordSelectMode:true
     UserPreferences current extendedWordSelectMode:false
    "

    "Created: / 03-07-2006 / 16:50:20 / cg"
!

numberOfRememberedUndoOperationsInEditor
    "the number of possible undo-operations.
     Nil means: unlimited.
     Notice: you may run out of memory, if editing a lot and the number of undos is not limited."

    ^ self at:#numberOfRememberedUndoOperationsInEditor ifAbsent:nil

    "
     UserPreferences current numberOfRememberedUndoOperationsInEditor
    "

    "Modified: / 09-10-2006 / 11:01:35 / cg"
!

numberOfRememberedUndoOperationsInEditor:aNumberOrNil
    "the number of possible undo-operations.
     Nil means: unlimited.
     Notice: you may run out of memory, if editing a lot and the number of undos is not limited."

    ^ self at:#numberOfRememberedUndoOperationsInEditor put:aNumberOrNil

    "
     UserPreferences current numberOfRememberedUndoOperationsInEditor:20
    "

    "Created: / 09-10-2006 / 11:00:56 / cg"
!

st80EditMode
    "editing as in st80 (do not allow cursor beyond endOfLine/endOftext)."

    ^ self at:#st80EditMode ifAbsent:false

    "
     UserPreferences current st80EditMode
    "
!

st80EditMode:aBoolean
    "editing as in st80 (do not allow cursor beyond endOfLine/endOftext)."

    ^ self at:#st80EditMode put:aBoolean

    "
     UserPreferences current st80EditMode:true
    "
!

st80SelectMode
    "select mode, when double clicking as in st80
     (select to corresponding lparen/double-quote) ?"

    ^ self at:#st80SelectMode ifAbsent:false

    "
     UserPreferences current st80SelectMode
    "

    "Created: / 03-07-2006 / 16:25:19 / cg"
!

st80SelectMode:aBoolean
    "select mode, when double clicking as in st80
     (select to corresponding lparen/double-quote)."

    ^ self at:#st80SelectMode put:aBoolean

    "
     UserPreferences current st80SelectMode:true
     UserPreferences current st80SelectMode:false
    "

    "Created: / 03-07-2006 / 16:25:27 / cg"
!

whitespaceWordSelectMode
    "when double clicking, treat ANY non-whitespace as word-characters ?
     (default is off)"

    ^ self at:#whitespaceWordSelectMode ifAbsent:false

    "
     UserPreferences current whitespaceWordSelectMode
    "

    "Created: / 03-07-2006 / 16:49:58 / cg"
!

whitespaceWordSelectMode:aBoolean
    "when double clicking, treat ANY non-whitespace as word-characters ?
     (default is off)"

    ^ self at:#whitespaceWordSelectMode put:aBoolean

    "
     UserPreferences current whitespaceWordSelectMode:true
     UserPreferences current whitespaceWordSelectMode:false
    "

    "Created: / 03-07-2006 / 16:50:20 / cg"
! !

!UserPreferences methodsFor:'accessing-prefs-times'!

timeToAutoExpandItemsWhenDraggingOver
    "in a hierarchical tree view"

    ^ 700  "/ millis
!

twoDigitDateHandler
    "return a block which converts a two-digit date.
     Possible algorithms:
	- identity: treat as year 00..99
	- add 1900: treat as 1900..1999
	- around: treat as 1950..1999 if value is 50..99; 2000..2049 otherwise.

     TODO: make this configurable, keep in dictionary and add to settings.
    "

    ^ [:x | (x >= 50) ifTrue:[1900+x] ifFalse:[2000+x]].
    "/ ^ [:x | 1900+x].
    "/ ^ [:x | x].
! !

!UserPreferences methodsFor:'accessing-prefs-tools'!

allowSendMailFromDebugger
    "if true inserts a button in Debugger for open a GUI to send useful debugger infos per mail to a default
     mail account "

    ^ self at:#allowSendMailFromDebugger ifAbsent:true

    "
     UserPreferences current allowSendMailFromDebugger
    "

    "Modified: / 11.9.1998 / 00:09:59 / cg"
!

allowSendMailFromDebugger:aBoolean
    "if true inserts a button in Debugger for open a GUI to send useful debugger infos per mail to a default
     mail account "

    ^ self at:#allowSendMailFromDebugger put:aBoolean

    "
     UserPreferences current allowSendMailFromDebugger:true
     UserPreferences current allowSendMailFromDebugger:false
    "
!

autoDefineWorkspaceVariables
    "return the flag which controls automatic definition of unknown variables
     as workspace variables (in doIts)"

    ^ self at:#autoDefineWorkspaceVariables ifAbsent:false

    "
     UserPreferences current autoDefineWorkspaceVariables
    "
!

autoDefineWorkspaceVariables:aBoolean
    "turn on/off automatic definition of unknown variables
     as workspace variables (in doIts)"

    ^ self at:#autoDefineWorkspaceVariables put:aBoolean

    "
     UserPreferences current autoDefineWorkspaceVariables:true
     UserPreferences current autoDefineWorkspaceVariables:false
    "
!

autoRaiseDebugger
    "if true, the debugger raises itself automatically when entered.
     The default is true"

    ^ self at:#autoRaiseDebugger ifAbsent:true

    "
     UserPreferences current autoRaiseDebugger
    "

    "Created: / 15-05-2007 / 13:29:10 / cg"
!

autoRaiseDebugger:aBoolean
    "if true, the debugger raises itself automatically when entered.
     The default is true"

    ^ self at:#autoRaiseDebugger put:aBoolean

    "
     UserPreferences current autoRaiseDebugger
     UserPreferences current autoRaiseDebugger:false
     UserPreferences current autoRaiseDebugger:true
    "

    "Created: / 15-05-2007 / 13:29:31 / cg"
!

buildDirectory
    ^ self at:#buildDirectory ifAbsent:nil

    "
     UserPreferences current buildDirectory
    "
!

buildDirectory:aFilenameStringOrNil
    ^ self at:#buildDirectory put:aFilenameStringOrNil

    "
     UserPreferences current buildDirectory
    "
!

editToolbarVisibleInWorkspace
    "return the flag which defaults the edit-toolbar-visibility in a workspace application"

    ^ self at:#editToolbarVisibleInWorkspace ifAbsent:false
!

editToolbarVisibleInWorkspace:aBooleanOrNil
    "set the flag which defaults the edit-toolbar-visibility in a workspace application"

    ^ self at:#editToolbarVisibleInWorkspace put:aBooleanOrNil
!

functionKeySequences
    "return the collection of function-key macros.
     Thats a dictionary, which assigns code to F-keys"

    ^ self at:#functionKeySequences ifAbsentPut:[Dictionary new]

    "
     UserPreferences current functionKeySequences
    "

    "Modified: / 11.9.1998 / 00:09:59 / cg"
!

infoVisibleInWorkspace
    "return the flag which defaults the info-visibility in a workspace application"

    ^ self at:#infoVisibleInWorkspace ifAbsent:false

    "Created: / 14-07-2007 / 16:43:37 / cg"
!

infoVisibleInWorkspace:aBooleanOrNil
    "set the flag which defaults the info-visibility in a workspace application"

    ^ self at:#infoVisibleInWorkspace put:aBooleanOrNil

    "Created: / 14-07-2007 / 16:43:44 / cg"
!

language
    "/ intermediate migration code;
    "/ for now, Smalltalk uses a global language and territory setting;
    "/ however, for multi-user operation, this must be in a preference-setting.
    "/ For now, forward to smalltalk, until all references to "Smalltalk-language"
    "/ are replaced with "UserPreferences current language"

    ^ Smalltalk language

    "
     UserPreferences current language
    "

    "Created: / 20-09-2006 / 23:55:01 / cg"
!

language:aLanguageSymbol
    "/ intermediate migration code;
    "/ for now, Smalltalk uses a global language and territory setting;
    "/ however, for multi-user operation, this must be in a preference-setting.
    "/ For now, forward to smalltalk, until all references to "Smalltalk-language"
    "/ are replaced with "UserPreferences current language"

    Smalltalk language:aLanguageSymbol

    "
     UserPreferences current language
     UserPreferences current language:#en
    "

    "Created: / 20-09-2006 / 23:55:01 / cg"
!

languageTerritory
    "/ intermediate migration code;
    "/ for now, Smalltalk uses a global language and territory setting;
    "/ however, for multi-user operation, this must be in a preference-setting.
    "/ for now, forward to smalltalk, while all references to "Smalltalk-language"
    "/ are replaced with "UserPreferences current language"

    ^ Smalltalk languageTerritory

    "
     UserPreferences current languageTerritory
    "

    "Created: / 20-09-2006 / 23:55:01 / cg"
!

languageTerritory:aLanguageSymbol
    "/ intermediate migration code;
    "/ for now, Smalltalk uses a global language and territory setting;
    "/ however, for multi-user operation, this must be in a preference-setting.
    "/ For now, forward to smalltalk, until all references to "Smalltalk-language"
    "/ are replaced with "UserPreferences current language"

    Smalltalk languageTerritory:aLanguageSymbol

    "
     UserPreferences current languageTerritory 
     UserPreferences current languageTerritory:#en
    "

    "Created: / 20-09-2006 / 23:55:01 / cg"
!

localBuild
    ^ self at:#localBuild ifAbsent:true

    "Created: / 20-09-2006 / 23:55:01 / cg"
!

localBuild:aBoolean
    ^ self at:#localBuild put:aBoolean

    "
     UserPreferences current localBuild
    "

    "Created: / 20-09-2006 / 23:55:26 / cg"
!

showClockInLauncher
    "return the flag which controls if a clock is shown in the launcher"

    ^ self at:#showClockInLauncher ifAbsent:false

    "
     UserPreferences current showClockInLauncher
    "

    "Modified: / 11.9.1998 / 00:09:59 / cg"
!

showClockInLauncher:aBooleanOrNil
    "set/clear the flag which controls if a clock is shown in the launcher"

    ^ self at:#showClockInLauncher put:aBooleanOrNil

    "
     UserPreferences current showClockInLauncher:false.
     NewLauncher open.

     UserPreferences current showClockInLauncher:true.
     NewLauncher open.
    "

    "Modified: / 11.9.1998 / 00:09:59 / cg"
!

toolbarVisibleInWorkspace
    "return the flag which defaults the toolbar-visibility in a workspace application"

    ^ self at:#toolbarVisibleInWorkspace ifAbsent:true

    "Modified: / 18-07-2007 / 08:55:44 / cg"
!

toolbarVisibleInWorkspace:aBooleanOrNil
    "set the flag which defaults the toolbar-visibility in a workspace application"

    ^ self at:#toolbarVisibleInWorkspace put:aBooleanOrNil

    "Created: / 14-07-2007 / 16:42:09 / cg"
!

useNewLayoutInDebugger
    ^ self at:#useNewLayoutInDebugger ifAbsent:true

    "
     UserPreferences current useNewLayoutInDebugger
    "
!

useNewLayoutInDebugger:aBoolean
    ^ self at:#useNewLayoutInDebugger put:aBoolean
!

useRefactoringSupport
    "return the flag which enables/disables use of refactoring package in browser.
     If enabled, this enables all kinds of refactorings, better search and undo features.
     There is usually no reason to disable these."

    ^ self at:#useRefactoringSupport ifAbsent:true
!

useRefactoringSupport:aBooleanOrNil
    "enable/disable use of refactoring package in browser.
     If enabled, this enables all kinds of refactorings, better search and undo features.
     There is usually no reason to disable these."

    ^ self at:#useRefactoringSupport put:aBooleanOrNil

    "
     UserPreferences current useRefactoringSupport:false
     UserPreferences current useRefactoringSupport:true
    "
!

verboseBacktraceInDebugger
    ^ self at:#verboseBacktraceInDebugger ifAbsent:true

    "
     UserPreferences current verboseBacktraceInDebugger
    "
!

verboseBacktraceInDebugger:aBoolean
    ^ self at:#verboseBacktraceInDebugger put:aBoolean
! !

!UserPreferences methodsFor:'default settings'!

listOfPredefinedSyntaxColoringSchemes
    "return a list of pre-defined syntax highlightning styles
     (as shown in the Launchers 'source and debugger settings' dialog."

    ^ #(
            (#resetSyntaxColors                                         'default')
            (#resetSyntaxColorsToVCStyle                                'green comments; blue controlFlow, red constants [visual-c style]')
            (#resetSyntaxColorsBlueControlFlowSelectors                 'blue controlFlow')
            (#resetSyntaxColorsGreenComments                            'green comments')
            (#resetSyntaxColorsGreenCommentsBlueControlFlowSelectors    'green comments; blue controlFlow')
            (#resetSyntaxColorsBlueSelectorsGreenComments               'blue selectors; green comments [dolphin style]')
            (#resetSyntaxColorsBlueSelectorsGreyComments                'blue selectors; grey comments')
            (#resetSyntaxColorsToSqueakStyle1                           'blue selectors; green comments [squeak style]')
            (#resetSyntaxColorsToSqueakStyle2                           'blue selectors; green comments; brown self [new squeak style]')
            (#resetSyntaxColorsAllBlackExceptBadIDs                     'no colors, but highlight errors')
            (#resetSyntaxColorsToVW7Style                               'light blue comments [vw7 style]')
      )

    "Modified: / 08-09-2006 / 16:11:34 / cg"
!

resetSyntaxColors
    "resets the colors in the CurrentPreferences to their default values"

    self class syntaxColorKeys do:[:k | self removeKey:k ifAbsent:nil].


!

resetSyntaxColorsAllBlackExceptBadIDs
    "resets the colors in the CurrentPreferences to no-color mode,
     except for bad identifiers, which are underwaved."

    self class syntaxColorKeys do:[:k | self removeKey:k ifAbsent:nil].
    self at:#badIdentifierEmphasis  put:(Array with:#underwave with:(#underlineColor->Color red)).
    self at:#errorColor             put:Color black.
    self at:#commentColor           put:Color black.
    self at:#constantColor          put:Color black.
    self at:#methodSelectorEmphasis put:#normal.
    self at:#selectorEmphasis       put:#normal.
!

resetSyntaxColorsBlueControlFlowSelectors
    "resets the colors in the CurrentPreferences to alternative default values
     (with blue control flow selectors)"

    self class syntaxColorKeys do:[:k | self removeKey:k ifAbsent:nil].
    self at:#controlFlowSelectorColor put:(Color blue).

    "Created: / 08-09-2006 / 16:11:52 / cg"
!

resetSyntaxColorsBlueSelectorsGreenComments
    "resets the colors in the CurrentPreferences to alternative default values
     (with blue selectors and green comments)"

    self class syntaxColorKeys do:[:k | self removeKey:k ifAbsent:nil].
    self at:#commentColor           put:(Color green darkened).
    self at:#commentEmphasis        put:#italic.
    self at:#selectorColor          put:(Color blue).
    self at:#selectorEmphasis       put:#normal.
    self at:#methodSelectorColor    put:(Color blue).
    self at:#methodSelectorEmphasis put:#bold.
!

resetSyntaxColorsBlueSelectorsGreyComments
    "resets the colors in the CurrentPreferences to alternative default values
     (with blue selectors and grey comments)"

    self resetSyntaxColorsBlueSelectorsGreenComments.
    self at:#commentColor    put:(Color gray).
!

resetSyntaxColorsGreenComments
    "resets the colors in the CurrentPreferences to alternative default values
     (with green comments)"

    self class syntaxColorKeys do:[:k | self removeKey:k ifAbsent:nil].
    self at:#commentColor put:(Color green darkened).

!

resetSyntaxColorsGreenCommentsBlueControlFlowSelectors
    "resets the colors in the CurrentPreferences to alternative default values
     (with green comments, blue control flow)"

    self class syntaxColorKeys do:[:k | self removeKey:k ifAbsent:nil].
    self at:#commentColor put:(Color green darkened).
    self at:#controlFlowSelectorColor put:(Color blue).

    "Created: / 08-09-2006 / 16:10:38 / cg"
!

resetSyntaxColorsToSqueakStyle
    "resets the colors in the CurrentPreferences to alternative default values
     (with blue selectors and green comments)"

    self resetSyntaxColorsToSqueakStyle2
!

resetSyntaxColorsToSqueakStyle1
    "resets the colors in the CurrentPreferences to alternative default values
     (with blue selectors and green comments)"

    self class syntaxColorKeys do:[:k | self removeKey:k ifAbsent:nil].
    self at:#commentColor             put:(Color green darkened).
    self at:#commentEmphasis          put:#italic.
    self at:#selectorColor            put:(Color blue:80).
    self at:#selectorEmphasis         put:#normal.
    self at:#methodSelectorColor      put:(Color black).
    self at:#methodSelectorEmphasis   put:#bold.
    self at:#globalIdentifierEmphasis put:#bold.
    self at:#localIdentifierColor     put:(Color grey:40).
    self at:#instVarIdentifierEmphasis put:#bold.
    self at:#constantColor            put:(Color red:67).
!

resetSyntaxColorsToSqueakStyle2
    "resets the colors in the CurrentPreferences to alternative default values
     (with blue selectors and green comments)"

    self class syntaxColorKeys do:[:k | self removeKey:k ifAbsent:nil].
    self at:#commentColor             put:(Color green darkened).
    self at:#commentEmphasis          put:#italic.
    self at:#selectorColor            put:(Color blue:80).
    self at:#selectorEmphasis         put:#normal.
    self at:#methodSelectorColor      put:(Color black).
    self at:#methodSelectorEmphasis   put:#bold.
    self at:#globalIdentifierEmphasis put:#bold.
    self at:#localIdentifierColor     put:(Color grey:40).
    self at:#instVarIdentifierEmphasis put:#bold.
    self at:#constantColor            put:(Color red:67).
    self at:#selfColor                put:(Color red:50 ).
    self at:#selfEmphasis             put:#bold.
    self at:#localIdentifierColor     put:(Color grey:50 ).
    self at:#localIdentifierEmphasis  put:#normal.
!

resetSyntaxColorsToVCStyle
    "resets the colors in the CurrentPreferences to visual C default style
     (green comments, blue keywords, redish string constants)"

    self class syntaxColorKeys do:[:k | self removeKey:k ifAbsent:nil].
    self at:#controlFlowSelectorColor put:(Color blue).
    self at:#commentColor             put:(Color green darkened).
    self at:#constantColor            put:(Color red:64 green:8 blue:8).
!

resetSyntaxColorsToVW7Style
    "resets the colors in the CurrentPreferences to alternative default values
     (with light blue comments, green variables)"

    self class syntaxColorKeys do:[:k | self removeKey:k ifAbsent:nil].
    self at:#commentColor             put:(Color blue lightened).
    self at:#selectorColor            put:(Color black).
    self at:#selectorEmphasis         put:#normal.
    self at:#methodSelectorColor      put:(Color black).
    self at:#methodSelectorEmphasis   put:#bold.
    self at:#identifierEmphasis       put:#normal.
    self at:#identifierColor          put:(Color green darkened).
! !

!UserPreferences methodsFor:'default values'!

defaultValue
    "the defaultValue for non-existing keys"

    ^ false
!

errorKeyNotFound:aKey
    "for any non-existing key, false is returned"

    ^ self defaultValue
! !

!UserPreferences methodsFor:'misc'!

flyByHelpSettingChanged
    FlyByHelp notNil ifTrue:[
	(CurrentPreferences at:#flyByHelpActive) ifTrue:[
	    FlyByHelp start.
	] ifFalse:[
	    FlyByHelp stop.
	].
    ].
! !

!UserPreferences methodsFor:'obsolete'!

useNewSettinsApplication
    <resource: #obsolete>
    "obsolete - will be removed in next release.
     (this is kept for a while, as it may have found its way into some
      saved user preference files)"

    self obsoleteMethodWarning.
    ^ self useNewSettingsApplication
!

useNewSettinsApplication:aBoolean
    <resource: #obsolete>
    "obsolete - will be removed in next release"

    self obsoleteMethodWarning.
    self useNewSettingsApplication:aBoolean.
! !

!UserPreferences methodsFor:'saving'!

saveIn:fileName
    self class saveSettings:self in:fileName
! !

!UserPreferences class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic/UserPreferences.st,v 1.235 2009-10-26 15:19:32 fm Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/libbasic/UserPreferences.st,v 1.235 2009-10-26 15:19:32 fm Exp $'
! !