Profile: Generify NeoProfile
This commit is contained in:
parent
d8c6ff82e3
commit
8f493d907f
@ -13,6 +13,7 @@ import io.neoterm.component.script.UserScriptComponent
|
|||||||
import io.neoterm.component.session.SessionComponent
|
import io.neoterm.component.session.SessionComponent
|
||||||
import io.neoterm.frontend.logging.NLog
|
import io.neoterm.frontend.logging.NLog
|
||||||
import io.neoterm.frontend.component.ComponentManager
|
import io.neoterm.frontend.component.ComponentManager
|
||||||
|
import io.neoterm.frontend.session.shell.ShellProfile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kiva
|
* @author kiva
|
||||||
@ -30,5 +31,8 @@ object NeoInitializer {
|
|||||||
ComponentManager.registerComponent(PackageComponent::class.java)
|
ComponentManager.registerComponent(PackageComponent::class.java)
|
||||||
ComponentManager.registerComponent(SessionComponent::class.java)
|
ComponentManager.registerComponent(SessionComponent::class.java)
|
||||||
ComponentManager.registerComponent(ProfileComponent::class.java)
|
ComponentManager.registerComponent(ProfileComponent::class.java)
|
||||||
|
|
||||||
|
val profileComp = ComponentManager.getComponent<ProfileComponent>()
|
||||||
|
profileComp.registerProfile(ShellProfile.PROFILE_META_NAME, ShellProfile::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,4 +3,6 @@ package io.neoterm.component.profile
|
|||||||
/**
|
/**
|
||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
abstract class NeoProfile
|
abstract class NeoProfile {
|
||||||
|
abstract val profileMetaName: String
|
||||||
|
}
|
@ -9,7 +9,16 @@ import java.io.File
|
|||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
class ProfileComponent : NeoComponent {
|
class ProfileComponent : NeoComponent {
|
||||||
private val profileList = mutableListOf<ShellProfile>()
|
private val profileRegistry = mutableMapOf<String, Class<out NeoProfile>>()
|
||||||
|
private val profileList = mutableListOf<NeoProfile>()
|
||||||
|
|
||||||
|
fun registerProfile(metaName: String, prototype: Class<out NeoProfile>) {
|
||||||
|
profileRegistry[metaName] = prototype
|
||||||
|
}
|
||||||
|
|
||||||
|
fun unregisterProfile(metaName: String) {
|
||||||
|
profileRegistry.remove(metaName)
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkForFiles() {
|
private fun checkForFiles() {
|
||||||
val profileDir = File(NeoTermPath.PROFILE_PATH)
|
val profileDir = File(NeoTermPath.PROFILE_PATH)
|
||||||
|
@ -11,6 +11,12 @@ import io.neoterm.frontend.config.NeoPreference
|
|||||||
* @author kiva
|
* @author kiva
|
||||||
*/
|
*/
|
||||||
class ShellProfile : NeoProfile() {
|
class ShellProfile : NeoProfile() {
|
||||||
|
companion object {
|
||||||
|
const val PROFILE_META_NAME = "profile-shell"
|
||||||
|
}
|
||||||
|
|
||||||
|
override val profileMetaName = PROFILE_META_NAME
|
||||||
|
|
||||||
var loginShell = DefaultValues.loginShell
|
var loginShell = DefaultValues.loginShell
|
||||||
var initialCommand = DefaultValues.initialCommand
|
var initialCommand = DefaultValues.initialCommand
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user