Profile: Apply profile values
This commit is contained in:
@ -30,6 +30,16 @@ class ConfigVisitor : IVisitorCallback {
|
|||||||
return NeoLangArray.createFromContext(getContext(contextPath).getChild(arrayName))
|
return NeoLangArray.createFromContext(getContext(contextPath).getChild(arrayName))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getStringValue(path: Array<String>, name: String): String? {
|
||||||
|
val value = this.getAttribute(path, name)
|
||||||
|
return if (value.isValid()) value.asString() else null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBooleanValue(path: Array<String>, name: String): Boolean? {
|
||||||
|
val value = this.getAttribute(path, name)
|
||||||
|
return if (value.isValid()) value.asString() == "true" else null
|
||||||
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
currentContext = NeoLangContext("global")
|
currentContext = NeoLangContext("global")
|
||||||
rootContext = currentContext
|
rootContext = currentContext
|
||||||
@ -60,9 +70,4 @@ class ConfigVisitor : IVisitorCallback {
|
|||||||
override fun getCurrentContext(): NeoLangContext {
|
override fun getCurrentContext(): NeoLangContext {
|
||||||
return currentContext!!
|
return currentContext!!
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStringValue(path: Array<String>, name: String): String? {
|
|
||||||
val value = this.getAttribute(path, name)
|
|
||||||
return if (value.isValid()) value.asString() else null
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ class ShellProfile : NeoProfile() {
|
|||||||
companion object {
|
companion object {
|
||||||
const val PROFILE_META_NAME = "profile-shell"
|
const val PROFILE_META_NAME = "profile-shell"
|
||||||
|
|
||||||
private const val LOGIN_SHELL_NAME = "login-shell"
|
private const val LOGIN_SHELL = "login-shell"
|
||||||
private const val INITIAL_COMMAND = "init-command"
|
private const val INITIAL_COMMAND = "init-command"
|
||||||
private const val BELL = "bell"
|
private const val BELL = "bell"
|
||||||
private const val VIBRATE = "vibrate"
|
private const val VIBRATE = "vibrate"
|
||||||
@ -26,6 +26,8 @@ class ShellProfile : NeoProfile() {
|
|||||||
private const val EXTRA_KEYS = "extra-keys"
|
private const val EXTRA_KEYS = "extra-keys"
|
||||||
private const val FONT = "font"
|
private const val FONT = "font"
|
||||||
private const val COLOR_SCHEME = "color-scheme"
|
private const val COLOR_SCHEME = "color-scheme"
|
||||||
|
|
||||||
|
private val PROFILE_META_PATH = arrayOf(PROFILE_META_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val profileMetaName = PROFILE_META_NAME
|
override val profileMetaName = PROFILE_META_NAME
|
||||||
@ -38,34 +40,58 @@ class ShellProfile : NeoProfile() {
|
|||||||
var enableExecveWrapper = DefaultValues.enableExecveWrapper
|
var enableExecveWrapper = DefaultValues.enableExecveWrapper
|
||||||
var enableSpecialVolumeKeys = DefaultValues.enableSpecialVolumeKeys
|
var enableSpecialVolumeKeys = DefaultValues.enableSpecialVolumeKeys
|
||||||
var enableAutoCompletion = DefaultValues.enableAutoCompletion
|
var enableAutoCompletion = DefaultValues.enableAutoCompletion
|
||||||
var enableBackButtonBeMappedToEscape = DefaultValues.enableBackButtonBeMappedToEscape
|
var enableBackKeyToEscape = DefaultValues.enableBackButtonBeMappedToEscape
|
||||||
var enableExtraKeys = DefaultValues.enableExtraKeys
|
var enableExtraKeys = DefaultValues.enableExtraKeys
|
||||||
|
|
||||||
var profileFont: String
|
var profileFont: String
|
||||||
var profileColorScheme: String
|
var profileColorScheme: String
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// val fontComp = ComponentManager.getComponent<FontComponent>()
|
val fontComp = ComponentManager.getComponent<FontComponent>()
|
||||||
// val colorComp = ComponentManager.getComponent<ColorSchemeComponent>()
|
val colorComp = ComponentManager.getComponent<ColorSchemeComponent>()
|
||||||
//
|
|
||||||
// profileFont = fontComp.getCurrentFontName()
|
|
||||||
// profileColorScheme = colorComp.getCurrentColorSchemeName()
|
|
||||||
|
|
||||||
profileFont = ""
|
profileFont = fontComp.getCurrentFontName()
|
||||||
profileColorScheme = ""
|
profileColorScheme = colorComp.getCurrentColorSchemeName()
|
||||||
|
|
||||||
// loginShell = NeoPreference.getLoginShellPath()
|
loginShell = NeoPreference.getLoginShellPath()
|
||||||
// initialCommand = NeoPreference.getInitialCommand()
|
initialCommand = NeoPreference.getInitialCommand()
|
||||||
// enableBell = NeoPreference.isBellEnabled()
|
enableBell = NeoPreference.isBellEnabled()
|
||||||
// enableVibrate = NeoPreference.isVibrateEnabled()
|
enableVibrate = NeoPreference.isVibrateEnabled()
|
||||||
// enableExecveWrapper = NeoPreference.isExecveWrapperEnabled()
|
enableExecveWrapper = NeoPreference.isExecveWrapperEnabled()
|
||||||
// enableSpecialVolumeKeys = NeoPreference.isSpecialVolumeKeysEnabled()
|
enableSpecialVolumeKeys = NeoPreference.isSpecialVolumeKeysEnabled()
|
||||||
// enableAutoCompletion = NeoPreference.isAutoCompletionEnabled()
|
enableAutoCompletion = NeoPreference.isAutoCompletionEnabled()
|
||||||
// enableBackButtonBeMappedToEscape = NeoPreference.isBackButtonBeMappedToEscapeEnabled()
|
enableBackKeyToEscape = NeoPreference.isBackButtonBeMappedToEscapeEnabled()
|
||||||
// enableExtraKeys = NeoPreference.isExtraKeysEnabled()
|
enableExtraKeys = NeoPreference.isExtraKeysEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onProfileLoaded(visitor: ConfigVisitor): Boolean {
|
override fun onProfileLoaded(V: ConfigVisitor): Boolean {
|
||||||
|
loginShell = V.getProfileString(LOGIN_SHELL, loginShell)
|
||||||
|
initialCommand = V.getProfileString(INITIAL_COMMAND, initialCommand)
|
||||||
|
enableBell = V.getProfileBoolean(BELL, enableBell)
|
||||||
|
enableVibrate = V.getProfileBoolean(VIBRATE, enableVibrate)
|
||||||
|
enableExecveWrapper = V.getProfileBoolean(EXECVE_WRAPPER, enableExecveWrapper)
|
||||||
|
enableSpecialVolumeKeys = V.getProfileBoolean(SPECIAL_VOLUME_KEYS, enableSpecialVolumeKeys)
|
||||||
|
enableAutoCompletion = V.getProfileBoolean(AUTO_COMPLETION, enableAutoCompletion)
|
||||||
|
enableBackKeyToEscape = V.getProfileBoolean(BACK_KEY_TO_ESC, enableBackKeyToEscape)
|
||||||
|
enableExtraKeys = V.getProfileBoolean(EXTRA_KEYS, enableExtraKeys)
|
||||||
|
profileFont = V.getProfileString(FONT, profileFont)
|
||||||
|
profileColorScheme = V.getProfileString(COLOR_SCHEME, profileColorScheme)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun ConfigVisitor.getProfileString(key: String, fallback: String): String {
|
||||||
|
return getProfileString(key) ?: fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ConfigVisitor.getProfileBoolean(key: String, fallback: Boolean): Boolean {
|
||||||
|
return getProfileBoolean(key) ?: fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ConfigVisitor.getProfileString(key: String): String? {
|
||||||
|
return this.getStringValue(PROFILE_META_PATH, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ConfigVisitor.getProfileBoolean(key: String): Boolean? {
|
||||||
|
return this.getBooleanValue(PROFILE_META_PATH, key)
|
||||||
|
}
|
||||||
}
|
}
|
@ -43,7 +43,7 @@ class TermViewClient(val context: Context) : TerminalViewClient {
|
|||||||
|
|
||||||
override fun shouldBackButtonBeMappedToEscape(): Boolean {
|
override fun shouldBackButtonBeMappedToEscape(): Boolean {
|
||||||
val shellSession = termData?.termSession as ShellTermSession? ?: return false
|
val shellSession = termData?.termSession as ShellTermSession? ?: return false
|
||||||
return shellSession.shellProfile.enableBackButtonBeMappedToEscape
|
return shellSession.shellProfile.enableBackKeyToEscape
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun copyModeChanged(copyMode: Boolean) {
|
override fun copyModeChanged(copyMode: Boolean) {
|
||||||
|
@ -60,6 +60,8 @@ class ConfigureFileTest {
|
|||||||
|
|
||||||
val comp = ComponentManager.getComponent<ProfileComponent>()
|
val comp = ComponentManager.getComponent<ProfileComponent>()
|
||||||
val profile = comp.loadConfigure<ShellProfile>(File("NeoLang/example/profile.nl"))
|
val profile = comp.loadConfigure<ShellProfile>(File("NeoLang/example/profile.nl"))
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user