Component: Use advanced list reloading operation

This commit is contained in:
zt515
2017-12-27 00:03:38 +08:00
parent 2ca2a47049
commit d2e9f06de3
3 changed files with 9 additions and 11 deletions

View File

@ -54,11 +54,9 @@ class ColorSchemeComponent : ConfigFileBasedComponent<NeoColorScheme>(NeoTermPat
File(baseDir)
.listFiles(NEOLANG_FILTER)
.mapNotNull { this.loadConfigure(it) }
.forEach {
val colorScheme = this.loadConfigure(it)
if (colorScheme != null) {
colors.put(colorScheme.colorName, colorScheme)
}
colors.put(it.colorName, it)
}
if (colors.containsKey(DefaultColorScheme.colorName)) {

View File

@ -62,13 +62,10 @@ class ExtraKeyComponent : ConfigFileBasedComponent<NeoExtraKey>(NeoTermPath.EKS_
extraKeys.clear()
File(baseDir)
.listFiles(NEOLANG_FILTER)
.filterNot { it.absolutePath != NeoTermPath.EKS_DEFAULT_FILE }
.mapNotNull { this.loadConfigure(it) }
.forEach {
if (it.absolutePath != NeoTermPath.EKS_DEFAULT_FILE) {
val extraKey = this.loadConfigure(it)
if (extraKey != null) {
registerShortcutKeys(extraKey)
}
}
registerShortcutKeys(it)
}
}
}

View File

@ -32,7 +32,10 @@ class ProfileComponent : ConfigFileBasedComponent<NeoProfile>(NeoTermPath.PROFIL
fun reloadProfiles() {
profileList.clear()
File(baseDir)
.listFiles(NEOLANG_FILTER)
.map { this.loadConfigure(it) }
.filterNotNullTo(profileList)
}
fun registerProfile(metaName: String, prototype: Class<out NeoProfile>) {