Skip to content

Commit

Permalink
Debugger: Source View - Added tab size option
Browse files Browse the repository at this point in the history
  • Loading branch information
SourMesen committed Nov 14, 2024
1 parent 2e6a2e5 commit a91f8ec
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions UI/Config/IntegrationConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class IntegrationConfig : BaseConfig<IntegrationConfig>
[Reactive] public bool ImportSaveRamLabels { get; set; } = true;
[Reactive] public bool ImportOtherLabels { get; set; } = true;
[Reactive] public bool ImportComments { get; set; } = true;

[Reactive] public int TabSize { get; set; } = 4;

public bool IsMemoryTypeImportEnabled(MemoryType memType)
{
Expand Down
15 changes: 14 additions & 1 deletion UI/Debugger/ViewModels/SourceViewViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,25 @@ private CodeLineData GetCodeLineData(SourceFileInfo file, int lineNumber)
Address = lineAddr,
AbsoluteAddress = address ?? new AddressInfo() { Address = -1 },
Flags = LineFlags.VerifiedCode | (!showLineAddress ? LineFlags.Empty : LineFlags.None),
Text = file.Data[lineNumber],
Text = ReplaceTabs(file.Data[lineNumber], ConfigManager.Config.Debug.Integration.TabSize),
ByteCode = byteCode ?? Array.Empty<byte>(),
OpSize = (byte)opSize
};
}

private string ReplaceTabs(string line, int tabSize)
{
StringBuilder sb = new();
for(int i = 0; i < line.Length; i++) {
if(line[i] != '\t') {
sb.Append(line[i]);
} else {
sb.Append(' ', tabSize - sb.Length % tabSize);
}
}
return sb.ToString();
}

private void QuickSearch_OnFind(OnFindEventArgs e)
{
SourceFileInfo? file = SelectedFile;
Expand Down
7 changes: 6 additions & 1 deletion UI/Debugger/Windows/DebuggerConfigWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@
Margin="0 5 0 0"
/>
</c:OptionSection>

<c:OptionSection Header="{l:Translate lblSourceView}">
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="{l:Translate lblTabSize}" />
<NumericUpDown Value="{Binding Integration.TabSize}" Minimum="1" Maximum="16" />
</StackPanel>
</c:OptionSection>
</StackPanel>
</TabItem>

Expand Down
5 changes: 4 additions & 1 deletion UI/Localization/resources.en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,10 @@
<Control ID="chkImportWorkRamLabels">Work RAM labels</Control>
<Control ID="chkImportOtherLabels">Other labels</Control>
<Control ID="chkImportComments">Import comments (restricted to the label types selected above)</Control>


<Control ID="lblSourceView">Source view</Control>
<Control ID="lblTabSize">Tab size: </Control>

<Control ID="tabShortcuts">Shortcuts</Control>
<Control ID="tabShared">Shared</Control>
<Control ID="tabMemoryTools">Memory Viewer</Control>
Expand Down

0 comments on commit a91f8ec

Please sign in to comment.