From f37440cd3f992f645547d194a666176cf24be126 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Fri, 15 Nov 2024 20:30:09 -0800 Subject: [PATCH] add colors --- .../contrib/void/browser/media/void.css | 15 +++ .../void/browser/registerInlineDiffs.ts | 102 ++++++++++++------ .../contrib/void/browser/void.contribution.ts | 2 + 3 files changed, 85 insertions(+), 34 deletions(-) create mode 100644 src/vs/workbench/contrib/void/browser/media/void.css diff --git a/src/vs/workbench/contrib/void/browser/media/void.css b/src/vs/workbench/contrib/void/browser/media/void.css new file mode 100644 index 00000000..90c274ba --- /dev/null +++ b/src/vs/workbench/contrib/void/browser/media/void.css @@ -0,0 +1,15 @@ +.monaco-editor .void-sweepIdxBG { + background-color: var(--vscode-void-sweepIdxBG); +} + +.void-sweepBG { + background-color: var(--vscode-void-sweepBG); +} + +.void-greenBG { + background-color: var(--vscode-void-greenBG); +} + +.void-redBG { + background-color: var(--vscode-void-redBG); +} diff --git a/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts b/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts index a7f6a419..e12d9f22 100644 --- a/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts +++ b/src/vs/workbench/contrib/void/browser/registerInlineDiffs.ts @@ -4,7 +4,7 @@ import { registerSingleton, InstantiationType } from '../../../../platform/insta import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js'; import { ICodeEditor, IViewZone } from '../../../../editor/browser/editorBrowser.js'; -import { IUndoRedoElement, IUndoRedoService, UndoRedoElementType } from '../../../../platform/undoRedo/common/undoRedo.js'; +// import { IUndoRedoService } from '../../../../platform/undoRedo/common/undoRedo.js'; import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js'; import { sendLLMMessage } from './react/out/util/sendLLMMessage.js'; // import { throttle } from '../../../../base/common/decorators.js'; @@ -14,10 +14,43 @@ import { findDiffs } from './findDiffs.js'; import { EndOfLinePreference, IModelDecorationOptions, IModelDeltaDecoration, ITextModel } from '../../../../editor/common/model.js'; import { IRange } from '../../../../editor/common/core/range.js'; import { EditorOption } from '../../../../editor/common/config/editorOptions.js'; +import { registerColor } from '../../../../platform/theme/common/colorUtils.js'; +import { Color, RGBA } from '../../../../base/common/color.js'; // import { IModelService } from '../../../../editor/common/services/model.js'; +// gets converted to --vscode-void-greenBG, see void.css +const greenBG = new Color(new RGBA(155, 185, 85, .3)); // default is RGBA(155, 185, 85, .2) +registerColor('void.greenBG', { + dark: greenBG, + light: greenBG, hcDark: null, hcLight: null +}, '', true); + +const redBG = new Color(new RGBA(255, 0, 0, .3)); // default is RGBA(255, 0, 0, .2) +registerColor('void.redBG', { + dark: redBG, + light: redBG, hcDark: null, hcLight: null +}, '', true); + +const sweepBG = new Color(new RGBA(100, 100, 100, .2)); +registerColor('void.sweepBG', { + dark: sweepBG, + light: sweepBG, hcDark: null, hcLight: null +}, '', true); + +const sweepIdxBG = new Color(new RGBA(100, 100, 100, .2)); +registerColor('void.sweepIdxBG', { + dark: sweepIdxBG, + light: sweepIdxBG, hcDark: null, hcLight: null +}, '', true); + + + + + + + export type Diff = { diffid: number, diffareaid: number, // the diff area this diff belongs to, "computed" @@ -55,28 +88,28 @@ type DiffArea = { // _generationid: number, } -const diffAreaSnapshotKeys = [ - 'diffareaid', - 'originalStartLine', - 'originalEndLine', - 'startLine', - 'endLine', -] as const satisfies (keyof DiffArea)[] +// const diffAreaSnapshotKeys = [ +// 'diffareaid', +// 'originalStartLine', +// 'originalEndLine', +// 'startLine', +// 'endLine', +// ] as const satisfies (keyof DiffArea)[] -type DiffAreaSnapshot = Pick +// type DiffAreaSnapshot = Pick -type HistorySnapshot = { - snapshottedDiffAreaOfId: Record, - snapshottedOriginalFileStr: string, // snapshot knows which model it belongs to -} & - ({ - type: 'ctrl+k', - ctrlKText: string - } | { - type: 'ctrl+l', - }) +// type HistorySnapshot = { +// snapshottedDiffAreaOfId: Record, +// snapshottedOriginalFileStr: string, // snapshot knows which model it belongs to +// } & +// ({ +// type: 'ctrl+k', +// ctrlKText: string +// } | { +// type: 'ctrl+l', +// }) export interface IInlineDiffsService { @@ -114,7 +147,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { // @IHistoryService private readonly _historyService: IHistoryService, // history service is the history of pressing alt left/right @IVoidConfigStateService private readonly _voidConfigStateService: IVoidConfigStateService, @ICodeEditorService private readonly _editorService: ICodeEditorService, - @IUndoRedoService private readonly _undoRedoService: IUndoRedoService, // undoRedo service is the history of pressing ctrl+z + // @IUndoRedoService private readonly _undoRedoService: IUndoRedoService, // undoRedo service is the history of pressing ctrl+z // @IModelService private readonly _modelService: IModelService, ) { @@ -134,32 +167,32 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { endLineNumber: sweepLine, endColumn: Number.MAX_SAFE_INTEGER } - const darkGrayDecoration: IModelDecorationOptions = { - className: 'sweep-dark-gray', - description: 'sweep-dark-gray', + const sweepIdxDecoration: IModelDecorationOptions = { + className: 'void-sweepIdxBG', + description: 'void-sweepIdxBG', isWholeLine: true } decorationIds.push( - model.changeDecorations(accessor => accessor.addDecoration(lineRange, darkGrayDecoration)) + model.changeDecorations(accessor => accessor.addDecoration(lineRange, sweepIdxDecoration)) ) - // sweepline+1 ... end + // sweepLine+1 ... endLine const bulkRange = { startLineNumber: sweepLine + 1, startColumn: 1, endLineNumber: endLine, endColumn: Number.MAX_SAFE_INTEGER } - const lightGrayDecoration: IModelDecorationOptions = { - className: 'sweep-light-gray', - description: 'sweep-light-gray', + const sweepDecoration: IModelDecorationOptions = { + className: 'void-sweepBG', + description: 'void-sweepBG', isWholeLine: true } decorationIds.push( - model.changeDecorations(accessor => accessor.addDecoration(bulkRange, lightGrayDecoration)) + model.changeDecorations(accessor => accessor.addDecoration(bulkRange, sweepDecoration)) ) const dispose = () => { for (let id of decorationIds) { @@ -177,8 +210,8 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { const greenDecoration: IModelDeltaDecoration[] = [{ range: greenRange, options: { - className: 'line-insert', // .monaco-editor .line-insert - description: 'line-insert', + className: 'void-greenBG line-insert', // .monaco-editor .line-insert + description: 'void-greenBG', isWholeLine: true, minimap: { color: { id: 'minimapGutter.addedBackground' }, @@ -209,7 +242,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { // div const lineContent = document.createElement('div'); - lineContent.className = 'view-line'; // .monaco-editor .inline-deleted-text + lineContent.className = 'void-redBG view-line'; // .monaco-editor .inline-deleted-text // span const contentSpan = document.createElement('span'); @@ -226,9 +259,9 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { // Gutter (thing to the left) const gutterDiv = document.createElement('div'); - gutterDiv.className = 'inline-diff-gutter'; + // gutterDiv.className = 'inline-diff-gutter'; const minusDiv = document.createElement('div'); - minusDiv.className = 'inline-diff-deleted-gutter'; + // minusDiv.className = 'inline-diff-deleted-gutter'; // minusDiv.textContent = '-'; gutterDiv.appendChild(minusDiv); @@ -367,6 +400,7 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService { + // private _registeredListeners = new Set() // set of model IDs // private _registerTextChangeListener(model: ITextModel) { diff --git a/src/vs/workbench/contrib/void/browser/void.contribution.ts b/src/vs/workbench/contrib/void/browser/void.contribution.ts index 7e5682a5..69d035e7 100644 --- a/src/vs/workbench/contrib/void/browser/void.contribution.ts +++ b/src/vs/workbench/contrib/void/browser/void.contribution.ts @@ -17,3 +17,5 @@ import './registerSidebar.js' // register Thread History import './registerThreads.js' +// register css +import './media/void.css'