Update default & ANSI theme names (#637)

This commit is contained in:
Miguel Solorio 2025-05-31 11:10:52 -07:00 committed by GitHub
parent c350fbef7f
commit cbc1614b84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 167 additions and 19 deletions

View File

@ -9,6 +9,8 @@ import * as path from 'path';
import { homedir } from 'os'; import { homedir } from 'os';
import { MCPServerConfig } from '@gemini-code/core/src/config/config.js'; import { MCPServerConfig } from '@gemini-code/core/src/config/config.js';
import stripJsonComments from 'strip-json-comments'; import stripJsonComments from 'strip-json-comments';
import { DefaultLight } from '../ui/themes/default-light.js';
import { DefaultDark } from '../ui/themes/default.js';
export const SETTINGS_DIRECTORY_NAME = '.gemini'; export const SETTINGS_DIRECTORY_NAME = '.gemini';
export const USER_SETTINGS_DIR = path.join(homedir(), SETTINGS_DIRECTORY_NAME); export const USER_SETTINGS_DIR = path.join(homedir(), SETTINGS_DIRECTORY_NAME);
@ -88,13 +90,19 @@ export class LoadedSettings {
*/ */
export function loadSettings(workspaceDir: string): LoadedSettings { export function loadSettings(workspaceDir: string): LoadedSettings {
let userSettings: Settings = {}; let userSettings: Settings = {};
let workspaceSettings = {}; let workspaceSettings: Settings = {};
// Load user settings // Load user settings
try { try {
if (fs.existsSync(USER_SETTINGS_PATH)) { if (fs.existsSync(USER_SETTINGS_PATH)) {
const userContent = fs.readFileSync(USER_SETTINGS_PATH, 'utf-8'); const userContent = fs.readFileSync(USER_SETTINGS_PATH, 'utf-8');
userSettings = JSON.parse(stripJsonComments(userContent)); userSettings = JSON.parse(stripJsonComments(userContent)) as Settings;
// Support legacy theme names
if (userSettings.theme && userSettings.theme === 'VS') {
userSettings.theme = DefaultLight.name;
} else if (userSettings.theme && userSettings.theme === 'VS2015') {
userSettings.theme = DefaultDark.name;
}
} }
} catch (error) { } catch (error) {
console.error('Error reading user settings file:', error); console.error('Error reading user settings file:', error);
@ -110,7 +118,17 @@ export function loadSettings(workspaceDir: string): LoadedSettings {
try { try {
if (fs.existsSync(workspaceSettingsPath)) { if (fs.existsSync(workspaceSettingsPath)) {
const projectContent = fs.readFileSync(workspaceSettingsPath, 'utf-8'); const projectContent = fs.readFileSync(workspaceSettingsPath, 'utf-8');
workspaceSettings = JSON.parse(stripJsonComments(projectContent)); workspaceSettings = JSON.parse(
stripJsonComments(projectContent),
) as Settings;
if (workspaceSettings.theme && workspaceSettings.theme === 'VS') {
workspaceSettings.theme = DefaultLight.name;
} else if (
workspaceSettings.theme &&
workspaceSettings.theme === 'VS2015'
) {
workspaceSettings.theme = DefaultDark.name;
}
} }
} catch (error) { } catch (error) {
console.error('Error reading workspace settings file:', error); console.error('Error reading workspace settings file:', error);

View File

@ -0,0 +1,130 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { lightTheme, Theme } from './theme.js';
export const ANSILight: Theme = new Theme(
'ANSI Light',
'light',
{
hljs: {
display: 'block',
overflowX: 'auto',
padding: '0.5em',
background: 'white',
color: 'black',
},
'hljs-keyword': {
color: 'blue',
},
'hljs-literal': {
color: 'blue',
},
'hljs-symbol': {
color: 'blue',
},
'hljs-name': {
color: 'blue',
},
'hljs-link': {
color: 'blue',
},
'hljs-built_in': {
color: 'cyan',
},
'hljs-type': {
color: 'cyan',
},
'hljs-number': {
color: 'green',
},
'hljs-class': {
color: 'green',
},
'hljs-string': {
color: 'red',
},
'hljs-meta-string': {
color: 'red',
},
'hljs-regexp': {
color: 'magenta',
},
'hljs-template-tag': {
color: 'magenta',
},
'hljs-subst': {
color: 'black',
},
'hljs-function': {
color: 'black',
},
'hljs-title': {
color: 'black',
},
'hljs-params': {
color: 'black',
},
'hljs-formula': {
color: 'black',
},
'hljs-comment': {
color: 'gray',
},
'hljs-quote': {
color: 'gray',
},
'hljs-doctag': {
color: 'gray',
},
'hljs-meta': {
color: 'gray',
},
'hljs-meta-keyword': {
color: 'gray',
},
'hljs-tag': {
color: 'gray',
},
'hljs-variable': {
color: 'purple',
},
'hljs-template-variable': {
color: 'purple',
},
'hljs-attr': {
color: 'blue',
},
'hljs-attribute': {
color: 'blue',
},
'hljs-builtin-name': {
color: 'blue',
},
'hljs-section': {
color: 'orange',
},
'hljs-bullet': {
color: 'orange',
},
'hljs-selector-tag': {
color: 'orange',
},
'hljs-selector-id': {
color: 'orange',
},
'hljs-selector-class': {
color: 'orange',
},
'hljs-selector-attr': {
color: 'orange',
},
'hljs-selector-pseudo': {
color: 'orange',
},
},
lightTheme,
);

View File

@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
import { ansiTheme, Theme } from './theme.js'; import { darkTheme, Theme } from './theme.js';
export const ANSI: Theme = new Theme( export const ANSI: Theme = new Theme(
'ANSI', 'ANSI',
'ansi', 'dark',
{ {
hljs: { hljs: {
display: 'block', display: 'block',
@ -135,5 +135,5 @@ export const ANSI: Theme = new Theme(
color: 'yellow', // Mapped from #D7BA7D color: 'yellow', // Mapped from #D7BA7D
}, },
}, },
ansiTheme, darkTheme,
); );

View File

@ -6,8 +6,8 @@
import { lightTheme, Theme } from './theme.js'; import { lightTheme, Theme } from './theme.js';
export const VS: Theme = new Theme( export const DefaultLight: Theme = new Theme(
'VS', 'Default Light',
'light', 'light',
{ {
hljs: { hljs: {

View File

@ -6,8 +6,8 @@
import { darkTheme, Theme } from './theme.js'; import { darkTheme, Theme } from './theme.js';
export const VS2015: Theme = new Theme( export const DefaultDark: Theme = new Theme(
'VS2015', 'Default',
'dark', 'dark',
{ {
hljs: { hljs: {

View File

@ -8,18 +8,19 @@ import { AtomOneDark } from './atom-one-dark.js';
import { Dracula } from './dracula.js'; import { Dracula } from './dracula.js';
import { GitHub } from './github.js'; import { GitHub } from './github.js';
import { GoogleCode } from './googlecode.js'; import { GoogleCode } from './googlecode.js';
import { VS } from './vs.js'; import { DefaultLight } from './default-light.js';
import { VS2015 } from './vs2015.js'; import { DefaultDark } from './default.js';
import { XCode } from './xcode.js'; import { XCode } from './xcode.js';
import { Theme, ThemeType } from './theme.js'; import { Theme, ThemeType } from './theme.js';
import { ANSI } from './ansi.js'; import { ANSI } from './ansi.js';
import { ANSILight } from './ansi-light.js';
export interface ThemeDisplay { export interface ThemeDisplay {
name: string; name: string;
type: ThemeType; type: ThemeType;
} }
export const DEFAULT_THEME: Theme = VS2015; export const DEFAULT_THEME: Theme = DefaultDark;
class ThemeManager { class ThemeManager {
private readonly availableThemes: Theme[]; private readonly availableThemes: Theme[];
@ -29,12 +30,13 @@ class ThemeManager {
this.availableThemes = [ this.availableThemes = [
AtomOneDark, AtomOneDark,
Dracula, Dracula,
VS, // Light mode. DefaultLight, // Light mode.
VS2015, DefaultDark,
GitHub, GitHub,
GoogleCode, GoogleCode,
XCode, XCode,
ANSI, ANSI,
ANSILight,
]; ];
this.activeTheme = DEFAULT_THEME; this.activeTheme = DEFAULT_THEME;
} }
@ -50,10 +52,8 @@ class ThemeManager {
return 1; return 1;
case 'light': case 'light':
return 2; return 2;
case 'ansi':
return 3;
default: default:
return 4; return 3;
} }
}; };

View File

@ -63,7 +63,7 @@ export const ansiTheme: ColorsTheme = {
LightBlue: 'blue', LightBlue: 'blue',
AccentBlue: 'blue', AccentBlue: 'blue',
AccentPurple: 'magenta', AccentPurple: 'magenta',
AccentCyan: 'cynan', AccentCyan: 'cyan',
AccentGreen: 'green', AccentGreen: 'green',
AccentYellow: 'yellow', AccentYellow: 'yellow',
AccentRed: 'red', AccentRed: 'red',