-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
DeNigrisPreferences.class.st
648 lines (509 loc) · 18.3 KB
/
DeNigrisPreferences.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
"
DeNigrisPreferences new syncSharedCaches.
"
Class {
#name : #DeNigrisPreferences,
#superclass : #Object,
#instVars : [
'lastLoadOnce',
'wasEachRunThisSession'
],
#classInstVars : [
'instance'
],
#category : 'DeNigrisPreferences-Core'
}
{ #category : #utilities }
DeNigrisPreferences class >> basicRun: str [
^ LibC system: str
]
{ #category : #utilities }
DeNigrisPreferences class >> extractTimestampsFromChunk: source [
| timestampParser |
self error: 'what about single digit months/days? 2015 is hard-coded'.
timestampParser := #digit asParser, #digit asParser, $/ asParser, #digit asParser, #digit asParser, '/2015 ' asParser, #digit asParser, #digit asParser, $: asParser, #digit asParser, #digit asParser.
timestampParser := timestampParser flatten.
^ (timestampParser island ==> #second) star parse: source
]
{ #category : #'class initialization' }
DeNigrisPreferences class >> initialize [
Smalltalk
addToStartUpList: self;
addToShutDownList: self
]
{ #category : #'instance creation' }
DeNigrisPreferences class >> instance [
^ instance ifNil: [ instance := self new ].
]
{ #category : #locations }
DeNigrisPreferences class >> laptopRepositoryRoot [
^ FileLocator home / 'Dynabook' / 'Repositories'.
]
{ #category : #utilities }
DeNigrisPreferences class >> linkPreferenceSupportFiles [
<script>
| cloneFolder source target |
cloneFolder := self localRepositoryRoot / 'DeNigris Preferences'.
#('localRepositoryRoot' 'startup.st') do: [ :filename |
source := cloneFolder / filename.
target := StartupPreferencesLoader preferencesGeneralFolder / filename.
LibC system: 'ln -s "', source fullName, '" "', target fullName, '"'. ]
]
{ #category : #locations }
DeNigrisPreferences class >> localRepositoryRoot [
^ self laptopRepositoryRoot exists
ifTrue: [ self laptopRepositoryRoot ]
ifFalse: [ self usbRepositoryRoot ].
]
{ #category : #private }
DeNigrisPreferences class >> log: aString [
UIManager default defer: [ UIManager default inform: 'DeNigrisPreferences: ', aString ].
Transcript show: aString; cr.
]
{ #category : #'world menu' }
DeNigrisPreferences class >> menuCommandOn: aBuilder [
<worldMenu>
(aBuilder item: #Finder)
action: [ Finder open ];
parent: #MostUsedTools;
help: 'Looking for something ?';
icon: Finder icon.
(aBuilder item: #Bootstraps)
with: [
(aBuilder item: #'SmallWorld')
action: [ self instance loadSmallWorld ].
(aBuilder item: #'DeNigrisSetup')
action: [ self instance loadSetup ] ].
(aBuilder item: #'Use LatAm Mirror')
action: [ self instance useLatAmMirror ].
(aBuilder item: #'IDE enhancements')
action: [ self instance loadDevEnhancements ].
(aBuilder item: #'Where Am I?')
action: [ self instance informImageFolder ].
]
{ #category : #locations }
DeNigrisPreferences class >> preferencesFolder [
| generalPreferencesFolder |
generalPreferencesFolder := self startupLoader default preferencesGeneralFolder.
^ generalPreferencesFolder exists
ifTrue: [ generalPreferencesFolder ]
ifFalse: [ self usbRepositoryRoot parent / 'Preferences' ].
]
{ #category : #utilities }
DeNigrisPreferences class >> run: aString [
"self run: 'open http://www.google.com'."
| exitCode |
exitCode := self basicRun: aString.
exitCode = 0 ifFalse: [ self error: '"', aString, '" failed with ', exitCode asString ].
]
{ #category : #utilities }
DeNigrisPreferences class >> saveStartupScript [
<script>
| loadActionBlock loadAction showErrorsAction |
self error: 'maybe broken'.
loadActionBlock := [
Gofer it
smalltalkhubUser: 'SeanDeNigris' project: 'DeNigrisPreferences';
package: 'DeNigrisPreferences-Core';
load ].
loadAction := StartupAction name: 'Load One-time Preferences' code: loadActionBlock runOnce: true.
showErrorsAction := StartupAction
name: 'Show any startup action errors'
code: [ StartupPreferencesLoader default errors ifNotEmpty: [ :errors | errors explore ] ]
runOnce: false.
StartupPreferencesLoader default addAtStartupInGeneralPreferenceFolder: { loadAction. showErrorsAction }.
]
{ #category : #UI }
DeNigrisPreferences class >> scriptBrowser [
<script>
| browser utils scripts |
utils := self methodsInProtocol: 'utilities'.
scripts := utils select: [ :u | u selector isUnary ].
browser := browser := GLMTabulator new.
browser
column: #one;
column: #two.
browser transmit
to: #one;
andShow: [ :a |
a list
format: [ :scr | scr selector normalizeCamelCase capitalized ];
onChangeOfPort: #strongSelection
act: [ :pres | pres selection valueWithReceiver: DeNigrisPreferences new arguments: #() ] ].
browser transmit
from: #one;
to: #two;
andShow: [ :a | a pharoMethod display: #sourceCode ].
"The following two lines could be replaced by #openOn:, but we'll keep them for documentation because #startOn: is what you would use when prototyping in the Moose Editor"
browser startOn: scripts.
browser open
]
{ #category : #locations }
DeNigrisPreferences class >> sharedCacheFolder [
^ self localRepositoryRoot / 'Shared Cache'.
]
{ #category : #'startup/shutdown' }
DeNigrisPreferences class >> shutDown: quitting [
DeNigrisPreferences instance shutDown: quitting.
]
{ #category : #'startup/shutdown' }
DeNigrisPreferences class >> startUp: newSession [
DeNigrisPreferences instance startUp: newSession.
]
{ #category : #accessing }
DeNigrisPreferences class >> startupLoader [
^ StartupPreferencesLoader
]
{ #category : #private }
DeNigrisPreferences class >> transcriptIsOpen [
World submorphThat: [ :e | e model = Transcript ] ifNone: [ ^ false ].
^ true.
]
{ #category : #locations }
DeNigrisPreferences class >> usbRepositoryRoot [
" | isMac |
isMac := FileLocator imageDirectory pathSegments first = 'Volumes'."
^ '/Volumes/SEAN/Smalltalk/Repositories' asFileReference.
]
{ #category : #MC }
DeNigrisPreferences >> addMyMcRepos [
| urls |
urls := { self myMetaRepoUrl. self myOutboxRepoUrl. self myPlaygroundRepoUrl }.
urls do: [ :url | | repo |
repo := MCHttpRepository location: url asString.
MCRepositoryGroup default addRepository: repo ].
MlFrontDesk new
logInToSqueakSource;
logInToSqueakSource3;
logInToSmalltalkHub.
]
{ #category : #testing }
DeNigrisPreferences >> areNonUpdateScriptPackagesPresent [
| updateMessage updateMethod scriptMessage filesLoadedByScript scriptPackagesNotLoaded packagesNotInScript |
updateMessage := ('update', SystemVersion current highestUpdate asString) asSymbol.
updateMethod := ScriptLoader >> updateMessage.
scriptMessage := (updateMethod literalStrings detect: [ :e | e matchesRegex: 'script[[:digit:]]+' ]) asSymbol.
filesLoadedByScript := ScriptLoader new perform: scriptMessage.
scriptPackagesNotLoaded := filesLoadedByScript reject: [ :e | MCPackage allInstances anySatisfy: [ :f | e beginsWith: f name ] ].
packagesNotInScript := MCPackage allInstances reject: [ :e | filesLoadedByScript anySatisfy: [ :f | f beginsWith: e name ] ].
^ scriptPackagesNotLoaded isEmpty and: [ packagesNotInScript isEmpty ].
]
{ #category : #'private-loading' }
DeNigrisPreferences >> basicLoadEachStartup [
self log: 'Loading "each startup" script...'.
Author fullName: 'SeanDeNigris'.
"Set paths on each startup because they will be different if we are on a USB stick"
self useSharedCacheRepository.
self setLocalRepositoryRoot.
self updateTheme.
self confirmCorrectVM.
" self syncSharedCaches."
self setMcConfigurationFolder.
self hasLoadOnceChanged ifFalse: [ ^ self ].
self log: 'Latest version of load-once script has never been run...'.
self loadOnce
]
{ #category : #utilities }
DeNigrisPreferences >> browseMethodsSelect: aBlock [
"self new browseMethodsSelect: [ :e | e dateMethodLastSubmitted = '1/24/2010' asDate ]"
[ :job | SystemNavigation new browseAllSelect: [ :e |
job increment.
aBlock value: e ] ] asJob
max: 100000;
run.
]
{ #category : #actions }
DeNigrisPreferences >> closeWelcomeWindow [
| welcomeWindows |
welcomeWindows := World windowsSatisfying: [ :e | e label beginsWith: 'Welcome to Pharo' ].
welcomeWindows do: [ :e | e delete ].
]
{ #category : #actions }
DeNigrisPreferences >> configureFormatter [
"See RBConfigurableFormatter class-side settings"
]
{ #category : #actions }
DeNigrisPreferences >> configureIceberg [
Iceberg enableMetacelloIntegration: true.
"Enable the following if needed, but judging from comments in the community, it does not really fit well with git workflows"
"IceLibgitRepository
shareRepositoriesBetweenImages: true;
sharedRepositoriesLocation: self class localRepositoryRoot"
]
{ #category : #actions }
DeNigrisPreferences >> confirmCorrectVM [
"Mac OS X is really weird. No matter how many times you associate an app with a file type, it often silently changes and starts using a different version of Pharo"
| normalVmLocations |
"For Windows, we don't know the drive letter where the USB drive will be mounted, so we leave it out and pattern match.
For Mac, right now we're assuming my home computer"
normalVmLocations := #(
'/usr/local/bin/pharo-vm/Pharo.app/Contents/MacOS/Pharo'
'/Volumes/SEAN/Smalltalk/pharo-vm/Pharo.app/Contents/MacOS/Pharo'
':\Smalltalk\pharo-vm\Win (92)\Pharo.exe').
(normalVmLocations anySatisfy: [ :e | Smalltalk vm vmFileName includesSubstring: e ])
ifFalse: [ self log: 'Different VM: ', Smalltalk vm vmFileName ].
]
{ #category : #actions }
DeNigrisPreferences >> customizeCompletion [
NECPreferences
enabled: true;
caseSensitive: true;
expandPrefixes: true;
useEnterToAccept: false;
smartCharacters: true;
smartCharactersWithDoubleSpace: '[]{}';
spaceAfterCompletion: false;
popupAutomaticDelay: 100.
]
{ #category : #Launcher }
DeNigrisPreferences >> customizeLauncher [
self isLauncherImage ifFalse: [ ^ self ].
self setLauncherImageDirectory.
PhLLaunchImageCommand warnOnArchMismatch: false. "Warns about 322-bit lib dependency on Linux"
self loadSmallWorld.
]
{ #category : #accessing }
DeNigrisPreferences >> daytimeTheme [
^ PharoLightTheme
]
{ #category : #utilities }
DeNigrisPreferences >> disableLatAmMirror [
(Smalltalk at: #MRManager) removeFrom: 'http://www.squeaksource.com/'.
]
{ #category : #utilities }
DeNigrisPreferences >> disablePackageCacheDuring: aBlock [
| originalCacheDirectory tempCache |
originalCacheDirectory := MCCacheRepository cacheDirectory.
tempCache := (FileLocator imageDirectory / 'temporary-empty-package-cache') ensureDirectory.
[
MCCacheRepository cacheDirectory: tempCache.
aBlock value.
] ensure: [
MCCacheRepository cacheDirectory: originalCacheDirectory.
tempCache deleteAll ].
]
{ #category : #actions }
DeNigrisPreferences >> enableShortcutHelp [
ShortcutReminder enabled: true.
]
{ #category : #utilities }
DeNigrisPreferences >> fixIcebergRepoLocations [
"E.g. after an image is moved or renamed, its local Iceberg repos become broken because the locations are stored as static FileReferences instead of dynamic FileLocations following the image around. Limitation: assumes all images are stored in flat folders under root"
| imageRoot repos |
imageRoot := FileLocator home / 'Dynabook' / 'Working Images'.
repos := IceLibgitRepository allSubInstances
select: [ :e |
e location isNotNil
and: [ (FileLocator imageDirectory contains: e location) not
and: [ imageRoot contains: e location ] ] ].
repos
do: [ :e |
| oldPath newPath fixedLocation |
oldPath := e location relativeTo: imageRoot.
newPath := RelativePath withAll: oldPath segments allButFirst.
fixedLocation := FileLocator imageDirectory withPath: newPath.
e location: fixedLocation ]
]
{ #category : #fixes }
DeNigrisPreferences >> fixIssue5656 [
"Issue 5656: Large fonts make tools slow
http://code.google.com/p/pharo/issues/detail?id=5656"
| smallerFont |
smallerFont := LogicalFont familyName: 'Bitmap DejaVu Sans' pointSize: 12.
StandardFonts defaultFont: smallerFont.
]
{ #category : #'private-testing' }
DeNigrisPreferences >> hasLoadOnceChanged [
^ lastLoadOnce ~= (self class>>#loadOnce) timeStamp.
]
{ #category : #actions }
DeNigrisPreferences >> informImageFolder [
UIManager default inform: FileLocator imageDirectory fullName.
]
{ #category : #'initialize-release' }
DeNigrisPreferences >> initialize [
super initialize.
wasEachRunThisSession := false.
]
{ #category : #utilities }
DeNigrisPreferences >> installCalypso [
Metacello new
baseline: 'Calypso';
repository: 'github://dionisiydk/Calypso';
load.
#ClyBrowser asClass beAllDefault
]
{ #category : #Launcher }
DeNigrisPreferences >> isLauncherImage [
^ Smalltalk globals hasClassNamed: #PhLDirectoryBasedImageRepository
]
{ #category : #'project loading' }
DeNigrisPreferences >> loadDevEnhancements [
Gofer it
squeaksource3: 'PharoSpd';
package: 'ConfigurationOfBatcave';
load.
(Smalltalk at: #ConfigurationOfBatcave) project bleedingEdge load.
]
{ #category : #loading }
DeNigrisPreferences >> loadEachStartup [
self wasEachRunThisSession ifTrue: [
"I want to figure out when this would be hit. I don't remember. After I figure it out, remove the exception.
* One circumstance is if an image is saved, then is not properly shut down e.g. crashes"
UIManager default inform: 'Preferences each load already run'.
^ self ].
wasEachRunThisSession := true.
"self log: 'Updating...'.
self class update."
self basicLoadEachStartup.
]
{ #category : #loading }
DeNigrisPreferences >> loadOnce [
self log: 'Loading one-time startup script...'.
self configureIceberg.
self closeWelcomeWindow.
self setFonts.
self configureFormatter.
self customizeLauncher.
self customizeCompletion.
Smalltalk tools debugger alwaysOpenFullDebugger: true.
WorldState easySelectingWorld: true.
Morph cycleHalosBothDirections: true.
self addMyMcRepos.
self enableShortcutHelp.
lastLoadOnce := thisContext method timeStamp.
]
{ #category : #'project loading' }
DeNigrisPreferences >> loadSetup [
Gofer it
directory: (self class localRepositoryRoot / 'Setup') fullName;
package: 'ConfigurationOfDeNigrisSetup';
load.
(Smalltalk at: #ConfigurationOfDeNigrisSetup) project bleedingEdge load.
]
{ #category : #'project loading' }
DeNigrisPreferences >> loadSmallWorld [
Metacello new
repository: 'github://seandenigris/Small-World:master/repository';
baseline: 'SmallWorld';"
onConflict: [ :ex | ex allow ];"
load
]
{ #category : #logging }
DeNigrisPreferences >> log: aString [
self class log: aString.
]
{ #category : #utilities }
DeNigrisPreferences >> migrate: oldProjectName fromSqueakSourceToSmalltalkHubAs: newProjectName [
| source destination |
self error: 'Moved to McProjectMigrate in Playground'.
MlConfigurationFile new credentialsForSmalltalkHubDuring: [ :username :password |
source := MCHttpRepository location: 'http://www.squeaksource.com/', oldProjectName.
destination := MCSmalltalkhubRepository
owner: username
project: newProjectName
user: username
password: password ].
#McProjectMigrate asClass new
source: source;
destination: destination;
execute.
]
{ #category : #utilities }
DeNigrisPreferences >> myMetaRepoUrl [
^ 'http://smalltalkhub.com/mc/SeanDeNigris/SeansMetaRepo/main' asUrl.
]
{ #category : #MC }
DeNigrisPreferences >> myOutboxRepoUrl [
^ 'http://smalltalkhub.com/mc/SeanDeNigris/SeansOutbox/main' asUrl.
]
{ #category : #MC }
DeNigrisPreferences >> myPlaygroundRepoUrl [
^ 'http://smalltalkhub.com/mc/SeanDeNigris/SeansPlayground/main' asUrl.
]
{ #category : #accessing }
DeNigrisPreferences >> nighttimeTheme [
^ PharoDarkTheme
]
{ #category : #folders }
DeNigrisPreferences >> pharoRepositories [
^ FileLocator home / 'Dynabook' / 'Repositories'
]
{ #category : #actions }
DeNigrisPreferences >> refreshPackageNamed: aString [
| package |
package := RPackageOrganizer default packageNamed: aString.
package
forceRefreshClassDefinedSelectors;
forceRefreshMetaclassDefinedSelectors.
]
{ #category : #utilities }
DeNigrisPreferences >> replace: oldString with: newString in: file [
"self new replace: 'fred' with: 'BOB' in: 'myfile.txt'"
| original newContents |
original := file asFileReference readStreamDo: [ :in | in contents ].
newContents := original copyReplaceAll: oldString with: newString.
file asFileReference writeStreamDo: [ :out | out nextPutAll: newContents ].
]
{ #category : #folders }
DeNigrisPreferences >> rootDataFolder [
^ FileLocator home / 'Dynabook' / 'User Data'
]
{ #category : #actions }
DeNigrisPreferences >> setFonts [
^ SourceCodeFonts setSourceCodeFonts: SourceCodeFonts sizeLarge.
]
{ #category : #Launcher }
DeNigrisPreferences >> setLauncherImageDirectory [
#PhLDirectoryBasedImageRepository asClass location: FileLocator home / 'Dynabook' / 'Working Images'
]
{ #category : #actions }
DeNigrisPreferences >> setLocalRepositoryRoot [
MCDirectoryRepository defaultDirectoryName: self class localRepositoryRoot fullName.
]
{ #category : #'private-loading' }
DeNigrisPreferences >> setMcConfigurationFolder [
MlConfigurationFile folder: self class preferencesFolder
]
{ #category : #'startup/shutdown' }
DeNigrisPreferences >> shutDown: quitting [
quitting ifTrue: [ wasEachRunThisSession := false ].
]
{ #category : #'startup/shutdown' }
DeNigrisPreferences >> startUp: newSession [
newSession ifFalse: [ ^ self ].
self loadEachStartup.
self class startupLoader default errors ifNotEmpty: [ :errors | errors explore ].
]
{ #category : #utilities }
DeNigrisPreferences >> syncSharedCaches [
"self new syncSharedCaches"
DpSyncSharedCaches new execute.
]
{ #category : #actions }
DeNigrisPreferences >> updateTheme [
"Try out the Dark Theme for now..."
"(Time now between: '7:00am' asTime and: '9:00pm' asTime)
ifTrue: [ self daytimeTheme installFullTheme ]
ifFalse: [" self nighttimeTheme beCurrent "]"
]
{ #category : #utilities }
DeNigrisPreferences >> useLatAmMirror [
Gofer new
url: 'http://dsal.cl/squeaksource/MetacelloRepository';
package: 'ConfigurationOfMonticelloRedirect';
load.
(Smalltalk at: #ConfigurationOfMonticelloRedirect) load.
(Smalltalk at: #MRManager) redirectFrom: 'http://www.squeaksource.com/' to: 'http://dsal.cl/squeaksource/'.
]
{ #category : #actions }
DeNigrisPreferences >> useSharedCacheRepository [
MCCacheRepository cacheDirectory resolve = self class sharedCacheFolder resolve ifTrue: [ ^ self ].
[ MCCacheRepository cacheDirectory: self class sharedCacheFolder ensureCreateDirectory ]
on: Error
do: [ :err | UIManager default inform: 'Failed setting the shared cache' ]
]
{ #category : #'private-testing' }
DeNigrisPreferences >> wasEachRunThisSession [
^ wasEachRunThisSession.
]