Skip to content

Commit

Permalink
Initial Side Map
Browse files Browse the repository at this point in the history
  • Loading branch information
sedwards2009 committed Oct 22, 2024
1 parent d79cc9c commit 5882450
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 34 deletions.
2 changes: 1 addition & 1 deletion main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test": "yarn run build-code && yarn node --experimental-vm-modules $(yarn bin jest)"
},
"dependencies": {
"@nodegui/nodegui": "0.66.0",
"@nodegui/nodegui": "0.69.0",
"nodegui-plugin-font-icon": "0.3.1",
"nodegui-plugin-qads": "^0.15.0",
"nodegui-plugin-qhotkey": "^0.1.1",
Expand Down
4 changes: 4 additions & 0 deletions main/src/extension/api/BlockImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export class BlockImpl implements ExtensionApi.Block, ExtensionApi.Disposable {
}
}

get metadata(): ExtensionApi.BlockMetadata {
return this.#blockFrame.getBlock().getMetadata();
}

get type(): string {
this.#init();
return this.#type;
Expand Down
13 changes: 12 additions & 1 deletion main/src/extension/api/StyleImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,16 @@ class PaletteImpl implements ExtensionApi.Palette {
get linkHover(): string {
return this.#uiStyle.getLinkHoverColor();
}

get running(): string {
return this.#uiStyle.getRunningColor();
}
get neutral(): string {
return this.#uiStyle.getNeutralColor();
}
get success(): string {
return this.#uiStyle.getSuccessColor();
}
get failure(): string {
return this.#uiStyle.getFailureColor();
}
}
5 changes: 5 additions & 0 deletions main/src/ui/UiStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ export interface UiStyle {
getLinkHoverColor(): string;
getTextMatchSelectedColor(): string;
getTextMatchColor(): string;

getRunningColor(): string;
getNeutralColor(): string;
getSuccessColor(): string;
getFailureColor(): string;
}
43 changes: 35 additions & 8 deletions main/src/ui/styles/DarkTwo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
*
* This source code is licensed under the MIT license which is detailed in the LICENSE.txt file.
*/
import { QIcon } from "@nodegui/nodegui";
import { QColor, QIcon } from "@nodegui/nodegui";
import { blue, darken, green, hsl, lighten, lightness, mix, red, rgba, saturate, toHex } from "khroma";

import { createIcon } from "../Icons.js";
import { IconPair, UiStyle } from "../UiStyle.js";
import { TitleBarStyle } from "../../config/Config.js";
import { Color } from "packages/extraterm-color-utilities/dist/ColorUtilities.js";


function toRgba(color: string): number {
return (red(color) << 24) | (green(color) << 16) | (blue(color) << 8) | 0xff;
}

function hslToRgb(hDegree: number, sPercent: number, lPercent: number): string {
const argb32 = QColor.fromHslF(hDegree/360, sPercent/100, lPercent/100).rgba();
return new Color((argb32 << 8) | 0xff).toHexString();
}

export function createUiStyle(resourceDirectory: string, titleBarStyle: TitleBarStyle): UiStyle {
let styleTextColor = "";
let styleDropdownLinkHoverColor = "";
Expand All @@ -29,6 +35,11 @@ export function createUiStyle(resourceDirectory: string, titleBarStyle: TitleBar
let styleLinkHoverColor = "";
let styleTextMatchColor = "";
let styleTextMatchSelectedColor = "";
let stylePostureRunningColor = "";
let stylePostureNeutralColor = "";
let stylePostureSuccessColor = "";
let stylePostureFailureColor = "";

const base100PercentFontSize = 10;

function DarkTwoStyleSheet(resourceDirectory: string, guiScale: number, dpi: number): string {
Expand Down Expand Up @@ -77,19 +88,19 @@ export function createUiStyle(resourceDirectory: string, titleBarStyle: TitleBar
const textMutedColor = mix(textColor, backgroundColor, 75);
const textDisabledColor = darken(backgroundColor, 6);

const brandPrimary = "hsl(219, 79%, 66%)";
const brandPrimary = hslToRgb(219, 79, 66);
const brandSuccess = "hsl(140, 44%, 62%)";
styleBrandSuccess = brandSuccess;
const brandInfo = "hsl(219, 79%, 66%)";
const brandWarning = "hsl( 36, 60%, 72%)";
const brandDanger = "hsl( 9, 100%, 64%)";
const brandDanger = hslToRgb(9, 100, 64);
styleBrandDanger = brandDanger;

const backgroundPrimaryColor = accentBgColor;
const backgroundSuccessColor = "hsl(132, 58%, 40%)";
const backgroundInfoColor = "hsl(208, 88%, 48%)";
const backgroundWarningColor = "hsl( 42, 88%, 36%)";
const backgroundDangerColor = "hsl( 5, 64%, 50%)";
const backgroundSuccessColor = hslToRgb(132, 58, 40);
const backgroundInfoColor = hslToRgb(208, 88, 48);
const backgroundWarningColor = hslToRgb(42, 88, 36);
const backgroundDangerColor = hslToRgb(5, 64, 50);

const brandTextPrimary = "#ffffff";
const brandTextSuccess = "#ffffff";
Expand Down Expand Up @@ -1211,6 +1222,10 @@ export function createUiStyle(resourceDirectory: string, titleBarStyle: TitleBar
function DecoratedFrameStyleSheet(): string {
const borderWidth = "1px";

stylePostureRunningColor = baseBorderColor;
stylePostureNeutralColor = baseBorderColor;
stylePostureSuccessColor = brandPrimary;
stylePostureFailureColor = brandDanger;
return `
QWidget[cssClass~="frame"] {
}
Expand Down Expand Up @@ -1624,7 +1639,19 @@ export function createUiStyle(resourceDirectory: string, titleBarStyle: TitleBar
},
getTextMatchSelectedColor(): string {
return styleTextMatchSelectedColor;
}
},
getRunningColor(): string {
return stylePostureRunningColor;
},
getNeutralColor(): string {
return stylePostureNeutralColor;
},
getSuccessColor(): string {
return stylePostureSuccessColor;
},
getFailureColor(): string {
return stylePostureFailureColor;
},
};
}

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"resolutions": {
"@types/node": "18.11.18",
"typescript": "5.2.2",
"@nodegui/nodegui": "0.66.0",
"@nodegui/nodegui": "0.69.0",
"7zip-bin": "5.1.1"
},
"private": true,
Expand Down Expand Up @@ -58,6 +58,7 @@
"extensions/ProxySessionBackend",
"extensions/ProxySessionEditor",
"extensions/OpenLink",
"extensions/ScrollMap",
"extensions/SSHSessionBackend",
"extensions/SSHSessionEditor",
"extensions/SSHQuickOpen",
Expand All @@ -73,7 +74,7 @@
]
},
"dependencies": {
"@nodegui/nodegui": "0.66.0",
"@nodegui/nodegui": "0.69.0",
"@nodegui/qode": "18.12.1",
"node-gyp": "^8.3.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/extraterm-char-render-canvas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"run": "false"
},
"dependencies": {
"@nodegui/nodegui": "0.66.0",
"@nodegui/nodegui": "0.69.0",
"extraterm-char-cell-line": "1.0.0",
"extraterm-color-utilities": "1.0.0",
"extraterm-data-structures": "1.0.0",
Expand Down
10 changes: 9 additions & 1 deletion packages/extraterm-color-utilities/src/ColorUtilities.jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Color } from "./ColorUtilities.js";

describe.each([
["#123456", 0x123456ff, "#123456", "rgba(18,52,86,1)"],
["#f03456", 0xf03456ff, "#f03456", "rgba(240,52,86,1)"],
["#1234567f", 0x1234567f, "#123456", "rgba(18,52,86,0.4980392156862745)"],
["#000001", 0x000001ff, "#000001", "rgba(0,0,1,1)"],
["#ffffff", 0xffffffff, "#ffffff", "rgba(255,255,255,1)"],
Expand All @@ -18,7 +19,7 @@ describe.each([
done();
});

test("Round trip ${input}", done => {
test(`Round trip ${input}`, done => {
const color = new Color(input);
expect(color.toHexString()).toBe(hexString);
done();
Expand All @@ -29,4 +30,11 @@ describe.each([
expect(color.toRGBAString()).toBe(rgbaString);
done();
});

test(`Round trip ${input} RGBA`, done => {
const color = new Color(rgba);
expect(color.toRGBA()).toBe(rgba);
expect(color.toRGBAString()).toBe(rgbaString);
done();
});
});
2 changes: 1 addition & 1 deletion packages/extraterm-color-utilities/src/ColorUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Color {
/**
* Creates a color object.
*
* @param redOrString CSS color string or the red component (0-255).
* @param rgbaOrRedOrString CSS color string or RGBA or the red component (0-255).
* @param green Green component (0-255).
* @param blue Blue compoennt (0-255).
* @param opacity Opacity or alpha (0-255). 0 is fully transparent, 255 is fully opaque.
Expand Down
2 changes: 1 addition & 1 deletion packages/extraterm-extension-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"typescript": "5.2.2"
},
"peerDependencies": {
"@nodegui/nodegui": "0.66.0"
"@nodegui/nodegui": "0.69.0"
}
}
6 changes: 4 additions & 2 deletions packages/extraterm-extension-api/src/Block.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Simon Edwards <[email protected]>
* Copyright 2024 Simon Edwards <[email protected]>
*
* This source code is licensed under the MIT license which is detailed in the LICENSE.txt file.
*/
Expand Down Expand Up @@ -38,7 +38,7 @@ export interface Block {
*
* For terminal output and current block receiving terminal output, this
* string will be equal to `TerminalType`, and the `details` field will
* contain a `TerminalDetails` object.
* contain a `TerminalOutputDetails` object.
*/
readonly type: string;

Expand All @@ -53,6 +53,8 @@ export interface Block {
readonly terminal: Terminal;

readonly geometry: BlockGeometry;

readonly metadata: BlockMetadata;
}

export interface BlockGeometry {
Expand Down
4 changes: 4 additions & 0 deletions packages/extraterm-extension-api/src/Style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1520,4 +1520,8 @@ export interface Palette {
backgroundSelected: string;
link: string;
linkHover: string;
running: string;
neutral: string;
success: string;
failure: string;
}
2 changes: 1 addition & 1 deletion packages/extraterm-timeoutqt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"url": "git://github.com/sedwards2009/extraterm.git"
},
"dependencies": {
"@nodegui/nodegui": "0.66.0"
"@nodegui/nodegui": "0.69.0"
},
"devDependencies": {
"eslint": "8.53.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/qt-construct/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"lint-strict": "eslint --max-warnings 1 \"src/**/*.ts\""
},
"peerDependencies": {
"@nodegui/nodegui": "0.66.0"
"@nodegui/nodegui": "0.69.0"
},
"devDependencies": {
"@nodegui/nodegui": "0.66.0",
"@nodegui/nodegui": "0.69.0",
"eslint": "8.53.0",
"eslint-config-extraterm": "1.0.0",
"eslint-plugin-unicorn": "42.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/term-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"url": "git://github.com/sedwards2009/extraterm.git"
},
"dependencies": {
"@nodegui/nodegui": "0.66.0",
"@nodegui/nodegui": "0.69.0",
"extraterm-char-cell-line": "1.0.0",
"text-term-api": "1.0.0"
},
Expand Down
Loading

0 comments on commit 5882450

Please sign in to comment.