Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions VHDLFormatter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions VHDLFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,10 @@ export class BeautifierSettings {
NewLineSettings: NewLineSettings;
EndOfLine: string;
AddNewLine: boolean;
CaseWhenIndent: boolean;
constructor(removeComments: boolean, removeReport: boolean, checkAlias: boolean,
signAlignSettings: signAlignSettings, keywordCase: string, typeNameCase: string, indentation: string,
newLineSettings: NewLineSettings, endOfLine: string, addNewLine: boolean) {
newLineSettings: NewLineSettings, endOfLine: string, addNewLine: boolean, caseWhenIndent: boolean) {
this.RemoveComments = removeComments;
this.RemoveAsserts = removeReport;
this.CheckAlias = checkAlias;
Expand All @@ -319,6 +320,7 @@ export class BeautifierSettings {
this.NewLineSettings = newLineSettings;
this.EndOfLine = endOfLine;
this.AddNewLine = addNewLine;
this.CaseWhenIndent = caseWhenIndent;
}
}

Expand Down Expand Up @@ -690,7 +692,11 @@ export function beautifyCaseBlock(block: CodeBlock, result: (FormattedLine | For
}
result.push(new FormattedLine(block.lines[block.cursor], indent));
block.cursor++;
beautify3(block, result, settings, indent + 2);
let caseindent = 2;
if (settings.CaseWhenIndent == false){
caseindent = 1;
}
beautify3(block, result, settings, indent + caseindent);
(<FormattedLine>result[block.cursor]).Indent = indent;
}

Expand Down
12 changes: 10 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ <h2>VHDL Beautifier, Formatter</h2>
<input type="checkbox" id="check_alias">
<label for="check_alias">Check ALIAS (all long names will be replaced by ALIAS names)</label>
</div>
<div class="checkbox" id="caseWhenIndent_div">
<input type="checkbox" id="caseWhenIndent" checked=true>
<label for="caseWhenIndent">Indent "whens" in a case statement</label>
</div>
<fieldset id="align_settings_div">
<legend>Sign Alignment</legend>
<div id="sign_align_in_div">
Expand Down Expand Up @@ -370,6 +374,7 @@ <h2>VHDL Beautifier, Formatter</h2>
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;
document.getElementById("caseWhenIndent").checked = beautifierSettings.CaseWhenIndent;
var eof = beautifierSettings.EndOfLine
eof = eof.replace(/\r/g, "\\r");
eof = eof.replace(/\n/g, "\\n");
Expand Down Expand Up @@ -409,8 +414,9 @@ <h2>VHDL Beautifier, Formatter</h2>

var remove_lines = document.getElementById("remove_lines").checked;
var mix_letter = document.getElementById("mix_letter").checked;
var caseWhenIndent = document.getElementById("caseWhenIndent").checked;
[beautifierSettings, compress] = CreateSettings();
vhdlSettings = new VhdlSettings(beautifierSettings, remove_lines, compress, mix_letter);
vhdlSettings = new VhdlSettings(beautifierSettings, remove_lines, compress, mix_letter, caseWhenIndent);
saveSetting(vhdlSettings);

input = beautify(input, beautifierSettings);
Expand Down Expand Up @@ -455,6 +461,7 @@ <h2>VHDL Beautifier, Formatter</h2>
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;
var caseWhenIndent = document.getElementById("caseWhenIndent").checked;
endOfLine = endOfLine.replace(/\\r/g, "\r");
endOfLine = endOfLine.replace(/\\n/g, "\n");
if (compress) {
Expand Down Expand Up @@ -500,7 +507,8 @@ <h2>VHDL Beautifier, Formatter</h2>
indentation,
newLineSettings,
endOfLine,
addNewLine);
addNewLine,
caseWhenIndent);

return [beautifierSettings, compress];
}
Expand Down
1 change: 1 addition & 0 deletions main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function noFormat() {
"customise_indentation",
"compress",
"mix_letter",
"caseWhenIndent",
"cust_eol",
"sign_align_mode",
"keyword",
Expand Down
4 changes: 2 additions & 2 deletions tests/VHDLFormatterUnitTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ function IntegrationTest78() {
}

function IntegrationTest79() {
let settings = new BeautifierSettings(false, false, false, null, "lowercase", "uppercase", null, null, "\r\n", false);
let settings = new BeautifierSettings(false, false, false, null, "lowercase", "uppercase", null, null, "\r\n", false, true);
let input = "case when others;\r\nx : STRING;\r\ny : BIT;";
let actual = beautify(input, settings);
assertAndCountTest("uppercase typename and lowercase keyword", input, actual);
Expand Down Expand Up @@ -1435,7 +1435,7 @@ function GetDefaultSettings(indentation: string = " "): BeautifierSettings {
}

function getDefaultBeautifierSettings(newLineSettings: NewLineSettings, signAlignSettings: signAlignSettings = null, indentation: string = " "): BeautifierSettings {
return new BeautifierSettings(false, false, false, signAlignSettings, "uppercase", "uppercase", indentation, newLineSettings, "\r\n", false);
return new BeautifierSettings(false, false, false, signAlignSettings, "uppercase", "uppercase", indentation, newLineSettings, "\r\n", false, true);
}


Expand Down