mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 05:58:06 +02:00
IDE: changing encoding of virtual files improved, IDE: added tool to change encoding of projects/packages
git-svn-id: trunk@16527 -
This commit is contained in:
parent
593181822e
commit
c93c466bc0
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1185,6 +1185,9 @@ components/turbopower_ipro/tipfiledataprovider.png -text svneol=unset#image/png
|
||||
components/turbopower_ipro/tiphtmlpanel.png -text svneol=unset#image/png
|
||||
components/turbopower_ipro/turbopoweripro.lpk svneol=native#text/pascal
|
||||
components/turbopower_ipro/turbopoweripro.pas svneol=native#text/plain
|
||||
converter/chgencodingdlg.lfm svneol=native#text/plain
|
||||
converter/chgencodingdlg.lrs svneol=native#text/plain
|
||||
converter/chgencodingdlg.pas svneol=native#text/plain
|
||||
converter/delphiproject2laz.pas svneol=native#text/plain
|
||||
converter/delphiunit2laz.lfm svneol=native#text/plain
|
||||
converter/delphiunit2laz.lrs svneol=native#text/pascal
|
||||
|
231
converter/chgencodingdlg.lfm
Normal file
231
converter/chgencodingdlg.lfm
Normal file
@ -0,0 +1,231 @@
|
||||
object ChgEncodingDialog: TChgEncodingDialog
|
||||
Left = 290
|
||||
Height = 479
|
||||
Top = 191
|
||||
Width = 509
|
||||
ActiveControl = OwnerComboBox
|
||||
Caption = 'ChgEncodingDialog'
|
||||
ClientHeight = 479
|
||||
ClientWidth = 509
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '0.9.25'
|
||||
object FilesGroupBox: TGroupBox
|
||||
Left = 6
|
||||
Height = 163
|
||||
Top = 72
|
||||
Width = 497
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'FilesGroupBox'
|
||||
ClientHeight = 144
|
||||
ClientWidth = 493
|
||||
TabOrder = 0
|
||||
object FileFilterLabel: TLabel
|
||||
AnchorSideLeft.Control = FilesGroupBox
|
||||
AnchorSideTop.Control = NonUTF8FilesCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 18
|
||||
Top = 71
|
||||
Width = 85
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 15
|
||||
BorderSpacing.Bottom = 2
|
||||
Caption = 'FileFilterLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object UTF8FilesCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = FilesGroupBox
|
||||
AnchorSideTop.Control = FilesGroupBox
|
||||
Left = 6
|
||||
Height = 22
|
||||
Top = 6
|
||||
Width = 146
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'UTF8FilesCheckBox'
|
||||
Checked = True
|
||||
State = cbChecked
|
||||
TabOrder = 0
|
||||
end
|
||||
object NonUTF8FilesCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = FilesGroupBox
|
||||
AnchorSideTop.Control = UTF8FilesCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 22
|
||||
Top = 34
|
||||
Width = 172
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'NonUTF8FilesCheckBox'
|
||||
Checked = True
|
||||
State = cbChecked
|
||||
TabOrder = 1
|
||||
end
|
||||
object RegExprCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = FilesGroupBox
|
||||
AnchorSideTop.Control = FileFilterCombobox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 22
|
||||
Top = 122
|
||||
Width = 138
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 2
|
||||
Caption = 'RegExprCheckBox'
|
||||
TabOrder = 2
|
||||
end
|
||||
object FileFilterCombobox: TComboBox
|
||||
AnchorSideLeft.Control = FilesGroupBox
|
||||
AnchorSideTop.Control = FileFilterLabel
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = FilesGroupBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 29
|
||||
Top = 91
|
||||
Width = 481
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Right = 6
|
||||
TabOrder = 3
|
||||
Text = 'FileFilterCombobox'
|
||||
end
|
||||
end
|
||||
object BtnPanel: TPanel
|
||||
Height = 41
|
||||
Top = 438
|
||||
Width = 509
|
||||
Align = alBottom
|
||||
AutoSize = True
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 41
|
||||
ClientWidth = 509
|
||||
TabOrder = 1
|
||||
object ApplyButton: TButton
|
||||
Left = 317
|
||||
Height = 29
|
||||
Top = 6
|
||||
Width = 90
|
||||
Align = alRight
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'ApplyButton'
|
||||
Constraints.MinWidth = 75
|
||||
OnClick = ApplyButtonClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object CloseButton: TButton
|
||||
Left = 413
|
||||
Height = 29
|
||||
Top = 6
|
||||
Width = 90
|
||||
Align = alRight
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'CloseButton'
|
||||
Constraints.MinWidth = 75
|
||||
ModalResult = 1
|
||||
TabOrder = 1
|
||||
end
|
||||
object PreviewButton: TButton
|
||||
Left = 208
|
||||
Height = 29
|
||||
Top = 6
|
||||
Width = 103
|
||||
Align = alRight
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'PreviewButton'
|
||||
Constraints.MinWidth = 75
|
||||
OnClick = PreviewButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
||||
object ScopeGroupBox: TGroupBox
|
||||
Left = 6
|
||||
Height = 60
|
||||
Top = 6
|
||||
Width = 497
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'ScopeGroupBox'
|
||||
ClientHeight = 41
|
||||
ClientWidth = 493
|
||||
TabOrder = 2
|
||||
object NewEncodingLabel: TLabel
|
||||
AnchorSideLeft.Control = NewEncodingComboBox
|
||||
AnchorSideTop.Control = NewEncodingComboBox
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = NewEncodingComboBox
|
||||
Left = 240
|
||||
Height = 18
|
||||
Top = 11
|
||||
Width = 120
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Left = 15
|
||||
Caption = 'NewEncodingLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object OwnerComboBox: TComboBox
|
||||
AnchorSideLeft.Control = ScopeGroupBox
|
||||
AnchorSideTop.Control = ScopeGroupBox
|
||||
AnchorSideRight.Control = NewEncodingLabel
|
||||
Left = 6
|
||||
Height = 29
|
||||
Top = 6
|
||||
Width = 219
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 0
|
||||
Text = 'OwnerComboBox'
|
||||
end
|
||||
object NewEncodingComboBox: TComboBox
|
||||
AnchorSideTop.Control = ScopeGroupBox
|
||||
AnchorSideRight.Control = ScopeGroupBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 360
|
||||
Height = 29
|
||||
Top = 6
|
||||
Width = 127
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
BorderSpacing.Right = 6
|
||||
BorderSpacing.Bottom = 6
|
||||
TabOrder = 1
|
||||
Text = 'NewEncodingComboBox'
|
||||
end
|
||||
end
|
||||
object PreviewGroupBox: TGroupBox
|
||||
Left = 6
|
||||
Height = 191
|
||||
Top = 241
|
||||
Width = 497
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'PreviewGroupBox'
|
||||
ClientHeight = 172
|
||||
ClientWidth = 493
|
||||
TabOrder = 3
|
||||
object PreviewListView: TListView
|
||||
Height = 172
|
||||
Width = 493
|
||||
Align = alClient
|
||||
Columns = <
|
||||
item
|
||||
Caption = 'Files'
|
||||
MinWidth = 75
|
||||
Width = 300
|
||||
end
|
||||
item
|
||||
Caption = 'Encoding'
|
||||
MinWidth = 75
|
||||
Width = 175
|
||||
end>
|
||||
TabOrder = 0
|
||||
ViewStyle = vsReport
|
||||
end
|
||||
end
|
||||
end
|
75
converter/chgencodingdlg.lrs
Normal file
75
converter/chgencodingdlg.lrs
Normal file
@ -0,0 +1,75 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TChgEncodingDialog','FORMDATA',[
|
||||
'TPF0'#18'TChgEncodingDialog'#17'ChgEncodingDialog'#4'Left'#3'"'#1#6'Height'#3
|
||||
+#223#1#3'Top'#3#191#0#5'Width'#3#253#1#13'ActiveControl'#7#13'OwnerComboBox'
|
||||
+#7'Caption'#6#17'ChgEncodingDialog'#12'ClientHeight'#3#223#1#11'ClientWidth'
|
||||
+#3#253#1#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#10'LCLV'
|
||||
+'ersion'#6#6'0.9.25'#0#9'TGroupBox'#13'FilesGroupBox'#4'Left'#2#6#6'Height'#3
|
||||
+#163#0#3'Top'#2'H'#5'Width'#3#241#1#5'Align'#7#5'alTop'#8'AutoSize'#9#20'Bor'
|
||||
+'derSpacing.Around'#2#6#7'Caption'#6#13'FilesGroupBox'#12'ClientHeight'#3#144
|
||||
+#0#11'ClientWidth'#3#237#1#8'TabOrder'#2#0#0#6'TLabel'#15'FileFilterLabel'#22
|
||||
+'AnchorSideLeft.Control'#7#13'FilesGroupBox'#21'AnchorSideTop.Control'#7#20
|
||||
+'NonUTF8FilesCheckBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6#6'H'
|
||||
+'eight'#2#18#3'Top'#2'G'#5'Width'#2'U'#18'BorderSpacing.Left'#2#6#17'BorderS'
|
||||
+'pacing.Top'#2#15#20'BorderSpacing.Bottom'#2#2#7'Caption'#6#15'FileFilterLab'
|
||||
+'el'#11'ParentColor'#8#0#0#9'TCheckBox'#17'UTF8FilesCheckBox'#22'AnchorSideL'
|
||||
+'eft.Control'#7#13'FilesGroupBox'#21'AnchorSideTop.Control'#7#13'FilesGroupB'
|
||||
+'ox'#4'Left'#2#6#6'Height'#2#22#3'Top'#2#6#5'Width'#3#146#0#20'BorderSpacing'
|
||||
+'.Around'#2#6#7'Caption'#6#17'UTF8FilesCheckBox'#7'Checked'#9#5'State'#7#9'c'
|
||||
+'bChecked'#8'TabOrder'#2#0#0#0#9'TCheckBox'#20'NonUTF8FilesCheckBox'#22'Anch'
|
||||
+'orSideLeft.Control'#7#13'FilesGroupBox'#21'AnchorSideTop.Control'#7#17'UTF8'
|
||||
+'FilesCheckBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2
|
||||
+#22#3'Top'#2'"'#5'Width'#3#172#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#20
|
||||
+'NonUTF8FilesCheckBox'#7'Checked'#9#5'State'#7#9'cbChecked'#8'TabOrder'#2#1#0
|
||||
+#0#9'TCheckBox'#15'RegExprCheckBox'#22'AnchorSideLeft.Control'#7#13'FilesGro'
|
||||
+'upBox'#21'AnchorSideTop.Control'#7#18'FileFilterCombobox'#18'AnchorSideTop.'
|
||||
+'Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2#22#3'Top'#2'z'#5'Width'#3#138#0
|
||||
+#18'BorderSpacing.Left'#2#6#17'BorderSpacing.Top'#2#2#7'Caption'#6#15'RegExp'
|
||||
+'rCheckBox'#8'TabOrder'#2#2#0#0#9'TComboBox'#18'FileFilterCombobox'#22'Ancho'
|
||||
+'rSideLeft.Control'#7#13'FilesGroupBox'#21'AnchorSideTop.Control'#7#15'FileF'
|
||||
+'ilterLabel'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Contro'
|
||||
+'l'#7#13'FilesGroupBox'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2#6#6
|
||||
+'Height'#2#29#3'Top'#2'['#5'Width'#3#225#1#7'Anchors'#11#5'akTop'#6'akLeft'#7
|
||||
+'akRight'#0#18'BorderSpacing.Left'#2#6#19'BorderSpacing.Right'#2#6#8'TabOrde'
|
||||
+'r'#2#3#4'Text'#6#18'FileFilterCombobox'#0#0#0#6'TPanel'#8'BtnPanel'#6'Heigh'
|
||||
+'t'#2')'#3'Top'#3#182#1#5'Width'#3#253#1#5'Align'#7#8'alBottom'#8'AutoSize'#9
|
||||
+#10'BevelOuter'#7#6'bvNone'#12'ClientHeight'#2')'#11'ClientWidth'#3#253#1#8
|
||||
+'TabOrder'#2#1#0#7'TButton'#11'ApplyButton'#4'Left'#3'='#1#6'Height'#2#29#3
|
||||
+'Top'#2#6#5'Width'#2'Z'#5'Align'#7#7'alRight'#8'AutoSize'#9#20'BorderSpacing'
|
||||
+'.Around'#2#6#7'Caption'#6#11'ApplyButton'#20'Constraints.MinWidth'#2'K'#7'O'
|
||||
+'nClick'#7#16'ApplyButtonClick'#8'TabOrder'#2#0#0#0#7'TButton'#11'CloseButto'
|
||||
+'n'#4'Left'#3#157#1#6'Height'#2#29#3'Top'#2#6#5'Width'#2'Z'#5'Align'#7#7'alR'
|
||||
+'ight'#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#7'Caption'#6#11'CloseButto'
|
||||
+'n'#20'Constraints.MinWidth'#2'K'#11'ModalResult'#2#1#8'TabOrder'#2#1#0#0#7
|
||||
+'TButton'#13'PreviewButton'#4'Left'#3#208#0#6'Height'#2#29#3'Top'#2#6#5'Widt'
|
||||
+'h'#2'g'#5'Align'#7#7'alRight'#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#7
|
||||
+'Caption'#6#13'PreviewButton'#20'Constraints.MinWidth'#2'K'#7'OnClick'#7#18
|
||||
+'PreviewButtonClick'#8'TabOrder'#2#2#0#0#0#9'TGroupBox'#13'ScopeGroupBox'#4
|
||||
+'Left'#2#6#6'Height'#2'<'#3'Top'#2#6#5'Width'#3#241#1#5'Align'#7#5'alTop'#8
|
||||
+'AutoSize'#9#20'BorderSpacing.Around'#2#6#7'Caption'#6#13'ScopeGroupBox'#12
|
||||
+'ClientHeight'#2')'#11'ClientWidth'#3#237#1#8'TabOrder'#2#2#0#6'TLabel'#16'N'
|
||||
+'ewEncodingLabel'#22'AnchorSideLeft.Control'#7#19'NewEncodingComboBox'#21'An'
|
||||
+'chorSideTop.Control'#7#19'NewEncodingComboBox'#18'AnchorSideTop.Side'#7#9'a'
|
||||
+'srCenter'#23'AnchorSideRight.Control'#7#19'NewEncodingComboBox'#4'Left'#3
|
||||
+#240#0#6'Height'#2#18#3'Top'#2#11#5'Width'#2'x'#7'Anchors'#11#5'akTop'#7'akR'
|
||||
+'ight'#0#18'BorderSpacing.Left'#2#15#7'Caption'#6#16'NewEncodingLabel'#11'Pa'
|
||||
+'rentColor'#8#0#0#9'TComboBox'#13'OwnerComboBox'#22'AnchorSideLeft.Control'#7
|
||||
+#13'ScopeGroupBox'#21'AnchorSideTop.Control'#7#13'ScopeGroupBox'#23'AnchorSi'
|
||||
+'deRight.Control'#7#16'NewEncodingLabel'#4'Left'#2#6#6'Height'#2#29#3'Top'#2
|
||||
+#6#5'Width'#3#219#0#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#20'BorderS'
|
||||
+'pacing.Around'#2#6#8'TabOrder'#2#0#4'Text'#6#13'OwnerComboBox'#0#0#9'TCombo'
|
||||
+'Box'#19'NewEncodingComboBox'#21'AnchorSideTop.Control'#7#13'ScopeGroupBox'
|
||||
+#23'AnchorSideRight.Control'#7#13'ScopeGroupBox'#20'AnchorSideRight.Side'#7#9
|
||||
+'asrBottom'#4'Left'#3'h'#1#6'Height'#2#29#3'Top'#2#6#5'Width'#2''#7'Anchors'
|
||||
+#11#5'akTop'#7'akRight'#0#17'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'#2
|
||||
+#6#20'BorderSpacing.Bottom'#2#6#8'TabOrder'#2#1#4'Text'#6#19'NewEncodingComb'
|
||||
+'oBox'#0#0#0#9'TGroupBox'#15'PreviewGroupBox'#4'Left'#2#6#6'Height'#3#191#0#3
|
||||
,'Top'#3#241#0#5'Width'#3#241#1#5'Align'#7#8'alClient'#20'BorderSpacing.Aroun'
|
||||
+'d'#2#6#7'Caption'#6#15'PreviewGroupBox'#12'ClientHeight'#3#172#0#11'ClientW'
|
||||
+'idth'#3#237#1#8'TabOrder'#2#3#0#9'TListView'#15'PreviewListView'#6'Height'#3
|
||||
+#172#0#5'Width'#3#237#1#5'Align'#7#8'alClient'#7'Columns'#14#1#7'Caption'#6#5
|
||||
+'Files'#8'MinWidth'#2'K'#5'Width'#3','#1#0#1#7'Caption'#6#8'Encoding'#8'MinW'
|
||||
+'idth'#2'K'#5'Width'#3#175#0#0#0#8'TabOrder'#2#0#9'ViewStyle'#7#8'vsReport'#0
|
||||
+#0#0#0
|
||||
]);
|
367
converter/chgencodingdlg.pas
Normal file
367
converter/chgencodingdlg.pas
Normal file
@ -0,0 +1,367 @@
|
||||
{
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
Author: Mattias Gaertner
|
||||
|
||||
Abstract:
|
||||
Dialog and functions to change encodings (e.g. UTF-8) of projects and
|
||||
packages.
|
||||
}
|
||||
unit ChgEncodingDlg;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, FileProcs, LResources, Forms, Controls, Graphics,
|
||||
Dialogs, LConvEncoding, ExtCtrls, StdCtrls, ComCtrls,
|
||||
IDEWindowIntf, SynRegExpr, SrcEditorIntf,
|
||||
CodeCache, CodeToolsStructs, CodeToolManager, AVL_Tree,
|
||||
// IDE
|
||||
IDEProcs, CodeBrowser, PackageDefs, PackageSystem, Project,
|
||||
LazarusIDEStrConsts;
|
||||
|
||||
type
|
||||
|
||||
{ TChgEncodingDialog }
|
||||
|
||||
TChgEncodingDialog = class(TForm)
|
||||
BtnPanel: TPanel;
|
||||
NewEncodingComboBox: TComboBox;
|
||||
FileFilterCombobox: TComboBox;
|
||||
NewEncodingLabel: TLabel;
|
||||
PreviewButton: TButton;
|
||||
PreviewListView: TListView;
|
||||
CloseButton: TButton;
|
||||
PreviewGroupBox: TGroupBox;
|
||||
OwnerComboBox: TComboBox;
|
||||
ScopeGroupBox: TGroupBox;
|
||||
ApplyButton: TButton;
|
||||
RegExprCheckBox: TCheckBox;
|
||||
FileFilterLabel: TLabel;
|
||||
NonUTF8FilesCheckBox: TCheckBox;
|
||||
UTF8FilesCheckBox: TCheckBox;
|
||||
FilesGroupBox: TGroupBox;
|
||||
procedure ApplyButtonClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure PreviewButtonClick(Sender: TObject);
|
||||
private
|
||||
procedure GetFiles(out Tree: TFilenameToStringTree);
|
||||
procedure UpdatePreview;
|
||||
public
|
||||
end;
|
||||
|
||||
function ShowConvertEncodingDlg: TModalResult;
|
||||
|
||||
implementation
|
||||
|
||||
function ShowConvertEncodingDlg: TModalResult;
|
||||
var
|
||||
ChgEncodingDialog: TChgEncodingDialog;
|
||||
begin
|
||||
ChgEncodingDialog:=TChgEncodingDialog.Create(nil);
|
||||
Result:=ChgEncodingDialog.ShowModal;
|
||||
ChgEncodingDialog.Free;
|
||||
end;
|
||||
|
||||
{ TChgEncodingDialog }
|
||||
|
||||
procedure TChgEncodingDialog.FormCreate(Sender: TObject);
|
||||
var
|
||||
List: TStringList;
|
||||
Encoding: string;
|
||||
i: Integer;
|
||||
begin
|
||||
IDEDialogLayoutList.ApplyLayout(Self);
|
||||
|
||||
Caption:='Convert encoding';
|
||||
|
||||
ScopeGroupBox.Caption:='Convert project or package';
|
||||
NewEncodingLabel.Caption:='New encoding:';
|
||||
FilesGroupBox.Caption:='File filter';
|
||||
UTF8FilesCheckBox.Caption:='Files in ASCII or UTF-8 encoding';
|
||||
NonUTF8FilesCheckBox.Caption:='Files not in ASCII nor UTF-8 encoding';
|
||||
FileFilterLabel.Caption:='Filter';
|
||||
RegExprCheckBox.Caption:='Regular expression';
|
||||
|
||||
PreviewButton.Caption:='Update preview';
|
||||
CloseButton.Caption:='Close';
|
||||
ApplyButton.Caption:='Convert';
|
||||
|
||||
PreviewGroupBox.Caption:='Preview';
|
||||
PreviewListView.Column[0].Caption:='Files';
|
||||
PreviewListView.Column[0].Width:=350;
|
||||
PreviewListView.Column[1].Caption:='Encoding';
|
||||
|
||||
// get possible encodings
|
||||
List:=TStringList.Create;
|
||||
GetSupportedEncodings(List);
|
||||
for i:=List.Count-1 downto 0 do begin
|
||||
Encoding:=List[i];
|
||||
if (Encoding='') or (SysUtils.CompareText(Encoding,EncodingAnsi)=0) then
|
||||
List.Delete(i);
|
||||
end;
|
||||
List.Sort;
|
||||
NewEncodingComboBox.Items.Assign(List);
|
||||
List.Free;
|
||||
NewEncodingComboBox.Text:='UTF-8';
|
||||
|
||||
// get possible filters
|
||||
List:=TStringList.Create;
|
||||
List.Add('*.pas;*.pp;*.p;*.inc;*.lpr;*.lfm;*.lrs;*.txt');
|
||||
List.Sort;
|
||||
FileFilterCombobox.Items.Assign(List);
|
||||
List.Free;
|
||||
FileFilterCombobox.Text:=FileFilterCombobox.Items[0];
|
||||
|
||||
// get possible projects and packages
|
||||
List:=TStringList.Create;
|
||||
for i:=0 to PackageGraph.Count-1 do
|
||||
if (List.IndexOf(PackageGraph[i].Name)<0)
|
||||
and (not PackageGraph[i].ReadOnly)
|
||||
and (not PackageGraph[i].IsVirtual)
|
||||
then
|
||||
List.Add(PackageGraph[i].Name);
|
||||
List.Sort;
|
||||
if not Project1.IsVirtual then
|
||||
List.Insert(0,dlgEnvProject);
|
||||
OwnerComboBox.Items.Assign(List);
|
||||
List.Free;
|
||||
if OwnerComboBox.Items.Count>0 then
|
||||
OwnerComboBox.Text:=OwnerComboBox.Items[0]
|
||||
else
|
||||
OwnerComboBox.Text:='';
|
||||
end;
|
||||
|
||||
procedure TChgEncodingDialog.ApplyButtonClick(Sender: TObject);
|
||||
var
|
||||
Buf: TCodeBuffer;
|
||||
SrcEdit: TSourceEditorInterface;
|
||||
NewEncoding: String;
|
||||
OldEncoding: String;
|
||||
Files: TFilenameToStringTree;
|
||||
Node: TAVLTreeNode;
|
||||
Item: PStringToStringTreeItem;
|
||||
Filename: String;
|
||||
Encoding: String;
|
||||
HasChanged: boolean;
|
||||
li: TListItem;
|
||||
begin
|
||||
GetFiles(Files);
|
||||
if Files=nil then exit;
|
||||
try
|
||||
NewEncoding:=NormalizeEncoding(NewEncodingComboBox.Text);
|
||||
|
||||
PreviewListView.BeginUpdate;
|
||||
PreviewListView.Items.Clear;
|
||||
Node:=Files.Tree.FindLowest;
|
||||
while Node<>nil do begin
|
||||
Item:=PStringToStringTreeItem(Node.Data);
|
||||
Filename:=Item^.Name;
|
||||
Encoding:=Item^.Value;
|
||||
DebugLn(['TChgEncodingDialog.ApplyButtonClick Filename=',Filename,' Encoding=',Encoding]);
|
||||
Buf:=CodeToolBoss.LoadFile(Filename,true,false);
|
||||
if not Buf.ReadOnly then begin
|
||||
OldEncoding:=Buf.DiskEncoding;
|
||||
SrcEdit:=SourceEditorWindow.SourceEditorIntfWithFilename(Filename);
|
||||
HasChanged:=true;
|
||||
if SrcEdit<>nil then begin
|
||||
DebugLn(['TChgEncodingDialog.ApplyButtonClick changing in source editor: ',Filename]);
|
||||
Buf.DiskEncoding:=NewEncoding;
|
||||
SrcEdit.Modified:=true;
|
||||
end else begin
|
||||
DebugLn(['TChgEncodingDialog.ApplyButtonClick changing on disk: ',Filename]);
|
||||
Buf:=CodeToolBoss.LoadFile(Filename,true,false);
|
||||
Buf.DiskEncoding:=NewEncoding;
|
||||
HasChanged:=Buf.Save;
|
||||
if not HasChanged then
|
||||
Buf.DiskEncoding:=OldEncoding;
|
||||
end;
|
||||
end;
|
||||
if not HasChanged then begin
|
||||
li:=PreviewListView.Items.Add;
|
||||
li.Caption:=Filename;
|
||||
li.SubItems.Add(Encoding);
|
||||
end;
|
||||
Node:=Files.Tree.FindSuccessor(Node);
|
||||
end;
|
||||
PreviewListView.EndUpdate;
|
||||
PreviewGroupBox.Caption:='Number of files failed to convert: '+IntToStr(PreviewListView.Items.Count);
|
||||
finally
|
||||
Files.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChgEncodingDialog.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
IDEDialogLayoutList.SaveLayout(Self);
|
||||
end;
|
||||
|
||||
procedure TChgEncodingDialog.PreviewButtonClick(Sender: TObject);
|
||||
begin
|
||||
UpdatePreview;
|
||||
end;
|
||||
|
||||
procedure TChgEncodingDialog.GetFiles(out Tree: TFilenameToStringTree);
|
||||
var
|
||||
AProject: TProject;
|
||||
SearchPath: String;
|
||||
APackage: TLazPackage;
|
||||
Dir: String;
|
||||
FileInfo: TSearchRec;
|
||||
CurFilename: String;
|
||||
Buf: TCodeBuffer;
|
||||
NewEncoding: String;
|
||||
IncludeFilterRegExpr: TRegExpr;
|
||||
CurOwner: TObject;
|
||||
Expr: String;
|
||||
ok: Boolean;
|
||||
p: Integer;
|
||||
CurEncoding: String;
|
||||
begin
|
||||
Tree:=nil;
|
||||
|
||||
// check owner
|
||||
if OwnerComboBox.Text=dlgEnvProject then
|
||||
CurOwner:=Project1
|
||||
else
|
||||
CurOwner:=PackageGraph.FindAPackageWithName(OwnerComboBox.Text,nil);
|
||||
if CurOwner=nil then begin
|
||||
DebugLn(['TChgEncodingDialog.UpdatePreview package not found: ',OwnerComboBox.Text]);
|
||||
exit;
|
||||
end;
|
||||
|
||||
// find search paths
|
||||
if CurOwner is TProject then begin
|
||||
AProject:=TProject(CurOwner);
|
||||
SearchPath:=AProject.SourceDirectories.CreateSearchPathFromAllFiles;
|
||||
SearchPath:=MergeSearchPaths(SearchPath,AProject.CompilerOptions.GetIncludePath(false));
|
||||
end else begin
|
||||
APackage:=TLazPackage(CurOwner);
|
||||
SearchPath:=APackage.SourceDirectories.CreateSearchPathFromAllFiles;
|
||||
SearchPath:=MergeSearchPaths(SearchPath,APackage.CompilerOptions.GetIncludePath(false));
|
||||
end;
|
||||
|
||||
// find files
|
||||
IncludeFilterRegExpr:=TRegExpr.Create;
|
||||
Expr:=FileFilterCombobox.Text;
|
||||
if not RegExprCheckBox.Checked then
|
||||
Expr:=SimpleSyntaxToRegExpr(Expr);
|
||||
ok:=false;
|
||||
try
|
||||
IncludeFilterRegExpr.Expression:=Expr;
|
||||
ok:=true;
|
||||
except
|
||||
on E: Exception do begin
|
||||
DebugLn('Invalid Include File Expression ',Expr,' ',E.Message);
|
||||
MessageDlg('Error in regular expression',
|
||||
E.Message,mtError,[mbCancel],0);
|
||||
end;
|
||||
end;
|
||||
if not ok then exit;
|
||||
|
||||
NewEncoding:=NormalizeEncoding(NewEncodingComboBox.Text);
|
||||
Tree:=TFilenameToStringTree.Create(FilenamesCaseSensitive);
|
||||
p:=1;
|
||||
repeat
|
||||
Dir:=GetNextDirectoryInSearchPath(SearchPath,p);
|
||||
if p>length(SearchPath) then break;
|
||||
Dir:=AppendPathDelim(Dir);
|
||||
DebugLn(['TChgEncodingDialog.GetFiles Dir=',Dir]);
|
||||
if FindFirstUTF8(Dir+FileMask,faAnyFile,FileInfo)=0 then begin
|
||||
repeat
|
||||
// check if special file
|
||||
//DebugLn(['TChgEncodingDialog.GetFiles ',FileInfo.Name,' ... ']);
|
||||
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') then
|
||||
continue;
|
||||
CurFilename:=Dir+FileInfo.Name;
|
||||
if Tree.Contains(CurFilename) then continue;
|
||||
if not IncludeFilterRegExpr.Exec(CurFilename) then begin
|
||||
DebugLn(['TChgEncodingDialog.GetFiles not matching filter: ',CurFilename]);
|
||||
continue;
|
||||
end;
|
||||
if not FileIsTextCached(CurFilename) then begin
|
||||
DebugLn(['TChgEncodingDialog.GetFiles not a text file: ',CurFilename]);
|
||||
continue;
|
||||
end;
|
||||
|
||||
if (FileInfo.Attr and faDirectory)>0 then begin
|
||||
// skip directory
|
||||
end else begin
|
||||
Buf:=CodeToolBoss.LoadFile(CurFilename,true,false);
|
||||
if Buf<>nil then begin
|
||||
//DebugLn(['TChgEncodingDialog.GetFiles Filename=',CurFilename,' Encoding=',NormalizeEncoding(Buf.DiskEncoding)]);
|
||||
CurEncoding:=NormalizeEncoding(Buf.DiskEncoding);
|
||||
if CurEncoding=NewEncoding then continue;
|
||||
if (CurEncoding=EncodingUTF8) and (not UTF8FilesCheckBox.Checked) then
|
||||
continue;
|
||||
if (CurEncoding<>EncodingUTF8)
|
||||
and (not NonUTF8FilesCheckBox.Checked) then
|
||||
continue;
|
||||
Tree[CurFilename]:=Buf.DiskEncoding;
|
||||
end else begin
|
||||
DebugLn(['TChgEncodingDialog.UpdatePreview read error: ',CurFilename]);
|
||||
end;
|
||||
end;
|
||||
until FindNextUTF8(FileInfo)<>0;
|
||||
end;
|
||||
FindCloseUTF8(FileInfo);
|
||||
until false;
|
||||
end;
|
||||
|
||||
procedure TChgEncodingDialog.UpdatePreview;
|
||||
var
|
||||
Files: TFilenameToStringTree;
|
||||
Node: TAVLTreeNode;
|
||||
Item: PStringToStringTreeItem;
|
||||
Filename: String;
|
||||
Encoding: String;
|
||||
li: TListItem;
|
||||
begin
|
||||
GetFiles(Files);
|
||||
if Files=nil then exit;
|
||||
try
|
||||
PreviewListView.BeginUpdate;
|
||||
PreviewListView.Items.Clear;
|
||||
Node:=Files.Tree.FindLowest;
|
||||
while Node<>nil do begin
|
||||
Item:=PStringToStringTreeItem(Node.Data);
|
||||
Filename:=Item^.Name;
|
||||
Encoding:=Item^.Value;
|
||||
DebugLn(['TChgEncodingDialog.UpdatePreview Filename=',Filename,' Encoding=',Encoding]);
|
||||
li:=PreviewListView.Items.Add;
|
||||
li.Caption:=Filename;
|
||||
li.SubItems.Add(Encoding);
|
||||
Node:=Files.Tree.FindSuccessor(Node);
|
||||
end;
|
||||
PreviewListView.EndUpdate;
|
||||
PreviewGroupBox.Caption:='Number of files to convert: '+IntToStr(PreviewListView.Items.Count);
|
||||
finally
|
||||
Files.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I chgencodingdlg.lrs}
|
||||
|
||||
end.
|
||||
|
@ -731,7 +731,7 @@ procedure TCodeBrowserView.WorkGatherPackages;
|
||||
begin
|
||||
List:=nil;
|
||||
try
|
||||
PackageGraph.GetAllRequiredPackages(Project1.FirstRequiredDependency,List);
|
||||
PackageGraph.GetAllRequiredPackages(FirstDependency,List);
|
||||
if (List=nil) then exit;
|
||||
for i:=0 to List.Count-1 do begin
|
||||
if TObject(List[i]) is TLazPackage then
|
||||
|
@ -360,6 +360,7 @@ begin
|
||||
ecConvertDelphiUnit: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertDelphiProject: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertDelphiPackage: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertEncoding: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecFindProcedureDefinition: SetResult(VK_UP,[ssShift,SSCtrl],VK_UNKNOWN,[]);
|
||||
ecFindProcedureMethod: SetResult(VK_DOWN,[ssShift,SSCtrl],VK_UNKNOWN,[]);
|
||||
ecFindDeclaration: SetResult(VK_UP,[ssAlt],VK_UNKNOWN,[]);
|
||||
@ -682,9 +683,10 @@ begin
|
||||
ecGuessMisplacedIFDEF: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertDFM2LFM: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecCheckLFM: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertDelphiUnit: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertDelphiProject: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertDelphiPackage: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertDelphiUnit: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertDelphiProject: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertDelphiPackage: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertEncoding: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecFindProcedureDefinition: SetResult(VK_UP,[ssShift,SSCtrl],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecFindProcedureMethod: SetResult(VK_DOWN,[ssShift,SSCtrl],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecFindDeclaration: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
@ -1189,6 +1191,7 @@ begin
|
||||
ecConvertDelphiUnit: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertDelphiProject: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertDelphiPackage: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecConvertEncoding: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
ecFindProcedureDefinition: SetResult(VK_UP,[ssShift,SSCtrl],VK_UNKNOWN,[]);
|
||||
ecFindProcedureMethod: SetResult(VK_DOWN,[ssShift,SSCtrl],VK_UNKNOWN,[]);
|
||||
ecFindDeclaration: SetResult(VK_UP,[ssAlt],VK_UNKNOWN,[]);
|
||||
@ -1618,6 +1621,7 @@ begin
|
||||
ecConvertDelphiUnit : Result:= lisMenuConvertDelphiUnit;
|
||||
ecConvertDelphiProject : Result:= lisMenuConvertDelphiProject;
|
||||
ecConvertDelphiPackage : Result:= lisMenuConvertDelphiPackage;
|
||||
ecConvertEncoding : Result:= lisMenuConvertEncoding;
|
||||
ecFindDeclaration : Result:= srkmecFindDeclaration;
|
||||
ecFindBlockOtherEnd : Result:= srkmecFindBlockOtherEnd;
|
||||
ecFindBlockStart : Result:= srkmecFindBlockStart;
|
||||
@ -2200,6 +2204,8 @@ begin
|
||||
lisKMConvertDelphiProjectToLazarusProject, ecConvertDelphiProject);
|
||||
AddDefault(C, 'Convert Delphi package to Lazarus package',
|
||||
lisKMConvertDelphiPackageToLazarusPackage, ecConvertDelphiPackage);
|
||||
AddDefault(C, 'Convert encoding',
|
||||
lisConvertEncodingOfProjectsPackages, ecConvertEncoding);
|
||||
|
||||
// environment menu
|
||||
C:=Categories[AddCategory('EnvironmentMenu',srkmCatEnvMenu,nil)];
|
||||
|
@ -365,6 +365,7 @@ resourcestring
|
||||
lisMenuConvertDelphiUnit = 'Convert Delphi unit to Lazarus unit ...';
|
||||
lisMenuConvertDelphiProject = 'Convert Delphi project to Lazarus project ...';
|
||||
lisMenuConvertDelphiPackage = 'Convert Delphi package to Lazarus package ...';
|
||||
lisMenuConvertEncoding = 'Convert encoding of projects/packages ...';
|
||||
lisMenuBuildLazarus = 'Build Lazarus';
|
||||
lisMenuConfigureBuildLazarus = 'Configure "Build Lazarus" ...';
|
||||
|
||||
@ -2016,6 +2017,8 @@ resourcestring
|
||||
srkmCatEnvMenu = 'Environment menu commands';
|
||||
lisKMConvertDelphiPackageToLazarusPackage = 'Convert Delphi package to '
|
||||
+'Lazarus package';
|
||||
lisConvertEncodingOfProjectsPackages =
|
||||
'Convert encoding of projects/packages';
|
||||
srkmCarHelpMenu = 'Help menu commands';
|
||||
lisKeyCatDesigner = 'Designer commands';
|
||||
lisKMCopySelectedComponentsToClipboard = 'Copy selected Components to '
|
||||
|
25
ide/main.pp
25
ide/main.pp
@ -117,7 +117,7 @@ uses
|
||||
CodeToolsDefines, DiffDialog, DiskDiffsDialog, UnitInfoDlg, EditorOptions,
|
||||
SourceEditProcs, MsgQuickFixes, ViewUnit_dlg,
|
||||
// converter
|
||||
DelphiUnit2Laz, DelphiProject2Laz, LazXMLForms,
|
||||
ChgEncodingDlg, DelphiUnit2Laz, DelphiProject2Laz, LazXMLForms,
|
||||
// rest of the ide
|
||||
Splash, IDEDefs, LazarusIDEStrConsts, LazConf, MsgView, SearchResultView,
|
||||
CodeTemplatesDlg, CodeBrowser,
|
||||
@ -305,6 +305,7 @@ type
|
||||
procedure mnuToolConvertDelphiUnitClicked(Sender: TObject);
|
||||
procedure mnuToolConvertDelphiProjectClicked(Sender: TObject);
|
||||
procedure mnuToolConvertDelphiPackageClicked(Sender: TObject);
|
||||
procedure mnuToolConvertEncodingClicked(Sender: TObject);
|
||||
procedure mnuToolBuildLazarusClicked(Sender: TObject);
|
||||
procedure mnuToolConfigBuildLazClicked(Sender: TObject);
|
||||
procedure mnuCustomExtToolClick(Sender: TObject);
|
||||
@ -760,14 +761,6 @@ type
|
||||
// edit menu
|
||||
procedure DoCommand(EditorCommand: integer); override;
|
||||
procedure DoSourceEditorCommand(EditorCommand: integer);
|
||||
procedure DoInsertGUID;
|
||||
|
||||
// Delphi conversion
|
||||
function DoConvertDFMtoLFM: TModalResult;
|
||||
function DoCheckLFMInEditor: TModalResult;
|
||||
function DoConvertDelphiUnit(const DelphiFilename: string): TModalResult;
|
||||
function DoConvertDelphiProject(const DelphiFilename: string): TModalResult;
|
||||
function DoConvertDelphiPackage(const DelphiFilename: string): TModalResult;
|
||||
procedure UpdateCustomToolsInMenu;
|
||||
|
||||
// external tools
|
||||
@ -887,6 +880,14 @@ type
|
||||
function DoMakeResourceString: TModalResult;
|
||||
function DoDiff: TModalResult;
|
||||
function DoFindInFiles: TModalResult;
|
||||
procedure DoInsertGUID;
|
||||
|
||||
// conversion
|
||||
function DoConvertDFMtoLFM: TModalResult;
|
||||
function DoCheckLFMInEditor: TModalResult;
|
||||
function DoConvertDelphiUnit(const DelphiFilename: string): TModalResult;
|
||||
function DoConvertDelphiProject(const DelphiFilename: string): TModalResult;
|
||||
function DoConvertDelphiPackage(const DelphiFilename: string): TModalResult;
|
||||
|
||||
// message view
|
||||
function DoJumpToCompilerMessage(Index:integer;
|
||||
@ -2213,6 +2214,7 @@ begin
|
||||
itmToolConvertDelphiUnit.OnClick := @mnuToolConvertDelphiUnitClicked;
|
||||
itmToolConvertDelphiProject.OnClick := @mnuToolConvertDelphiProjectClicked;
|
||||
itmToolConvertDelphiPackage.OnClick := @mnuToolConvertDelphiPackageClicked;
|
||||
itmToolConvertEncoding.OnClick := @mnuToolConvertEncodingClicked;
|
||||
itmToolBuildLazarus.OnClick := @mnuToolBuildLazarusClicked;
|
||||
itmToolConfigureBuildLazarus.OnClick := @mnuToolConfigBuildLazClicked;
|
||||
end;
|
||||
@ -3782,6 +3784,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.mnuToolConvertEncodingClicked(Sender: TObject);
|
||||
begin
|
||||
ShowConvertEncodingDlg;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.mnuToolBuildLazarusClicked(Sender: TObject);
|
||||
begin
|
||||
if MiscellaneousOptions.BuildLazOpts.ConfirmBuild then
|
||||
|
@ -297,6 +297,7 @@ type
|
||||
itmToolConvertDelphiProject: TIDEMenuCommand;
|
||||
itmToolConvertDelphiPackage: TIDEMenuCommand;
|
||||
itmToolConvertDFMtoLFM: TIDEMenuCommand;
|
||||
itmToolConvertEncoding: TIDEMenuCommand;
|
||||
//itmBuildingLazarus: TIDEMenuSection;
|
||||
itmToolBuildLazarus: TIDEMenuCommand;
|
||||
itmToolConfigureBuildLazarus: TIDEMenuCommand;
|
||||
|
@ -720,6 +720,7 @@ begin
|
||||
CreateMenuItem(ParentMI,itmToolConvertDelphiProject,'itmToolConvertDelphiProject',lisMenuConvertDelphiProject);
|
||||
CreateMenuItem(ParentMI,itmToolConvertDelphiPackage,'itmToolConvertDelphiPackage',lisMenuConvertDelphiPackage);
|
||||
CreateMenuItem(ParentMI,itmToolConvertDFMtoLFM,'itmToolConvertDFMtoLFM',lisMenuConvertDFMtoLFM,'menu_tool_dfm_to_lfm');
|
||||
CreateMenuItem(ParentMI,itmToolConvertEncoding,'itmToolConvertEncoding',lisMenuConvertEncoding);
|
||||
|
||||
CreateMenuSeparatorSection(mnuTools,itmBuildingLazarus,'itmBuildingLazarus');
|
||||
ParentMI:=itmBuildingLazarus;
|
||||
@ -967,6 +968,7 @@ begin
|
||||
itmToolConvertDelphiUnit.Command:=GetCommand(ecConvertDelphiUnit);
|
||||
itmToolConvertDelphiProject.Command:=GetCommand(ecConvertDelphiProject);
|
||||
itmToolConvertDelphiPackage.Command:=GetCommand(ecConvertDelphiPackage);
|
||||
itmToolConvertEncoding.Command:=GetCommand(ecConvertEncoding);
|
||||
itmToolBuildLazarus.Command:=GetCommand(ecBuildLazarus);
|
||||
itmToolConfigureBuildLazarus.Command:=GetCommand(ecConfigBuildLazarus);
|
||||
|
||||
|
@ -142,26 +142,26 @@ type
|
||||
|
||||
FSourceNoteBook: TSourceNotebook;
|
||||
|
||||
Procedure EditorMouseMoved(Sender: TObject; Shift: TShiftState; X,Y:Integer);
|
||||
Procedure EditorMouseDown(Sender: TObject; Button: TMouseButton;
|
||||
procedure EditorMouseMoved(Sender: TObject; Shift: TShiftState; X,Y:Integer);
|
||||
procedure EditorMouseDown(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X,Y: Integer);
|
||||
Procedure EditorClickLink(Sender: TObject; Button: TMouseButton;
|
||||
procedure EditorClickLink(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X,Y: Integer);
|
||||
procedure EditorMouseWheel(Sender: TObject; Shift: TShiftState;
|
||||
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
|
||||
Procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
Procedure EditorStatusChanged(Sender: TObject; Changes: TSynStatusChanges);
|
||||
procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
procedure EditorStatusChanged(Sender: TObject; Changes: TSynStatusChanges);
|
||||
procedure SetCodeBuffer(NewCodeBuffer: TCodeBuffer);
|
||||
Function GetSource: TStrings;
|
||||
function GetSource: TStrings;
|
||||
procedure SetPageName(const AValue: string);
|
||||
procedure UpdatePageName;
|
||||
Procedure SetSource(Value: TStrings);
|
||||
Function GetCurrentCursorXLine: Integer;
|
||||
Procedure SetCurrentCursorXLine(num : Integer);
|
||||
Function GetCurrentCursorYLine: Integer;
|
||||
Procedure SetCurrentCursorYLine(num: Integer);
|
||||
Function GetModified: Boolean;
|
||||
procedure SetModified(NewValue:boolean);
|
||||
procedure SetSource(Value: TStrings);
|
||||
function GetCurrentCursorXLine: Integer;
|
||||
procedure SetCurrentCursorXLine(num : Integer);
|
||||
function GetCurrentCursorYLine: Integer;
|
||||
procedure SetCurrentCursorYLine(num: Integer);
|
||||
function GetModified: Boolean; override;
|
||||
procedure SetModified(const NewValue:boolean); override;
|
||||
Function GetInsertMode: Boolean;
|
||||
procedure SetCodeTemplates(NewCodeTemplates: TSynEditAutoComplete);
|
||||
procedure SetPopupMenu(NewPopupMenu: TPopupMenu);
|
||||
@ -349,7 +349,6 @@ type
|
||||
property ErrorLine: integer read FErrorLine write SetErrorLine;
|
||||
property ExecutionLine: integer read FExecutionLine write SetExecutionLine;
|
||||
property InsertMode: Boolean read GetInsertmode;
|
||||
property Modified: Boolean read GetModified write SetModified;
|
||||
property OnAfterClose: TNotifyEvent read FOnAfterClose write FOnAfterClose;
|
||||
property OnBeforeClose: TNotifyEvent read FOnBeforeClose
|
||||
write FOnBeforeClose;
|
||||
@ -2539,7 +2538,7 @@ Begin
|
||||
Result := FEditor.Modified or FModified;
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.SetModified(NewValue:boolean);
|
||||
procedure TSourceEditor.SetModified(const NewValue:boolean);
|
||||
var
|
||||
OldModified: Boolean;
|
||||
begin
|
||||
@ -3887,7 +3886,7 @@ begin
|
||||
// the ansi encoding is shown as 'ansi (system encoding)' -> cut
|
||||
NewEncoding:=EncodingAnsi;
|
||||
end;
|
||||
DebugLn(['TSourceNotebook.EncodingClicked ',NewEncoding]);
|
||||
DebugLn(['TSourceNotebook.EncodingClicked NewEncoding=',NewEncoding]);
|
||||
if SrcEdit.CodeBuffer<>nil then begin
|
||||
OldEncoding:=NormalizeEncoding(SrcEdit.CodeBuffer.DiskEncoding);
|
||||
if OldEncoding='' then
|
||||
@ -3895,23 +3894,33 @@ begin
|
||||
if NewEncoding<>SrcEdit.CodeBuffer.DiskEncoding then begin
|
||||
DebugLn(['TSourceNotebook.EncodingClicked Old=',OldEncoding,' New=',NewEncoding]);
|
||||
if SrcEdit.ReadOnly then begin
|
||||
CurResult:=IDEQuestionDialog(lisChangeEncoding,
|
||||
Format(lisEncodingOfFileOnDiskIsNewEncodingIs, ['"',
|
||||
SrcEdit.CodeBuffer.Filename, '"', #13, OldEncoding, NewEncoding]),
|
||||
mtConfirmation, [mrOk, lisReopenWithAnotherEncoding, mrCancel], '');
|
||||
if SrcEdit.CodeBuffer.IsVirtual then
|
||||
CurResult:=mrCancel
|
||||
else
|
||||
CurResult:=IDEQuestionDialog(lisChangeEncoding,
|
||||
Format(lisEncodingOfFileOnDiskIsNewEncodingIs, ['"',
|
||||
SrcEdit.CodeBuffer.Filename, '"', #13, OldEncoding, NewEncoding]),
|
||||
mtConfirmation, [mrOk, lisReopenWithAnotherEncoding, mrCancel], '');
|
||||
end else begin
|
||||
CurResult:=IDEQuestionDialog(lisChangeEncoding,
|
||||
Format(lisEncodingOfFileOnDiskIsNewEncodingIs2, ['"',
|
||||
SrcEdit.CodeBuffer.Filename, '"', #13, OldEncoding, NewEncoding]),
|
||||
mtConfirmation, [mrYes, lisChangeFile, mrOk,
|
||||
lisReopenWithAnotherEncoding, mrCancel], '');
|
||||
if SrcEdit.CodeBuffer.IsVirtual then
|
||||
CurResult:=IDEQuestionDialog(lisChangeEncoding,
|
||||
Format(lisEncodingOfFileOnDiskIsNewEncodingIs, ['"',
|
||||
SrcEdit.CodeBuffer.Filename, '"', #13, OldEncoding, NewEncoding]),
|
||||
mtConfirmation, [mrYes, lisChangeFile, mrCancel], '')
|
||||
else
|
||||
CurResult:=IDEQuestionDialog(lisChangeEncoding,
|
||||
Format(lisEncodingOfFileOnDiskIsNewEncodingIs2, ['"',
|
||||
SrcEdit.CodeBuffer.Filename, '"', #13, OldEncoding, NewEncoding]),
|
||||
mtConfirmation, [mrYes, lisChangeFile, mrOk,
|
||||
lisReopenWithAnotherEncoding, mrCancel], '');
|
||||
end;
|
||||
if CurResult=mrYes then begin
|
||||
// change file
|
||||
SrcEdit.CodeBuffer.DiskEncoding:=NewEncoding;
|
||||
SrcEdit.Modified:=true;
|
||||
DebugLn(['TSourceNotebook.EncodingClicked ',SrcEdit.CodeBuffer.DiskEncoding]);
|
||||
if LazarusIDE.DoSaveEditorFile(SrcEdit.PageIndex,[])<>mrOk then begin
|
||||
DebugLn(['TSourceNotebook.EncodingClicked Change file to ',SrcEdit.CodeBuffer.DiskEncoding]);
|
||||
if (not SrcEdit.CodeBuffer.IsVirtual)
|
||||
and (LazarusIDE.DoSaveEditorFile(SrcEdit.PageIndex,[])<>mrOk) then begin
|
||||
DebugLn(['TSourceNotebook.EncodingClicked LazarusIDE.DoSaveEditorFile failed']);
|
||||
end;
|
||||
end else if CurResult=mrOK then begin
|
||||
|
@ -129,15 +129,16 @@ const
|
||||
ecConvertDelphiUnit = ecFirstLazarus + 108;
|
||||
ecConvertDelphiProject = ecFirstLazarus + 109;
|
||||
ecConvertDelphiPackage = ecFirstLazarus + 110;
|
||||
ecMakeResourceString = ecFirstLazarus + 111;
|
||||
ecDiff = ecFirstLazarus + 112;
|
||||
ecExtractProc = ecFirstLazarus + 113;
|
||||
ecFindIdentifierRefs = ecFirstLazarus + 114;
|
||||
ecRenameIdentifier = ecFirstLazarus + 115;
|
||||
ecInvertAssignment = ecFirstLazarus + 116;
|
||||
ecShowCodeContext = ecFirstLazarus + 117;
|
||||
ecShowAbstractMethods = ecFirstLazarus + 118;
|
||||
ecRemoveEmptyMethods = ecFirstLazarus + 119;
|
||||
ecConvertEncoding = ecFirstLazarus + 111;
|
||||
ecMakeResourceString = ecFirstLazarus + 112;
|
||||
ecDiff = ecFirstLazarus + 113;
|
||||
ecExtractProc = ecFirstLazarus + 114;
|
||||
ecFindIdentifierRefs = ecFirstLazarus + 115;
|
||||
ecRenameIdentifier = ecFirstLazarus + 116;
|
||||
ecInvertAssignment = ecFirstLazarus + 117;
|
||||
ecShowCodeContext = ecFirstLazarus + 118;
|
||||
ecShowAbstractMethods = ecFirstLazarus + 119;
|
||||
ecRemoveEmptyMethods = ecFirstLazarus + 120;
|
||||
|
||||
// file menu
|
||||
ecNew = ecFirstLazarus + 201;
|
||||
|
@ -52,6 +52,7 @@ type
|
||||
function GetFileName: string; virtual; abstract;
|
||||
function GetLines: TStrings; virtual; abstract;
|
||||
function GetLineText: string; virtual; abstract;
|
||||
function GetModified: Boolean; virtual; abstract;
|
||||
function GetReadOnly: Boolean; virtual; abstract;
|
||||
function GetSelection: string; virtual; abstract;
|
||||
function GetSelEnd: Integer; virtual; abstract;
|
||||
@ -64,6 +65,7 @@ type
|
||||
procedure SetCursorTextXY(const AValue: TPoint); virtual; abstract;
|
||||
procedure SetLines(const AValue: TStrings); virtual; abstract;
|
||||
procedure SetLineText(const AValue: string); virtual; abstract;
|
||||
procedure SetModified(const NewValue: Boolean); virtual; abstract;
|
||||
procedure SetReadOnly(const AValue: Boolean); virtual; abstract;
|
||||
procedure SetSelection(const AValue: string); virtual; abstract;
|
||||
procedure SetSelEnd(const AValue: Integer); virtual; abstract;
|
||||
@ -131,6 +133,7 @@ type
|
||||
property SelStart: Integer read GetSelStart write SetSelStart;
|
||||
property SourceText: string read GetSourceText write SetSourceText;// the whole file
|
||||
property TopLine: Integer read GetTopLine write SetTopLine;// first visible line
|
||||
property Modified: Boolean read GetModified write SetModified;
|
||||
end;
|
||||
|
||||
{ TSourceEditorWindowInterface }
|
||||
|
Loading…
Reference in New Issue
Block a user