Browse Source

Show line indents in Textmode IDE

Margers 9 months ago
parent
commit
a8520ad03e
4 changed files with 36 additions and 22 deletions
  1. 1 1
      packages/ide/fpconst.pas
  2. 1 0
      packages/ide/fpide.pas
  3. 23 20
      packages/ide/fpmopts.inc
  4. 11 1
      packages/ide/weditor.pas

+ 1 - 1
packages/ide/fpconst.pas

@@ -490,7 +490,7 @@ const
          { CSourceWindow }
          { CSourceWindow }
 {167-182}#$17#$1F#$1A#$31#$31#$1E#$71#$1F#$00#$00#$00#$00#$00#$00#$00#$00 + { 1-16}
 {167-182}#$17#$1F#$1A#$31#$31#$1E#$71#$1F#$00#$00#$00#$00#$00#$00#$00#$00 + { 1-16}
 {183-198}#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00 + {17-32}
 {183-198}#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00 + {17-32}
-{199-214}#$1E#$1F#$17#$1F#$1E#$1B#$13#$1A#$1E#$71#$3F#$30#$1C#$13#$1F#$4E + {33-48}
+{199-214}#$1E#$19#$17#$1F#$1E#$1B#$13#$1A#$1E#$71#$3F#$30#$1C#$13#$19#$4E + {33-48}
          { CBrowserWindow }
          { CBrowserWindow }
 {215-226}#$31#$3F#$3A#$31#$31#$31#$71#$1F#$31#$2F#$3E#$3F +
 {215-226}#$31#$3F#$3A#$31#$31#$31#$71#$1F#$31#$2F#$3E#$3F +
          { CFPClockView }
          { CFPClockView }

+ 1 - 0
packages/ide/fpide.pas

@@ -607,6 +607,7 @@ resourcestring  menu_local_gotosource = '~G~oto source';
                 label_editor_persistentblocks = '~P~ersistent blocks';
                 label_editor_persistentblocks = '~P~ersistent blocks';
                 label_editor_overwriteblocks = '~O~verwrite blocks';
                 label_editor_overwriteblocks = '~O~verwrite blocks';
                 label_editor_syntaxhighlight = '~S~yntax highlight';
                 label_editor_syntaxhighlight = '~S~yntax highlight';
+                label_editor_showlineindents = 'Sho~w~ line indents';
                 label_editor_blockinsertcursor = 'B~l~ock insert cursor';
                 label_editor_blockinsertcursor = 'B~l~ock insert cursor';
                 label_editor_verticalblocks = '~V~ertical blocks';
                 label_editor_verticalblocks = '~V~ertical blocks';
                 label_editor_highlightcolumn = 'Highlight ~c~olumn';
                 label_editor_highlightcolumn = 'Highlight ~c~olumn';

+ 23 - 20
packages/ide/fpmopts.inc

@@ -1217,21 +1217,22 @@ begin
   if (EFlags and efPersistentBlocks  )<>0 then EFValue:=EFValue or (1 shl  5);
   if (EFlags and efPersistentBlocks  )<>0 then EFValue:=EFValue or (1 shl  5);
   if (EFlags and efOverwriteBlocks   )<>0 then EFValue:=EFValue or (1 shl  6);
   if (EFlags and efOverwriteBlocks   )<>0 then EFValue:=EFValue or (1 shl  6);
   if (EFlags and efSyntaxHighlight   )<>0 then EFValue:=EFValue or (1 shl  7);
   if (EFlags and efSyntaxHighlight   )<>0 then EFValue:=EFValue or (1 shl  7);
-  if (EFlags and efVerticalBlocks    )<>0 then EFValue:=EFValue or (1 shl  8);
-  if (EFlags and efHighlightColumn   )<>0 then EFValue:=EFValue or (1 shl  9);
-  if (EFlags and efHighlightRow      )<>0 then EFValue:=EFValue or (1 shl 10);
-  if (EFlags and efAutoBrackets      )<>0 then EFValue:=EFValue or (1 shl 11);
-  if (EFlags and efKeepTrailingSpaces)<>0 then EFValue:=EFValue or (1 shl 12);
-  if (EFlags and efCodeComplete      )<>0 then EFValue:=EFValue or (1 shl 13);
-  if (EFlags and efFolds             )<>0 then EFValue:=EFValue or (1 shl 14);
-  if (EFlags and efBlockInsCursor    )<>0 then EFValue:=EFValue or (1 shl 15);
-
-  R.Assign(0,0,66,20);
+  if (EFlags and efShowIndent        )<>0 then EFValue:=EFValue or (1 shl  8);
+  if (EFlags and efVerticalBlocks    )<>0 then EFValue:=EFValue or (1 shl  9);
+  if (EFlags and efHighlightColumn   )<>0 then EFValue:=EFValue or (1 shl 10);
+  if (EFlags and efHighlightRow      )<>0 then EFValue:=EFValue or (1 shl 11);
+  if (EFlags and efAutoBrackets      )<>0 then EFValue:=EFValue or (1 shl 12);
+  if (EFlags and efKeepTrailingSpaces)<>0 then EFValue:=EFValue or (1 shl 13);
+  if (EFlags and efCodeComplete      )<>0 then EFValue:=EFValue or (1 shl 14);
+  if (EFlags and efFolds             )<>0 then EFValue:=EFValue or (1 shl 15);
+  if (EFlags and efBlockInsCursor    )<>0 then EFValue:=EFValue or (1 shl 16);
+
+  R.Assign(0,0,66,21);
   New(D, Init(R, Title));
   New(D, Init(R, Title));
   with D^ do
   with D^ do
   begin
   begin
     HelpCtx:=hcEditor;
     HelpCtx:=hcEditor;
-    GetExtent(R); R.Grow(-2,-2); R.B.Y:=R.A.Y+9;
+    GetExtent(R); R.Grow(-2,-2); R.B.Y:=R.A.Y+10;
     R2.Copy(R); Inc(R2.A.Y);
     R2.Copy(R); Inc(R2.A.Y);
     New(CB, Init(R2,
     New(CB, Init(R2,
       NewSItem(label_editor_backupfiles,
       NewSItem(label_editor_backupfiles,
@@ -1242,6 +1243,7 @@ begin
       NewSItem(label_editor_persistentblocks,
       NewSItem(label_editor_persistentblocks,
       NewSItem(label_editor_overwriteblocks,
       NewSItem(label_editor_overwriteblocks,
       NewSItem(label_editor_syntaxhighlight,
       NewSItem(label_editor_syntaxhighlight,
+      NewSItem(label_editor_showlineindents,
       NewSItem(label_editor_verticalblocks,
       NewSItem(label_editor_verticalblocks,
       NewSItem(label_editor_highlightcolumn,
       NewSItem(label_editor_highlightcolumn,
       NewSItem(label_editor_highlightrow,
       NewSItem(label_editor_highlightrow,
@@ -1250,7 +1252,7 @@ begin
       NewSItem(label_editor_codecomplete,
       NewSItem(label_editor_codecomplete,
       NewSItem(label_editor_folds,
       NewSItem(label_editor_folds,
       NewSItem(label_editor_blockinsertcursor,
       NewSItem(label_editor_blockinsertcursor,
-      nil))))))))))))))))));
+      nil)))))))))))))))))));
     CB^.Value:=EFValue;
     CB^.Value:=EFValue;
     Insert(CB);
     Insert(CB);
     R2.Move(0,-1); R2.B.Y:=R2.A.Y+1;
     R2.Move(0,-1); R2.B.Y:=R2.A.Y+1;
@@ -1300,14 +1302,15 @@ begin
     if (CB^.Value and (1 shl  5))<>0 then EFlags:=EFlags or efPersistentBlocks;
     if (CB^.Value and (1 shl  5))<>0 then EFlags:=EFlags or efPersistentBlocks;
     if (CB^.Value and (1 shl  6))<>0 then EFlags:=EFlags or efOverwriteBlocks;
     if (CB^.Value and (1 shl  6))<>0 then EFlags:=EFlags or efOverwriteBlocks;
     if (CB^.Value and (1 shl  7))<>0 then EFlags:=EFlags or efSyntaxHighlight;
     if (CB^.Value and (1 shl  7))<>0 then EFlags:=EFlags or efSyntaxHighlight;
-    if (CB^.Value and (1 shl  8))<>0 then EFlags:=EFlags or efVerticalBlocks;
-    if (CB^.Value and (1 shl  9))<>0 then EFlags:=EFlags or efHighlightColumn;
-    if (CB^.Value and (1 shl 10))<>0 then EFlags:=EFlags or efHighlightRow;
-    if (CB^.Value and (1 shl 11))<>0 then EFlags:=EFlags or efAutoBrackets;
-    if (CB^.Value and (1 shl 12))<>0 then EFlags:=EFlags or efKeepTrailingSpaces;
-    if (CB^.Value and (1 shl 13))<>0 then EFlags:=EFlags or efCodeComplete;
-    if (CB^.Value and (1 shl 14))<>0 then EFlags:=EFlags or efFolds;
-    if (CB^.Value and (1 shl 15))<>0 then EFlags:=EFlags or efBlockInsCursor;
+    if (CB^.Value and (1 shl  8))<>0 then EFlags:=EFlags or efShowIndent;
+    if (CB^.Value and (1 shl  9))<>0 then EFlags:=EFlags or efVerticalBlocks;
+    if (CB^.Value and (1 shl 10))<>0 then EFlags:=EFlags or efHighlightColumn;
+    if (CB^.Value and (1 shl 11))<>0 then EFlags:=EFlags or efHighlightRow;
+    if (CB^.Value and (1 shl 12))<>0 then EFlags:=EFlags or efAutoBrackets;
+    if (CB^.Value and (1 shl 13))<>0 then EFlags:=EFlags or efKeepTrailingSpaces;
+    if (CB^.Value and (1 shl 14))<>0 then EFlags:=EFlags or efCodeComplete;
+    if (CB^.Value and (1 shl 15))<>0 then EFlags:=EFlags or efFolds;
+    if (CB^.Value and (1 shl 16))<>0 then EFlags:=EFlags or efBlockInsCursor;
     TabSize:=StrToInt(ILTab^.Data^);
     TabSize:=StrToInt(ILTab^.Data^);
     IndentSize:=StrToInt(ILIdent^.Data^);
     IndentSize:=StrToInt(ILIdent^.Data^);
     if Editor=nil then
     if Editor=nil then

+ 11 - 1
packages/ide/weditor.pas

@@ -95,6 +95,7 @@ const
       efNoIndent            = $00010000;
       efNoIndent            = $00010000;
       efKeepLineAttr        = $00020000;
       efKeepLineAttr        = $00020000;
       efOverwriteBlocks     = $00040000;
       efOverwriteBlocks     = $00040000;
+      efShowIndent          = $00080000;
       efStoreContent        = $80000000;
       efStoreContent        = $80000000;
 
 
       attrAsm       = 1;
       attrAsm       = 1;
@@ -3926,7 +3927,7 @@ begin
     Color:=(Color and $F0) or $F;
     Color:=(Color and $F0) or $F;
   CombineColors:=Color;
   CombineColors:=Color;
 end;
 end;
-var
+var ShowIndent:boolean;
     FoldPrefix,FoldSuffix: string;
     FoldPrefix,FoldSuffix: string;
 {    SkipLine: boolean;}
 {    SkipLine: boolean;}
 {    FoldStartLine: sw_integer;}
 {    FoldStartLine: sw_integer;}
@@ -3962,6 +3963,7 @@ begin
   HighlightColColor:=GetColor(11);
   HighlightColColor:=GetColor(11);
   HighlightRowColor:=GetColor(12);
   HighlightRowColor:=GetColor(12);
   ErrorMessageColor:=GetColor(16);
   ErrorMessageColor:=GetColor(16);
+  ShowIndent:=IsFlagSet(efShowIndent) and IsFlagSet(efSyntaxHighlight);
 {$ifdef TEST_PARTIAL_SYNTAX}
 {$ifdef TEST_PARTIAL_SYNTAX}
   If (not GetSyntaxCompleted) and (GetLastSyntaxedLine<Delta.Y+Size.Y) then
   If (not GetSyntaxCompleted) and (GetLastSyntaxedLine<Delta.Y+Size.Y) then
     UpdateAttrsRange(GetLastSyntaxedLine,Delta.Y+Size.Y,AttrAll);
     UpdateAttrsRange(GetLastSyntaxedLine,Delta.Y+Size.Y,AttrAll);
@@ -4002,6 +4004,14 @@ begin
           FillChar(FreeFormat,SizeOf(FreeFormat),1);
           FillChar(FreeFormat,SizeOf(FreeFormat),1);
           MoveChar(B,' ',Color,Size.X);
           MoveChar(B,' ',Color,Size.X);
           GetDisplayTextFormat(AY,LineText,Format);
           GetDisplayTextFormat(AY,LineText,Format);
+          if ShowIndent and (length(Format)=length(LineText)) then
+            for X:=1 to length(LineText) do
+            begin
+              if LineText[X] <> ' ' then break;
+              if (X>1 ) and (X and 1 = 1) then
+                if ord(Format[X]) in [coWhiteSpaceColor,coTabColor] then
+                  LineText[X]:=#179; { | show line indent }
+            end;
 
 
           MaxX:=Min(Delta.X+1+Size.X,MaxLineLength);
           MaxX:=Min(Delta.X+1+Size.X,MaxLineLength);
           for X:=(MaxX-Size.X) to MaxX+1 do
           for X:=(MaxX-Size.X) to MaxX+1 do