Improve: extract common method
This commit is contained in:
@ -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<String>, name: String): String? {
|
||||
val value = this.getAttribute(path, name)
|
||||
return if (value.isValid()) value.asString() else null
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -0,0 +1,9 @@
|
||||
package io.neoterm.component.profile
|
||||
|
||||
/**
|
||||
* @author kiva
|
||||
*/
|
||||
class Profile {
|
||||
lateinit var profileFont: String
|
||||
lateinit var profileColorScheme: String
|
||||
}
|
Reference in New Issue
Block a user