| author | wenzelm |
| Sun, 02 Nov 2025 23:56:01 +0100 | |
| changeset 83465 | 4023a9c7070f |
| parent 83461 | fca677fc8a35 |
| child 83466 | 4e3eae17917f |
| permissions | -rw-r--r-- |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
1 |
(function () {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
2 |
const vscode = acquireVsCodeApi(); |
| 83461 | 3 |
let all_symbols = {};
|
4 |
let all_abbrevs_from_thy = []; |
|
5 |
let control_sup = ""; |
|
6 |
let control_sub = ""; |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
7 |
|
| 83461 | 8 |
function decode_html_entity(code) {
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
9 |
try {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
10 |
return String.fromCodePoint(code); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
11 |
} catch (error) {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
12 |
return "?"; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
13 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
14 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
15 |
|
| 83461 | 16 |
function format_group_name(group) {
|
17 |
const group_name_map = {
|
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
18 |
"Z_Notation": "Z Notation", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
19 |
"Control_Block": "Control Block", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
20 |
"Arrow": "Arrow", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
21 |
"Control": "Control", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
22 |
"Digit": "Digit", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
23 |
"Document": "Document", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
24 |
"Greek": "Greek", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
25 |
"Icon": "Icon", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
26 |
"Letter": "Letter", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
27 |
"Logic": "Logic", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
28 |
"Operator": "Operator", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
29 |
"Punctuation": "Punctuation", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
30 |
"Relation": "Relation", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
31 |
"Unsorted": "Unsorted", |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
32 |
"Search": "Search" |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
33 |
}; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
34 |
|
| 83461 | 35 |
return group_name_map[group] || group.replace(/_/g, " ").replace(/\b\w/g, c => c.toUpperCase()); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
36 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
37 |
|
| 83461 | 38 |
function create_search_field() {
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
39 |
const search_container = document.createElement("div");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
40 |
search_container.classList.add("search-container");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
41 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
42 |
const search_input = document.createElement("input");
|
| 83461 | 43 |
search_input.type = "text"; |
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
44 |
search_input.classList.add("search-input");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
45 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
46 |
const search_results = document.createElement("div");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
47 |
search_results.classList.add("search-results");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
48 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
49 |
search_input.addEventListener("input", () => filterSymbols(search_input.value, search_results));
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
50 |
|
| 83461 | 51 |
search_container.appendChild(search_input); |
52 |
search_container.appendChild(search_results); |
|
53 |
return { search_container, search_results };
|
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
54 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
55 |
|
| 83461 | 56 |
function filterSymbols(query, results_container) {
|
57 |
const normalized_query = query.toLowerCase().trim(); |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
58 |
results_container.innerHTML = ""; |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
59 |
|
| 83461 | 60 |
if (normalized_query === "") return; |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
61 |
|
| 83461 | 62 |
const matching_symbols = []; |
63 |
Object.values(all_symbols).forEach(symbolList => {
|
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
64 |
symbolList.forEach(symbol => {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
65 |
if (!symbol.code) return; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
66 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
67 |
if ( |
| 83461 | 68 |
symbol.symbol.toLowerCase().includes(normalized_query) || |
69 |
(symbol.abbrevs && symbol.abbrevs.some(abbr => abbr.toLowerCase().includes(normalized_query))) |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
70 |
) {
|
| 83461 | 71 |
matching_symbols.push(symbol); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
72 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
73 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
74 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
75 |
|
| 83461 | 76 |
const search_limit = 50; |
77 |
if (matching_symbols.length === 0) {
|
|
78 |
results_container.innerHTML = "<p>No symbols found</p>"; |
|
| 83396 | 79 |
} |
80 |
else {
|
|
| 83461 | 81 |
matching_symbols.slice(0, search_limit).forEach(symbol => {
|
82 |
const decoded_symbol = decode_html_entity(symbol.code); |
|
83 |
if (!decoded_symbol) return; |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
84 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
85 |
const button = document.createElement("div");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
86 |
button.classList.add("symbol-button");
|
| 83461 | 87 |
button.textContent = decoded_symbol; |
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
88 |
button.setAttribute("data-tooltip", `${symbol.symbol}\nAbbreviations: ${symbol.abbrevs.join(", ")}`);
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
89 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
90 |
button.addEventListener("click", () => {
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
91 |
vscode.postMessage({ command: "insertSymbol", symbol: decoded_symbol });
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
92 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
93 |
|
| 83461 | 94 |
results_container.appendChild(button); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
95 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
96 |
|
| 83461 | 97 |
if (matching_symbols.length > search_limit) {
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
98 |
const more_results = document.createElement("div");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
99 |
more_results.classList.add("more-results");
|
| 83461 | 100 |
more_results.textContent = `(${matching_symbols.length - search_limit} more...)`;
|
101 |
results_container.appendChild(more_results); |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
102 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
103 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
104 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
105 |
|
| 83461 | 106 |
function render_with_effects(symbol) {
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
107 |
if (!symbol) return ""; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
108 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
109 |
let result = ""; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
110 |
let i = 0; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
111 |
while (i < symbol.length) {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
112 |
const char = symbol[i]; |
|
83369
8696fb442049
avoid literal Unicode symbols, which are in danger of being recoded;
wenzelm
parents:
83368
diff
changeset
|
113 |
if (char === "\u21e7") {
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
114 |
i++; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
115 |
if (i < symbol.length) result += "<sup>" + symbol[i] + "</sup>"; |
| 83396 | 116 |
} |
117 |
else if (char === "\u21e9") {
|
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
118 |
i++; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
119 |
if (i < symbol.length) result += "<sub>" + symbol[i] + "</sub>"; |
| 83396 | 120 |
} |
121 |
else {
|
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
122 |
result += char; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
123 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
124 |
i++; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
125 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
126 |
return result; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
127 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
128 |
|
| 83461 | 129 |
function convert_symbol_with_effects(symbol) {
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
130 |
let result = ""; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
131 |
let i = 0; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
132 |
while (i < symbol.length) {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
133 |
const char = symbol[i]; |
|
83369
8696fb442049
avoid literal Unicode symbols, which are in danger of being recoded;
wenzelm
parents:
83368
diff
changeset
|
134 |
if (char === "\u21e7") {
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
135 |
i++; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
136 |
if (i < symbol.length) {
|
| 83461 | 137 |
if (control_sup) result += control_sup + symbol[i]; |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
138 |
else result += symbol[i]; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
139 |
} |
| 83396 | 140 |
} |
141 |
else if (char === "\u21e9") {
|
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
142 |
i++; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
143 |
if (i < symbol.length) {
|
| 83461 | 144 |
if (control_sub) result += control_sub + symbol[i]; |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
145 |
else result += symbol[i]; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
146 |
} |
| 83396 | 147 |
} |
148 |
else {
|
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
149 |
result += char; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
150 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
151 |
i++; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
152 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
153 |
return result; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
154 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
155 |
|
| 83461 | 156 |
function sanitize_symbol_for_insert(symbol) {
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
157 |
return symbol.replace(/\u0007/g, ""); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
158 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
159 |
|
| 83461 | 160 |
function extract_control_symbols(symbol_groups) {
|
161 |
if (!symbol_groups || !symbol_groups["control"]) return; |
|
162 |
symbol_groups["control"].forEach(symbol => {
|
|
163 |
if (symbol.name === "sup") control_sup = String.fromCodePoint(symbol.code); |
|
164 |
if (symbol.name === "sub") control_sub = String.fromCodePoint(symbol.code); |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
165 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
166 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
167 |
|
| 83461 | 168 |
function render_symbols(grouped_symbols, abbrevs_from_thy) {
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
169 |
const container = document.getElementById("symbols-container");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
170 |
container.innerHTML = ""; |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
171 |
|
| 83461 | 172 |
all_symbols = grouped_symbols; |
173 |
all_abbrevs_from_thy = abbrevs_from_thy || []; |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
174 |
|
| 83461 | 175 |
extract_control_symbols(grouped_symbols); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
176 |
|
| 83461 | 177 |
vscode.setState({ symbols: grouped_symbols, abbrevs_from_Thy: all_abbrevs_from_thy });
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
178 |
|
| 83461 | 179 |
if (!grouped_symbols || Object.keys(grouped_symbols).length === 0) {
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
180 |
container.innerHTML = "<p>No symbols available.</p>"; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
181 |
return; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
182 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
183 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
184 |
const tabs = document.createElement("div");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
185 |
tabs.classList.add("tabs");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
186 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
187 |
const content = document.createElement("div");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
188 |
content.classList.add("content");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
189 |
|
| 83461 | 190 |
Object.keys(grouped_symbols).forEach((group, index) => {
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
191 |
const tab = document.createElement("button");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
192 |
tab.classList.add("tab");
|
| 83461 | 193 |
tab.textContent = format_group_name(group); |
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
194 |
if (index === 0) tab.classList.add("active");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
195 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
196 |
tab.addEventListener("click", () => {
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
197 |
document.querySelectorAll(".tab").forEach(t => t.classList.remove("active"));
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
198 |
tab.classList.add("active");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
199 |
document.querySelectorAll(".tab-content").forEach(c => c.classList.add("hidden"));
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
200 |
document.getElementById(`content-${group}`).classList.remove("hidden");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
201 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
202 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
203 |
tabs.appendChild(tab); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
204 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
205 |
const group_content = document.createElement("div");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
206 |
group_content.classList.add("tab-content");
|
| 83461 | 207 |
group_content.id = `content-${group}`;
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
208 |
if (index !== 0) group_content.classList.add("hidden");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
209 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
210 |
if (group === "control") {
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
211 |
const reset_button = document.createElement("button");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
212 |
reset_button.classList.add("reset-button");
|
| 83461 | 213 |
reset_button.textContent = "Reset"; |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
214 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
215 |
reset_button.addEventListener("click", () => {
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
216 |
vscode.postMessage({ command: "resetControlSymbols" });
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
217 |
}); |
| 83461 | 218 |
group_content.appendChild(reset_button); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
219 |
|
| 83461 | 220 |
const control_buttons = ["sup", "sub", "bold"]; |
221 |
control_buttons.forEach(action => {
|
|
222 |
const control_symbol = grouped_symbols[group].find(s => s.name === action); |
|
223 |
if (control_symbol) {
|
|
224 |
const decoded_symbol = decode_html_entity(control_symbol.code); |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
225 |
const button = document.createElement("button");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
226 |
button.classList.add("control-button");
|
| 83461 | 227 |
button.textContent = decoded_symbol; |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
228 |
button.title = action.charAt(0).toUpperCase() + action.slice(1); |
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
229 |
button.addEventListener("click", () => {
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
230 |
vscode.postMessage({ command: "applyControl", action: action });
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
231 |
}); |
| 83461 | 232 |
group_content.appendChild(button); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
233 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
234 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
235 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
236 |
|
| 83461 | 237 |
grouped_symbols[group].forEach(symbol => {
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
238 |
if (!symbol.code) return; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
239 |
if (["sup", "sub", "bold"].includes(symbol.name)) return; |
| 83461 | 240 |
const decoded_symbol = decode_html_entity(symbol.code); |
241 |
if (!decoded_symbol) return; |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
242 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
243 |
const button = document.createElement("div");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
244 |
if (group === "arrow") {
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
245 |
button.classList.add("arrow-button"); // special class for arrows
|
| 83396 | 246 |
} |
247 |
else {
|
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
248 |
button.classList.add("symbol-button");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
249 |
} |
| 83461 | 250 |
button.textContent = decoded_symbol; |
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
251 |
button.setAttribute("data-tooltip", `${symbol.symbol}\nAbbreviations: ${symbol.abbrevs.join(", ")}`);
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
252 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
253 |
button.addEventListener("click", () => {
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
254 |
vscode.postMessage({ command: "insertSymbol", symbol: decoded_symbol });
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
255 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
256 |
|
| 83461 | 257 |
group_content.appendChild(button); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
258 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
259 |
|
| 83461 | 260 |
content.appendChild(group_content); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
261 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
262 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
263 |
const abbrevs_tab = document.createElement("button");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
264 |
abbrevs_tab.classList.add("tab");
|
| 83461 | 265 |
abbrevs_tab.textContent = "Abbrevs"; |
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
266 |
abbrevs_tab.addEventListener("click", () => {
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
267 |
document.querySelectorAll(".tab").forEach(t => t.classList.remove("active"));
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
268 |
abbrevs_tab.classList.add("active");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
269 |
document.querySelectorAll(".tab-content").forEach(c => c.classList.add("hidden"));
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
270 |
document.getElementById("abbrevs-tab-content").classList.remove("hidden");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
271 |
}); |
| 83461 | 272 |
tabs.appendChild(abbrevs_tab); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
273 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
274 |
const abbrevs_content = document.createElement("div");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
275 |
abbrevs_content.classList.add("tab-content", "hidden");
|
| 83461 | 276 |
abbrevs_content.id = "abbrevs-tab-content"; |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
277 |
|
| 83461 | 278 |
all_abbrevs_from_thy |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
279 |
.filter(([abbr, symbol]) => symbol && symbol.trim() !== "" && !/^[a-zA-Z0-9 _-]+$/.test(symbol)) |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
280 |
.forEach(([abbr, symbol]) => {
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
281 |
const btn = document.createElement("div");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
282 |
btn.classList.add("abbrevs-button");
|
| 83461 | 283 |
btn.innerHTML = render_with_effects(symbol); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
284 |
btn.title = abbr; |
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
285 |
btn.addEventListener("click", () => {
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
286 |
vscode.postMessage({ command: "insertSymbol", symbol: convert_symbol_with_effects(sanitize_symbol_for_insert(symbol)) });
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
287 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
288 |
|
| 83461 | 289 |
abbrevs_content.appendChild(btn); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
290 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
291 |
|
| 83461 | 292 |
content.appendChild(abbrevs_content); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
293 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
294 |
const search_tab = document.createElement("button");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
295 |
search_tab.classList.add("tab");
|
| 83461 | 296 |
search_tab.textContent = "Search"; |
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
297 |
search_tab.addEventListener("click", () => {
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
298 |
document.querySelectorAll(".tab").forEach(t => t.classList.remove("active"));
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
299 |
search_tab.classList.add("active");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
300 |
document.querySelectorAll(".tab-content").forEach(c => c.classList.add("hidden"));
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
301 |
document.getElementById("search-tab-content").classList.remove("hidden");
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
302 |
}); |
| 83461 | 303 |
tabs.appendChild(search_tab); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
304 |
|
| 83461 | 305 |
const { search_container, search_results } = create_search_field();
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
306 |
const search_content = document.createElement("div");
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
307 |
search_content.classList.add("tab-content", "hidden");
|
| 83461 | 308 |
search_content.id = "search-tab-content"; |
309 |
search_content.appendChild(search_container); |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
310 |
|
| 83461 | 311 |
content.appendChild(search_content); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
312 |
container.appendChild(tabs); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
313 |
container.appendChild(content); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
314 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
315 |
const tooltip = document.createElement("div");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
316 |
tooltip.className = "tooltip"; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
317 |
document.body.appendChild(tooltip); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
318 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
319 |
document.querySelectorAll(".symbol-button, .arrow-button, .abbrevs-button").forEach(button => {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
320 |
button.addEventListener("mouseenter", (e) => {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
321 |
const rect = button.getBoundingClientRect(); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
322 |
const text = button.getAttribute("data-tooltip");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
323 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
324 |
if (text) {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
325 |
tooltip.textContent = text; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
326 |
tooltip.style.left = `${rect.left + window.scrollX}px`;
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
327 |
tooltip.style.top = `${rect.bottom + 6 + window.scrollY}px`;
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
328 |
tooltip.classList.add("visible");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
329 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
330 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
331 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
332 |
button.addEventListener("mouseleave", () => {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
333 |
tooltip.classList.remove("visible");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
334 |
tooltip.textContent = ""; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
335 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
336 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
337 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
338 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
339 |
|
|
83465
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
340 |
window.addEventListener("message", event => {
|
|
4023a9c7070f
tuned quotes: follow Isabelle majority style, instead of JS/TS;
wenzelm
parents:
83461
diff
changeset
|
341 |
if (event.data.command === "update" && event.data.symbols) {
|
| 83461 | 342 |
render_symbols(event.data.symbols, event.data.abbrevs_from_Thy); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
343 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
344 |
}); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
345 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
346 |
window.onload = function () {
|
| 83461 | 347 |
const state = vscode.getState(); |
348 |
if (state && state.symbols) {
|
|
349 |
render_symbols(state.symbols, state.abbrevs_from_Thy); |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
350 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
351 |
}; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
352 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
353 |
})(); |