Fixed custom terminal emulator not opening on windows

This commit is contained in:
Abdelilah El Aissaoui 2023-09-20 19:59:02 +02:00
parent d642c1e2d8
commit ec6c5412a4

View File

@ -1,24 +1,29 @@
package com.jetpackduba.gitnuro.terminal package com.jetpackduba.gitnuro.terminal
import com.jetpackduba.gitnuro.managers.IShellManager import com.jetpackduba.gitnuro.managers.IShellManager
import java.io.File
import javax.inject.Inject import javax.inject.Inject
class WindowsTerminalProvider @Inject constructor( class WindowsTerminalProvider @Inject constructor(
private val shellManager: IShellManager private val shellManager: IShellManager
) : ITerminalProvider { ) : ITerminalProvider {
private val powerShellEmulator =
TerminalEmulator("Powershell", "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe")
override fun getTerminalEmulators(): List<TerminalEmulator> { override fun getTerminalEmulators(): List<TerminalEmulator> {
return listOf( return listOf(powerShellEmulator)
// TODO powershell is the only terminal emulator supported until we add support for custom
TerminalEmulator("Powershell", "powershell.exe"),
)
} }
override fun isTerminalInstalled(terminalEmulator: TerminalEmulator): Boolean { override fun isTerminalInstalled(terminalEmulator: TerminalEmulator): Boolean {
// TODO how do we know if it's installed? We must check the output when trying to start an app that doesn't exist // We don't care if it's not installed
return true return true
} }
override fun startTerminal(terminalEmulator: TerminalEmulator, repositoryPath: String) { override fun startTerminal(terminalEmulator: TerminalEmulator, repositoryPath: String) {
shellManager.runCommandInPath(listOf("cmd", "/c", "start", terminalEmulator.path), repositoryPath) if (terminalEmulator == powerShellEmulator) {
shellManager.runCommandInPath(listOf("cmd", "/c", "start", terminalEmulator.path), repositoryPath)
} else {
shellManager.runCommandInPath(listOf("cmd", "/c", terminalEmulator.path), repositoryPath)
}
} }
} }