in src/main/java/com/maddyhome/idea/vim/ui/widgets/mode/Util.kt [102:163]
fun getModeForeground(mode: Mode?): Color {
val isLight = !(LafManager.getInstance()?.currentUIThemeLookAndFeel?.isDark ?: false)
val keyPostfix = if (isLight) "_light" else "_dark"
if (injector.variableService.getVimVariable("widget_mode_is_full_customization$keyPostfix")?.toVimNumber()?.booleanValue != true) {
val themeString = injector.variableService.getVimVariable("widget_mode_theme$keyPostfix")?.toVimString()?.value ?: ""
val theme = ModeWidgetTheme.parseString(themeString) ?: ModeWidgetTheme.getDefaultTheme()
return when (theme) {
ModeWidgetTheme.TERM -> if (isLight) Color.WHITE else Color.BLACK
ModeWidgetTheme.DRACULA -> Color.BLACK
ModeWidgetTheme.COLORLESS -> UIUtil.getLabelForeground()
}
} else {
val colorString = when (mode) {
Mode.INSERT -> injector.variableService.getVimVariable("widget_mode_insert_foreground$keyPostfix")
Mode.REPLACE -> injector.variableService.getVimVariable("widget_mode_replace_foreground$keyPostfix")
is Mode.NORMAL -> injector.variableService.getVimVariable("widget_mode_normal_foreground$keyPostfix")
is Mode.CMD_LINE -> injector.variableService.getVimVariable("widget_mode_command_foreground$keyPostfix")
is Mode.VISUAL -> {
val visualModeBackground = injector.variableService.getVimVariable("widget_mode_visual_foreground$keyPostfix")
when (mode.selectionType) {
SelectionType.CHARACTER_WISE -> visualModeBackground
SelectionType.LINE_WISE -> injector.variableService.getVimVariable("widget_mode_visual_line_foreground$keyPostfix")
?: visualModeBackground
SelectionType.BLOCK_WISE -> injector.variableService.getVimVariable("widget_mode_visual_block_foreground$keyPostfix")
?: visualModeBackground
}
}
is Mode.SELECT -> {
val selectModeBackground = injector.variableService.getVimVariable("widget_mode_select_foreground$keyPostfix")
when (mode.selectionType) {
SelectionType.CHARACTER_WISE -> selectModeBackground
SelectionType.LINE_WISE -> injector.variableService.getVimVariable("widget_mode_select_line_foreground$keyPostfix")
?: selectModeBackground
SelectionType.BLOCK_WISE -> injector.variableService.getVimVariable("widget_mode_select_block_foreground$keyPostfix")
?: selectModeBackground
}
}
is Mode.OP_PENDING, null -> null
}?.toVimString()?.value
val defaultColor = UIUtil.getLabelForeground()
val color = when (colorString) {
"v:status_bar_bg" -> UIUtil.getPanelBackground()
"v:status_bar_fg" -> UIUtil.getLabelForeground()
else -> {
if (colorString == null) {
defaultColor
} else {
try {
Color.decode(colorString)
} catch (e: Exception) {
defaultColor
}
}
}
}
return color
}
}