UI: Create session with profile
This commit is contained in:
parent
eb845484b5
commit
29c4f92625
@ -26,7 +26,8 @@ class ColorSchemeComponent : ConfigFileBasedComponent<NeoColorScheme>(NeoTermPat
|
||||
}
|
||||
}
|
||||
|
||||
override val checkComponentFileWhenObtained = true
|
||||
override val checkComponentFileWhenObtained
|
||||
get() = true
|
||||
|
||||
private lateinit var DEFAULT_COLOR: NeoColorScheme
|
||||
private var colors: MutableMap<String, NeoColorScheme> = mutableMapOf()
|
||||
|
@ -14,7 +14,8 @@ import java.io.File
|
||||
* @author kiva
|
||||
*/
|
||||
class ExtraKeyComponent : ConfigFileBasedComponent<NeoExtraKey>(NeoTermPath.EKS_PATH) {
|
||||
override val checkComponentFileWhenObtained = true
|
||||
override val checkComponentFileWhenObtained
|
||||
get() = true
|
||||
|
||||
private val extraKeys: MutableMap<String, NeoExtraKey> = mutableMapOf()
|
||||
|
||||
|
@ -9,7 +9,8 @@ import java.io.File
|
||||
* @author kiva
|
||||
*/
|
||||
class ProfileComponent : ConfigFileBasedComponent<NeoProfile>(NeoTermPath.PROFILE_PATH) {
|
||||
override val checkComponentFileWhenObtained = true
|
||||
override val checkComponentFileWhenObtained
|
||||
get() = true
|
||||
|
||||
private val profileRegistry = mutableMapOf<String, Class<out NeoProfile>>()
|
||||
private val profileList = mutableMapOf<String, MutableList<NeoProfile>>()
|
||||
@ -20,14 +21,16 @@ class ProfileComponent : ConfigFileBasedComponent<NeoProfile>(NeoTermPath.PROFIL
|
||||
val rootContext = configVisitor.getRootContext()
|
||||
|
||||
val profileClass = rootContext.children
|
||||
.mapNotNull { profileRegistry[it.contextName] }
|
||||
.mapNotNull {
|
||||
profileRegistry[it.contextName]
|
||||
}
|
||||
.singleOrNull()
|
||||
|
||||
if (profileClass != null) {
|
||||
return profileClass.newInstance()
|
||||
}
|
||||
|
||||
throw IllegalArgumentException("No proper profile registry for found")
|
||||
throw IllegalArgumentException("No proper profile registry found")
|
||||
}
|
||||
|
||||
fun getProfiles(metaName: String): List<NeoProfile> = profileList[metaName] ?: listOf()
|
||||
@ -36,7 +39,9 @@ class ProfileComponent : ConfigFileBasedComponent<NeoProfile>(NeoTermPath.PROFIL
|
||||
profileList.clear()
|
||||
File(baseDir)
|
||||
.listFiles(NEOLANG_FILTER)
|
||||
.mapNotNull { this.loadConfigure(it) }
|
||||
.mapNotNull {
|
||||
this.loadConfigure(it)
|
||||
}
|
||||
.forEach {
|
||||
val list = profileList[it.profileName]
|
||||
if (list != null) {
|
||||
|
@ -435,12 +435,21 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
|
||||
private fun showProfileDialog() {
|
||||
val profileComponent = ComponentManager.getComponent<ProfileComponent>()
|
||||
val profiles = profileComponent.getProfiles(ShellProfile.PROFILE_META_NAME)
|
||||
.filterIsInstance<ShellProfile>()
|
||||
val profilesShell = profiles.filterIsInstance<ShellProfile>()
|
||||
|
||||
if (profiles.isEmpty()) {
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(R.string.error)
|
||||
.setMessage(R.string.no_profile_available)
|
||||
.setPositiveButton(android.R.string.yes, null)
|
||||
.show()
|
||||
return
|
||||
}
|
||||
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(R.string.new_session_with_profile)
|
||||
.setItems(profiles.map { it.profileName }.toTypedArray(), { dialog, which ->
|
||||
val selectedProfile = profiles[which]
|
||||
val selectedProfile = profilesShell[which]
|
||||
addNewSessionWithProfile(selectedProfile)
|
||||
})
|
||||
.setPositiveButton(android.R.string.no, null)
|
||||
|
@ -154,6 +154,7 @@
|
||||
<string name="toggle_eks">切换拓展键</string>
|
||||
<string name="new_x_session">新建图形会话</string>
|
||||
<string name="new_session_with_profile">新建个性化会话</string>
|
||||
<string name="no_profile_available">没有可用的个性化配置</string>
|
||||
|
||||
<string-array name="color_item_names">
|
||||
<item>背景色</item>
|
||||
|
@ -158,6 +158,7 @@
|
||||
<string name="toggle_eks">Toggle extra keys</string>
|
||||
<string name="new_x_session">New X Session</string>
|
||||
<string name="new_session_with_profile">New Session With Profile</string>
|
||||
<string name="no_profile_available">No profile available</string>
|
||||
|
||||
<string name="default_source_url">http://neoterm.studio</string>
|
||||
<string name="lnpo_source_url">http://lnpo.top:81/neoterm</string>
|
||||
|
Loading…
Reference in New Issue
Block a user