Component: Make filter public to everyone
This commit is contained in:
parent
8445254e0d
commit
2ca2a47049
@ -52,14 +52,14 @@ class ColorSchemeComponent : ConfigFileBasedComponent<NeoColorScheme>(NeoTermPat
|
||||
fun reloadColorSchemes(): Boolean {
|
||||
colors.clear()
|
||||
|
||||
File(NeoTermPath.COLORS_PATH).listFiles { pathname ->
|
||||
pathname.name.endsWith(".color") || pathname.name.endsWith(".nl")
|
||||
}.forEach {
|
||||
val colorScheme = this.loadConfigure(it)
|
||||
if (colorScheme != null) {
|
||||
colors.put(colorScheme.colorName, colorScheme)
|
||||
}
|
||||
}
|
||||
File(baseDir)
|
||||
.listFiles(NEOLANG_FILTER)
|
||||
.forEach {
|
||||
val colorScheme = this.loadConfigure(it)
|
||||
if (colorScheme != null) {
|
||||
colors.put(colorScheme.colorName, colorScheme)
|
||||
}
|
||||
}
|
||||
|
||||
if (colors.containsKey(DefaultColorScheme.colorName)) {
|
||||
DEFAULT_COLOR = colors[DefaultColorScheme.colorName]!!
|
||||
@ -105,7 +105,7 @@ class ColorSchemeComponent : ConfigFileBasedComponent<NeoColorScheme>(NeoTermPat
|
||||
|
||||
private fun extractDefaultColor(context: Context): Boolean {
|
||||
try {
|
||||
AssetsUtils.extractAssetsDir(context, "colors", NeoTermPath.COLORS_PATH)
|
||||
AssetsUtils.extractAssetsDir(context, "colors", baseDir)
|
||||
return true
|
||||
} catch (e: Exception) {
|
||||
NLog.e("ColorScheme", "Failed to extract default colors: ${e.localizedMessage}")
|
||||
|
@ -9,18 +9,11 @@ import io.neoterm.frontend.logging.NLog
|
||||
import io.neoterm.frontend.terminal.extrakey.ExtraKeysView
|
||||
import io.neoterm.utils.AssetsUtils
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
/**
|
||||
* @author kiva
|
||||
*/
|
||||
class ExtraKeyComponent : ConfigFileBasedComponent<NeoExtraKey>(NeoTermPath.EKS_PATH) {
|
||||
companion object {
|
||||
private val FILTER = FileFilter {
|
||||
it.extension == "nl"
|
||||
}
|
||||
}
|
||||
|
||||
override val checkComponentFileWhenObtained = true
|
||||
|
||||
private val extraKeys: MutableMap<String, NeoExtraKey> = mutableMapOf()
|
||||
@ -59,22 +52,23 @@ class ExtraKeyComponent : ConfigFileBasedComponent<NeoExtraKey>(NeoTermPath.EKS_
|
||||
|
||||
private fun extractDefaultConfig(context: Context) {
|
||||
try {
|
||||
AssetsUtils.extractAssetsDir(context, "eks", NeoTermPath.EKS_PATH)
|
||||
AssetsUtils.extractAssetsDir(context, "eks", baseDir)
|
||||
} catch (e: Exception) {
|
||||
NLog.e("ExtraKey", "Failed to extract configure: ${e.localizedMessage}")
|
||||
}
|
||||
}
|
||||
|
||||
private fun reloadExtraKeyConfig() {
|
||||
val configDir = File(NeoTermPath.EKS_PATH)
|
||||
|
||||
configDir.listFiles(FILTER).forEach {
|
||||
if (it.absolutePath != NeoTermPath.EKS_DEFAULT_FILE) {
|
||||
val extraKey = this.loadConfigure(it)
|
||||
if (extraKey != null) {
|
||||
registerShortcutKeys(extraKey)
|
||||
extraKeys.clear()
|
||||
File(baseDir)
|
||||
.listFiles(NEOLANG_FILTER)
|
||||
.forEach {
|
||||
if (it.absolutePath != NeoTermPath.EKS_DEFAULT_FILE) {
|
||||
val extraKey = this.loadConfigure(it)
|
||||
if (extraKey != null) {
|
||||
registerShortcutKeys(extraKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package io.neoterm.component.profile
|
||||
import io.neolang.visitor.ConfigVisitor
|
||||
import io.neoterm.frontend.component.helper.ConfigFileBasedComponent
|
||||
import io.neoterm.frontend.config.NeoTermPath
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* @author kiva
|
||||
@ -31,6 +32,7 @@ class ProfileComponent : ConfigFileBasedComponent<NeoProfile>(NeoTermPath.PROFIL
|
||||
|
||||
fun reloadProfiles() {
|
||||
profileList.clear()
|
||||
|
||||
}
|
||||
|
||||
fun registerProfile(metaName: String, prototype: Class<out NeoProfile>) {
|
||||
|
@ -6,6 +6,7 @@ import io.neoterm.frontend.component.ComponentManager
|
||||
import io.neoterm.frontend.component.NeoComponent
|
||||
import io.neoterm.frontend.logging.NLog
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
|
||||
/**
|
||||
* @author kiva
|
||||
@ -13,6 +14,10 @@ import java.io.File
|
||||
abstract class ConfigFileBasedComponent<out T : ConfigFileBasedObject>(protected val baseDir: String) : NeoComponent {
|
||||
companion object {
|
||||
private val TAG = ConfigFileBasedComponent::class.java.simpleName
|
||||
|
||||
val NEOLANG_FILTER = FileFilter {
|
||||
it.extension == "nl"
|
||||
}
|
||||
}
|
||||
|
||||
open val checkComponentFileWhenObtained = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user