Explorar o código

Improve ShowCaretPosition debug option to show style names instead of only numbers.

Martijn Laan hai 3 meses
pai
achega
55d5df2b45
Modificáronse 2 ficheiros con 12 adicións e 7 borrados
  1. 9 5
      Projects/Src/IDE.MainForm.pas
  2. 3 2
      Projects/Src/IDE.ScintStylerInnoSetup.pas

+ 9 - 5
Projects/Src/IDE.MainForm.pas

@@ -677,7 +677,7 @@ implementation
 
 uses
   ActiveX, Clipbrd, ShellApi, ShlObj, IniFiles, Registry, Consts, Types, UITypes,
-  Math, StrUtils, WideStrUtils,
+  Math, StrUtils, WideStrUtils, TypInfo,
   PathFunc, Shared.CommonFunc.Vcl, Shared.CommonFunc, Shared.FileClass, IDE.Messages, NewUxTheme.TmSchema, BrowseFunc,
   IDE.HtmlHelpFunc, TaskbarProgressFunc, IDE.ImagesModule,
   {$IFDEF STATICCOMPILER} Compiler.Compile, {$ENDIF}
@@ -890,8 +890,10 @@ constructor TMainForm.Create(AOwner: TComponent);
 
       { Debug options }
       FOptions.ShowCaretPosition := Ini.ReadBool('Options', 'ShowCaretPosition', False);
-      if FOptions.ShowCaretPosition then
-        StatusBar.Panels[spCaretPos].Width := StatusBar.Panels[spCaretPos].Width * 2;
+      if FOptions.ShowCaretPosition then begin
+        StatusBar.Panels[spCaretPos].Width := MulDiv(StatusBar.Panels[spCaretPos].Width, 7, 2);
+        StatusBar.Panels[spCaretPos].Alignment := taLeftJustify;
+      end;
 
       SyncEditorOptions;
       UpdateNewMainFileButtons;
@@ -4840,8 +4842,10 @@ begin
   var Text := Format('%4d:%4d', [FActiveMemo.CaretLine + 1,
     FActiveMemo.CaretColumnExpandedForTabs + 1]);
   if FOptions.ShowCaretPosition then begin
-    var CaretPos := FActiveMemo.CaretPosition;
-    Text := Format('%d@%d+%d:%s', [FActiveMemo.GetStyleAtPosition(CaretPos), CaretPos, FActiveMemo.CaretVirtualSpace, Text]);
+    const CaretPos = FActiveMemo.CaretPosition;
+    const Style = FActiveMemo.GetStyleAtPosition(CaretPos);
+    Text := Format('%s@%d+%d:%s', [Copy(GetEnumName(TypeInfo(TInnoSetupStylerStyle), Style), 3, MaxInt),
+      CaretPos, FActiveMemo.CaretVirtualSpace, Text]);
   end;
   StatusBar.Panels[spCaretPos].Text := Text;
 

+ 3 - 2
Projects/Src/IDE.ScintStylerInnoSetup.pas

@@ -67,8 +67,9 @@ type
 
   { Starts at 1 instead of 0 to make sure ApplyStyle doesn't overwrite already applied stDefault
     styles which is needed for PreStyleInlineISPPDirectives to work properly when the inline
-    directive is inside a comment or string }
-  TInnoSetupStylerStyle = (stDefault = 1, stCompilerDirective,
+    directive is inside a comment or string. This is done by added a dummy 'st0' style. If done by
+    using 'stDefault = 1' then this enum looses its TypeInfo. }
+  TInnoSetupStylerStyle = (st0, stDefault, stCompilerDirective,
     stComment, stSection, stSymbol, stKeyword, stParameterValue,
     stEventFunction, stConstant, stMessageArg,
     stPascalReservedWord, stPascalString, stPascalNumber,