forked from HaarigerHarald/VHDLFormatter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
597 lines (552 loc) · 30 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
<html>
<head>
<meta charset="UTF-8">
<title>VHDL Beautifier, Formatter Online</title>
<link rel="stylesheet" href="style.css" />
<link href="highlight.css" rel="stylesheet" />
<script src="highlight.js"></script>
<script>
function selectText(element) {
var doc = document,
text = element,
range, selection;
if (doc.body.createTextRange) { //ms
range = doc.body.createTextRange();
range.moveToElementText(text);
range.select();
} else if (window.getSelection) { //all others
selection = window.getSelection();
range = doc.createRange();
range.selectNodeContents(text);
selection.removeAllRanges();
selection.addRange(range);
}
}
</script>
</head>
<body>
<div class="content">
<div class="top-bar">
<div class="container">
<h2>VHDL Beautifier, Formatter</h2>
<ul>
<li>
<div class="tooltip emoji top-button" onclick="showInfo();">ℹ
<span class="tooltiptext">Beautify and format your VHDL code online</span>
</div>
<div id="info" class="modal">
<div class="modal-content">
<span id="close-info" class="close">×</span>
<p>Beautify and format your VHDL code online</p>
</div>
</div>
</li>
<li>
<div class="tooltip emoji top-button" onclick="showWarning();">⚠
<span class="tooltiptext">Please make a backup before you replace your code!</span>
</div>
<div id="warning" class="modal">
<div class="modal-content">
<span id="close-warning" class="close">×</span>
<p>Please make a backup before you replace your code!</p>
</div>
</div>
</li>
<li>
<div class="tooltip emoji top-button" onclick="showHappy();">😸
<span class="tooltiptext">Proper formatting makes code easier to read and understand.</span>
</div>
<div id="happy" class="modal">
<div class="modal-content">
<span id="close-happy" class="close">×</span>
<p>Proper formatting makes code easier to read and understand.</p>
</div>
</div>
</li>
<li>
<a class="top-button" href="https://github.com/g2384/VHDLFormatter/issues/new" target="_blank">Report
<span class="inline-emoji">🐞</span> bug</a>
</li>
<li>
<a class="top-button" href="https://github.com/g2384/VHDLFormatter">Source code</a>
</li>
</ul>
</div>
</div>
<textarea id="in" rows="10" wrap="off"></textarea>
<br>
<div class="setting-field">
<div class="checkbox">
<input type="checkbox" id="no_format" onclick="noFormat()">
<label for="no_format">Only highlight, don't format</label>
</div>
<form id="keyword_div">Keyword case:
<label>
<input type="radio" name="keywordcase" value="UpperCase" checked="checked">UPPERCASE</label> |
<label>
<input type="radio" name="keywordcase" value="LowerCase">lowercase</label> |
<label>
<input type="radio" name="keywordcase" value="DefaultCase">Default</label>
<div class="inline-note">
e.g. begin, case, when
</div>
</form>
<form id="typename_div">Type name case:
<label>
<input type="radio" name="typenamecase" value="UpperCase" checked="checked">UPPERCASE</label> |
<label>
<input type="radio" name="typenamecase" value="LowerCase">lowercase</label> |
<label>
<input type="radio" name="typenamecase" value="DefaultCase">Default</label>
<div class="inline-note">
e.g. boolean, natural, string
</div>
</form>
<div class="hide" id="settings_div">
<fieldset id="new_line_after_div" style="text-align: right;">
<legend>New line after</legend>
<form id="new_line_after_then">
<span class="code">THEN</span>
<label>
<input type="radio" name="new_line_after_thencase" value="NewLine" checked="checked">New Line</label>
<label>
<input type="radio" name="new_line_after_thencase" value="NoNewLine">No New Line</label>
<label>
<input type="radio" name="new_line_after_thencase" value="None">None</label>
</form>
<form id="new_line_after_semicolon">
<span class="code">semicolon ";"</span>
<label>
<input type="radio" name="new_line_after_semicoloncase" value="NewLine" checked="checked">New Line</label>
<label>
<input type="radio" name="new_line_after_semicoloncase" value="NoNewLine">No New Line</label>
<label>
<input type="radio" name="new_line_after_semicoloncase" value="None">None</label>
</form>
<form id="new_line_after_else">
<span class="code">ELSE</span>
<label>
<input type="radio" name="new_line_after_elsecase" value="NewLine">New Line</label>
<label>
<input type="radio" name="new_line_after_elsecase" value="NoNewLine">No New Line</label>
<label>
<input type="radio" name="new_line_after_elsecase" value="None" checked="checked">None</label>
</form>
<form id="new_line_after_port">
<span class="code">PORT | PORT MAP</span>
<label>
<input type="radio" name="new_line_after_portcase" value="NewLine">New Line</label>
<label>
<input type="radio" name="new_line_after_portcase" value="NoNewLine">No New Line</label>
<label>
<input type="radio" name="new_line_after_portcase" value="None" checked="checked">None</label>
</form>
<form id="new_line_after_generic">
<span class="code">GENERIC</span>
<label>
<input type="radio" name="new_line_after_genericcase" value="NewLine">New Line</label>
<label>
<input type="radio" name="new_line_after_genericcase" value="NoNewLine">No New Line</label>
<label>
<input type="radio" name="new_line_after_genericcase" value="None" checked="checked">None</label>
</form>
</fieldset>
<div class="checkbox inline" id="remove_comments_div">
<input type="checkbox" id="remove_comments">
<label for="remove_comments">Remove commments</label> |
</div>
<div class="checkbox inline" id="remove_lines_div">
<input type="checkbox" id="remove_lines">
<label for="remove_lines">Remove blank lines</label> |
</div>
<div class="checkbox inline" id="remove_report_div">
<input type="checkbox" id="remove_report">
<label for="remove_report">Remove REPORT</label>
</div>
<br>
<div class="checkbox" id="check_alias_div">
<input type="checkbox" id="check_alias">
<label for="check_alias">Check ALIAS (all long names will be replaced by ALIAS names)</label>
</div>
<fieldset id="align_settings_div">
<legend>Sign Alignment</legend>
<div id="sign_align_in_div">
Align signs in
<div class="checkbox inline" id="sign_align_port_div">
<input type="checkbox" id="sign_align_port" onclick="alignAllSigns(false);">
<label for="sign_align_port" class="code">PORT()</label>
</div>
<div class="checkbox inline" id="sign_align_generic_div">
<input type="checkbox" id="sign_align_generic" onclick="alignAllSigns(false);">
<label for="sign_align_generic" class="code">GENERIC()</label></div>
<div class="checkbox inline" id="sign_align_procedure_div">
<input type="checkbox" id="sign_align_procedure" onclick="alignAllSigns(false);">
<label for="sign_align_procedure" class="code">PROCEDURE()</label>
</div>
<div class="checkbox inline" id="sign_align_function_div">
<input type="checkbox" id="sign_align_function" onclick="alignAllSigns(false);">
<label for="sign_align_function" class="code">FUNCTION()</label>
</div>
</div>
<div class="checkbox inline" id="sign_align_all_div">
<input type="checkbox" id="sign_align_all" onclick="alignAllSigns(true);">
<label for="sign_align_all">Align signs in all places</label>
</div>
<form class="inline" id="sign_align_mode_div">
<span> | Mode: </span>
<label>
<input type="radio" name="sign_align_modecase" value="local">Local</label>
<label>
<input type="radio" name="sign_align_modecase" value="global">Global</label>
</form>
<div>
<div class="checkbox inline" id="align_comments_div">
<input type="checkbox" id="align_comments">
<label for="align_comments">Align comments</label>
</div>
</div>
</fieldset>
<div id="customise_indentation_div">
<div class="checkbox inline" id="use_space_div">
<input type="checkbox" id="use_space">
<label for="use_space">Customise Indentation: </label>
</div>(tab is \t)
<input type="text" id="customise_indentation" size="8" onKeyUp="counterDecode('customise_indentation', 'indent_s')" value=" " /> (
<span id="indent_s">four blankspaces</span>)
</div>
<div id="cust_eol_div">
End of line:
<input type="text" id="cust_eol" size="8" onKeyUp="counterDecode('cust_eol', 'eol_s')" value="\r\n" /> (
<span id="eol_s">one \r & one \n</span>)
</div>
<div id="customise_extraEOL_div">
<div class="checkbox inline" id="add_extraEOL_div">
<input type="checkbox" id="add_extraEOL" checked=true>
<label for="add_extraEOL">Add a new line at the end of file</label>
</div>
</div>
<div class="checkbox" id="compress_div">
<input type="checkbox" id="compress">
<label for="compress">! EVIL - compress VHDL (\r\n, comments will be removed)</label>
</div>
<div class="checkbox" id="mix_letter_div">
<input type="checkbox" id="mix_letter">
<label for="mix_letter">! EVIL - unreadable (mix upper/lower-case letters)</label>
</div>
</div>
</div>
<div>
<a id="settings_control" onclick="showHideSettings();">Show More Settings ▼</a>
<a onclick="outputSetting()">Output Settings</a>
</div>
<input type="button" class="btn" onclick="f()" value="Start" />
<span class="show">
<input type="button" class="btn " id="selectAll" value="Select All" onclick="selectText(document.getElementById('vhdl'))" />
<div class="checkbox inline">
<input type="checkbox" onclick="wordWrap()" id="word_wrap">
<label for="word_wrap">Word wrap</label>
</div>
</span>
<br>
<pre id="result"><code class="vhdl" id="vhdl">
<font style="background-color:#9D9D9D; color:#fff"> output sample </font>
<span class="hljs-keyword">LIBRARY</span> IEEE; <span class="hljs-comment">-- declare the library</span>
<span class="hljs-keyword">USE</span> IEEE.std_logic_1164.<span class="hljs-keyword">ALL</span>;
<span class="hljs-keyword">USE</span> IEEE.std_logic_arith.<span class="hljs-keyword">ALL</span>;
<font style="background-color:#9D9D9D; color:#fff"> (All reserved words are in capital) </font>
<font style="background-color:#9D9D9D; color:#fff"> (All indents are in the right place) </font>
<span class="hljs-comment">---------------------------------------------------------------</span>
<span class="hljs-keyword">ENTITY</span> example <span class="hljs-keyword">IS</span>
<span class="hljs-keyword">PORT</span> (
rst : <span class="hljs-keyword">IN</span> <span class="hljs-typename">std_logic</span>;
clk : <span class="hljs-keyword">IN</span> <span class="hljs-typename">std_logic</span>;
example_of_long_words : <span class="hljs-keyword">OUT</span> <span class="hljs-typename">std_logic_vector</span>(<span class="hljs-number">3</span> <span class="hljs-keyword">DOWNTO</span> <span class="hljs-number">0</span>)
<font style="background-color:#9D9D9D; color:#fff"> (<strong>Align signs in PORT()</strong> aligns these colons) </font>
);
<span class="hljs-keyword">END</span> example;
<span class="hljs-keyword">ARCHITECTURE</span> EXA <span class="hljs-keyword">OF</span> example <span class="hljs-keyword">IS</span>
<span class="hljs-keyword">ALIAS</span> slv <span class="hljs-keyword">IS</span> <span class="hljs-typename">std_logic_vector</span>;
<span class="hljs-keyword">SUBTYPE</span> bit4 <span class="hljs-keyword">IS</span> slv(<span class="hljs-number">3</span> <span class="hljs-keyword">DOWNTO</span> <span class="hljs-number">0</span>); <font style="background-color:#9D9D9D; color:#fff"> (<strong>Check ALIAS</strong> replaces all "<strong>std_logic_vector</strong>" with "<strong>slv</strong>") </font>
<span class="hljs-keyword">BEGIN</span>
<del><span class="hljs-keyword">REPORT</span> <span class="hljs-string">"Hello World"</span></del>; <font style="background-color:#9D9D9D; color:#fff"> (Remove REPORT) </font>
stages : <span class="hljs-keyword">PROCESS</span> (rst, clk)
<span class="hljs-keyword">BEGIN</span>
<span class="hljs-keyword">IF</span> (rst = <span class="hljs-literal">'0'</span>) <span class="hljs-keyword">THEN</span>
<span class="hljs-keyword">CASE</span> bit4 <span class="hljs-keyword">IS</span>
<span class="hljs-keyword">WHEN</span> <span class="hljs-string">"0000"</span> => bit4 <= <span class="hljs-string">"0001"</span>;
<span class="hljs-keyword">WHEN</span> <span class="hljs-string">"0001"</span> => bit4 <= <span class="hljs-string">"0100"</span>;
<span class="hljs-keyword">WHEN</span> <span class="hljs-string">"0010"</span> => bit4 <= <span class="hljs-string">"0010"</span>;
<span class="hljs-keyword">WHEN</span> <span class="hljs-string">"0100"</span> => bit4 <= <span class="hljs-string">"0000"</span>;
<span class="hljs-keyword">WHEN</span> <span class="hljs-keyword">OTHERS</span> =>
<del><span class="hljs-keyword">REPORT</span> <span class="hljs-string">"Are there any more cases?"</span></del>; <font style="background-color:#9D9D9D; color:#fff"> (Remove REPORT) </font>
<span class="hljs-keyword">END</span> <span class="hljs-keyword">CASE</span>;
<span class="hljs-keyword">ELSIF</span> (clk<span class="hljs-attribute">'event</span> <span class="hljs-keyword">AND</span> clk = <span class="hljs-literal">'1'</span>) <span class="hljs-keyword">THEN</span>
<span class="hljs-keyword">IF</span> (bit4 = '<span class="hljs-number">0111</span>') <span class="hljs-keyword">THEN</span>
bit4 <= <span class="hljs-string">"0000"</span>;
<span class="hljs-keyword">ELSE</span>
bit4 <= <span class="hljs-string">"1111"</span>;
<span class="hljs-keyword">END</span> <span class="hljs-keyword">IF</span>;
<del><span class="hljs-comment">-- Sample comments 1;</span> </del>
<del> <span class="hljs-comment">-- Sample comments 2;</span></del> <font style="background-color:#9D9D9D; color:#fff"> (Remove comments) </font>
<span class="hljs-keyword">END</span> <span class="hljs-keyword">IF</span>;
<span class="hljs-keyword">END</span> <span class="hljs-keyword">PROCESS</span>;
<span class="hljs-keyword">END</span> EXA;</code></pre>
</div>
<script>
var exports = {};
</script>
<script src="VHDLFormatter.js"></script>
<script src="descriptiveCounter.js"></script>
<script src="main.js"></script>
<script>
const localStorageSettingKey = "settings";
const localStorageNoFormatKey = "noFormat";
var areaIn = document.getElementById("in");
areaIn.placeholder = "library IEEE;\nuse IEEE.std_logic_1164.all;\nuse IEEE.std_logic_unsigned.all;\n...";
function showHideSettings() {
var settingsDiv = document.getElementById("settings_div");
var control = document.getElementById("settings_control");
if (settingsDiv.className.indexOf("hide") >= 0) {
settingsDiv.className = settingsDiv.className.replace(/\s*hide/, "");
control.innerHTML = "Show Less ▲";
}
else {
settingsDiv.className += "hide";
control.innerHTML = "Show More Settings ▼";
}
}
function onLoad() {
let global_endOfLine = navigator.platform === 'Win32' ? '\\r\\n' : '\\n';
document.getElementById("cust_eol").value = global_endOfLine;
var setting = loadSetting();
if (setting == null) {
return;
}
var beautifierSettings = setting.setting;
document.getElementById("remove_comments").checked = beautifierSettings.RemoveComments;
document.getElementById("remove_lines").checked = setting.removeLines;
document.getElementById("remove_report").checked = beautifierSettings.RemoveAsserts;
document.getElementById("check_alias").checked = beautifierSettings.CheckAlias;
var alignSettings = beautifierSettings.SignAlignSettings;
if (alignSettings != null) {
var signAlignKeywords = alignSettings.keyWords;
if (signAlignKeywords != null && signAlignKeywords.length > 0) {
document.getElementById("sign_align_port").checked = signAlignKeywords.indexOf("PORT") >= 0;
document.getElementById("sign_align_function").checked = signAlignKeywords.indexOf("FUNCTION") >= 0;
document.getElementById("sign_align_procedure").checked = signAlignKeywords.indexOf("PROCEDURE") >= 0;
document.getElementById("sign_align_generic").checked = signAlignKeywords.indexOf("GENERIC") >= 0;
}
document.getElementById("sign_align_all").checked = alignSettings.isAll;
document.getElementById("sign_align_mode_div").elements.namedItem("sign_align_modecase").value = alignSettings.mode;
document.getElementById("align_comments").checked = alignSettings.alignComments;
}
var newLineSettings = beautifierSettings.NewLineSettings;
var newLineAfter = newLineSettings.newLineAfter;
var noNewLineAfter = newLineSettings.noNewLineAfter;
document.getElementById("new_line_after_port").elements.namedItem("new_line_after_portcase").value = decodeNewLineSetting(newLineAfter, noNewLineAfter, "port");
document.getElementById("new_line_after_then").elements.namedItem("new_line_after_thencase").value = decodeNewLineSetting(newLineAfter, noNewLineAfter, "then");
document.getElementById("new_line_after_semicolon").elements.namedItem("new_line_after_semicoloncase").value = decodeNewLineSetting(newLineAfter, noNewLineAfter, ";");
document.getElementById("new_line_after_else").elements.namedItem("new_line_after_elsecase").value = decodeNewLineSetting(newLineAfter, noNewLineAfter, "else");
document.getElementById("new_line_after_generic").elements.namedItem("new_line_after_genericcase").value = decodeNewLineSetting(newLineAfter, noNewLineAfter, "generic");
document.getElementById("compress").checked = setting.compress;
var indentation = beautifierSettings.Indentation;
document.getElementById("use_space").checked = indentation != "\t";
document.getElementById("add_extraEOL").checked = beautifierSettings.AddNewLine;
document.getElementById("customise_indentation").value = indentation;
document.getElementById("keyword_div").elements.namedItem("keywordcase").value = beautifierSettings.KeywordCase;
document.getElementById("typename_div").elements.namedItem("typenamecase").value = beautifierSettings.TypeNameCase;
document.getElementById("mix_letter").checked = setting.mixLetter;
var eof = beautifierSettings.EndOfLine
eof = eof.replace(/\r/g, "\\r");
eof = eof.replace(/\n/g, "\\n");
eof = eof.replace(/\t/g, "\\t");
document.getElementById("cust_eol").value = eof;
var noFormatBool = loadNoFormatSetting();
if (noFormatBool) {
document.getElementById("no_format").checked = true;
noFormat();
}
counterDecode('customise_indentation', 'indent_s');
counterDecode('cust_eol', 'eol_s');
}
function decodeNewLineSetting(hasNewLine, noNewLine, str) {
if (hasNewLine.indexOf(str) >= 0) {
return "NewLine";
}
if (noNewLine.indexOf(str) >= 0) {
return "NoNewLine";
}
return "None";
}
onLoad();
function f() {
var input = document.getElementById("in").value;
var no_format = document.getElementById("no_format").checked;
saveNoFormatSetting(no_format);
if (no_format) {
document.getElementById("vhdl").innerHTML = input;
document.querySelector(".show").style.display = "inline-block";
hljs.highlightBlock(document.getElementById("vhdl"));
return;
}
var remove_lines = document.getElementById("remove_lines").checked;
var mix_letter = document.getElementById("mix_letter").checked;
[beautifierSettings, compress] = CreateSettings();
vhdlSettings = new VhdlSettings(beautifierSettings, remove_lines, compress, mix_letter);
saveSetting(vhdlSettings);
input = beautify(input, beautifierSettings);
if (remove_lines) {
input = input.replace(/(\r\n)*[ \t]*\r\n/g, '\r\n');
}
if (compress) {
input = Compress(input);
}
if (mix_letter) {
input = MixLetters(input);
}
document.getElementById("vhdl").innerHTML = input;
document.querySelector(".show").style.display = "inline-block";
hljs.highlightBlock(document.getElementById("vhdl"));
}
function CreateSettings() {
var remove_comments = document.getElementById("remove_comments").checked;
var remove_report = document.getElementById("remove_report").checked;
var check_alias = document.getElementById("check_alias").checked;
var sign_align_port = document.getElementById("sign_align_port").checked;
var sign_align_function = document.getElementById("sign_align_function").checked;
var sign_align_procedure = document.getElementById("sign_align_procedure").checked;
var sign_align_generic = document.getElementById("sign_align_generic").checked;
var sign_align_all = document.getElementById("sign_align_all").checked;
var align_comments = document.getElementById("align_comments").checked;
var sign_align_mode = document.getElementById("sign_align_mode_div").elements.namedItem("sign_align_modecase").value;
var new_line_after_port = document.getElementById("new_line_after_port").elements.namedItem("new_line_after_portcase").value;
var new_line_after_then = document.getElementById("new_line_after_then").elements.namedItem("new_line_after_thencase").value;
var new_line_after_semicolon = document.getElementById("new_line_after_semicolon").elements.namedItem("new_line_after_semicoloncase").value;
var new_line_after_else = document.getElementById("new_line_after_else").elements.namedItem("new_line_after_elsecase").value;
var new_line_after_generic = document.getElementById("new_line_after_generic").elements.namedItem("new_line_after_genericcase").value;
var use_space = document.getElementById("use_space").checked;
var compress = document.getElementById("compress").checked;
var cust_indent = document.getElementById("customise_indentation").value;
var addNewLine = document.getElementById("add_extraEOL").checked;
var keywordcase = document.getElementById("keyword_div").elements.namedItem("keywordcase").value;
var typenamecase = document.getElementById("typename_div").elements.namedItem("typenamecase").value;
var endOfLine = document.getElementById("cust_eol").value;
endOfLine = endOfLine.replace(/\\r/g, "\r");
endOfLine = endOfLine.replace(/\\n/g, "\n");
if (compress) {
remove_comments = true;
}
indentation = "\t";
if (use_space) {
cust_indent = cust_indent.replace(/\\t/, " ");
indentation = cust_indent;
}
var newLineSettingsDict = {};
newLineSettingsDict["generic"] = new_line_after_generic;
newLineSettingsDict["generic map"] = new_line_after_generic;
newLineSettingsDict["port"] = new_line_after_port;
newLineSettingsDict["port map"] = new_line_after_port;
newLineSettingsDict[";"] = new_line_after_semicolon;
newLineSettingsDict["then"] = new_line_after_then;
newLineSettingsDict["else"] = new_line_after_else;
newLineSettings = ConstructNewLineSettings(newLineSettingsDict);
var signAlignKeywords = [];
if (sign_align_function) {
signAlignKeywords.push("FUNCTION");
signAlignKeywords.push("IMPURE FUNCTION");
}
if (sign_align_generic) {
signAlignKeywords.push("GENERIC");
}
if (sign_align_port) {
signAlignKeywords.push("PORT");
}
if (sign_align_procedure) {
signAlignKeywords.push("PROCEDURE");
}
sign_align = signAlignKeywords.length > 0;
let alignSettings = new signAlignSettings(sign_align, sign_align_all, sign_align_mode, signAlignKeywords, align_comments)
beautifierSettings = new BeautifierSettings(remove_comments, remove_report, check_alias,
alignSettings,
keywordcase,
typenamecase,
indentation,
newLineSettings,
endOfLine,
addNewLine);
return [beautifierSettings, compress];
}
function outputSetting() {
[beautifierSettings, compress] = CreateSettings();
var json = JSON.stringify(beautifierSettings, null, 4);
document.getElementById("vhdl").innerHTML = json;
}
function saveSetting(setting) {
var json = JSON.stringify(setting);
json = json.replace(/\r/g, "\\r");
json = json.replace(/\n/g, "\\n");
json = json.replace(/\t/g, "\\t");
localStorage.setItem(localStorageSettingKey, json);
}
function loadSetting() {
var json = localStorage.getItem(localStorageSettingKey);
if (json == null) {
return null;
}
return JSON.parse(json);
}
function saveNoFormatSetting(no_format) {
localStorage.setItem(localStorageNoFormatKey, no_format);
}
function loadNoFormatSetting() {
return JSON.parse(localStorage.getItem(localStorageNoFormatKey));
}
class VhdlSettings {
constructor(setting, removeLines, compress, mixLetter) {
this.setting = setting;
this.removeLines = removeLines;
this.compress = compress;
this.mixLetter = mixLetter;
}
}
var warning = document.getElementById('warning');
var info = document.getElementById('info');
var happy = document.getElementById('happy');
var closeInfo = document.getElementById("close-info");
var closeWarning = document.getElementById("close-warning");
var closeHappy = document.getElementById("close-happy");
function showWarning() {
warning.style.display = "block";
}
function showInfo() {
info.style.display = "block";
}
function showHappy() {
happy.style.display = "block";
}
closeInfo.onclick = function() {
hidePopups();
}
closeWarning.onclick = function() {
hidePopups();
}
closeHappy.onclick = function(){
hidePopups();
}
function hidePopups() {
warning.style.display = "none";
info.style.display = "none";
happy.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
var target = event.target;
if (target == warning
|| target == info
|| target == happy) {
hidePopups();
}
}
</script>
</body>
</html>