Feature: ColorScheme
This commit is contained in:
parent
7a3ec1c924
commit
6a810af698
24
app/src/main/java/io/neoterm/customize/NeoTermColorScheme.kt
Normal file
24
app/src/main/java/io/neoterm/customize/NeoTermColorScheme.kt
Normal file
@ -0,0 +1,24 @@
|
||||
package io.neoterm.customize
|
||||
|
||||
import io.neoterm.terminal.TerminalColors
|
||||
import io.neoterm.terminal.TerminalSession
|
||||
|
||||
/**
|
||||
* @author kiva
|
||||
*/
|
||||
class NeoTermColorScheme {
|
||||
var foreground: String? = null
|
||||
var background: String? = null
|
||||
var cursor: String? = null
|
||||
var color: MutableMap<Int, String> = mutableMapOf()
|
||||
|
||||
fun apply(session: TerminalSession?) {
|
||||
if (session == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val termSession = session
|
||||
TerminalColors.COLOR_SCHEME.updateWith(foreground, background, cursor, color)
|
||||
termSession.emulator.mColors.reset()
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import android.support.v7.widget.Toolbar
|
||||
import de.mrapp.android.tabswitcher.Tab
|
||||
import io.neoterm.customize.NeoTermColorScheme
|
||||
import io.neoterm.terminal.TerminalSession
|
||||
|
||||
/**
|
||||
@ -20,6 +21,10 @@ class TermTab : Tab {
|
||||
|
||||
private constructor(source: Parcel) : super(source)
|
||||
|
||||
fun changeColorScheme(colorScheme: NeoTermColorScheme?) {
|
||||
colorScheme?.apply(termSession)
|
||||
}
|
||||
|
||||
fun cleanup() {
|
||||
termSession?.finishIfRunning()
|
||||
viewClient?.termView = null
|
||||
|
@ -69,6 +69,17 @@ public final class TerminalColorScheme {
|
||||
System.arraycopy(DEFAULT_COLORSCHEME, 0, mDefaultColors, 0, TextStyle.NUM_INDEXED_COLORS);
|
||||
}
|
||||
|
||||
public void updateWith(String foreground, String background, String cursor, Map<Integer, String> color) {
|
||||
Properties prop = new Properties();
|
||||
prop.put("foreground", foreground);
|
||||
prop.put("background", background);
|
||||
prop.put("cursor", cursor);
|
||||
for (int i : color.keySet()) {
|
||||
prop.put("color" + i, color.get(i));
|
||||
}
|
||||
updateWith(prop);
|
||||
}
|
||||
|
||||
public void updateWith(Properties props) {
|
||||
reset();
|
||||
for (Map.Entry<Object, Object> entries : props.entrySet()) {
|
||||
|
Loading…
Reference in New Issue
Block a user