1- #[ cfg( target_os = "linux" ) ]
2- use crate :: git:: types:: LinuxTerminalEmulator ;
31use crate :: git:: types:: {
42 CloneRequest , CommitDetails , CommitDetailsRequest , CommitFileItem , CommitFilesRequest ,
53 CommitMarkers , CommitMessageRecovery , CommitRequest , DiffRequest , ExportCommitPatchRequest ,
6- ExportPatchRequest ,
7- ExternalDiffRequest , FetchRequest , FileDiff , FileRequest , GitIdentity , HunkStageRequest ,
8- IdentityRequest , ImportPatchRequest , NumstatRequest , NumstatResult , OperationResult ,
9- PullAnalysis , PullStrategyRequest , PushRequest , PushResult , RepoRequest , RepoStatus ,
10- SetIdentityRequest , SshAllowedSignerStatus , StageFilesRequest , StashEntry , StashPushRequest ,
11- StashRequest , SubmoduleActionRequest ,
4+ ExportPatchRequest , ExternalDiffRequest , FetchRequest , FileDiff , FileRequest , GitIdentity ,
5+ HunkStageRequest , IdentityRequest , ImportPatchRequest , NumstatRequest , NumstatResult ,
6+ OperationResult , PullAnalysis , PullStrategyRequest , PushRequest , PushResult , RepoRequest ,
7+ RepoStatus , SetIdentityRequest , SshAllowedSignerStatus , StageFilesRequest , StashEntry ,
8+ StashPushRequest , StashRequest , SubmoduleActionRequest ,
129} ;
10+ #[ cfg( target_os = "linux" ) ]
11+ use crate :: git:: types:: { LINUX_TERMINAL_AUTO_ID , LINUX_TERMINAL_CUSTOM_ID } ;
1312use crate :: { AppState , CloneCancelFlag , configure_command} ;
1413use serde:: { Deserialize , Serialize } ;
1514use std:: io:: Read ;
@@ -268,7 +267,7 @@ fn default_file_manager_label() -> &'static str {
268267fn default_terminal_label ( settings : & crate :: git:: types:: Settings ) -> String {
269268 #[ cfg( target_os = "linux" ) ]
270269 {
271- return linux_terminal_label ( settings) . to_string ( ) ;
270+ return linux_terminal_label ( settings) ;
272271 }
273272
274273 #[ cfg( not( target_os = "linux" ) ) ]
@@ -370,9 +369,10 @@ fn open_terminal_at_linux(
370369}
371370
372371#[ cfg( target_os = "linux" ) ]
373- fn linux_terminal_label ( settings : & crate :: git:: types:: Settings ) -> & ' static str {
374- linux_terminal_launch:: terminal_label ( linux_terminal_preference (
375- settings. linux_terminal_emulator ,
372+ fn linux_terminal_label ( settings : & crate :: git:: types:: Settings ) -> String {
373+ let registry = linux_terminal_launch:: TerminalRegistry :: with_known_terminals ( ) ;
374+ registry. label_for_preference ( & linux_terminal_preference (
375+ settings. linux_terminal_emulator . as_str ( ) ,
376376 ) )
377377}
378378
@@ -383,40 +383,20 @@ fn linux_terminal_launcher(
383383) -> linux_terminal_launch:: TerminalLauncher {
384384 linux_terminal_launch:: TerminalLauncher :: new ( )
385385 . working_dir ( path)
386- . preference ( linux_terminal_preference ( settings. linux_terminal_emulator ) )
386+ . registry ( linux_terminal_launch:: TerminalRegistry :: with_known_terminals ( ) )
387+ . preference ( linux_terminal_preference (
388+ settings. linux_terminal_emulator . as_str ( ) ,
389+ ) )
387390 . custom_command ( settings. linux_terminal_custom_command . clone ( ) )
388391 . detach_from_parent ( true )
389392}
390393
391394#[ cfg( target_os = "linux" ) ]
392- fn linux_terminal_preference (
393- emulator : LinuxTerminalEmulator ,
394- ) -> linux_terminal_launch:: TerminalPreference {
395- use linux_terminal_launch:: { KnownTerminal , TerminalPreference } ;
396-
397- match emulator {
398- LinuxTerminalEmulator :: Auto => TerminalPreference :: Auto ,
399- LinuxTerminalEmulator :: Konsole => TerminalPreference :: Known ( KnownTerminal :: Konsole ) ,
400- LinuxTerminalEmulator :: GnomeTerminal => {
401- TerminalPreference :: Known ( KnownTerminal :: GnomeTerminal )
402- }
403- LinuxTerminalEmulator :: GnomeConsole => {
404- TerminalPreference :: Known ( KnownTerminal :: GnomeConsole )
405- }
406- LinuxTerminalEmulator :: Xfce4Terminal => {
407- TerminalPreference :: Known ( KnownTerminal :: Xfce4Terminal )
408- }
409- LinuxTerminalEmulator :: MateTerminal => {
410- TerminalPreference :: Known ( KnownTerminal :: MateTerminal )
411- }
412- LinuxTerminalEmulator :: Lxterminal => TerminalPreference :: Known ( KnownTerminal :: Lxterminal ) ,
413- LinuxTerminalEmulator :: Alacritty => TerminalPreference :: Known ( KnownTerminal :: Alacritty ) ,
414- LinuxTerminalEmulator :: Ghostty => TerminalPreference :: Known ( KnownTerminal :: Ghostty ) ,
415- LinuxTerminalEmulator :: Kitty => TerminalPreference :: Known ( KnownTerminal :: Kitty ) ,
416- LinuxTerminalEmulator :: WezTerm => TerminalPreference :: Known ( KnownTerminal :: WezTerm ) ,
417- LinuxTerminalEmulator :: Foot => TerminalPreference :: Known ( KnownTerminal :: Foot ) ,
418- LinuxTerminalEmulator :: Xterm => TerminalPreference :: Known ( KnownTerminal :: Xterm ) ,
419- LinuxTerminalEmulator :: Custom => TerminalPreference :: Custom ,
395+ fn linux_terminal_preference ( id : & str ) -> linux_terminal_launch:: TerminalPreference {
396+ match id {
397+ LINUX_TERMINAL_AUTO_ID => linux_terminal_launch:: TerminalPreference :: Auto ,
398+ LINUX_TERMINAL_CUSTOM_ID => linux_terminal_launch:: TerminalPreference :: Custom ,
399+ other => linux_terminal_launch:: TerminalPreference :: registered ( other) ,
420400 }
421401}
422402
0 commit comments