Skip to content

Commit

Permalink
added day night prefix to colour properties
Browse files Browse the repository at this point in the history
  • Loading branch information
john-peterson committed Sep 26, 2024
1 parent 2ff5956 commit 972789a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.termux.app.TermuxService;
import com.termux.shared.termux.settings.properties.TermuxPropertyConstants;
import com.termux.shared.termux.terminal.io.BellHandler;
import com.termux.shared.theme.ThemeUtils;
import com.termux.shared.logger.Logger;
import com.termux.terminal.TerminalColors;
import com.termux.terminal.TerminalSession;
Expand Down Expand Up @@ -296,6 +297,7 @@ public void setCurrentSession(TerminalSession session) {
if (mActivity.getTerminalView().attachSession(session)) {
// notify about switched session if not already displaying the session
notifyOfSessionChange();
checkForFontAndColors();
}

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

TerminalColors.COLOR_SCHEME.updateWith(props);
TerminalColors.COLOR_SCHEME.updateWith(props, !ThemeUtils.shouldEnableDarkTheme(mActivity));
TerminalSession session = mActivity.getCurrentSession();
if (session != null && session.getEmulator() != null) {
session.getEmulator().mColors.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,29 @@ private void reset() {
System.arraycopy(DEFAULT_COLORSCHEME, 0, mDefaultColors, 0, TextStyle.NUM_INDEXED_COLORS);
}

public void updateWith(Properties props) {
void logEx(Exception e) {
throw new IllegalArgumentException(e.toString()+e.getMessage());
}

public void updateWith(Properties props, boolean isDay) {
reset();
boolean cursorPropExists = false;
for (Map.Entry<Object, Object> entries : props.entrySet()) {
String key = (String) entries.getKey();

try {
if (key.contains(".")) {
String prefix = key.split("\\.")[0];
boolean useDay = isDay && prefix.equals("day");
boolean useNight = !isDay && prefix.equals("night");

if (useDay || useNight)
key = key.split("\\.")[1];
else
continue;
}
} catch (Exception e) { logEx(e); }

String value = (String) entries.getValue();
int colorIndex;

Expand Down

0 comments on commit 972789a

Please sign in to comment.