colon and comma same color as brackets

master
David Volovskiy 2025-04-20 15:33:34 -04:00
parent dff1259813
commit 352cbdc5d3
3 changed files with 13 additions and 3 deletions

View File

@ -185,12 +185,19 @@ let redraw = function() {
// Key
g.setColor(clrs.keys);
const keyText = indent + `"${key}": `
const keyText = indent + `"${key}"`;
g.drawString(keyText, numWidth, y);
const keyWidth = g.stringWidth(keyText);
const valueX = numWidth + keyWidth;
let valueX = numWidth + keyWidth;
g.setColor(clrs.brackets);
const colonText = ": ";
g.drawString(colonText, valueX, y);
valueX += g.stringWidth(colonText);
// Value color
const endComma = value.endsWith(',');
if (endComma) value = value.slice(0, -1);
if (value.startsWith('"')) {
g.setColor(clrs.strings);
} else if (value.startsWith('{') || value.startsWith('}')) {
@ -199,7 +206,10 @@ let redraw = function() {
g.setColor(clrs.ints);
}
g.drawString(value, valueX, y);
if (endComma){
g.setColor(clrs.brackets);
g.drawString(',', valueX + g.stringWidth(value), y);
}
valuePositions.push({
key,
x: valueX,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB