Skip to content

Commit c9cd1d1

Browse files
committed
added day night prefix to colour properties
1 parent b6ddafd commit c9cd1d1

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

app/src/main/java/com/termux/app/terminal/TermuxTerminalSessionActivityClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.termux.app.TermuxService;
2727
import com.termux.shared.termux.settings.properties.TermuxPropertyConstants;
2828
import com.termux.shared.termux.terminal.io.BellHandler;
29+
import com.termux.shared.theme.ThemeUtils;
2930
import com.termux.shared.logger.Logger;
3031
import com.termux.terminal.TerminalColors;
3132
import com.termux.terminal.TerminalSession;
@@ -296,6 +297,7 @@ public void setCurrentSession(TerminalSession session) {
296297
if (mActivity.getTerminalView().attachSession(session)) {
297298
// notify about switched session if not already displaying the session
298299
notifyOfSessionChange();
300+
checkForFontAndColors();
299301
}
300302

301303
// We call the following even when the session is already being displayed since config may
@@ -503,7 +505,7 @@ public void checkForFontAndColors() {
503505
}
504506
}
505507

506-
TerminalColors.COLOR_SCHEME.updateWith(props);
508+
TerminalColors.COLOR_SCHEME.updateWith(props, !ThemeUtils.shouldEnableDarkTheme(mActivity));
507509
TerminalSession session = mActivity.getCurrentSession();
508510
if (session != null && session.getEmulator() != null) {
509511
session.getEmulator().mColors.reset();

terminal-emulator/src/main/java/com/termux/terminal/TerminalColorScheme.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,29 @@ private void reset() {
6969
System.arraycopy(DEFAULT_COLORSCHEME, 0, mDefaultColors, 0, TextStyle.NUM_INDEXED_COLORS);
7070
}
7171

72-
public void updateWith(Properties props) {
72+
void logEx(Exception e) {
73+
throw new IllegalArgumentException(e.toString()+e.getMessage());
74+
}
75+
76+
public void updateWith(Properties props, boolean isDay) {
7377
reset();
7478
boolean cursorPropExists = false;
7579
for (Map.Entry<Object, Object> entries : props.entrySet()) {
7680
String key = (String) entries.getKey();
81+
82+
try {
83+
if (key.contains(".")) {
84+
String prefix = key.split("\\.")[0];
85+
boolean useDay = isDay && prefix.equals("day");
86+
boolean useNight = !isDay && prefix.equals("night");
87+
88+
if (useDay || useNight)
89+
key = key.split("\\.")[1];
90+
else
91+
continue;
92+
}
93+
} catch (Exception e) { logEx(e); }
94+
7795
String value = (String) entries.getValue();
7896
int colorIndex;
7997

0 commit comments

Comments
 (0)