You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

620 lines
27 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. <html>
  2. <head>
  3. <title>VHDL Beautifier, Formatter Online</title>
  4. <style>
  5. body {
  6. margin: 0 auto;
  7. max-width: 960px;
  8. tab-size: 4;
  9. font-family: arial, sans-serif;
  10. }
  11. textarea {
  12. width: 100%;
  13. font-family: Consolas, Courier;
  14. }
  15. fieldset {
  16. width: fit-content;
  17. border: 1px solid #9a9a9a;
  18. margin: 25px 0 5px 0;
  19. padding-left: 0;
  20. }
  21. legend {
  22. padding: 2px 5px;
  23. background-color: #e0e0e0;
  24. border-radius: 2px;
  25. margin: -27px 0 0 -1px;
  26. position: absolute;
  27. }
  28. .subtitle {
  29. font-weight: normal;
  30. }
  31. .btn {
  32. margin: 10px 10px;
  33. padding: 5px 8px;
  34. font-size: 16px;
  35. line-height: 1.33;
  36. border-radius: 3px;
  37. color: #333;
  38. border-color: #ccc;
  39. cursor: pointer;
  40. text-align: center;
  41. white-space: nowrap;
  42. border: 1px solid rgb(194, 194, 194);
  43. background-color: #fff;
  44. }
  45. .btn:hover {
  46. background-color: #eee;
  47. }
  48. .show {
  49. display: none;
  50. }
  51. .wordwrap {
  52. white-space: pre-wrap;
  53. white-space: -moz-pre-wrap;
  54. white-space: -pre-wrap;
  55. white-space: -o-pre-wrap;
  56. word-wrap: break-word;
  57. }
  58. label {
  59. cursor: pointer;
  60. line-height: 1.5em;
  61. }
  62. label:hover {
  63. color: #555;
  64. text-decoration: underline;
  65. }
  66. form {
  67. margin-bottom: 0px;
  68. }
  69. form span {
  70. width: 170px;
  71. display: inline-block;
  72. text-align: right;
  73. }
  74. a {
  75. color: #4b9aff;
  76. text-decoration: none;
  77. background: #f0f8ff;
  78. padding: 2px 5px;
  79. border-radius: 3px;
  80. font-size: 0.8em;
  81. }
  82. a:hover {
  83. text-decoration: none;
  84. background: #d6e8ff;
  85. }
  86. p {
  87. line-height: 1em;
  88. margin: 0.5em 0em;
  89. }
  90. .code {
  91. font-family: 'Consolas', Courier, monospace;
  92. }
  93. .inline {
  94. display: inline-block;
  95. }
  96. .disabled {
  97. color: #ccc;
  98. cursor: default;
  99. }
  100. .disabled label:hover {
  101. color: #ccc;
  102. text-decoration: none;
  103. cursor: default;
  104. }
  105. .checkbox input[type="checkbox"] {
  106. opacity: 0;
  107. display: none;
  108. }
  109. .checkbox label {
  110. position: relative;
  111. display: inline-block;
  112. /*16px width of fake checkbox + 6px distance between fake checkbox and text*/
  113. padding-left: 22px;
  114. }
  115. .checkbox label::before,
  116. .checkbox label::after {
  117. position: absolute;
  118. content: "";
  119. /*Needed for the line-height to take effect*/
  120. display: inline-block;
  121. }
  122. /*Outer box of the fake checkbox*/
  123. .checkbox label::before {
  124. height: 16px;
  125. width: 16px;
  126. border: 1px solid #9A9A9A;
  127. left: 0px;
  128. /*(24px line-height - 16px height of fake checkbox) / 2 - 1px for the border to vertically center it.*/
  129. top: 3px;
  130. }
  131. /*Checkmark of the fake checkbox*/
  132. .checkbox label::after {
  133. height: 5px;
  134. width: 9px;
  135. border-left: 2px solid;
  136. border-bottom: 2px solid;
  137. transform: rotate(-45deg);
  138. left: 4px;
  139. top: 7px;
  140. color: #333;
  141. }
  142. /*Hide the checkmark by default*/
  143. .checkbox input[type="checkbox"]+label::after {
  144. content: none;
  145. }
  146. /*Unhide on the checked state*/
  147. .checkbox input[type="checkbox"]:checked+label::after {
  148. content: "";
  149. }
  150. /*Adding focus styles on the outer-box of the fake checkbox*/
  151. .checkbox input[type="checkbox"]:hover+label::after {
  152. border-color: #888;
  153. outline: #ccc;
  154. }
  155. .checkbox input[type="checkbox"]:hover+label::before {
  156. outline: #888;
  157. border-color: #888;
  158. background-color: #eee;
  159. }
  160. .checkbox input[type="checkbox"]:disabled+label::before {
  161. outline: #ccc;
  162. border-color: #ccc;
  163. background-color: #fff;
  164. color: #ccc;
  165. }
  166. .checkbox input[type="checkbox"]:disabled+label::after {
  167. color: #888;
  168. }
  169. .checkbox input[type="checkbox"]:focus+label::before {
  170. outline: #333 auto 5px;
  171. }
  172. </style>
  173. <link href="highlight.css" rel="stylesheet" />
  174. <script src="highlight.js"></script>
  175. <script>
  176. function selectText(element) {
  177. var doc = document,
  178. text = element,
  179. range, selection;
  180. if (doc.body.createTextRange) { //ms
  181. range = doc.body.createTextRange();
  182. range.moveToElementText(text);
  183. range.select();
  184. } else if (window.getSelection) { //all others
  185. selection = window.getSelection();
  186. range = doc.createRange();
  187. range.selectNodeContents(text);
  188. selection.removeAllRanges();
  189. selection.addRange(range);
  190. }
  191. }
  192. </script>
  193. </head>
  194. <body>
  195. <h2>VHDL Beautifier, Formatter</h2>
  196. <h4 class="subtitle">Beautify and format your VHDL code online</h4>
  197. <p>Proper formatting makes code easier to read and understand.</p>
  198. <p>Please make a backup before you replace your code!</p>
  199. <p style="color:#888">
  200. <a href="https://github.com/g2384/VHDLFormatter#release-notes">Release notes</a>
  201. <a href="https://github.com/g2384/VHDLFormatter/issues/new" target="_blank">Report <span>&#x1f41e;</span> bug</a>
  202. <a href="https://github.com/g2384/VHDLFormatter">Source code</a>
  203. </p>
  204. <textarea id="in" rows="10" wrap="off"></textarea>
  205. <br>
  206. <div class="checkbox">
  207. <input type="checkbox" id="no_format" onclick="noFormat()">
  208. <label for="no_format">Only highlight, don't format</label>
  209. </div>
  210. <form id="keyword">Keyword Case:
  211. <label>
  212. <input type="radio" name="keywordcase" value="UpperCase" checked="checked">UPPERCASE</label> |
  213. <label>
  214. <input type="radio" name="keywordcase" value="LowerCase">lowercase</label> |
  215. <label>
  216. <input type="radio" name="keywordcase" value="DefaultCase">Default</label>
  217. </form>
  218. <fieldset id="new_line_after_div">
  219. <legend>New line after</legend>
  220. <form id="new_line_after_then">
  221. <span class="code">THEN</span>
  222. <label>
  223. <input type="radio" name="new_line_after_thencase" value="NewLine" checked="checked">New Line</label>
  224. <label>
  225. <input type="radio" name="new_line_after_thencase" value="NoNewLine">No New Line</label>
  226. <label>
  227. <input type="radio" name="new_line_after_thencase" value="None">None</label>
  228. </form>
  229. <form id="new_line_after_semicolon">
  230. <span class="code">semicolon ";"</span>
  231. <label>
  232. <input type="radio" name="new_line_after_semicoloncase" value="NewLine" checked="checked">New Line</label>
  233. <label>
  234. <input type="radio" name="new_line_after_semicoloncase" value="NoNewLine">No New Line</label>
  235. <label>
  236. <input type="radio" name="new_line_after_semicoloncase" value="None">None</label>
  237. </form>
  238. <form id="new_line_after_else">
  239. <span class="code">ELSE</span>
  240. <label>
  241. <input type="radio" name="new_line_after_elsecase" value="NewLine">New Line</label>
  242. <label>
  243. <input type="radio" name="new_line_after_elsecase" value="NoNewLine">No New Line</label>
  244. <label>
  245. <input type="radio" name="new_line_after_elsecase" value="None" checked="checked">None</label>
  246. </form>
  247. <form id="new_line_after_port">
  248. <span class="code">PORT | PORT MAP</span>
  249. <label>
  250. <input type="radio" name="new_line_after_portcase" value="NewLine">New Line</label>
  251. <label>
  252. <input type="radio" name="new_line_after_portcase" value="NoNewLine">No New Line</label>
  253. <label>
  254. <input type="radio" name="new_line_after_portcase" value="None" checked="checked">None</label>
  255. </form>
  256. <form id="new_line_after_generic">
  257. <span class="code">GENERIC</span>
  258. <label>
  259. <input type="radio" name="new_line_after_genericcase" value="NewLine">New Line</label>
  260. <label>
  261. <input type="radio" name="new_line_after_genericcase" value="NoNewLine">No New Line</label>
  262. <label>
  263. <input type="radio" name="new_line_after_genericcase" value="None" checked="checked">None</label>
  264. </form>
  265. </fieldset>
  266. <div class="checkbox inline" id="remove_comments_div">
  267. <input type="checkbox" id="remove_comments">
  268. <label for="remove_comments">Remove commments</label> |
  269. </div>
  270. <div class="checkbox inline" id="remove_lines_div">
  271. <input type="checkbox" id="remove_lines">
  272. <label for="remove_lines">Remove blank lines</label> |
  273. </div>
  274. <div class="checkbox inline" id="remove_report_div">
  275. <input type="checkbox" id="remove_report">
  276. <label for="remove_report">Remove REPORT</label>
  277. </div>
  278. <br>
  279. <div class="checkbox" id="check_alias_div">
  280. <input type="checkbox" id="check_alias">
  281. <label for="check_alias">Check ALIAS (every long name is replaced with ALIAS)</label>
  282. </div>
  283. <div id="sign_align_in_div">
  284. Align signs in
  285. <div class="checkbox inline" id="sign_align_port_div">
  286. <input type="checkbox" id="sign_align_port">
  287. <label for="sign_align_port" class="code">PORT()</label>
  288. </div>
  289. <div class="checkbox inline" id="sign_align_generic_div">
  290. <input type="checkbox" id="sign_align_generic">
  291. <label for="sign_align_generic" class="code">GENERIC()</label></div>
  292. <div class="checkbox inline" id="sign_align_procedure_div">
  293. <input type="checkbox" id="sign_align_procedure">
  294. <label for="sign_align_procedure" class="code">PROCEDURE()</label>
  295. </div>
  296. <div class="checkbox inline" id="sign_align_function_div">
  297. <input type="checkbox" id="sign_align_function">
  298. <label for="sign_align_function" class="code">FUNCTION()</label>
  299. </div>
  300. </div>
  301. <div class="checkbox" id="sign_align_all_div">
  302. <input type="checkbox" id="sign_align_all">
  303. <label for="sign_align_all">Align signs in all places</label>
  304. </div>
  305. <div id="customise_indentation_div">
  306. <div class="checkbox inline" id="use_space_div">
  307. <input type="checkbox" id="use_space">
  308. <label for="use_space">Customise Indentation: </label>
  309. </div>(tab is \t)
  310. <input type="text" id="customise_indentation" size="8" onKeyUp="counterDecode('customise_indentation', 'indent_s')" value=" " /> (
  311. <span id="indent_s">four blankspaces</span>)
  312. </div>
  313. <div id="cust_eol_div">
  314. End of line:
  315. <input type="text" id="cust_eol" size="8" onKeyUp="counterDecode('cust_eol', 'eol_s')" value="\r\n" /> (
  316. <span id="eol_s">one \r & one \n</span>)
  317. </div>
  318. <div class="checkbox" id="compress_div">
  319. <input type="checkbox" id="compress">
  320. <label for="compress">! EVIL - compress VHDL (\r\n, comments will be removed)</label>
  321. </div>
  322. <div class="checkbox" id="mix_letter_div">
  323. <input type="checkbox" id="mix_letter">
  324. <label for="mix_letter">! EVIL - unreadable (mix upper/lower-case letters)</label>
  325. </div>
  326. <input type="button" class="btn" onclick="f()" value="start" />
  327. <span class="show">
  328. <input type="button" class="btn " id="selectAll" value="Select All" onclick="selectText(document.getElementById('vhdl'))" />
  329. <div class="checkbox inline">
  330. <input type="checkbox" onclick="wordWrap()" id="word_wrap">
  331. <label for="word_wrap">Word wrap</label>
  332. </div>
  333. </span>
  334. <br>
  335. <pre id="result"><code class="vhdl" id="vhdl">
  336. <font style="background-color:#9D9D9D; color:#fff"> output sample </font>
  337. <span class="hljs-keyword">LIBRARY</span> IEEE; <span class="hljs-comment">-- declare the library</span>
  338. <span class="hljs-keyword">USE</span> IEEE.std_logic_1164.<span class="hljs-keyword">ALL</span>;
  339. <span class="hljs-keyword">USE</span> IEEE.std_logic_arith.<span class="hljs-keyword">ALL</span>;
  340. <font style="background-color:#9D9D9D; color:#fff"> (All reserved words are in capital) </font>
  341. <font style="background-color:#9D9D9D; color:#fff"> (All indents are in the right place) </font>
  342. <span class="hljs-comment">---------------------------------------------------------------</span>
  343. <span class="hljs-keyword">ENTITY</span> example <span class="hljs-keyword">IS</span>
  344. <span class="hljs-keyword">PORT</span> (
  345. rst : <span class="hljs-keyword">IN</span> <span class="hljs-typename">std_logic</span>;
  346. clk : <span class="hljs-keyword">IN</span> <span class="hljs-typename">std_logic</span>;
  347. 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>)
  348. <font style="background-color:#9D9D9D; color:#fff"> (<strong>Align signs in PORT()</strong> aligns these colons) </font>
  349. );
  350. <span class="hljs-keyword">END</span> example;
  351. <span class="hljs-keyword">ARCHITECTURE</span> EXA <span class="hljs-keyword">OF</span> example <span class="hljs-keyword">IS</span>
  352. <span class="hljs-keyword">ALIAS</span> slv <span class="hljs-keyword">IS</span> <span class="hljs-typename">std_logic_vector</span>;
  353. <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>
  354. <span class="hljs-keyword">BEGIN</span>
  355. <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>
  356. stages : <span class="hljs-keyword">PROCESS</span> (rst, clk)
  357. <span class="hljs-keyword">BEGIN</span>
  358. <span class="hljs-keyword">IF</span> (rst = <span class="hljs-literal">'0'</span>) <span class="hljs-keyword">THEN</span>
  359. <span class="hljs-keyword">CASE</span> bit4 <span class="hljs-keyword">IS</span>
  360. <span class="hljs-keyword">WHEN</span> <span class="hljs-string">"0000"</span> =&gt; bit4 &lt;= <span class="hljs-string">"0001"</span>;
  361. <span class="hljs-keyword">WHEN</span> <span class="hljs-string">"0001"</span> =&gt; bit4 &lt;= <span class="hljs-string">"0100"</span>;
  362. <span class="hljs-keyword">WHEN</span> <span class="hljs-string">"0010"</span> =&gt; bit4 &lt;= <span class="hljs-string">"0010"</span>;
  363. <span class="hljs-keyword">WHEN</span> <span class="hljs-string">"0100"</span> =&gt; bit4 &lt;= <span class="hljs-string">"0000"</span>;
  364. <span class="hljs-keyword">WHEN</span> <span class="hljs-keyword">OTHERS</span> =&gt;
  365. <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>
  366. <span class="hljs-keyword">END</span> <span class="hljs-keyword">CASE</span>;
  367. <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>
  368. <span class="hljs-keyword">IF</span> (bit4 = '<span class="hljs-number">0111</span>') <span class="hljs-keyword">THEN</span>
  369. bit4 &lt;= <span class="hljs-string">"0000"</span>;
  370. <span class="hljs-keyword">ELSE</span>
  371. bit4 &lt;= <span class="hljs-string">"1111"</span>;
  372. <span class="hljs-keyword">END</span> <span class="hljs-keyword">IF</span>;
  373. <del><span class="hljs-comment">-- Sample comments 1;</span> </del>
  374. <del> <span class="hljs-comment">-- Sample comments 2;</span></del> <font style="background-color:#9D9D9D; color:#fff"> (Remove comments) </font>
  375. <span class="hljs-keyword">END</span> <span class="hljs-keyword">IF</span>;
  376. <span class="hljs-keyword">END</span> <span class="hljs-keyword">PROCESS</span>;
  377. <span class="hljs-keyword">END</span> EXA;</code></pre>
  378. <script>
  379. var exports = {};
  380. </script>
  381. <script src="VHDLFormatter.js"></script>
  382. <script src="descriptiveCounter.js"></script>
  383. <script src="main.js"></script>
  384. <script>
  385. const localStorageSettingKey = "settings";
  386. const localStorageNoFormatKey = "noFormat";
  387. function onLoad() {
  388. let global_endOfLine = navigator.platform === 'Win32' ? '\\r\\n' : '\\n';
  389. document.getElementById("cust_eol").value = global_endOfLine;
  390. var setting = loadSetting();
  391. if (setting == null) {
  392. return;
  393. }
  394. var beautifierSettings = setting.setting;
  395. document.getElementById("remove_comments").checked = beautifierSettings.RemoveComments;
  396. document.getElementById("remove_lines").checked = setting.removeLines;
  397. document.getElementById("remove_report").checked = beautifierSettings.RemoveAsserts;
  398. document.getElementById("check_alias").checked = beautifierSettings.CheckAlias;
  399. var signAlignKeywords = beautifierSettings.SignAlignKeyWords;
  400. if (signAlignKeywords != null && signAlignKeywords.length > 0) {
  401. document.getElementById("sign_align_port").checked = signAlignKeywords.indexOf("PORT") >= 0;
  402. document.getElementById("sign_align_function").checked = signAlignKeywords.indexOf("FUNCTION") >= 0;
  403. document.getElementById("sign_align_procedure").checked = signAlignKeywords.indexOf("PROCEDURE") >= 0;
  404. document.getElementById("sign_align_generic").checked = signAlignKeywords.indexOf("GENERIC") >= 0;
  405. }
  406. document.getElementById("sign_align_all").checked = beautifierSettings.SignAlignAll;
  407. var newLineSettings = beautifierSettings.NewLineSettings;
  408. var newLineAfter = newLineSettings.newLineAfter;
  409. var noNewLineAfter = newLineSettings.noNewLineAfter;
  410. document.getElementById("new_line_after_port").elements.namedItem("new_line_after_portcase").value = decodeNewLineSetting(newLineAfter, noNewLineAfter, "port");
  411. document.getElementById("new_line_after_then").elements.namedItem("new_line_after_thencase").value = decodeNewLineSetting(newLineAfter, noNewLineAfter, "then");
  412. document.getElementById("new_line_after_semicolon").elements.namedItem("new_line_after_semicoloncase").value = decodeNewLineSetting(newLineAfter, noNewLineAfter, ";");
  413. document.getElementById("new_line_after_else").elements.namedItem("new_line_after_elsecase").value = decodeNewLineSetting(newLineAfter, noNewLineAfter, "else");
  414. document.getElementById("new_line_after_generic").elements.namedItem("new_line_after_genericcase").value = decodeNewLineSetting(newLineAfter, noNewLineAfter, "generic");
  415. document.getElementById("compress").checked = setting.compress;
  416. var indentation = beautifierSettings.Indentation;
  417. document.getElementById("use_space").checked = indentation != "\t";
  418. document.getElementById("customise_indentation").value = indentation;
  419. document.getElementById("keyword").elements.namedItem("keywordcase").value = beautifierSettings.KeywordCase;
  420. document.getElementById("mix_letter").checked = setting.mixLetter;
  421. var eof = beautifierSettings.EndOfLine
  422. eof = eof.replace(/\r/g, "\\r");
  423. eof = eof.replace(/\n/g, "\\n");
  424. eof = eof.replace(/\t/g, "\\t");
  425. document.getElementById("cust_eol").value = eof;
  426. var noFormatBool = loadNoFormatSetting();
  427. if (noFormatBool) {
  428. document.getElementById("no_format").checked = true;
  429. noFormat();
  430. }
  431. counterDecode('customise_indentation', 'indent_s');
  432. counterDecode('cust_eol', 'eol_s');
  433. }
  434. function decodeNewLineSetting(hasNewLine, noNewLine, str) {
  435. if (hasNewLine.indexOf(str) >= 0) {
  436. return "NewLine";
  437. }
  438. if (noNewLine.indexOf(str) >= 0) {
  439. return "NoNewLine";
  440. }
  441. return "None";
  442. }
  443. onLoad();
  444. function f() {
  445. var input = document.getElementById("in").value;
  446. var no_format = document.getElementById("no_format").checked;
  447. saveNoFormatSetting(no_format);
  448. if (no_format) {
  449. document.getElementById("vhdl").innerHTML = input;
  450. document.querySelector(".show").style.display = "inline-block";
  451. hljs.highlightBlock(document.getElementById("vhdl"));
  452. return;
  453. }
  454. var remove_comments = document.getElementById("remove_comments").checked;
  455. var remove_lines = document.getElementById("remove_lines").checked;
  456. var remove_report = document.getElementById("remove_report").checked;
  457. var check_alias = document.getElementById("check_alias").checked;
  458. var sign_align_port = document.getElementById("sign_align_port").checked;
  459. var sign_align_function = document.getElementById("sign_align_function").checked;
  460. var sign_align_procedure = document.getElementById("sign_align_procedure").checked;
  461. var sign_align_generic = document.getElementById("sign_align_generic").checked;
  462. var sign_align_all = document.getElementById("sign_align_all").checked;
  463. var new_line_after_port = document.getElementById("new_line_after_port").elements.namedItem("new_line_after_portcase").value;
  464. var new_line_after_then = document.getElementById("new_line_after_then").elements.namedItem("new_line_after_thencase").value;
  465. var new_line_after_semicolon = document.getElementById("new_line_after_semicolon").elements.namedItem("new_line_after_semicoloncase").value;
  466. var new_line_after_else = document.getElementById("new_line_after_else").elements.namedItem("new_line_after_elsecase").value;
  467. var new_line_after_generic = document.getElementById("new_line_after_generic").elements.namedItem("new_line_after_genericcase").value;
  468. var use_space = document.getElementById("use_space").checked;
  469. var compress = document.getElementById("compress").checked;
  470. var cust_indent = document.getElementById("customise_indentation").value;
  471. var keywordcase = document.getElementById("keyword").elements.namedItem("keywordcase").value;
  472. var mix_letter = document.getElementById("mix_letter").checked;
  473. var endOfLine = document.getElementById("cust_eol").value;
  474. endOfLine = endOfLine.replace(/\\r/g, "\r");
  475. endOfLine = endOfLine.replace(/\\n/g, "\n");
  476. if (compress) {
  477. remove_comments = true;
  478. }
  479. indentation = "\t";
  480. if (use_space) {
  481. cust_indent = cust_indent.replace(/\\t/, " ");
  482. indentation = cust_indent;
  483. }
  484. var newLineSettingsDict = {};
  485. newLineSettingsDict["generic"] = new_line_after_generic;
  486. newLineSettingsDict["generic map"] = new_line_after_generic;
  487. newLineSettingsDict["port"] = new_line_after_port;
  488. newLineSettingsDict["port map"] = new_line_after_port;
  489. newLineSettingsDict[";"] = new_line_after_semicolon;
  490. newLineSettingsDict["then"] = new_line_after_then;
  491. newLineSettingsDict["else"] = new_line_after_else;
  492. newLineSettings = ConstructNewLineSettings(newLineSettingsDict);
  493. var signAlignKeywords = [];
  494. if (sign_align_function) {
  495. signAlignKeywords.push("FUNCTION");
  496. signAlignKeywords.push("IMPURE FUNCTION");
  497. }
  498. if (sign_align_generic) {
  499. signAlignKeywords.push("GENERIC");
  500. }
  501. if (sign_align_port) {
  502. signAlignKeywords.push("PORT");
  503. }
  504. if (sign_align_procedure) {
  505. signAlignKeywords.push("PROCEDURE");
  506. }
  507. sign_align = signAlignKeywords.length > 0;
  508. beautifierSettings = new BeautifierSettings(remove_comments, remove_report, check_alias, sign_align,
  509. sign_align_all,
  510. keywordcase,
  511. indentation,
  512. newLineSettings,
  513. endOfLine);
  514. beautifierSettings.SignAlignKeyWords = signAlignKeywords;
  515. vhdlSettings = new VhdlSettings(beautifierSettings, remove_lines, compress, mix_letter);
  516. saveSetting(vhdlSettings);
  517. input = beautify(input, beautifierSettings);
  518. if (remove_lines) {
  519. input = input.replace(/(\r\n)*[ \t]*\r\n/g, '\r\n');
  520. }
  521. if (compress) {
  522. input = Compress(input);
  523. }
  524. if (mix_letter) {
  525. input = MixLetters(input);
  526. }
  527. document.getElementById("vhdl").innerHTML = input;
  528. document.querySelector(".show").style.display = "inline-block";
  529. hljs.highlightBlock(document.getElementById("vhdl"));
  530. }
  531. function saveSetting(setting) {
  532. var json = JSON.stringify(setting);
  533. json = json.replace(/\r/g, "\\r");
  534. json = json.replace(/\n/g, "\\n");
  535. json = json.replace(/\t/g, "\\t");
  536. localStorage.setItem(localStorageSettingKey, json);
  537. }
  538. function loadSetting() {
  539. var json = localStorage.getItem(localStorageSettingKey);
  540. if (json == null) {
  541. return null;
  542. }
  543. return JSON.parse(json);
  544. }
  545. function saveNoFormatSetting(no_format) {
  546. localStorage.setItem(localStorageNoFormatKey, no_format);
  547. }
  548. function loadNoFormatSetting() {
  549. return JSON.parse(localStorage.getItem(localStorageNoFormatKey));
  550. }
  551. class VhdlSettings {
  552. constructor(setting, removeLines, compress, mixLetter) {
  553. this.setting = setting;
  554. this.removeLines = removeLines;
  555. this.compress = compress;
  556. this.mixLetter = mixLetter;
  557. }
  558. }
  559. </script>
  560. </body>
  561. </html>