Skip to content

Commit

Permalink
Added "TabToSpace" function
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.viathinksoft.com/svn/fastphp/trunk@119 4275edf5-accd-43b1-89a6-70d33797d1ed
  • Loading branch information
danielmarschall committed Jun 9, 2024
1 parent 4eabcc2 commit a20471a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
24 changes: 20 additions & 4 deletions EditorMain.dfm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Form1: TForm1
Left = 0
Top = 0
Caption = 'ViaThinkSoft FastPHP 0.9'
Caption = 'ViaThinkSoft FastPHP 0.10'
ClientHeight = 661
ClientWidth = 1120
Color = clBtnFace
Expand Down Expand Up @@ -705,7 +705,7 @@ object Form1: TForm1
Left = 733
Top = 0
Width = 75
Height = 35
Height = 17
Action = ActionSpaceToTab
ParentShowHint = False
ShowHint = True
Expand All @@ -719,6 +719,16 @@ object Form1: TForm1
Action = ActionLint
ParentShowHint = False
ShowHint = True
TabOrder = 11
end
object Button10: TButton
Left = 733
Top = 18
Width = 75
Height = 17
Action = ActionTabToSpace
ParentShowHint = False
ShowHint = True
TabOrder = 10
end
end
Expand Down Expand Up @@ -844,6 +854,12 @@ object Form1: TForm1
ShortCut = 24660
OnExecute = ActionSpaceToTabExecute
end
object ActionTabToSpace: TAction
Caption = 'TabToSpace'
Hint = 'Convert leading tabs to 4 spaces each'
ShortCut = 57428
OnExecute = ActionTabToSpaceExecute
end
object ActionLint: TAction
Caption = 'Lint'
Hint = 'Run PHP Lint (php -l) to check for syntax errors'
Expand All @@ -854,8 +870,8 @@ object Form1: TForm1
object Timer1: TTimer
Enabled = False
OnTimer = Timer1Timer
Left = 776
Top = 8
Left = 864
Top = 88
end
object SynEditSearch1: TSynEditSearch
Left = 788
Expand Down
11 changes: 11 additions & 0 deletions EditorMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ TForm1 = class(TForm)
FontSizeTimer: TTimer;
ChooseanotherPHPinterpreter1: TMenuItem;
ChooseanotherCHMhelpfile1: TMenuItem;
Button10: TButton;
ActionTabToSpace: TAction;
procedure Run(Sender: TObject);
procedure RunConsole(Sender: TObject);
procedure FormShow(Sender: TObject);
Expand Down Expand Up @@ -196,6 +198,7 @@ TForm1 = class(TForm)
procedure SynEdit1StatusChange(Sender: TObject; Changes: TSynStatusChanges);
procedure ChooseanotherPHPinterpreter1Click(Sender: TObject);
procedure ChooseanotherCHMhelpfile1Click(Sender: TObject);
procedure ActionTabToSpaceExecute(Sender: TObject);
private
hMutex: THandle;
CurSearchTerm: string;
Expand Down Expand Up @@ -1781,4 +1784,12 @@ function TForm1.OutputNotifyCallback(const data: AnsiString): boolean;
result := TreeView1.FillWithFastPHPData(string(data));
end;

procedure TForm1.ActionTabToSpaceExecute(Sender: TObject);
begin
// TODO: if something is selected, only process the selected part
// TODO: Only change tabs which are at line beginning. Not tabs in the middle of the code.
SynEdit1.Text := StringReplace(SynEdit1.Text, #9, ' ', [rfReplaceAll]);

end;

end.

0 comments on commit a20471a

Please sign in to comment.