Debugger: Source View - Added tab size option

This commit is contained in:
Sour 2024-11-14 19:38:52 +09:00
parent 2e6a2e5494
commit a91f8ecf73
4 changed files with 26 additions and 3 deletions

View file

@ -25,6 +25,8 @@ namespace Mesen.Config
[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)
{

View file

@ -155,12 +155,25 @@ public class SourceViewViewModel : DisposableViewModel, ISelectableModel
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;

View file

@ -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>

View file

@ -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>