mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Mark powerline symbol range as reserved
This commit is contained in:
+2
-2
@@ -29,7 +29,7 @@ import { WebglAddon } from '@xterm/addon-webgl';
|
||||
import { Unicode11Addon } from '@xterm/addon-unicode11';
|
||||
import { UnicodeGraphemesAddon } from '@xterm/addon-unicode-graphemes';
|
||||
|
||||
import { writeUnicodeTable, type UnicodeRangeDefinition } from './unicodeTable';
|
||||
import { writeUnicodeTable } from './unicodeTable';
|
||||
|
||||
export interface IWindowWithTerminal extends Window {
|
||||
term: typeof Terminal;
|
||||
@@ -886,7 +886,7 @@ function customGlyphRangesHandler(): void {
|
||||
// Range: E0A0–E0BF
|
||||
// https://github.com/ryanoasis/nerd-fonts
|
||||
writeUnicodeTable(term, 'Powerline Symbols', 0xE0A0, 0xE0BF, [
|
||||
['Powerline Symbols', 0xE0A0, 0xE0B3],
|
||||
['Powerline Symbols', 0xE0A0, 0xE0B3, [0xE0A4, 0xE0A5, 0xE0A6, 0xE0A7, 0xE0A8, 0xE0A9, 0xE0AA, 0xE0AB, 0xE0AC, 0xE0AD, 0xE0AE, 0xE0AF]],
|
||||
['Powerline Extra Symbols', 0xE0B4, 0xE0BF],
|
||||
]);
|
||||
// Symbols for Legacy Computing
|
||||
|
||||
+33
-6
@@ -93,11 +93,15 @@ export function writeUnicodeTable(term: Terminal, name: string, start: number, e
|
||||
term.write(' ');
|
||||
if (codePoint >= start && codePoint <= end) {
|
||||
const charColorIndex = codePointColorMap.get(codePoint);
|
||||
const isReserved = reservedSet.has(codePoint);
|
||||
let char = String.fromCodePoint(codePoint);
|
||||
if (charColorIndex !== undefined) {
|
||||
term.write(color(String.fromCodePoint(codePoint), charColorIndex));
|
||||
} else {
|
||||
term.write(String.fromCodePoint(codePoint));
|
||||
char = color(char, charColorIndex);
|
||||
}
|
||||
if (isReserved) {
|
||||
char = faint(char);
|
||||
}
|
||||
term.write(char);
|
||||
} else {
|
||||
term.write(' ');
|
||||
}
|
||||
@@ -197,16 +201,39 @@ export function writeUnicodeTable(term: Terminal, name: string, start: number, e
|
||||
if (codePoint >= start && codePoint <= effectiveEnd) {
|
||||
// Color the character if it's part of a definition range
|
||||
const charColorIndex = codePointColorMap.get(codePoint);
|
||||
const isReserved = reservedSet.has(codePoint);
|
||||
let char = String.fromCodePoint(codePoint);
|
||||
if (charColorIndex !== undefined) {
|
||||
term.write(color(String.fromCodePoint(codePoint), charColorIndex));
|
||||
} else {
|
||||
term.write(String.fromCodePoint(codePoint));
|
||||
char = color(char, charColorIndex);
|
||||
}
|
||||
if (isReserved) {
|
||||
char = faint(char);
|
||||
}
|
||||
term.write(char);
|
||||
} else {
|
||||
term.write(' ');
|
||||
}
|
||||
}
|
||||
|
||||
term.write('\n\r');
|
||||
|
||||
// Render reserved labels that appear after the first label (below the row)
|
||||
// Only show one label pointing to the first reserved item when there are multiple
|
||||
const lateReserved = rowLabels.length > 0
|
||||
? rowReserved.filter(r => r.col >= rowLabels[0].col)
|
||||
: rowReserved;
|
||||
if (lateReserved.length > 0) {
|
||||
const prefix = ' '.repeat(8);
|
||||
const firstReserved = lateReserved[0];
|
||||
const colPos = firstReserved.col * 2 + 1;
|
||||
const padding = ' '.repeat(colPos);
|
||||
let line: string;
|
||||
if (firstReserved.colorIndex >= 0) {
|
||||
line = padding + color('└<reserved>', firstReserved.colorIndex);
|
||||
} else {
|
||||
line = padding + '└<reserved>';
|
||||
}
|
||||
term.write(faint(prefix + line) + '\n\r');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user