-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow setting terminal color #28
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
import type { TerminalOptions } from "vscode"; | ||
|
||
export enum TerminalColor { | ||
"black" = "terminal.ansiBlack", | ||
"red" = "terminal.ansiRed", | ||
"green" = "terminal.ansiGreen", | ||
"yellow" = "terminal.ansiYellow", | ||
"blue" = "terminal.ansiBlue", | ||
"magenta" = "terminal.ansiMagenta", | ||
"cyan" = "terminal.ansiCyan", | ||
"white" = "terminal.ansiWhite", | ||
} | ||
Comment on lines
+3
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why put this in an enum if you're gonna use it like a map? Imo it's better to do a readonly object. |
||
|
||
export interface TerminalConfig { | ||
commands?: string[]; | ||
name?: string; | ||
icon?: string; | ||
color?: string; | ||
color?: keyof typeof TerminalColor; | ||
shouldRunCommands?: boolean; //whether to actually run the commands, or just paste them in | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import * as vscode from "vscode"; | ||
import { delay } from "./utils"; | ||
import { Configuration, TerminalConfig, TerminalWindow } from "./model"; | ||
import { | ||
Configuration, | ||
TerminalColor, | ||
TerminalConfig, | ||
TerminalWindow, | ||
} from "./model"; | ||
|
||
const DEFAULT_ARTIFICAL_DELAY = 300; | ||
const SPLIT_TERM_CHECK_DELAY = 100; | ||
|
@@ -66,8 +71,15 @@ export default async function restoreTerminals(configuration: Configuration) { | |
); | ||
} | ||
} else { | ||
let color = TerminalColor.white; | ||
|
||
if (terminalWindow.splitTerminals[0]?.color) { | ||
color = TerminalColor[terminalWindow.splitTerminals[0].color]; | ||
} | ||
Comment on lines
+76
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to check that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In any case, it falls back to white |
||
|
||
term = vscode.window.createTerminal({ | ||
name: name, | ||
color: new vscode.ThemeColor(color), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what happens if you call |
||
iconPath: new vscode.ThemeIcon(icon ?? "terminal"), | ||
// cwd: vscode.window.activeTextEditor?.document.uri.fsPath, //i think this happens by default | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it required to update the version? because this could possibly be breaking otherwise.