Skip to content

Commit 3c851a8

Browse files
committed
I don't like the term Double Wide.
1 parent c707d59 commit 3c851a8

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

server/static/renderer.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class NeovimRenderer {
112112
this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
113113
}
114114

115-
isDoubleWidth(char) {
115+
isWideChar(char) {
116116
if (!char || char.length === 0) return false;
117117

118118
const code = char.codePointAt(0);
@@ -141,7 +141,6 @@ class NeovimRenderer {
141141
(code >= 0x2700 && code <= 0x27bf) || // Dingbats
142142
(code >= 0x1f900 && code <= 0x1f9ff) || // Supplemental Symbols
143143
(code >= 0x1fa70 && code <= 0x1faff) || // Extended-A
144-
// Additional ranges for symbols that should be double-width
145144
(code >= 0x2e80 && code <= 0x2eff) || // CJK Radicals
146145
(code >= 0x2f00 && code <= 0x2fdf) || // Kangxi Radicals
147146
(code >= 0x3000 && code <= 0x303f) || // CJK Symbols
@@ -176,27 +175,29 @@ class NeovimRenderer {
176175
const x = col * this.cellWidth;
177176
const y = row * this.cellHeight;
178177

179-
// Only fill background if it's different from default
178+
// Fill background for current cell
180179
if (cell.bg !== this.colors.bg) {
181180
this.ctx.fillStyle = cell.bg;
182181
this.ctx.fillRect(x, y, this.cellWidth, this.cellHeight);
183182
}
184183

185-
// Handle double-width background
186-
if (
187-
cell.isDoubleWidth &&
188-
col + 1 < this.cols &&
189-
cell.bg !== this.colors.bg
190-
) {
191-
this.ctx.fillRect(x + this.cellWidth, y, this.cellWidth, this.cellHeight);
184+
if (cell.isWideChar && col + 1 < this.cols) {
185+
if (cell.bg !== this.colors.bg) {
186+
this.ctx.fillStyle = cell.bg;
187+
this.ctx.fillRect(
188+
x + this.cellWidth,
189+
y,
190+
this.cellWidth,
191+
this.cellHeight,
192+
);
193+
}
192194
}
193195

194196
// Draw character if not empty
195197
if (cell.char && cell.char !== " ") {
196198
this.ctx.fillStyle = cell.fg;
197199

198-
if (cell.isDoubleWidth) {
199-
// Minimize context state changes
200+
if (cell.isWideChar) {
200201
const oldAlign = this.ctx.textAlign;
201202
this.ctx.textAlign = "left";
202203
this.ctx.fillText(cell.char, x, y + 2);
@@ -544,7 +545,7 @@ class NeovimRenderer {
544545
char: char,
545546
fg: highlight.fg,
546547
bg: highlight.bg,
547-
isDoubleWidth: this.isDoubleWidth(char),
548+
isWideChar: this.isWideChar(char),
548549
};
549550

550551
col++;
@@ -657,11 +658,11 @@ class NeovimRenderer {
657658
char: cell.char,
658659
x: col * this.cellWidth,
659660
y: row * this.cellHeight,
660-
isDoubleWidth: cell.isDoubleWidth,
661+
isWideChar: cell.isWideChar,
661662
});
662663
}
663664

664-
if (cell.isDoubleWidth) col++;
665+
if (cell.isWideChar) col++;
665666
}
666667
}
667668

@@ -677,7 +678,7 @@ class NeovimRenderer {
677678
for (const [color, texts] of textBatches) {
678679
this.ctx.fillStyle = color;
679680
for (const text of texts) {
680-
if (text.isDoubleWidth) {
681+
if (text.isWideChar) {
681682
const oldAlign = this.ctx.textAlign;
682683
this.ctx.textAlign = "left";
683684
this.ctx.fillText(text.char, text.x, text.y + 2);

0 commit comments

Comments
 (0)