mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-26 15:33:46 +02:00
added insert IFDEF tool from Colin
git-svn-id: trunk@5644 -
This commit is contained in:
parent
7ef0f40a46
commit
52cfcb4f89
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -452,6 +452,9 @@ ide/codetoolsoptions.pas svneol=native#text/pascal
|
||||
ide/compiler.pp svneol=native#text/pascal
|
||||
ide/compileroptions.pp svneol=native#text/pascal
|
||||
ide/componentpalette.pas svneol=native#text/pascal
|
||||
ide/condef.lfm svneol=native#text/plain
|
||||
ide/condef.lrs svneol=native#text/pascal
|
||||
ide/condef.pas svneol=native#text/pascal
|
||||
ide/customformeditor.pp svneol=native#text/pascal
|
||||
ide/debugmanager.pas svneol=native#text/pascal
|
||||
ide/debugoptionsfrm.lfm svneol=native#text/plain
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install
|
||||
the package GTKOpenGL 1.0.
|
||||
}
|
||||
}
|
||||
|
||||
unit GTKOpenGL;
|
||||
|
||||
|
151
ide/condef.lfm
Normal file
151
ide/condef.lfm
Normal file
@ -0,0 +1,151 @@
|
||||
object CondForm: TCondForm
|
||||
ActiveControl = ListBox
|
||||
Caption = 'Conditional Defines'
|
||||
ClientHeight = 239
|
||||
ClientWidth = 218
|
||||
OnClose = CondFormCLOSE
|
||||
OnCreate = CondFormCREATE
|
||||
OnDestroy = FormDestroy
|
||||
OnShow = FormShow
|
||||
Position = poMainFormCenter
|
||||
TextHeight = 13
|
||||
HorzScrollBar.Page = 219
|
||||
HorzScrollBar.Range = 186
|
||||
VertScrollBar.Page = 240
|
||||
VertScrollBar.Range = 157
|
||||
Left = 776
|
||||
Height = 239
|
||||
Top = 158
|
||||
Width = 218
|
||||
object Label1: TLabel
|
||||
Caption = '&First test'
|
||||
FocusControl = FirstTest
|
||||
Left = 6
|
||||
Height = 13
|
||||
Top = 2
|
||||
Width = 50
|
||||
end
|
||||
object Label2: TLabel
|
||||
Caption = '&Second test'
|
||||
FocusControl = SecondTest
|
||||
Left = 6
|
||||
Height = 13
|
||||
Top = 34
|
||||
Width = 73
|
||||
end
|
||||
object FirstTest: TComboBox
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
ItemHeight = 13
|
||||
Items.Strings = (
|
||||
'MSWINDOWS'
|
||||
'UNIX'
|
||||
'LINUX'
|
||||
'WIN32'
|
||||
'CLX_'
|
||||
'LCL_'
|
||||
'VCL_'
|
||||
'FPC'
|
||||
'KYLIX'
|
||||
'VER1_0'
|
||||
)
|
||||
MaxLength = 0
|
||||
ParentCtl3D = False
|
||||
TabOrder = 0
|
||||
Text = 'MSWINDOWS'
|
||||
Left = 5
|
||||
Height = 21
|
||||
Top = 14
|
||||
Width = 123
|
||||
end
|
||||
object ListBox: TListBox
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
ItemHeight = 13
|
||||
OnKeyDown = ListBoxKeyDown
|
||||
TabOrder = 2
|
||||
TopIndex = -1
|
||||
Left = 5
|
||||
Height = 160
|
||||
Top = 72
|
||||
Width = 123
|
||||
end
|
||||
object SecondTest: TComboBox
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
ItemHeight = 13
|
||||
Items.Strings = (
|
||||
'NONE'
|
||||
'ELSE'
|
||||
)
|
||||
MaxLength = 0
|
||||
ParentCtl3D = False
|
||||
TabOrder = 1
|
||||
Text = 'NONE'
|
||||
Left = 5
|
||||
Height = 21
|
||||
Top = 47
|
||||
Width = 123
|
||||
end
|
||||
object AddBtn: TBitBtn
|
||||
Anchors = [akTop, akRight]
|
||||
OnClick = AddBtnClick
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = '&Add'
|
||||
TabOrder = 3
|
||||
OnClick = AddBtnClick
|
||||
Left = 134
|
||||
Height = 25
|
||||
Top = 6
|
||||
Width = 82
|
||||
end
|
||||
object RemoveBtn: TBitBtn
|
||||
Anchors = [akTop, akRight]
|
||||
OnClick = RemoveBtnClick
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = '&Remove'
|
||||
TabOrder = 5
|
||||
OnClick = RemoveBtnClick
|
||||
Left = 133
|
||||
Height = 25
|
||||
Top = 64
|
||||
Width = 82
|
||||
end
|
||||
object OkBtn: TBitBtn
|
||||
Anchors = [akTop, akRight]
|
||||
Default = True
|
||||
Kind = bkOK
|
||||
ModalResult = 1
|
||||
Anchors = [akTop, akRight]
|
||||
Default = True
|
||||
ModalResult = 1
|
||||
Caption = '&OK'
|
||||
TabOrder = 6
|
||||
Left = 134
|
||||
Height = 25
|
||||
Top = 95
|
||||
Width = 82
|
||||
end
|
||||
object BitBtn1: TBitBtn
|
||||
Anchors = [akTop, akRight]
|
||||
Kind = bkCancel
|
||||
ModalResult = 2
|
||||
Anchors = [akTop, akRight]
|
||||
ModalResult = 2
|
||||
Cancel = True
|
||||
Caption = 'Cancel'
|
||||
TabOrder = 7
|
||||
Left = 136
|
||||
Height = 25
|
||||
Top = 125
|
||||
Width = 82
|
||||
end
|
||||
object AddInverse: TButton
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = 'Add Inverse'
|
||||
TabOrder = 4
|
||||
OnClick = AddInverseCLICK
|
||||
Left = 134
|
||||
Height = 25
|
||||
Top = 34
|
||||
Width = 82
|
||||
HelpType = htKeyword
|
||||
end
|
||||
end
|
43
ide/condef.lrs
Normal file
43
ide/condef.lrs
Normal file
@ -0,0 +1,43 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TCondForm','FORMDATA',[
|
||||
'TPF0'#9'TCondForm'#8'CondForm'#13'ActiveControl'#7#7'ListBox'#7'Caption'#6#19
|
||||
+'Conditional Defines'#12'ClientHeight'#3#239#0#11'ClientWidth'#3#218#0#7'OnC'
|
||||
+'lose'#7#13'CondFormCLOSE'#8'OnCreate'#7#14'CondFormCREATE'#9'OnDestroy'#7#11
|
||||
+'FormDestroy'#6'OnShow'#7#8'FormShow'#8'Position'#7#16'poMainFormCenter'#10
|
||||
+'TextHeight'#2#13#18'HorzScrollBar.Page'#3#219#0#19'HorzScrollBar.Range'#3
|
||||
+#186#0#18'VertScrollBar.Page'#3#240#0#19'VertScrollBar.Range'#3#157#0#4'Left'
|
||||
+#3#8#3#6'Height'#3#239#0#3'Top'#3#158#0#5'Width'#3#218#0#0#6'TLabel'#6'Label'
|
||||
+'1'#7'Caption'#6#11'&First test'#12'FocusControl'#7#9'FirstTest'#4'Left'#2#6
|
||||
+#6'Height'#2#13#3'Top'#2#2#5'Width'#2'2'#0#0#6'TLabel'#6'Label2'#7'Caption'#6
|
||||
+#12'&Second test'#12'FocusControl'#7#10'SecondTest'#4'Left'#2#6#6'Height'#2
|
||||
+#13#3'Top'#2'"'#5'Width'#2'I'#0#0#9'TComboBox'#9'FirstTest'#7'Anchors'#11#5
|
||||
+'akTop'#6'akLeft'#7'akRight'#0#10'ItemHeight'#2#13#13'Items.Strings'#1#6#9'M'
|
||||
+'SWINDOWS'#6#4'UNIX'#6#5'LINUX'#6#5'WIN32'#6#4'CLX_'#6#4'LCL_'#6#4'VCL_'#6#3
|
||||
+'FPC'#6#5'KYLIX'#6#6'VER1_0'#0#9'MaxLength'#2#0#11'ParentCtl3D'#8#8'TabOrder'
|
||||
+#2#0#4'Text'#6#9'MSWINDOWS'#4'Left'#2#5#6'Height'#2#21#3'Top'#2#14#5'Width'#2
|
||||
+'{'#0#0#8'TListBox'#7'ListBox'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8
|
||||
+'akBottom'#0#10'ItemHeight'#2#13#9'OnKeyDown'#7#14'ListBoxKeyDown'#8'TabOrde'
|
||||
+'r'#2#2#8'TopIndex'#2#255#4'Left'#2#5#6'Height'#3#160#0#3'Top'#2'H'#5'Width'
|
||||
+#2'{'#0#0#9'TComboBox'#10'SecondTest'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akR'
|
||||
+'ight'#0#10'ItemHeight'#2#13#13'Items.Strings'#1#6#4'NONE'#6#4'ELSE'#0#9'Max'
|
||||
+'Length'#2#0#11'ParentCtl3D'#8#8'TabOrder'#2#1#4'Text'#6#4'NONE'#4'Left'#2#5
|
||||
+#6'Height'#2#21#3'Top'#2'/'#5'Width'#2'{'#0#0#7'TBitBtn'#6'AddBtn'#7'Anchors'
|
||||
+#11#5'akTop'#7'akRight'#0#7'OnClick'#7#11'AddBtnClick'#7'Anchors'#11#5'akTop'
|
||||
+#7'akRight'#0#7'Caption'#6#4'&Add'#8'TabOrder'#2#3#7'OnClick'#7#11'AddBtnCli'
|
||||
+'ck'#4'Left'#3#134#0#6'Height'#2#25#3'Top'#2#6#5'Width'#2'R'#0#0#7'TBitBtn'#9
|
||||
+'RemoveBtn'#7'Anchors'#11#5'akTop'#7'akRight'#0#7'OnClick'#7#14'RemoveBtnCli'
|
||||
+'ck'#7'Anchors'#11#5'akTop'#7'akRight'#0#7'Caption'#6#7'&Remove'#8'TabOrder'
|
||||
+#2#5#7'OnClick'#7#14'RemoveBtnClick'#4'Left'#3#133#0#6'Height'#2#25#3'Top'#2
|
||||
+'@'#5'Width'#2'R'#0#0#7'TBitBtn'#5'OkBtn'#7'Anchors'#11#5'akTop'#7'akRight'#0
|
||||
+#7'Default'#9#4'Kind'#7#4'bkOK'#11'ModalResult'#2#1#7'Anchors'#11#5'akTop'#7
|
||||
+'akRight'#0#7'Default'#9#11'ModalResult'#2#1#7'Caption'#6#3'&OK'#8'TabOrder'
|
||||
+#2#6#4'Left'#3#134#0#6'Height'#2#25#3'Top'#2'_'#5'Width'#2'R'#0#0#7'TBitBtn'
|
||||
+#7'BitBtn1'#7'Anchors'#11#5'akTop'#7'akRight'#0#4'Kind'#7#8'bkCancel'#11'Mod'
|
||||
+'alResult'#2#2#7'Anchors'#11#5'akTop'#7'akRight'#0#11'ModalResult'#2#2#6'Can'
|
||||
+'cel'#9#7'Caption'#6#6'Cancel'#8'TabOrder'#2#7#4'Left'#3#136#0#6'Height'#2#25
|
||||
+#3'Top'#2'}'#5'Width'#2'R'#0#0#7'TButton'#10'AddInverse'#7'Anchors'#11#5'akT'
|
||||
+'op'#7'akRight'#0#7'Caption'#6#11'Add Inverse'#8'TabOrder'#2#4#7'OnClick'#7
|
||||
+#15'AddInverseCLICK'#4'Left'#3#134#0#6'Height'#2#25#3'Top'#2'"'#5'Width'#2'R'
|
||||
+#8'HelpType'#7#9'htKeyword'#0#0#0
|
||||
]);
|
295
ide/condef.pas
Normal file
295
ide/condef.pas
Normal file
@ -0,0 +1,295 @@
|
||||
unit ConDef;
|
||||
{$mode objfpc}{$H+}
|
||||
interface
|
||||
|
||||
(* Utility to assist in inserting conditional defines. For example, to convert
|
||||
OnCreate := @CreateHandler
|
||||
to:
|
||||
OnCreate := {$IFDEF FPC} @ {$ENDIF} CreateHandler
|
||||
select @ and then use Edit, Insert $IFDEF (default shortcut Ctrl+Shift+D),
|
||||
select "FPC,NONE" and hit rerurn. If you select one or more complete lines then the
|
||||
conditional defines are put on sepearate lines as in:
|
||||
{$IFDEF DEBUG}
|
||||
Writeln('State= ', State)
|
||||
{$ENDIF}
|
||||
The choices are listed in abbreviated form so:
|
||||
MSWINDOWS,UNIX => {$IFDEF MSWINDOWS} ... {$ENDIF} {$IFDEF UNIX} ... {$ENDIF}
|
||||
FPC,ELSE => {$IFDEF FPC} ... {$ELSE} ... {$ENDIF}
|
||||
DEBUG,NONE => {$IFDEF DEBUG} ... {$ENDIF}
|
||||
This tool is most useful when you need to put several identical conditionals in a file,
|
||||
You can add to the possible conditionals by selecting or typing the required symbols
|
||||
in "First test" and /or "Second test" and using the Add button.
|
||||
Your additons are saved in the condef.xml file in the lazarus configuration directory.
|
||||
*)
|
||||
|
||||
uses
|
||||
Messages, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons,
|
||||
Laz_XMLCfg, SysUtils, Classes;
|
||||
|
||||
type
|
||||
TCondForm = class(TForm)
|
||||
AddInverse: TButton;
|
||||
FirstTest: TComboBox;
|
||||
ListBox: TListBox;
|
||||
Label1: TLabel;
|
||||
Label2: TLabel;
|
||||
SecondTest: TComboBox;
|
||||
AddBtn: TBitBtn;
|
||||
RemoveBtn: TBitBtn;
|
||||
OkBtn: TBitBtn;
|
||||
BitBtn1: TBitBtn;
|
||||
procedure AddBtnClick(Sender: TObject);
|
||||
procedure AddInverseCLICK(Sender: TObject);
|
||||
procedure CondFormCLOSE(Sender: TObject; var CloseAction: TCloseAction);
|
||||
procedure CondFormCREATE(Sender: TObject);
|
||||
procedure RemoveBtnClick(Sender: TObject);
|
||||
procedure ListBoxKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
private
|
||||
XMLConfig: TXMLCOnfig;
|
||||
public
|
||||
Choice, First, Second, FS: string;
|
||||
procedure DeleteSelected;
|
||||
procedure SaveChoices;
|
||||
end;
|
||||
|
||||
|
||||
function ShowConDefDlg: string;
|
||||
function AddConditional(Text: string; IsPascal: Boolean):string;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
LResources, LCLType, LazConf;
|
||||
|
||||
function ShowConDefDlg: string;
|
||||
var
|
||||
DialogResult: Integer;
|
||||
CondForm: TCondForm;
|
||||
begin
|
||||
Result := '';
|
||||
CondForm := TCondForm.Create(Application);
|
||||
try
|
||||
CondForm.ActiveControl := CondForm.ListBox;
|
||||
DialogResult := CondForm.ShowModal;
|
||||
if DialogResult <> mrOK then
|
||||
Result := ''
|
||||
else
|
||||
Result := CondForm.FS;
|
||||
finally
|
||||
CondForm.Free;
|
||||
end
|
||||
end;
|
||||
|
||||
procedure TCondForm.AddBtnClick(Sender: TObject);
|
||||
begin
|
||||
ListBox.Items.Add(FirstTest.Text+','+SecondTest.Text);
|
||||
end;
|
||||
|
||||
procedure TCondForm.AddInverseCLICK(Sender: TObject);
|
||||
begin
|
||||
ListBox.Items.Add('!'+FirstTest.Text+','+SecondTest.Text);
|
||||
end;
|
||||
|
||||
procedure TCondForm.CondFormCLOSE(Sender: TObject; var CloseAction: TCloseAction);
|
||||
var
|
||||
SChanged: Boolean;
|
||||
i: Integer;
|
||||
procedure SUpdate(var s: string; n: string);
|
||||
begin
|
||||
if s <> n then begin
|
||||
SChanged := True;
|
||||
s := n;
|
||||
end;
|
||||
end;
|
||||
begin
|
||||
SChanged := False;
|
||||
with ListBox do begin
|
||||
SUpdate(Choice,Items.CommaText);
|
||||
if ItemIndex >= 0 then begin
|
||||
FS := Items[ItemIndex];
|
||||
i := Pos(',', FS);
|
||||
if i > 0 then begin
|
||||
SUpdate(First, Copy(FS, 1, i-1));
|
||||
SUpdate(Second, Copy(FS, i+1, Length(FS)));
|
||||
end
|
||||
end;
|
||||
end;
|
||||
if SChanged then
|
||||
SaveChoices;
|
||||
end;
|
||||
|
||||
procedure TCondForm.CondFormCREATE(Sender: TObject);
|
||||
var
|
||||
ConfFileName: string;
|
||||
i: Integer;
|
||||
begin
|
||||
ConfFileName:=SetDirSeparators(GetPrimaryConfigPath+'/condef.xml');
|
||||
try
|
||||
if (not FileExists(ConfFileName)) then
|
||||
XMLConfig:=TXMLConfig.CreateClean(ConfFileName)
|
||||
else
|
||||
XMLConfig:=TXMLConfig.Create(ConfFileName);
|
||||
Choice := XMLConfig.GetValue('condef/Choice', '"MSWINDOWS,UNIX","MSWINDOWS,ELSE","FPC,NONE","FPC,ELSE","DEBUG,NONE"');
|
||||
First := XMLConfig.GetValue('condef/First', 'MSWINDOWS');
|
||||
Second := XMLConfig.GetValue('condef/Second', 'UNIX');
|
||||
with ListBox do begin
|
||||
Items.CommaText := Choice;
|
||||
i := Items.IndexOf(First+','+Second);
|
||||
if i < 0 then begin
|
||||
Items.Add(First+','+Second);
|
||||
ItemIndex := 0;
|
||||
end else
|
||||
ItemIndex := i;
|
||||
end;
|
||||
except
|
||||
XMLConfig:=nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCondForm.RemoveBtnClick(Sender: TObject);
|
||||
begin
|
||||
DeleteSelected;
|
||||
end;
|
||||
|
||||
procedure TCondForm.ListBoxKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
if Key = VK_DELETE then begin
|
||||
DeleteSelected;
|
||||
Key := 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCondForm.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FreeAndNil(XMLConfig);
|
||||
end;
|
||||
|
||||
procedure TCondForm.FormShow(Sender: TObject);
|
||||
begin
|
||||
if SecondTest.Items.Count < 10 then
|
||||
SecondTest.Items.AddStrings(FirstTest.Items);
|
||||
end;
|
||||
|
||||
procedure TCondForm.DeleteSelected;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
with ListBox.Items do
|
||||
for i := Count-1 downto 0 do
|
||||
if ListBox.Selected[i] then
|
||||
Delete(i);
|
||||
end;
|
||||
|
||||
procedure TCondForm.SaveChoices;
|
||||
begin
|
||||
if Assigned(XMLConfig) then begin
|
||||
XMLConfig.SetValue('condef/Choice', Choice);
|
||||
XMLConfig.SetValue('condef/First', First);
|
||||
XMLConfig.SetValue('condef/Second', Second);
|
||||
XMLConfig.Flush;
|
||||
end;
|
||||
end;
|
||||
|
||||
function AddConditional(Text: string; IsPascal: Boolean):string;
|
||||
var
|
||||
cond, s, f: string;
|
||||
p, p1: Integer;
|
||||
IsElse, IsTwo, HasNewline: Boolean;
|
||||
Tail, Indent: string;
|
||||
function ifdef(s:string):string;
|
||||
begin
|
||||
if (s <>'') and (s[1] = '!') then begin
|
||||
if IsPascal then
|
||||
Result := 'N'
|
||||
else
|
||||
Result := 'n';
|
||||
s := Copy(s,2,Length(s)-1);
|
||||
end;
|
||||
if IsPascal then
|
||||
Result := '{$IF' + Result + 'DEF ' + s + '}'
|
||||
else
|
||||
Result := '#if' + Result + 'def ' + s;
|
||||
end;
|
||||
begin
|
||||
Result := Text;
|
||||
cond := ShowConDefDlg;
|
||||
p := Pos(',',cond);
|
||||
if p <= 0 then Exit;
|
||||
f := Copy(Cond, 1, p-1);
|
||||
s := Copy(Cond, p+1, Length(Cond));
|
||||
IsElse := CompareText(s, 'ELSE') = 0;
|
||||
IsTwo := CompareText(s, 'NONE') <> 0;
|
||||
HasNewline := Pos(#10, Text) > 0;
|
||||
if HasNewline then begin
|
||||
p := 1;
|
||||
{ leave leading newlines unchanged (outside $IFDEF) }
|
||||
while (p <= Length(Text)) and (Text[p] in [#10,#13]) do Inc(p);
|
||||
Result := Copy(Text,1,p-1);
|
||||
p1 := p;
|
||||
{ Work out current indentation, to line up $IFDEFS }
|
||||
while (p <= Length(Text)) and (Text[p] in [#9,' ']) do Inc(p);
|
||||
Indent := Copy(Text, p1, p-p1);
|
||||
Text := Copy(Text,p,Length(Text));
|
||||
p := Length(Text);
|
||||
{ Tailing whitespace is left outside $IFDEF }
|
||||
while (p>0) and (Text[p] in [' ',#9,#10,#13]) do Dec(p);
|
||||
Tail := Copy(Text, p+1, Length(Text));
|
||||
SetLength(Text,p);
|
||||
end else begin
|
||||
Result := '';
|
||||
Tail := '';
|
||||
Indent := '';
|
||||
end;
|
||||
if IsPascal then begin
|
||||
if HasNewline then begin
|
||||
Result := Result + Indent + f + LineEnding + Indent + Text + LineEnding;
|
||||
if IsElse then
|
||||
Result := Result + Indent + '{$ELSE}' + LineEnding
|
||||
else begin
|
||||
Result := Result + Indent + '{$ENDIF}';
|
||||
if IsTwo then
|
||||
Result := Result + LineEnding + Indent + s + LineEnding;
|
||||
end;
|
||||
if IsTwo then
|
||||
Result := Result + Indent + Text + LineEnding + Indent + '{$ENDIF}';
|
||||
Result := Result + Tail;
|
||||
end else begin
|
||||
Result := Result + f + ' ' + Text;
|
||||
if IsElse then
|
||||
Result := Result + ' {$ELSE} '
|
||||
else begin
|
||||
Result := Result + ' {$ENDIF}';
|
||||
if IsTwo then
|
||||
Result := Result + ' ' + s + ' ';
|
||||
end;
|
||||
if IsTwo then
|
||||
Result := Result + Text + ' {$ENDIF}';
|
||||
end;
|
||||
end else begin
|
||||
Result := Result + '#ifdef ' + f + LineEnding + indent + Text + LineEnding;
|
||||
if IsElse then
|
||||
Result := Result + '#else' + LineEnding
|
||||
else begin
|
||||
Result := Result + '#endif /* ' + f + ' */' + LineEnding;
|
||||
if IsTwo then
|
||||
Result := Result + '#ifdef '+ s + LineEnding;
|
||||
end;
|
||||
if IsTwo then begin
|
||||
Result := Result + indent + Text + LineEnding + '#endif /* ';
|
||||
if IsElse then
|
||||
Result := Result + f
|
||||
else
|
||||
Result := Result + s;
|
||||
Result := Result + ' */' + LineEnding;
|
||||
end;
|
||||
Result := Result + Tail;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I condef.lrs}
|
||||
end.
|
@ -92,6 +92,7 @@ const
|
||||
ecSelectCodeBlock = ecUserFirst + 59;
|
||||
ecSelectLine = ecUserFirst + 60;
|
||||
ecSelectParagraph = ecUserFirst + 61;
|
||||
ecSelectionConditional = ecUserFirst + 65;
|
||||
|
||||
// insert text
|
||||
ecInsertCharacter = ecUserFirst + 80;
|
||||
@ -472,6 +473,7 @@ begin
|
||||
ecSelectionEnclose: SetResult(VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
||||
ecSelectionComment: SetResult(VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
||||
ecSelectionUncomment: SetResult(VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
||||
ecSelectionConditional: SetResult(VK_D, [ssShift,ssCtrl],VK_UNKNOWN,[]);
|
||||
ecSelectionSort: SetResult(VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
||||
ecSelectionBreakLines: SetResult(VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
||||
|
||||
@ -1084,6 +1086,7 @@ begin
|
||||
ecSelectionEnclose : Result:= lismenucommentselection;
|
||||
ecSelectionComment : Result:= lismenucommentselection;
|
||||
ecSelectionUncomment : Result:= lismenuuncommentselection;
|
||||
ecSelectionConditional : Result:= lisMenuConditionalSelection;
|
||||
ecSelectionSort : Result:= lismenusortselection;
|
||||
ecSelectionBreakLines : Result:= lismenusortselection;
|
||||
ecSelectToBrace : Result:= lismenuselecttobrace;
|
||||
@ -1841,6 +1844,7 @@ begin
|
||||
AddDefault(C,'Enclose selection',ecSelectionEnclose);
|
||||
AddDefault(C,'Comment selection',ecSelectionComment);
|
||||
AddDefault(C,'Uncomment selection',ecSelectionUncomment);
|
||||
AddDefault(C,'Insert $IFDEF',ecSelectionConditional);
|
||||
AddDefault(C,'Sort selection',ecSelectionSort);
|
||||
AddDefault(C,'Break Lines in selection',ecSelectionBreakLines);
|
||||
|
||||
|
@ -130,6 +130,7 @@ resourcestring
|
||||
lisMenuEncloseSelection = 'Enclose selection';
|
||||
lisMenuCommentSelection = 'Comment selection';
|
||||
lisMenuUncommentSelection = 'Uncomment selection';
|
||||
lisMenuConditionalSelection = 'Insert $IFDEF...';
|
||||
lisMenuSortSelection = 'Sort selection';
|
||||
lisMenuBeakLinesInSelection = 'Break Lines in selection';
|
||||
lisMenuSelect = 'Select';
|
||||
|
10
ide/main.pp
10
ide/main.pp
@ -131,6 +131,7 @@ type
|
||||
procedure mnuEditTabsToSpacesBlockClicked(Sender: TObject);
|
||||
procedure mnuEditCommentBlockClicked(Sender: TObject);
|
||||
procedure mnuEditUncommentBlockClicked(Sender: TObject);
|
||||
procedure mnuEditConditionalBlockClicked(Sender: TObject);
|
||||
procedure mnuEditSortBlockClicked(Sender: TObject);
|
||||
procedure mnuEditSelectionBreakLinesClicked(Sender: TObject);
|
||||
procedure mnuEditSelectAllClick(Sender: TObject);
|
||||
@ -1532,6 +1533,7 @@ begin
|
||||
itmEditTabsToSpacesBlock.OnClick:=@mnuEditTabsToSpacesBlockClicked;
|
||||
itmEditCommentBlock.OnClick:=@mnuEditCommentBlockClicked;
|
||||
itmEditUncommentBlock.OnClick:=@mnuEditUncommentBlockClicked;
|
||||
itmEditConditionalBlock.OnClick:=@mnuEditConditionalBlockClicked;
|
||||
itmEditSortBlock.OnClick:=@mnuEditSortBlockClicked;
|
||||
itmEditSelectionBreakLines.OnClick:=@mnuEditSelectionBreakLinesClicked;
|
||||
itmEditSelectAll.OnClick:=@mnuEditSelectAllClick;
|
||||
@ -10223,6 +10225,11 @@ begin
|
||||
DoEditMenuCommand(ecSelectionUncomment);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.mnuEditConditionalBlockClicked(Sender: TObject);
|
||||
begin
|
||||
DoEditMenuCommand(ecSelectionConditional);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.mnuEditSortBlockClicked(Sender: TObject);
|
||||
begin
|
||||
DoEditMenuCommand(ecSelectionSort);
|
||||
@ -10441,6 +10448,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.735 2004/07/03 15:10:57 mattias
|
||||
added insert IFDEF tool from Colin
|
||||
|
||||
Revision 1.734 2004/07/03 13:06:28 mattias
|
||||
improved key handling for OI
|
||||
|
||||
|
@ -210,6 +210,7 @@ type
|
||||
itmEditTabsToSpacesBlock: TMenuItem;
|
||||
itmEditCommentBlock: TMenuItem;
|
||||
itmEditUncommentBlock: TMenuItem;
|
||||
itmEditConditionalBlock: TMenuItem;
|
||||
itmEditSortBlock: TMenuItem;
|
||||
itmEditSelectionBreakLines: TMenuItem;
|
||||
itmEditSelect: TMenuItem;
|
||||
@ -659,6 +660,7 @@ begin
|
||||
|
||||
CreateMenuItem(mnuEdit,itmEditCommentBlock,'itmEditCommentBlock',lisMenuCommentSelection);
|
||||
CreateMenuItem(mnuEdit,itmEditUncommentBlock,'itmEditUncommentBlock',lisMenuUncommentSelection);
|
||||
CreateMenuItem(mnuEdit,itmEditConditionalBlock,'itmEditConditionalBlock',lisMenuConditionalSelection);
|
||||
CreateMenuItem(mnuEdit,itmEditSortBlock,'itmEditSortBlock',lisMenuSortSelection);
|
||||
|
||||
mnuEdit.Add(CreateMenuSeparator);
|
||||
@ -911,6 +913,7 @@ begin
|
||||
itmEditTabsToSpacesBlock.ShortCut:=CommandToShortCut(ecSelectionTabs2Spaces);
|
||||
itmEditCommentBlock.ShortCut:=CommandToShortCut(ecSelectionComment);
|
||||
itmEditUncommentBlock.ShortCut:=CommandToShortCut(ecSelectionUncomment);
|
||||
itmEditConditionalBlock.ShortCut:=CommandToShortCut(ecSelectionConditional);
|
||||
itmEditSortBlock.ShortCut:=CommandToShortCut(ecSelectionSort);
|
||||
itmEditSelectionBreakLines.ShortCut:=CommandToShortCut(ecSelectionBreakLines);
|
||||
itmEditSelectAll.ShortCut:=CommandToShortCut(ecSelectAll);
|
||||
|
@ -54,7 +54,7 @@ uses
|
||||
FindReplaceDialog, WordCompletion, FindInFilesDlg, IDEProcs, IDEOptionDefs,
|
||||
MsgView, SearchResultView, InputHistory, LazarusIDEStrConsts,
|
||||
BaseDebugManager, Debugger, LResources, LazConf, EnvironmentOpts,
|
||||
SortSelectionDlg, EncloseSelectionDlg, DiffDialog,
|
||||
SortSelectionDlg, EncloseSelectionDlg, DiffDialog, ConDef,
|
||||
SourceEditProcs, SourceMarks, CharacterMapDlg, frmSearch;
|
||||
|
||||
type
|
||||
@ -225,6 +225,7 @@ type
|
||||
procedure TabsToSpacesInSelection;
|
||||
procedure CommentSelection;
|
||||
procedure UncommentSelection;
|
||||
procedure ConditionalSelection;
|
||||
procedure SortSelection;
|
||||
procedure BreakLinesInSelection;
|
||||
procedure SelectToBrace;
|
||||
@ -1048,6 +1049,9 @@ Begin
|
||||
ecSelectionUnComment:
|
||||
UncommentSelection;
|
||||
|
||||
ecSelectionConditional:
|
||||
ConditionalSelection;
|
||||
|
||||
ecSelectionSort:
|
||||
SortSelection;
|
||||
|
||||
@ -1257,6 +1261,32 @@ begin
|
||||
FEditor.EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.ConditionalSelection;
|
||||
var
|
||||
IsPascal: Boolean;
|
||||
i: Integer;
|
||||
P: TPoint;
|
||||
begin
|
||||
FEditor.BeginUpdate;
|
||||
FEditor.BeginUndoBlock;
|
||||
if not EditorComponent.SelAvail then begin
|
||||
P := FEditor.CaretXY;
|
||||
P.X := 0;
|
||||
FEditor.BlockBegin := P;
|
||||
Inc(P.Y);
|
||||
FEditor.BlockEnd := P;
|
||||
end;
|
||||
// ToDo: replace step by step to keep bookmarks and breakpoints
|
||||
IsPascal := True;
|
||||
i:=EditorOpts.HighlighterList.FindByHighlighter(FEditor.Highlighter);
|
||||
if i>=0 then
|
||||
IsPascal := EditorOpts.HighlighterList[i].DefaultCommentType <> comtCPP;
|
||||
FEditor.SelText:=AddConditional(EditorComponent.SelText, IsPascal);
|
||||
FEditor.EndUndoBlock;
|
||||
FEditor.EndUpdate;
|
||||
end;
|
||||
|
||||
|
||||
procedure TSourceEditor.SortSelection;
|
||||
var
|
||||
OldSelText, NewSortedText: string;
|
||||
|
Loading…
Reference in New Issue
Block a user