From a91f8ecf730ea480df2cb7ace9c731ee5d18c8ce Mon Sep 17 00:00:00 2001 From: Sour Date: Thu, 14 Nov 2024 19:38:52 +0900 Subject: [PATCH] Debugger: Source View - Added tab size option --- UI/Config/IntegrationConfig.cs | 2 ++ UI/Debugger/ViewModels/SourceViewViewModel.cs | 15 ++++++++++++++- UI/Debugger/Windows/DebuggerConfigWindow.axaml | 7 ++++++- UI/Localization/resources.en.xml | 5 ++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/UI/Config/IntegrationConfig.cs b/UI/Config/IntegrationConfig.cs index 8de02ba68..dea486fd9 100644 --- a/UI/Config/IntegrationConfig.cs +++ b/UI/Config/IntegrationConfig.cs @@ -25,6 +25,8 @@ public class IntegrationConfig : BaseConfig [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) { diff --git a/UI/Debugger/ViewModels/SourceViewViewModel.cs b/UI/Debugger/ViewModels/SourceViewViewModel.cs index 0d86881c2..4c36992a8 100644 --- a/UI/Debugger/ViewModels/SourceViewViewModel.cs +++ b/UI/Debugger/ViewModels/SourceViewViewModel.cs @@ -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(), 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; diff --git a/UI/Debugger/Windows/DebuggerConfigWindow.axaml b/UI/Debugger/Windows/DebuggerConfigWindow.axaml index 184edc4f2..ce7aaee74 100644 --- a/UI/Debugger/Windows/DebuggerConfigWindow.axaml +++ b/UI/Debugger/Windows/DebuggerConfigWindow.axaml @@ -252,7 +252,12 @@ Margin="0 5 0 0" /> - + + + + + + diff --git a/UI/Localization/resources.en.xml b/UI/Localization/resources.en.xml index c2bcb2efb..59ab840b3 100644 --- a/UI/Localization/resources.en.xml +++ b/UI/Localization/resources.en.xml @@ -1524,7 +1524,10 @@ Work RAM labels Other labels Import comments (restricted to the label types selected above) - + + Source view + Tab size: + Shortcuts Shared Memory Viewer