Repository navigation
Expand file tree
/
Copy pathsettingspanel.cpp
More file actions
782 lines (768 loc) · 35.8 KB
/
Copy pathsettingspanel.cpp
File metadata and controls
782 lines (768 loc) · 35.8 KB
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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
#include "settingspanel.hpp"
#include "eterm.hpp"
#include <eepp/ui/tools/fileassociationssettings.hpp>
#include <eepp/ui/tools/uisettingspanel.hpp>
#include <eepp/ui/uidropdownlist.hpp>
#include <eepp/ui/uifiledialog.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/uiwindow.hpp>
#include <string>
using namespace EE::UI::Tools;
namespace eterm {
UIWindow* SettingsPanel::create( App& app ) {
UIWindow::StyleConfig windowStyle{ UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON |
UI_WIN_MODAL };
auto settingsWindow = UIWindow::NewOpt( UIWindow::SIMPLE_LAYOUT, windowStyle );
settingsWindow->setId( "settings_panel" );
settingsWindow->setTitle( app.i18n( "settings", "Settings" ) );
const auto sceneSize = app.scene->getPixelsSize();
settingsWindow->setPixelsSize(
{ std::min( sceneSize.getWidth() * 0.9f, PixelDensity::dpToPx( 1280 ) ),
std::min( sceneSize.getHeight() * 0.9f, PixelDensity::dpToPx( 900 ) ) } );
settingsWindow->setMinWindowSize( 640, 440 );
auto* panel = UISettingsPanel::New( settingsWindow->getContainer() );
panel->setId( "settings_panel_content" );
panel->setSearchResultsText( app.i18n( "search_results", "Search Results" ) );
panel->addCategory( "general.keybindings", app.i18n( "general", "General" ),
app.i18n( "kb_title", "Keyboard Shortcuts" ) );
panel->addCustomWidget(
{ "keybindingsEditor",
"general.keybindings",
app.i18n( "kb_title", "Keyboard Shortcuts" ),
{} },
[&app]( UIWidget* parent ) { return app.createKeybindingsEditor( parent ); }, true );
FileAssociationsSettings::addLauncherTo( panel, "eterm" );
panel->addCategory( "appearance.theme", app.i18n( "appearance", "Appearance" ),
app.i18n( "theme_and_language", "Theme & Language" ) );
panel->addChoice(
{ "uiColorScheme", "appearance.theme",
app.i18n( "ui_prefes_color_scheme", "UI Prefers Color Scheme" ),
app.i18n(
"ui_prefers_color_scheme_desc",
"Choose whether the interface follows the system, light, or dark appearance." ) },
{ app.i18n( "system", "System" ), app.i18n( "light", "Light" ),
app.i18n( "dark", "Dark" ) },
[&app] {
return app.config->theme.uiColorScheme == ColorSchemeExtPreference::System ? size_t{ 0 }
: app.config->theme.uiColorScheme == ColorSchemeExtPreference::Light
? size_t{ 1 }
: size_t{ 2 };
},
[&app]( size_t selected ) {
static constexpr ColorSchemeExtPreference values[] = { ColorSchemeExtPreference::System,
ColorSchemeExtPreference::Light,
ColorSchemeExtPreference::Dark };
app.config->theme.uiColorScheme = values[std::min( selected, size_t{ 2 } )];
app.scene->setColorSchemePreference( app.config->theme.uiColorScheme );
app.scene->updateWindowTitleBarColor();
app.savePreferences();
} );
panel->addCategory( "appearance.fonts", app.i18n( "appearance", "Appearance" ),
app.i18n( "fonts_and_scale", "Fonts & Scale" ) );
panel->addAction(
{ "uiFont", "appearance.fonts",
app.i18n( "ui_font_and_size_ellipsis", "UI Font & Size..." ),
app.i18n( "ui_font_desc", "Choose the proportional font used by the interface." ) },
app.i18n( "choose_font", "Choose Font..." ),
[&app] { app.settingsActions->openFontPicker( true ); } );
panel->addAction(
{ "terminalFont", "appearance.fonts",
app.i18n( "terminal_font_and_size_ellipsis", "Terminal Font & Size..." ),
app.i18n( "terminal_font_desc", "Choose the monospace font used by terminals." ) },
app.i18n( "choose_font", "Choose Font..." ),
[&app] { app.settingsActions->openFontPicker( false ); } );
panel->addAction(
{ "fallbackFont", "appearance.fonts",
app.i18n( "fallback_font_ellipsis", "Fallback Font..." ),
app.i18n( "fallback_font_desc", "Choose the font used for missing glyphs." ) },
app.i18n( "choose_font", "Choose Font..." ),
[&app] { app.settingsActions->openFontPicker( false, true ); } );
panel->addFloat(
{ "uiFontSize", "appearance.fonts", app.i18n( "ui_font_size", "UI Font Size" ),
app.i18n( "ui_font_size_desc", "Set the font size used by the application UI." ) },
6, 72, 0.5,
[&app] {
if ( app.config->font.uiSize > 0 )
return app.config->font.uiSize;
auto* theme = app.scene->getUIThemeManager()->getDefaultTheme();
return theme ? PixelDensity::pxToDp( theme->getDefaultFontSize() ) : Float( 11 );
},
[&app]( double value ) { app.settingsActions->setUIFontSize( value ); } );
panel->addFloat(
{ "terminalFontSize", "appearance.fonts",
app.i18n( "terminal_font_size", "Terminal Font Size" ),
app.i18n( "terminal_font_size_desc", "Set the default terminal font size." ) },
6, 72, 0.5, [&app] { return app.config->font.size; },
[&app]( double value ) { app.settingsActions->setTerminalFontSize( value ); } );
panel->addFloat(
{ "uiScaleFactor", "appearance.fonts", app.i18n( "ui_scale_factor", "UI Scale Factor" ),
app.i18n( "ui_scale_factor_desc",
"Scale the complete user interface. Restart required." ) },
1, 6, 0.1,
[&app] {
return app.config->window.pixelDensity > 0 ? app.config->window.pixelDensity
: PixelDensity::getPixelDensity();
},
[&app]( double value ) {
app.config->window.pixelDensity = value;
app.savePreferences();
} );
panel->addChoice(
{ "fontHinting", "appearance.fonts", app.i18n( "ui_font_hint", "Font Hinting" ),
app.i18n( "ui_font_hint_desc", "Control glyph alignment to the pixel grid." ) },
{ app.i18n( "none", "None" ), app.i18n( "slight", "Slight" ), app.i18n( "full", "Full" ) },
[&app] { return static_cast<size_t>( app.config->font.hinting ); },
[&app]( size_t selected ) {
static constexpr FontHinting values[] = { FontHinting::None, FontHinting::Slight,
FontHinting::Full };
app.config->font.hinting = values[std::min( selected, size_t{ 2 } )];
app.settingsActions->applyFontRendering();
app.savePreferences();
} );
panel->addChoice(
{ "fontAntialiasing", "appearance.fonts",
app.i18n( "ui_font_antialiasing", "Font Anti-Aliasing" ),
app.i18n( "ui_font_antialiasing_desc", "Choose how glyph edges are smoothed." ) },
{ app.i18n( "none", "None" ), app.i18n( "grayscale", "Grayscale" ),
app.i18n( "subpixel", "Subpixel" ) },
[&app] { return static_cast<size_t>( app.config->font.antialiasing ); },
[&app]( size_t selected ) {
static constexpr FontAntialiasing values[] = {
FontAntialiasing::None, FontAntialiasing::Grayscale, FontAntialiasing::Subpixel };
app.config->font.antialiasing = values[std::min( selected, size_t{ 2 } )];
app.settingsActions->applyFontRendering();
app.savePreferences();
} );
panel->addCategory( "window.behavior", app.i18n( "window", "Window" ),
app.i18n( "behavior", "Behavior" ) );
panel->addBool(
{ "exitOnClose", "window.behavior", app.i18n( "exit_on_close", "Exit on Close" ),
app.i18n( "exit_on_close_desc", "Exit when closing the window. Disable to keep the "
"application and its workspace open." ) },
&app.config->window.exitOnClose, [&app]( bool value ) {
app.application->setExitOnClose( value );
app.savePreferences();
} );
panel->addCategory( "window.renderer", app.i18n( "window", "Window" ),
app.i18n( "renderer", "Renderer" ) );
panel->addBool(
{ "vsync", "window.renderer", app.i18n( "vsync", "VSync" ),
app.i18n( "vsync_desc", "Synchronize rendering with the display. Restart required." ) },
&app.config->window.vsync, [&app]( bool ) { app.savePreferences(); } );
const String monitorRefreshRate = app.i18n( "monitor_refresh_rate", "Monitor Refresh Rate" );
const String unlimitedFrameRate = app.i18n( "unlimited", "Unlimited" );
panel->addEditableChoice(
{ "frameRateLimit", "window.renderer", app.i18n( "frame_rate_limit", "Frame Rate Limit" ),
app.i18n( "frame_rate_limit_desc", "Limit rendered frames per second, follow the monitor "
"refresh rate, or disable the limit." ) },
{ monitorRefreshRate, unlimitedFrameRate, "30", "60", "75", "120", "144", "165", "240" },
[&app, monitorRefreshRate, unlimitedFrameRate] {
return app.config->window.maxFPS ==
static_cast<Uint32>( ContextSettings::FrameRateLimitScreenRefreshRate )
? monitorRefreshRate
: app.config->window.maxFPS == 0
? unlimitedFrameRate
: String( String::toString( app.config->window.maxFPS ) );
},
[&app, monitorRefreshRate, unlimitedFrameRate]( const String& selection ) {
Uint32 value;
if ( selection == monitorRefreshRate )
value = ContextSettings::FrameRateLimitScreenRefreshRate;
else if ( selection == unlimitedFrameRate )
value = 0;
else if ( !String::fromString( value, selection ) || value > 1000 )
return false;
app.config->window.maxFPS = value;
app.appWindow->setFrameRateLimit( value );
app.savePreferences();
return true;
} );
auto rendererVersions = Renderer::getAvailableGraphicsLibraryVersions();
std::vector<String> rendererNames;
for ( auto version : rendererVersions )
rendererNames.emplace_back( Renderer::graphicsLibraryVersionToString( version ) );
if ( !rendererVersions.empty() )
panel->addChoice(
{ "rendererVersion", "window.renderer",
app.i18n( "ui_renderer_version", "Renderer Version" ),
app.i18n( "ui_renderer_version_desc",
"Select the graphics API. Restart required." ) },
rendererNames,
[&app, rendererVersions] {
auto found = std::find( rendererVersions.begin(), rendererVersions.end(),
app.config->window.rendererVersion );
return found == rendererVersions.end()
? size_t{ 0 }
: static_cast<size_t>( found - rendererVersions.begin() );
},
[&app, rendererVersions]( size_t selected ) {
app.config->window.rendererVersion =
rendererVersions[std::min( selected, rendererVersions.size() - 1 )];
app.savePreferences();
} );
panel->addChoice(
{ "multisamples", "window.renderer",
app.i18n( "ui_multisamples_level", "Multisample Anti-Aliasing Level" ),
app.i18n( "ui_multisamples_level_desc",
"Set renderer multisampling. Restart required." ) },
{ "0", "2", "4", "8", "16" },
[&app] {
static constexpr Uint32 values[] = { 0, 2, 4, 8, 16 };
auto found = std::find( std::begin( values ), std::end( values ),
app.config->window.multisamples );
return found == std::end( values )
? size_t{ 0 }
: static_cast<size_t>( found - std::begin( values ) );
},
[&app]( size_t selected ) {
static constexpr Uint32 values[] = { 0, 2, 4, 8, 16 };
app.config->window.multisamples = values[std::min( selected, size_t{ 4 } )];
app.savePreferences();
} );
panel->addBool(
{ "benchmarkMode", "window.renderer", app.i18n( "benchmark_mode", "Benchmark Mode" ),
app.i18n( "benchmark_mode_desc", "Render continuously to measure performance." ) },
&app.config->window.benchmarkMode, [&app]( bool value ) {
app.benchmarkMode = value;
app.savePreferences();
} );
panel->addCategory( "terminal.behavior", app.i18n( "terminal", "Terminal" ),
app.i18n( "behavior", "Behavior" ) );
panel->addBool( { "enableOsc8Hyperlinks", "terminal.behavior",
app.i18n( "enable_osc8_hyperlinks", "Enable Hyperlinks (OSC 8)" ),
app.i18n( "enable_osc8_hyperlinks_desc",
"Allow terminal programs to attach clickable links to text." ) },
&app.config->terminal.enableOsc8Hyperlinks, [&app]( bool value ) {
app.forEachTerminal( [value]( UITerminal* terminal ) {
terminal->getTerm()->setOsc8HyperlinksEnabled( value );
} );
app.savePreferences();
} );
panel->addBool( { "detectLinks", "terminal.behavior",
app.i18n( "detect_links", "Detect Links and Paths" ),
app.i18n( "detect_links_desc",
"Underline URLs and file paths in the text while the default "
"modifier is held, and open them on click." ) },
&app.config->terminal.detectLinks, [&app]( bool value ) {
app.forEachTerminal( [value]( UITerminal* terminal ) {
terminal->getTerm()->setLinkDetectionEnabled( value );
} );
app.savePreferences();
} );
panel->addBool( { "showProgramStatus", "terminal.behavior",
app.i18n( "show_program_status", "Show Program Status" ),
app.i18n( "show_program_status_desc",
"Show in each tab whether its program is working, waiting for you, "
"finished or failed, when the program reports it." ) },
&app.config->terminal.showProgramStatus, [&app]( bool ) {
app.forEachTerminal( [&app]( UITerminal* terminal ) {
app.updateWidgetProgramStatus( terminal );
} );
app.savePreferences();
} );
panel->addCategory( "terminal.alerts", app.i18n( "terminal", "Terminal" ),
app.i18n( "program_status_alerts", "Program Status Alerts" ) );
panel->addBool( { "programStatusNotifications", "terminal.alerts",
app.i18n( "programStatusNotifications", "OS Notifications" ),
app.i18n( "programStatusNotifications_desc",
"Send OS notifications when a program needs attention, finishes or "
"fails." ) },
&app.config->terminal.programStatusNotifications,
[&app]( bool ) { app.savePreferences(); } );
panel->addAction(
{ "testProgramStatusNotification", "terminal.alerts",
app.i18n( "test_notification", "Test Notification" ),
app.i18n( "test_notification_desc",
"Send one OS notification, even when automatic notifications are disabled." ) },
app.i18n( "test", "Test" ), [&app] {
const auto feedback = [&app]( const String& text ) {
// Resolve on the UI thread: settings may have been closed while the helper ran.
if ( auto* row =
app.scene->find<UIWidget>( "setting_testProgramStatusNotification" ) )
row->find<UITextView>( "setting_description" )->setText( text );
};
feedback( app.i18n( "sending_notification", "Sending test notification…" ) );
const bool accepted = app.programStatusAlerts.deliver(
app.i18n( "test_notification_title", "eterm · Test notification" ).toUtf8(),
app.i18n( "test_notification_message", "This is a test notification from eterm." )
.toUtf8(),
true, false, {}, 0, true, [&app, feedback]( bool success, std::string error ) {
// App joins the alert worker before destroying the scene.
app.scene->runOnMainThread( [&app, feedback, success,
error = std::move( error )] {
feedback( success
? app.i18n( "notification_submitted",
"Notification submitted. If no banner appears, "
"check OS notification permissions and Do Not "
"Disturb (eterm on macOS)." )
: String::fromUtf8( error ) );
} );
} );
if ( !accepted )
feedback( app.i18n( "notification_busy",
"Another alert is being delivered. Try again shortly." ) );
} );
panel->addBool(
{ "programStatusSounds", "terminal.alerts", app.i18n( "programStatusSounds", "Play Sound" ),
app.i18n( "programStatusSounds_desc",
"Play the selected sound on program status changes." ) },
&app.config->terminal.programStatusSounds, [&app]( bool ) { app.savePreferences(); } );
panel->addBool( { "programStatusAlertsWhenActive", "terminal.alerts",
app.i18n( "programStatusAlertsWhenActive", "Alert for Active Terminal" ),
app.i18n( "programStatusAlertsWhenActive_desc",
"Also alert while you are using that terminal." ) },
&app.config->terminal.programStatusAlertsWhenActive,
[&app]( bool ) { app.savePreferences(); } );
panel->addBool( { "programStatusAlertsAllStates", "terminal.alerts",
app.i18n( "programStatusAlertsAllStates", "Include Working and Idle" ),
app.i18n( "programStatusAlertsAllStates_desc",
"Also alert when programs start working or become idle. Percentage "
"and text updates stay silent." ) },
&app.config->terminal.programStatusAlertsAllStates,
[&app]( bool ) { app.savePreferences(); } );
panel->addCustomWidget(
{ "programStatusSound", "terminal.alerts", app.i18n( "alert_sound", "Sound" ),
app.i18n( "alert_sound_desc",
"Choose a built-in sound or an MP3, WAV (PCM), Ogg/Vorbis or FLAC file." ) },
[&app]( UIWidget* parent ) {
auto* layout = app.scene->loadLayoutFromString( R"xml(
<vbox lw="mp" lh="wc">
<hbox lw="mp" lh="wc">
<DropDownList id="program_status_sound_choice" lw="0" lw8="1" lh="wc" />
<PushButton id="program_status_sound_browse" lw="wc" lh="wc" margin-left="4dp" />
</hbox>
<TextView id="program_status_sound_path" lw="mp" lh="wc" word-wrap="true" />
</vbox>
)xml",
parent );
auto* choice = layout->find<UIDropDownList>( "program_status_sound_choice" );
choice->getListBox()->addListBoxItems( { app.i18n( "chime", "Chime" ),
app.i18n( "bell", "Bell" ),
app.i18n( "pulse", "Pulse" ) } );
const auto sync = [&app] {
auto* drop = app.scene->find<UIDropDownList>( "program_status_sound_choice" );
auto* path = app.scene->find<UITextView>( "program_status_sound_path" );
if ( !drop || !path )
return;
const auto& sound = app.config->terminal.programStatusSound;
const Uint32 selected = sound == "chime" ? 0
: sound == "bell" ? 1
: sound == "pulse" ? 2
: 3;
// This widget's data is a local guard against programmatic selection callbacks.
drop->setData( 1 );
if ( selected == 3 ) {
const auto filename = String::fromUtf8( FileSystem::fileNameFromPath( sound ) );
if ( drop->getListBox()->getItemsCount() == 3 )
drop->getListBox()->addListBoxItem( filename );
else
drop->getListBox()->setItemText( 3, filename );
} else if ( drop->getListBox()->getItemsCount() > 3 ) {
drop->getListBox()->removeListBoxItem( 3 );
}
drop->getListBox()->setSelected( selected );
drop->setData( 0 );
path->setText( selected == 3 ? String::fromUtf8( sound ) : String{} );
path->setTooltipText( path->getText() );
path->setVisible( selected == 3 );
};
sync();
const auto browse = [&app, sync] {
if ( app.scene->find<UIFileDialog>( "program_status_sound_dialog" ) )
return;
const auto& sound = app.config->terminal.programStatusSound;
const std::string directory = FileSystem::fileExists( sound )
? FileSystem::fileRemoveFileName( sound )
: Sys::getUserDirectory();
auto* dialog = UIFileDialog::New( UIFileDialog::DefaultFlags,
"*.mp3;*.wav;*.ogg;*.flac", directory );
dialog->setId( "program_status_sound_dialog" );
dialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON |
UI_WIN_MODAL );
dialog->setTitle( app.i18n( "select_alert_sound", "Select Alert Sound" ) );
dialog->setCloseShortcut( KEY_ESCAPE );
dialog->on( Event::OpenFile, [&app, sync]( const Event* event ) {
app.config->terminal.programStatusSound =
event->getNode()->asType<UIFileDialog>()->getFullPath();
app.savePreferences();
sync();
} );
dialog->on( Event::OnWindowClose, [sync]( const Event* ) { sync(); } );
dialog->center();
dialog->show();
};
auto* browseButton = layout->find<UIPushButton>( "program_status_sound_browse" );
browseButton->setText( app.i18n( "browse", "Browse…" ) );
browseButton->onClick( [browse]( const Event* ) { browse(); } );
choice->on( Event::OnValueChange, [&app, choice, sync]( const Event* ) {
if ( choice->getData() )
return;
const auto selected = choice->getListBox()->getItemSelectedIndex();
if ( selected < 3 ) {
static constexpr const char* sounds[] = { "chime", "bell", "pulse" };
app.config->terminal.programStatusSound = sounds[selected];
app.savePreferences();
sync();
}
} );
return layout;
} );
panel->addInteger(
{ "programStatusSoundVolume", "terminal.alerts", app.i18n( "alert_volume", "Sound Volume" ),
app.i18n( "alert_volume_desc", "Volume from 0 to 100." ) },
0, 100, [&app] { return app.config->terminal.programStatusSoundVolume; },
[&app]( int value ) {
app.config->terminal.programStatusSoundVolume = value;
app.savePreferences();
} );
panel->addAction(
{ "previewProgramStatusSound", "terminal.alerts",
app.i18n( "preview_sound", "Preview Sound" ),
app.i18n( "preview_sound_desc",
"Play the selected sound once, even when sound alerts are disabled." ) },
app.i18n( "play", "Play" ), [&app] {
app.programStatusAlerts.deliver( {}, {}, false, true,
app.config->terminal.programStatusSound,
app.config->terminal.programStatusSoundVolume, true );
} );
panel->addBool(
{ "restoreLastSession", "terminal.behavior",
app.i18n( "restore_last_session", "Restore Last Session" ),
app.i18n( "restore_last_session_desc", "Reopen the tabs, splits and working directories "
"of the previous session at startup." ) },
&app.config->terminal.restoreLastSession, [&app]( bool ) { app.savePreferences(); } );
panel->addBool(
{ "recoverHarnessSessions", "terminal.behavior",
app.i18n( "recover_harness_sessions", "Try to Recover Agent Sessions (Experimental)" ),
app.i18n(
"recover_harness_sessions_desc",
"Best-effort Codex and Claude recovery for new local fish/Bash/zsh/PowerShell panes. "
"Standalone sessions require hooks; see the eterm integration guide. Recovery is not "
"guaranteed." ) },
&app.config->terminal.recoverHarnessSessions, [&app]( bool ) { app.savePreferences(); } );
panel->addBool( { "graphemeClustering", "terminal.behavior",
app.i18n( "grapheme_clustering", "Grapheme Clustering" ),
app.i18n( "grapheme_clustering_desc",
"Join emoji sequences, flags and combining characters into single "
"characters (DEC mode 2027)." ) },
&app.config->terminal.graphemeClustering, [&app]( bool value ) {
app.forEachTerminal( [value]( UITerminal* terminal ) {
terminal->getTerm()->setGraphemeClusteringEnabled( value );
} );
app.savePreferences();
} );
panel->addBool(
{ "inheritWorkingDirectory", "terminal.behavior",
app.i18n( "inherit_working_directory", "Inherit Working Directory" ),
app.i18n(
"inherit_working_directory_desc",
"Start new tabs and splits in the source terminal's reported local directory." ) },
&app.config->terminal.inheritWorkingDirectory, [&app]( bool ) { app.savePreferences(); } );
panel->addBool( { "allowOsc52ClipboardWrite", "terminal.behavior",
app.i18n( "allow_osc52_clipboard_write",
"Allow Programs to Write to Clipboard (OSC 52)" ),
app.i18n( "allow_osc52_clipboard_write_desc",
"Allow terminal programs, including programs over SSH, to change "
"the local clipboard." ) },
&app.config->terminal.allowOsc52ClipboardWrite, [&app]( bool value ) {
app.forEachTerminal( [value]( UITerminal* terminal ) {
terminal->getTerm()->setAllowOsc52ClipboardWrite( value );
} );
app.savePreferences();
} );
panel->addChoice(
{ "newTerminalBehavior", "terminal.behavior",
app.i18n( "new_terminal_behavior", "New Terminal Behavior" ),
app.i18n( "new_terminal_behavior_desc",
"Choose where new terminal sessions are opened." ) },
{ app.i18n( "open_in_same_tabbar", "Open in Current Tab Bar" ),
app.i18n( "open_in_vertical_split", "Open in New Vertical Split" ),
app.i18n( "open_in_horizontal_split", "Open in New Horizontal Split" ) },
[&app] { return static_cast<size_t>( app.config->terminal.newTerminalBehavior ); },
[&app]( size_t selected ) {
app.config->terminal.newTerminalBehavior =
static_cast<NewTerminalBehavior>( std::min( selected, size_t{ 2 } ) );
app.savePreferences();
} );
panel->addBool(
{ "terminalExclusiveMode", "terminal.behavior",
app.i18n( "enable_exclusive_mode_by_default", "Enable Exclusive Mode by Default" ),
app.i18n( "enable_exclusive_mode_by_default_tooltip",
"Disable global keybindings in newly created terminals." ) },
&app.config->terminal.exclusiveMode, [&app]( bool value ) {
app.forEachTerminal(
[value]( UITerminal* terminal ) { terminal->setExclusiveMode( value ); } );
app.savePreferences();
} );
panel->addBool(
{ "smoothScroll", "terminal.behavior", app.i18n( "smooth_scroll", "Smooth Scrolling" ),
app.i18n( "smooth_scroll_desc", "Animate scrolling from mouse wheels and trackpads." ) },
&app.config->ui.smoothScroll, [&app]( bool value ) {
app.scene->setSmoothScrollEnabled( value, true );
app.savePreferences();
} );
panel->addBool(
{ "closeTerminalTabOnExit", "terminal.behavior",
app.i18n( "close_terminal_tab_on_exit", "Close Terminal Tab on Exit" ),
app.i18n( "close_terminal_tab_on_exit_tooltip", "Close a tab when its process exits." ) },
&app.config->terminal.closeOnExit, [&app]( bool value ) {
app.terminalConfig.closeOnExit = value;
app.forEachTerminal(
[value]( UITerminal* terminal ) { terminal->getTerm()->setKeepAlive( !value ); } );
app.savePreferences();
} );
panel->addBool( { "warnBeforeClosingTerminal", "terminal.behavior",
app.i18n( "warn_before_closing_tab", "Warn Before Closing Tab" ),
app.i18n( "warn_before_closing_tab_tooltip",
"Ask before closing a terminal while a program is running." ) },
&app.config->window.warnBeforeClose, [&app]( bool value ) {
app.warnBeforeClose = value;
app.savePreferences();
} );
const std::vector<std::string> knownShells{ "bash", "sh", "zsh", "fish",
"nu", "csh", "tcsh", "ksh",
"dash", "cmd", "powershell", "pwsh" };
std::vector<String> installedShells;
for ( const auto& shell : knownShells ) {
auto path = Sys::which( shell );
if ( !path.empty() )
installedShells.emplace_back( std::move( path ) );
}
auto currentShell = app.config->terminal.shell;
if ( currentShell.empty() ) {
if ( const char* shell = std::getenv( "SHELL" ); shell )
currentShell = FileSystem::fileExists( shell ) ? shell : Sys::which( shell );
if ( currentShell.empty() )
currentShell = Sys::which(
Sys::getPlatformType() == Sys::PlatformType::Windows ? "powershell" : "bash" );
}
if ( !currentShell.empty() && std::find( installedShells.begin(), installedShells.end(),
String( currentShell ) ) == installedShells.end() )
installedShells.emplace_back( currentShell );
panel->addEditableChoice(
{ "terminalShell", "terminal.behavior", app.i18n( "terminal_shell", "Terminal Shell" ),
app.i18n( "terminal_shell_desc", "Set the shell executable used by new terminals." ) },
installedShells, [currentShell] { return String( currentShell ); },
[&app]( const String& selection ) {
auto shell = selection.toUtf8();
if ( Sys::which( shell ).empty() && !FileSystem::fileExists( shell ) )
return false;
app.config->terminal.shell = shell;
app.terminalConfig.program = shell;
app.savePreferences();
return true;
} );
panel->addText(
{ "terminalShellArguments", "terminal.behavior",
app.i18n( "terminal_shell_arguments", "Terminal Shell Arguments" ),
app.i18n( "terminal_shell_arguments_desc",
"Set shell arguments used by new terminals." ) },
[&app] { return app.config->terminal.shellArguments; },
[&app]( const std::string& value ) {
app.config->terminal.shellArguments = value;
app.terminalConfig.arguments = String::split( value );
app.savePreferences();
return true;
},
true );
panel->addText(
{ "terminalDefaultWorkingDirectory", "terminal.behavior",
app.i18n( "default_working_directory", "Default Working Directory" ),
app.i18n( "default_working_directory_desc",
"Set the starting directory for new terminals. Leave empty to use your home "
"directory. A command-line directory overrides it for that launch." ) },
[&app] { return app.config->terminal.defaultWorkingDirectory; },
[&app]( const std::string& value ) {
auto directory = FileSystem::expandTilde( value );
if ( !directory.empty() ) {
if ( !FileSystem::isDirectory( directory ) )
return false;
directory = FileSystem::getRealPath( directory );
}
app.config->terminal.defaultWorkingDirectory = directory;
app.terminalConfig.workingDirectory =
directory.empty() ? Sys::getUserDirectory() : std::move( directory );
app.savePreferences();
return true;
},
true );
panel->addInteger(
{ "terminalScrollback", "terminal.behavior",
app.i18n( "terminal_scrollback", "Terminal Scrollback" ),
app.i18n( "configure_terminal_scrollback_desc",
"Set retained terminal history lines." ) },
0, std::numeric_limits<int>::max(),
[&app] {
return static_cast<int>( std::min<size_t>( app.config->terminal.historySize,
std::numeric_limits<int>::max() ) );
},
[&app]( int value ) {
app.config->terminal.historySize = value;
app.terminalConfig.historySize = value;
app.savePreferences();
} );
panel->addBool(
{ "terminalFrameBuffer", "terminal.behavior", app.i18n( "framebuffer", "Use Framebuffer" ),
app.i18n(
"framebuffer_desc",
"Render terminals through an FBO instead of the default VBO path. This can improve "
"rendering performance by using a different invalidation strategy." ) },
&app.config->terminal.useFrameBuffer, [&app]( bool value ) {
app.terminalConfig.useFrameBuffer = value;
app.savePreferences();
} );
panel->addCategory( "terminal.appearance", app.i18n( "terminal", "Terminal" ),
app.i18n( "appearance", "Appearance" ) );
std::vector<String> schemeNames{ app.i18n( "default", "Default" ) };
std::vector<std::string> schemeIds{ "" };
for ( const auto& [name, scheme] : app.terminalColorSchemes ) {
schemeNames.emplace_back( name );
schemeIds.emplace_back( name );
}
if ( !schemeIds.empty() )
panel->addChoice(
{ "terminalColorScheme", "terminal.appearance",
app.i18n( "terminal_color_scheme", "Terminal Color Scheme" ),
app.i18n( "terminal_color_scheme_desc", "Choose the colors used by terminals." ) },
schemeNames,
[&app, schemeIds] {
auto found =
std::find( schemeIds.begin(), schemeIds.end(), app.config->theme.colorScheme );
return found == schemeIds.end() ? size_t{ 0 }
: static_cast<size_t>( found - schemeIds.begin() );
},
[&app, schemeIds]( size_t selected ) {
app.config->theme.colorScheme =
schemeIds[std::min( selected, schemeIds.size() - 1 )];
if ( app.config->theme.colorScheme.empty() ) {
app.selectedColorScheme = nullptr;
auto defaultScheme = TerminalColorScheme::getDefault();
app.forEachTerminal( [&defaultScheme]( UITerminal* terminal ) {
terminal->setColorScheme( defaultScheme );
} );
app.savePreferences();
return;
}
auto found = app.terminalColorSchemes.find( app.config->theme.colorScheme );
if ( found != app.terminalColorSchemes.end() ) {
app.selectedColorScheme = &found->second;
app.forEachTerminal( [&app]( UITerminal* terminal ) {
terminal->setColorScheme( *app.selectedColorScheme );
} );
}
app.savePreferences();
} );
panel->addChoice(
{ "terminalScrollbarType", "terminal.appearance",
app.i18n( "scrollbar_type", "Scrollbar Type" ),
app.i18n( "scrollbar_type_desc",
"Place the scrollbar over or outside terminal content." ) },
{ app.i18n( "overlay", "Overlay" ), app.i18n( "outside", "Outside" ) },
[&app] { return app.config->terminal.scrollBarType == ScrollViewType::Overlay ? 0 : 1; },
[&app]( size_t selected ) {
app.config->terminal.scrollBarType =
selected == 0 ? ScrollViewType::Overlay : ScrollViewType::Outside;
app.forEachTerminal( [&app]( UITerminal* terminal ) {
terminal->setScrollViewType( app.config->terminal.scrollBarType );
} );
app.savePreferences();
} );
panel->addChoice(
{ "terminalCursorStyle", "terminal.appearance", app.i18n( "cursor_style", "Cursor Style" ),
app.i18n( "cursor_style_desc", "Choose the terminal cursor shape and animation." ) },
{ app.i18n( "blinking_block", "Blinking Block" ),
app.i18n( "steady_block", "Steady Block" ),
app.i18n( "blink_underline", "Blink Underline" ),
app.i18n( "steady_underline", "Steady Underline" ), app.i18n( "blink_bar", "Blink Bar" ),
app.i18n( "steady_bar", "Steady Bar" ) },
[&app] {
static constexpr TerminalCursorMode modes[] = {
TerminalCursorMode::BlinkingBlock, TerminalCursorMode::SteadyBlock,
TerminalCursorMode::BlinkUnderline, TerminalCursorMode::SteadyUnderline,
TerminalCursorMode::BlinkBar, TerminalCursorMode::SteadyBar };
auto found = std::find( std::begin( modes ), std::end( modes ),
app.config->terminal.cursorStyle );
return found == std::end( modes ) ? size_t{ 0 }
: static_cast<size_t>( found - std::begin( modes ) );
},
[&app]( size_t selected ) {
static constexpr TerminalCursorMode modes[] = {
TerminalCursorMode::BlinkingBlock, TerminalCursorMode::SteadyBlock,
TerminalCursorMode::BlinkUnderline, TerminalCursorMode::SteadyUnderline,
TerminalCursorMode::BlinkBar, TerminalCursorMode::SteadyBar };
app.config->terminal.cursorStyle = modes[std::min( selected, size_t{ 5 } )];
app.terminalConfig.cursorStyle = app.config->terminal.cursorStyle;
app.forEachTerminal( [&app]( UITerminal* terminal ) {
terminal->getTerm()->setCursorMode( app.config->terminal.cursorStyle );
} );
app.savePreferences();
} );
panel->addChoice(
{ "terminalScrollbarMode", "terminal.appearance",
app.i18n( "scrollbar_mode", "Scrollbar Mode" ),
app.i18n( "scrollbar_mode_desc", "Control when the terminal scrollbar is visible." ) },
{ app.i18n( "auto", "Auto" ), app.i18n( "always_visible", "Always Visible" ),
app.i18n( "always_hidden", "Always Hidden" ) },
[&app] {
return app.config->terminal.scrollBarMode == ScrollBarMode::Auto ? 0
: app.config->terminal.scrollBarMode == ScrollBarMode::AlwaysOn ? 1
: 2;
},
[&app]( size_t selected ) {
app.config->terminal.scrollBarMode = selected == 0 ? ScrollBarMode::Auto
: selected == 1 ? ScrollBarMode::AlwaysOn
: ScrollBarMode::AlwaysOff;
app.forEachTerminal( [&app]( UITerminal* terminal ) {
terminal->setVerticalScrollMode( app.config->terminal.scrollBarMode );
} );
app.savePreferences();
} );
panel->addBool( { "alwaysShowTabBar", "terminal.appearance",
app.i18n( "always_show_tab_bar", "Always Show Tab Bar" ),
app.i18n( "always_show_tab_bar_desc",
"Show the tab bar even when it contains one tab." ) },
&app.config->window.alwaysShowTabBar, [&app]( bool value ) {
app.tabSplitter->setHideTabBarOnSingleTab( !value );
app.savePreferences();
} );
panel->addChoice(
{ "tabPosition", "terminal.appearance", app.i18n( "tab_position", "Tab Bar Position" ),
app.i18n( "tab_position_desc", "Choose the edge of the terminal that holds the tabs." ) },
{ app.i18n( "tab_position_top", "Top" ), app.i18n( "tab_position_bottom", "Bottom" ),
app.i18n( "tab_position_left", "Left" ), app.i18n( "tab_position_right", "Right" ) },
[&app] { return static_cast<size_t>( app.config->window.tabPosition ); },
[&app]( size_t selected ) {
const auto position =
static_cast<UITabWidget::TabPosition>( std::min( selected, size_t{ 3 } ) );
app.config->window.tabPosition = position;
app.tabSplitter->forEachTabWidget(
[position]( UITabWidget* tabs ) { tabs->setTabPosition( position ); } );
app.savePreferences();
} );
panel->addBool(
{ "showTabBarWhenSplit", "terminal.appearance",
app.i18n( "show_tab_bar_when_split", "Show Tab Bar When Split" ),
app.i18n( "show_tab_bar_when_split_desc",
"Show single-tab bars when the terminal is split into multiple panes." ) },
&app.config->window.showTabBarWhenSplit, [&app]( bool value ) {
app.tabSplitter->setShowTabBarWhenSplit( value );
app.savePreferences();
} );
panel->build();
settingsWindow->on( Event::OnWindowReady, [panel]( const Event* ) {
panel->runOnMainThread( [panel] { panel->focusSearch(); } );
} );
settingsWindow->setKeyBindingCommand( "closeWindow",
[settingsWindow] { settingsWindow->closeWindow(); } );
settingsWindow->getKeyBindings().addKeybind( { KEY_ESCAPE }, "closeWindow" );
settingsWindow->on( Event::OnWindowClose, [&app]( const Event* ) {
app.savePreferences();
if ( app.tabSplitter && app.tabSplitter->getCurWidget() )
app.tabSplitter->getCurWidget()->setFocus();
} );
settingsWindow->center();
settingsWindow->showWhenReady();
panel->focusSearch();
return settingsWindow;
}
} // namespace eterm