Remove string mapping, improve types, standardize on 'outline'

This commit is contained in:
Daniel Imms
2023-08-11 13:09:31 -07:00
parent 136e2f2afe
commit 6f6cc6a686
3 changed files with 8 additions and 23 deletions
@@ -255,7 +255,7 @@ export class RectangleRenderer extends Disposable {
let offset: number;
let rectangleCount = 0;
if (cursor.style === 'bar' || cursor.style === 'blur') {
if (cursor.style === 'bar' || cursor.style === 'outline') {
// Left edge
offset = rectangleCount++ * INDICES_PER_RECTANGLE;
this._addRectangleFloat(
@@ -268,7 +268,7 @@ export class RectangleRenderer extends Disposable {
this._cursorFloat
);
}
if (cursor.style === 'underline' || cursor.style === 'blur') {
if (cursor.style === 'underline' || cursor.style === 'outline') {
// Bottom edge
offset = rectangleCount++ * INDICES_PER_RECTANGLE;
this._addRectangleFloat(
@@ -281,7 +281,7 @@ export class RectangleRenderer extends Disposable {
this._cursorFloat
);
}
if (cursor.style === 'blur') {
if (cursor.style === 'outline') {
// Top edge
offset = rectangleCount++ * INDICES_PER_RECTANGLE;
this._addRectangleFloat(
+3 -1
View File
@@ -16,11 +16,13 @@ export interface ICursorRenderModel {
x: number;
y: number;
width: number;
style: string;
style: CursorStyle;
cursorWidth: number;
dpr: number;
}
export type CursorStyle = 'outline' | 'block' | 'bar' | 'underline' | 'none';
export interface IWebGL2RenderingContext extends WebGLRenderingContext {
vertexAttribDivisor(index: number, divisor: number): void;
createVertexArray(): IWebGLVertexArrayObject;
+2 -19
View File
@@ -455,14 +455,13 @@ export class WebglRenderer extends Disposable implements IRenderer {
// Override colors for cursor cell
if (isCursorVisible && row === cursorY) {
const inactiveCursorStyle = this._getInactiveCursorStyle(terminal.options.cursorInactiveStyle);
if (x === cursorX) {
this._model.cursor = {
x: cursorX,
y: this._terminal.buffer.active.cursorY,
width: cell.getWidth(),
style: this._coreBrowserService.isFocused ?
(terminal.options.cursorStyle || 'block') : inactiveCursorStyle,
(terminal.options.cursorStyle || 'block') : terminal.options.cursorInactiveStyle,
cursorWidth: terminal.options.cursorWidth,
dpr: this._devicePixelRatio
};
@@ -472,7 +471,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
((this._coreBrowserService.isFocused &&
(terminal.options.cursorStyle || 'block') === 'block') ||
(this._coreBrowserService.isFocused === false &&
inactiveCursorStyle === 'block'))) {
terminal.options.cursorInactiveStyle === 'block'))) {
this._cellColorResolver.result.fg =
Attributes.CM_RGB | (this._themeService.colors.cursorAccent.rgba >> 8 & Attributes.RGB_MASK);
this._cellColorResolver.result.bg =
@@ -603,22 +602,6 @@ export class WebglRenderer extends Disposable implements IRenderer {
const cursorY = this._terminal.buffer.active.cursorY;
this._onRequestRedraw.fire({ start: cursorY, end: cursorY });
}
private _getInactiveCursorStyle(cursorInactiveStyle: 'outline' | 'block' | 'bar' | 'underline' | 'none'): string {
if (cursorInactiveStyle === 'outline') {
return 'blur';
}
if (cursorInactiveStyle === 'block') {
return 'block';
}
if (cursorInactiveStyle === 'bar') {
return 'bar';
}
if (cursorInactiveStyle === 'underline') {
return 'underline';
}
return '';
}
}
// TODO: Share impl with core