diff --git a/NeoLang/src/main/java/io/neolang/visitor/ConfigVisitor.kt b/NeoLang/src/main/java/io/neolang/visitor/ConfigVisitor.kt index 1e00ec4..a07ad55 100644 --- a/NeoLang/src/main/java/io/neolang/visitor/ConfigVisitor.kt +++ b/NeoLang/src/main/java/io/neolang/visitor/ConfigVisitor.kt @@ -8,7 +8,7 @@ import io.neolang.runtime.type.NeoLangValue class ConfigVisitor : IVisitorCallback { private var currentContext: NeoLangContext? = null - fun getContext(contextPath: Array) : NeoLangContext { + fun getContext(contextPath: Array): NeoLangContext { var context = getCurrentContext() contextPath.forEach { context = context.getChild(it) @@ -16,11 +16,11 @@ class ConfigVisitor : IVisitorCallback { return context } - fun getAttribute(contextPath: Array, attrName: String) : NeoLangValue { + fun getAttribute(contextPath: Array, attrName: String): NeoLangValue { return getContext(contextPath).getAttribute(attrName) } - fun getArray(contextPath: Array, arrayName: String) : NeoLangArray { + fun getArray(contextPath: Array, arrayName: String): NeoLangArray { // We use NeoLangContext as arrays and array elements now return NeoLangArray.createFromContext(getContext(contextPath).getChild(arrayName)) } @@ -46,7 +46,7 @@ class ConfigVisitor : IVisitorCallback { override fun onExitContext() { val context = currentContext - if (context != null && context.parent != null) { + if (context?.parent != null) { this.currentContext = context.parent } } @@ -54,4 +54,9 @@ class ConfigVisitor : IVisitorCallback { override fun getCurrentContext(): NeoLangContext { return currentContext!! } + + fun getStringValue(path: Array, name: String): String? { + val value = this.getAttribute(path, name) + return if (value.isValid()) value.asString() else null + } } \ No newline at end of file diff --git a/app/src/main/java/io/neoterm/component/color/NeoColorScheme.kt b/app/src/main/java/io/neoterm/component/color/NeoColorScheme.kt index 09f904a..f6a1b3e 100644 --- a/app/src/main/java/io/neoterm/component/color/NeoColorScheme.kt +++ b/app/src/main/java/io/neoterm/component/color/NeoColorScheme.kt @@ -183,12 +183,10 @@ open class NeoColorScheme : CodeGenObject { } private fun getMetaByVisitor(visitor: ConfigVisitor, metaName: String): String? { - val value = visitor.getAttribute(COLOR_META_PATH, metaName) - return if (value.isValid()) value.asString() else null + return visitor.getStringValue(COLOR_META_PATH, metaName) } private fun getColorByVisitor(visitor: ConfigVisitor, colorName: String): String? { - val value = visitor.getAttribute(COLOR_PATH, colorName) - return if (value.isValid()) value.asString() else null + return visitor.getStringValue(COLOR_PATH, colorName) } } \ No newline at end of file diff --git a/app/src/main/java/io/neoterm/component/eks/NeoExtraKey.kt b/app/src/main/java/io/neoterm/component/eks/NeoExtraKey.kt index d343805..0abfc72 100644 --- a/app/src/main/java/io/neoterm/component/eks/NeoExtraKey.kt +++ b/app/src/main/java/io/neoterm/component/eks/NeoExtraKey.kt @@ -101,7 +101,6 @@ class NeoExtraKey { } private fun getMetaByVisitor(visitor: ConfigVisitor, metaName: String): String? { - val value = visitor.getAttribute(EKS_META_CONTEXT_PATH, metaName) - return if (value.isValid()) value.asString() else null + return visitor.getStringValue(EKS_META_CONTEXT_PATH, metaName) } } \ No newline at end of file diff --git a/app/src/main/java/io/neoterm/component/font/FontComponent.kt b/app/src/main/java/io/neoterm/component/font/FontComponent.kt index 6f7d05d..ac12117 100644 --- a/app/src/main/java/io/neoterm/component/font/FontComponent.kt +++ b/app/src/main/java/io/neoterm/component/font/FontComponent.kt @@ -55,9 +55,9 @@ class FontComponent : NeoComponent { fun reloadFonts(): Boolean { fonts.clear() - fonts.put("Android Monospace", NeoFont(Typeface.MONOSPACE)) - fonts.put("Android Sans Serif", NeoFont(Typeface.SANS_SERIF)) - fonts.put("Android Serif", NeoFont(Typeface.SERIF)) + fonts.put("Monospace", NeoFont(Typeface.MONOSPACE)) + fonts.put("Sans Serif", NeoFont(Typeface.SANS_SERIF)) + fonts.put("Serif", NeoFont(Typeface.SERIF)) val fontDir = File(NeoTermPath.FONT_PATH) for (file in fontDir.listFiles({ pathname -> pathname.name.endsWith(".ttf") })) { val fontName = fontName(file) diff --git a/app/src/main/java/io/neoterm/component/profile/Profile.kt b/app/src/main/java/io/neoterm/component/profile/Profile.kt new file mode 100644 index 0000000..ec12ac2 --- /dev/null +++ b/app/src/main/java/io/neoterm/component/profile/Profile.kt @@ -0,0 +1,9 @@ +package io.neoterm.component.profile + +/** + * @author kiva + */ +class Profile { + lateinit var profileFont: String + lateinit var profileColorScheme: String +} \ No newline at end of file