IDE: moved conditionals to page Other

git-svn-id: trunk@41628 -
This commit is contained in:
mattias 2013-06-09 13:17:48 +00:00
parent 28699e981c
commit e9b0f7740b
6 changed files with 1282 additions and 1213 deletions

View File

@ -167,652 +167,4 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
Align = alTop
ResizeAnchor = akTop
end
object ConditionalsGroupBox: TGroupBox
Left = 0
Height = 196
Top = 248
Width = 514
Align = alClient
Caption = 'ConditionalsGroupBox'
ClientHeight = 178
ClientWidth = 510
TabOrder = 2
inline CondSynEdit: TSynEdit
Left = 0
Height = 155
Top = 0
Width = 510
Align = alClient
Font.Height = 9
Font.Name = '-misc-dejavu sans mono-*-*-*-*-*-*-*-*-*-*-iso10646-1'
Font.Pitch = fpFixed
Font.Quality = fqNonAntialiased
ParentColor = False
ParentFont = False
TabOrder = 0
OnKeyPress = CondSynEditKeyPress
Gutter.Width = 57
Gutter.MouseActions = <
item
ClickCount = ccAny
ClickDir = cdDown
Command = emcOnMainGutterClick
end
item
Button = mbRight
Command = emcContextMenu
end>
RightGutter.Width = 0
RightGutter.MouseActions = <
item
ClickCount = ccAny
ClickDir = cdDown
Command = emcOnMainGutterClick
end
item
Button = mbRight
Command = emcContextMenu
end>
Keystrokes = <
item
Command = ecUp
ShortCut = 38
end
item
Command = ecSelUp
ShortCut = 8230
end
item
Command = ecScrollUp
ShortCut = 16422
end
item
Command = ecDown
ShortCut = 40
end
item
Command = ecSelDown
ShortCut = 8232
end
item
Command = ecScrollDown
ShortCut = 16424
end
item
Command = ecLeft
ShortCut = 37
end
item
Command = ecSelLeft
ShortCut = 8229
end
item
Command = ecWordLeft
ShortCut = 16421
end
item
Command = ecSelWordLeft
ShortCut = 24613
end
item
Command = ecRight
ShortCut = 39
end
item
Command = ecSelRight
ShortCut = 8231
end
item
Command = ecWordRight
ShortCut = 16423
end
item
Command = ecSelWordRight
ShortCut = 24615
end
item
Command = ecPageDown
ShortCut = 34
end
item
Command = ecSelPageDown
ShortCut = 8226
end
item
Command = ecPageBottom
ShortCut = 16418
end
item
Command = ecSelPageBottom
ShortCut = 24610
end
item
Command = ecPageUp
ShortCut = 33
end
item
Command = ecSelPageUp
ShortCut = 8225
end
item
Command = ecPageTop
ShortCut = 16417
end
item
Command = ecSelPageTop
ShortCut = 24609
end
item
Command = ecLineStart
ShortCut = 36
end
item
Command = ecSelLineStart
ShortCut = 8228
end
item
Command = ecEditorTop
ShortCut = 16420
end
item
Command = ecSelEditorTop
ShortCut = 24612
end
item
Command = ecLineEnd
ShortCut = 35
end
item
Command = ecSelLineEnd
ShortCut = 8227
end
item
Command = ecEditorBottom
ShortCut = 16419
end
item
Command = ecSelEditorBottom
ShortCut = 24611
end
item
Command = ecToggleMode
ShortCut = 45
end
item
Command = ecCopy
ShortCut = 16429
end
item
Command = ecPaste
ShortCut = 8237
end
item
Command = ecDeleteChar
ShortCut = 46
end
item
Command = ecCut
ShortCut = 8238
end
item
Command = ecDeleteLastChar
ShortCut = 8
end
item
Command = ecDeleteLastChar
ShortCut = 8200
end
item
Command = ecDeleteLastWord
ShortCut = 16392
end
item
Command = ecUndo
ShortCut = 32776
end
item
Command = ecRedo
ShortCut = 40968
end
item
Command = ecLineBreak
ShortCut = 13
end
item
Command = ecSelectAll
ShortCut = 16449
end
item
Command = ecCopy
ShortCut = 16451
end
item
Command = ecBlockIndent
ShortCut = 24649
end
item
Command = ecLineBreak
ShortCut = 16461
end
item
Command = ecInsertLine
ShortCut = 16462
end
item
Command = ecDeleteWord
ShortCut = 16468
end
item
Command = ecBlockUnindent
ShortCut = 24661
end
item
Command = ecPaste
ShortCut = 16470
end
item
Command = ecCut
ShortCut = 16472
end
item
Command = ecDeleteLine
ShortCut = 16473
end
item
Command = ecDeleteEOL
ShortCut = 24665
end
item
Command = ecUndo
ShortCut = 16474
end
item
Command = ecRedo
ShortCut = 24666
end
item
Command = ecGotoMarker0
ShortCut = 16432
end
item
Command = ecGotoMarker1
ShortCut = 16433
end
item
Command = ecGotoMarker2
ShortCut = 16434
end
item
Command = ecGotoMarker3
ShortCut = 16435
end
item
Command = ecGotoMarker4
ShortCut = 16436
end
item
Command = ecGotoMarker5
ShortCut = 16437
end
item
Command = ecGotoMarker6
ShortCut = 16438
end
item
Command = ecGotoMarker7
ShortCut = 16439
end
item
Command = ecGotoMarker8
ShortCut = 16440
end
item
Command = ecGotoMarker9
ShortCut = 16441
end
item
Command = ecSetMarker0
ShortCut = 24624
end
item
Command = ecSetMarker1
ShortCut = 24625
end
item
Command = ecSetMarker2
ShortCut = 24626
end
item
Command = ecSetMarker3
ShortCut = 24627
end
item
Command = ecSetMarker4
ShortCut = 24628
end
item
Command = ecSetMarker5
ShortCut = 24629
end
item
Command = ecSetMarker6
ShortCut = 24630
end
item
Command = ecSetMarker7
ShortCut = 24631
end
item
Command = ecSetMarker8
ShortCut = 24632
end
item
Command = ecSetMarker9
ShortCut = 24633
end
item
Command = EcFoldLevel1
ShortCut = 41009
end
item
Command = EcFoldLevel2
ShortCut = 41010
end
item
Command = EcFoldLevel1
ShortCut = 41011
end
item
Command = EcFoldLevel1
ShortCut = 41012
end
item
Command = EcFoldLevel1
ShortCut = 41013
end
item
Command = EcFoldLevel6
ShortCut = 41014
end
item
Command = EcFoldLevel7
ShortCut = 41015
end
item
Command = EcFoldLevel8
ShortCut = 41016
end
item
Command = EcFoldLevel9
ShortCut = 41017
end
item
Command = EcFoldLevel0
ShortCut = 41008
end
item
Command = EcFoldCurrent
ShortCut = 41005
end
item
Command = EcUnFoldCurrent
ShortCut = 41003
end
item
Command = EcToggleMarkupWord
ShortCut = 32845
end
item
Command = ecNormalSelect
ShortCut = 24654
end
item
Command = ecColumnSelect
ShortCut = 24643
end
item
Command = ecLineSelect
ShortCut = 24652
end
item
Command = ecTab
ShortCut = 9
end
item
Command = ecShiftTab
ShortCut = 8201
end
item
Command = ecMatchBracket
ShortCut = 24642
end
item
Command = ecColSelUp
ShortCut = 40998
end
item
Command = ecColSelDown
ShortCut = 41000
end
item
Command = ecColSelLeft
ShortCut = 40997
end
item
Command = ecColSelRight
ShortCut = 40999
end
item
Command = ecColSelPageDown
ShortCut = 40994
end
item
Command = ecColSelPageBottom
ShortCut = 57378
end
item
Command = ecColSelPageUp
ShortCut = 40993
end
item
Command = ecColSelPageTop
ShortCut = 57377
end
item
Command = ecColSelLineStart
ShortCut = 40996
end
item
Command = ecColSelLineEnd
ShortCut = 40995
end
item
Command = ecColSelEditorTop
ShortCut = 57380
end
item
Command = ecColSelEditorBottom
ShortCut = 57379
end>
MouseActions = <
item
ShiftMask = [ssShift, ssAlt]
ClickDir = cdDown
Command = emcStartSelections
MoveCaret = True
end
item
Shift = [ssShift]
ShiftMask = [ssShift, ssAlt]
ClickDir = cdDown
Command = emcStartSelections
MoveCaret = True
Option = 1
end
item
Shift = [ssAlt]
ShiftMask = [ssShift, ssAlt]
ClickDir = cdDown
Command = emcStartColumnSelections
MoveCaret = True
end
item
Shift = [ssShift, ssAlt]
ShiftMask = [ssShift, ssAlt]
ClickDir = cdDown
Command = emcStartColumnSelections
MoveCaret = True
Option = 1
end
item
Button = mbRight
Command = emcContextMenu
end
item
ClickCount = ccDouble
ClickDir = cdDown
Command = emcSelectWord
MoveCaret = True
end
item
ClickCount = ccTriple
ClickDir = cdDown
Command = emcSelectLine
MoveCaret = True
end
item
ClickCount = ccQuad
ClickDir = cdDown
Command = emcSelectPara
MoveCaret = True
end
item
Button = mbMiddle
ClickDir = cdDown
Command = emcPasteSelection
MoveCaret = True
end
item
Shift = [ssCtrl]
ShiftMask = [ssShift, ssAlt, ssCtrl]
Command = emcMouseLink
end>
MouseSelActions = <
item
ClickDir = cdDown
Command = emcStartDragMove
end>
Lines.Strings = (
'CondSynEdit'
)
VisibleSpecialChars = [vscSpace, vscTabAtLast]
BracketHighlightStyle = sbhsBoth
BracketMatchColor.Background = clNone
BracketMatchColor.Foreground = clNone
BracketMatchColor.Style = [fsBold]
FoldedCodeColor.Background = clNone
FoldedCodeColor.Foreground = clGray
FoldedCodeColor.FrameColor = clGray
MouseLinkColor.Background = clNone
MouseLinkColor.Foreground = clBlue
LineHighlightColor.Background = clNone
LineHighlightColor.Foreground = clNone
OnChange = CondSynEditChange
OnProcessUserCommand = CondSynEditProcessUserCommand
inline SynLeftGutterPartList1: TSynGutterPartList
object SynGutterMarks1: TSynGutterMarks
Width = 24
MouseActions = <>
end
object SynGutterLineNumber1: TSynGutterLineNumber
Width = 17
MouseActions = <>
MarkupInfo.Background = clBtnFace
MarkupInfo.Foreground = clNone
DigitCount = 2
ShowOnlyLineNumbersMultiplesOf = 1
ZeroStart = False
LeadingZeros = False
end
object SynGutterChanges1: TSynGutterChanges
Width = 4
MouseActions = <>
ModifiedColor = 59900
SavedColor = clGreen
end
object SynGutterSeparator1: TSynGutterSeparator
Width = 2
MouseActions = <>
end
object SynGutterCodeFolding1: TSynGutterCodeFolding
MouseActions = <
item
Button = mbRight
Command = emcCodeFoldContextMenu
end
item
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = emcCodeFoldCollaps
end
item
Shift = [ssShift]
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = emcCodeFoldCollaps
Option = 1
end
item
ClickCount = ccAny
ClickDir = cdDown
Command = emcNone
end>
MarkupInfo.Background = clNone
MarkupInfo.Foreground = clGray
MouseActionsExpanded = <
item
ClickCount = ccAny
ClickDir = cdDown
Command = emcCodeFoldCollaps
end>
MouseActionsCollapsed = <
item
Shift = [ssCtrl]
ShiftMask = [ssCtrl]
ClickCount = ccAny
ClickDir = cdDown
Command = emcCodeFoldExpand
end
item
ShiftMask = [ssCtrl]
ClickCount = ccAny
ClickDir = cdDown
Command = emcCodeFoldExpand
Option = 1
end>
end
end
end
object CondStatusbar: TStatusBar
Left = 0
Height = 23
Top = 155
Width = 510
Panels = <
item
Width = 80
end
item
Width = 50
end
item
Width = 50
end>
SimplePanel = False
end
end
end

View File

@ -29,13 +29,11 @@ unit Compiler_BuildMacro_Options;
interface
uses
Classes, SysUtils, Math, types, AVL_Tree, LCLProc, FileUtil, Controls, Forms,
StdCtrls, Grids, LCLType, Buttons, ExtCtrls, Dialogs, ComCtrls, Menus,
AvgLvlTree, SynEdit, SynHighlighterPas, SynEditKeyCmds, SynCompletion,
KeywordFuncLists, CodeToolsCfgScript, IDEImagesIntf, IDECommands, ProjectIntf,
PackageIntf, IDEOptionsIntf, MacroIntf, CompilerOptions, EditorOptions,
CompOptsIntf, IDEDialogs, LazarusIDEStrConsts, CompOptsModes, SourceSynEditor,
PackageDefs;
Classes, SysUtils, Controls, Forms, StdCtrls, Buttons, ExtCtrls, Dialogs,
ComCtrls,
KeywordFuncLists, CodeToolsCfgScript,
IDEImagesIntf, IDEOptionsIntf, MacroIntf, CompOptsIntf,
CompilerOptions, IDEDialogs, LazarusIDEStrConsts, PackageDefs;
type
TCBMNodeType = (
@ -60,9 +58,6 @@ type
BuildMacrosTreeView: TTreeView;
BuildMacroDefaultLabel: TLabel;
BuildMacroDescriptionLabel: TLabel;
ConditionalsGroupBox: TGroupBox;
CondStatusbar: TStatusBar;
CondSynEdit: TSynEdit;
MacrosGroupBox: TGroupBox;
MacrosSplitter: TSplitter;
Splitter1: TSplitter;
@ -75,44 +70,14 @@ type
procedure BuildMacrosTreeViewEditing(Sender: TObject; Node: TTreeNode;
var AllowEdit: Boolean);
procedure BuildMacrosTreeViewSelectionChanged(Sender: TObject);
procedure CondSynEditChange(Sender: TObject);
procedure CondSynEditKeyPress(Sender: TObject; var Key: char);
procedure CondSynEditProcessUserCommand(Sender: TObject;
var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer);
procedure CondSynEditStatusChange(Sender: TObject;
Changes: TSynStatusChanges);
procedure fSynCompletionCancel(Sender: TObject);
procedure fSynCompletionExecute(Sender: TObject);
procedure fSynCompletionKeyCompletePrefix(Sender: TObject);
procedure fSynCompletionKeyDelete(Sender: TObject);
procedure fSynCompletionKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure fSynCompletionKeyNextChar(Sender: TObject);
procedure fSynCompletionKeyPrevChar(Sender: TObject);
procedure fSynCompletionSearchPosition(var Position: integer);
procedure fSynCompletionUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
procedure fSynCompletionValidate(Sender: TObject; KeyChar: TUTF8Char;
Shift: TShiftState);
procedure OnIdle(Sender: TObject; var Done: Boolean);
private
FCompletionHistory: TStrings;
FCompletionValues: TStrings;
FDefaultVariables: TCTCfgScriptVariables;
FHighlighter: TIDESynFreePasSyn;
FBuildMacros: TIDEBuildMacros;
FIdleConnected: Boolean;
FIsPackage: boolean;
FMacrosOwner: TObject;
FStatusMessage: string;
fVarImgID: LongInt;
fValueImgID: LongInt;
fDefValueImgID: LongInt;
fEngine: TIDECfgScriptEngine;
fSynCompletion: TSynCompletion;
procedure SetBuildMacros(const AValue: TIDEBuildMacros);
procedure RebuildTreeView;
procedure SetIdleConnected(const AValue: Boolean);
procedure SetStatusMessage(const AValue: string);
function TreeViewAddBuildMacro(aBuildMacro: TLazBuildMacro): TTreeNode;
procedure TreeViewAddValue(ValuesTVNode: TTreeNode; aValue: string);
function GetNodeInfo(Node: TTreeNode; out BuildMacro: TLazBuildMacro): TCBMNodeType;
@ -121,11 +86,6 @@ type
function GetBuildMacroTVNode(aBuildMacro: TLazBuildMacro): TTreeNode;
function GetMacroNamePrefix(PrefixType: TCBMPrefixType): string;
procedure UpdateItemPropertyControls;
procedure UpdateMessages;
procedure UpdateStatusBar;
procedure StartCompletion;
procedure UpdateCompletionValues;
function GetCondCursorWord: string;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
@ -138,12 +98,6 @@ type
property MacrosOwner: TObject read FMacrosOwner;
procedure LoadFromOptions(Options: TBaseCompilerOptions);
procedure SaveToOptions(Options: TBaseCompilerOptions);
property IdleConnected: Boolean read FIdleConnected write SetIdleConnected;
property StatusMessage: string read FStatusMessage write SetStatusMessage;
property DefaultVariables: TCTCfgScriptVariables read FDefaultVariables;
property IsPackage: boolean read FIsPackage;
property CompletionValues: TStrings read FCompletionValues;
property CompletionHistory: TStrings read FCompletionHistory;
end;
implementation
@ -152,181 +106,6 @@ implementation
{ TCompOptBuildMacrosFrame }
procedure TCompOptBuildMacrosFrame.OnIdle(Sender: TObject; var Done: Boolean);
begin
IdleConnected:=false;
UpdateMessages;
end;
procedure TCompOptBuildMacrosFrame.CondSynEditChange(Sender: TObject);
begin
UpdateStatusBar;
IdleConnected:=true;
end;
procedure TCompOptBuildMacrosFrame.CondSynEditKeyPress(Sender: TObject;
var Key: char);
begin
//debugln(['TCompOptBuildMacrosFrame.CondSynEditKeyPress ',ord(Key)]);
end;
procedure TCompOptBuildMacrosFrame.CondSynEditProcessUserCommand(
Sender: TObject; var Command: TSynEditorCommand; var AChar: TUTF8Char;
Data: pointer);
begin
if (Command=ecWordCompletion) or (Command=ecIdentCompletion) then
StartCompletion;
end;
procedure TCompOptBuildMacrosFrame.CondSynEditStatusChange(Sender: TObject;
Changes: TSynStatusChanges);
begin
if fSynCompletion.TheForm.Visible then
begin
//debugln(['TCompOptBuildMacrosFrame.CondSynEditStatusChange ']);
fSynCompletion.CurrentString := GetCondCursorWord;
end;
UpdateStatusBar;
end;
procedure TCompOptBuildMacrosFrame.fSynCompletionCancel(Sender: TObject);
begin
//debugln(['TCompOptBuildMacrosFrame.fSynCompletionCancel ',fSynCompletion.TheForm.Visible]);
if fSynCompletion.TheForm.Visible then
fSynCompletion.Deactivate;
fSynCompletion.RemoveEditor(CondSynEdit);
end;
procedure TCompOptBuildMacrosFrame.fSynCompletionExecute(Sender: TObject);
begin
//debugln(['TCompOptBuildMacrosFrame.fSynCompletionExecute ']);
end;
procedure TCompOptBuildMacrosFrame.fSynCompletionKeyCompletePrefix(
Sender: TObject);
begin
//debugln(['TCompOptBuildMacrosFrame.fSynCompletionKeyCompletePrefix ToDo']);
end;
procedure TCompOptBuildMacrosFrame.fSynCompletionKeyDelete(Sender: TObject);
begin
//debugln(['TCompOptBuildMacrosFrame.fSynCompletionKeyDelete']);
end;
procedure TCompOptBuildMacrosFrame.fSynCompletionKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
//debugln(['TCompOptBuildMacrosFrame.fSynCompletionKeyDown ']);
if Key=VK_BACK then
begin
Key:=VK_UNKNOWN;
if fSynCompletion.CurrentString<>'' then
CondSynEdit.CommandProcessor(ecDeleteLastChar,#0,nil);
end;
end;
procedure TCompOptBuildMacrosFrame.fSynCompletionKeyNextChar(Sender: TObject);
var
XY: TPoint;
StartX: integer;
EndX: integer;
Line: string;
begin
XY:=CondSynEdit.LogicalCaretXY;
if XY.Y>CondSynEdit.Lines.Count then exit;
CondSynEdit.GetWordBoundsAtRowCol(XY,StartX,EndX);
if EndX<=XY.X then exit;
Line := CondSynEdit.Lines[XY.Y - 1];
inc(XY.X,UTF8CharacterLength(@Line[XY.X-1]));
CondSynEdit.LogicalCaretXY:=XY;
end;
procedure TCompOptBuildMacrosFrame.fSynCompletionKeyPrevChar(Sender: TObject);
var
XY: TPoint;
StartX: integer;
EndX: integer;
Line: string;
begin
XY:=CondSynEdit.LogicalCaretXY;
if XY.Y>CondSynEdit.Lines.Count then exit;
CondSynEdit.GetWordBoundsAtRowCol(XY,StartX,EndX);
if StartX>=XY.X then exit;
Line := CondSynEdit.Lines[XY.Y - 1];
XY.X:=UTF8FindNearestCharStart(PChar(Line),length(Line),XY.X-2)+1;
CondSynEdit.LogicalCaretXY:=XY;
end;
procedure TCompOptBuildMacrosFrame.fSynCompletionSearchPosition(
var Position: integer);
var
sl: TStringList;
Prefix: String;
s: string;
i: Integer;
begin
//debugln(['TCompOptBuildMacrosFrame.fSynCompletionSearchPosition "',fSynCompletion.CurrentString,'"']);
Prefix:=fSynCompletion.CurrentString;
sl:=TStringList.Create;
try
Position:=-1;
for i:=0 to CompletionValues.Count-1 do
begin
s:=CompletionValues[i];
if SysUtils.CompareText(Prefix,copy(s,1,length(Prefix)))<>0 then continue;
if (Position<0) or (length(Prefix)=length(s)) then
Position:=sl.Count;
sl.AddObject(s,TObject({%H-}Pointer(i)));
end;
fSynCompletion.ItemList.Assign(sl);
finally
sl.Free;
end;
end;
procedure TCompOptBuildMacrosFrame.fSynCompletionUTF8KeyPress(Sender: TObject;
var UTF8Key: TUTF8Char);
begin
//debugln(['TCompOptBuildMacrosFrame.fSynCompletionUTF8KeyPress ']);
end;
procedure TCompOptBuildMacrosFrame.fSynCompletionValidate(Sender: TObject;
KeyChar: TUTF8Char; Shift: TShiftState);
var
i: LongInt;
s: string;
p: LongInt;
TxtXY: TPoint;
TxtStartX: integer;
TxtEndX: integer;
begin
//debugln(['TCompOptBuildMacrosFrame.fSynCompletionValidate ']);
i:=fSynCompletion.Position;
if (i>=0) and (i<fSynCompletion.ItemList.Count) then begin
i:=PtrUInt(fSynCompletion.ItemList.Objects[i]);
if (i>=0) and (i<CompletionValues.Count) then begin
s:=CompletionValues[i];
p:=System.Pos(#9,s);
if p>0 then s:=copy(s,1,p-1);
TxtXY:=CondSynEdit.LogicalCaretXY;
CondSynEdit.GetWordBoundsAtRowCol(TxtXY,TxtStartX,TxtEndX);
CondSynEdit.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCompOptBuildMacrosFrame.fSynCompletionValidate'){$ENDIF};
try
CondSynEdit.BlockBegin:=Point(TxtStartX,TxtXY.Y);
CondSynEdit.BlockEnd:=Point(TxtEndX,TxtXY.Y);
CondSynEdit.SelText:=s;
finally
CondSynEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCompOptBuildMacrosFrame.fSynCompletionValidate'){$ENDIF};
end;
FCompletionHistory.Insert(0,s);
if FCompletionHistory.Count>100 then
FCompletionHistory.Delete(FCompletionHistory.Count-1);
end;
end;
fSynCompletion.Deactivate;
end;
procedure TCompOptBuildMacrosFrame.BuildMacrosTreeViewEditing(Sender: TObject;
Node: TTreeNode; var AllowEdit: Boolean);
var
@ -562,7 +341,6 @@ begin
end;
RebuildTreeView;
UpdateItemPropertyControls;
IdleConnected:=true;
end;
procedure TCompOptBuildMacrosFrame.RebuildTreeView;
@ -579,23 +357,6 @@ begin
BuildMacrosTreeView.EndUpdate;
end;
procedure TCompOptBuildMacrosFrame.SetIdleConnected(const AValue: Boolean);
begin
if FIdleConnected=AValue then exit;
FIdleConnected:=AValue;
if FIdleConnected then
Application.AddOnIdleHandler(@OnIdle)
else
Application.RemoveOnIdleHandler(@OnIdle);
end;
procedure TCompOptBuildMacrosFrame.SetStatusMessage(const AValue: string);
begin
if FStatusMessage=AValue then exit;
FStatusMessage:=AValue;
CondStatusbar.Panels[2].Text := FStatusMessage;
end;
function TCompOptBuildMacrosFrame.TreeViewAddBuildMacro(
aBuildMacro: TLazBuildMacro): TTreeNode;
var
@ -717,252 +478,11 @@ begin
BMDeleteMacroSpeedButton.Enabled:=NodeType in [cbmntBuildMacro,cbmntValue];
end;
procedure TCompOptBuildMacrosFrame.UpdateMessages;
begin
fEngine.Variables.Assign(DefaultVariables);
fEngine.Execute(CondSynEdit.Lines.Text,1);
if fEngine.ErrorCount>0 then begin
StatusMessage:=fEngine.GetErrorStr(0);
end else begin
StatusMessage:=lisNoErrors;
end;
end;
procedure TCompOptBuildMacrosFrame.UpdateStatusBar;
var
PanelCharMode: String;
PanelXY: String;
begin
PanelXY := Format(' %6d:%4d',[CondSynEdit.CaretY,CondSynEdit.CaretX]);
if CondSynEdit.InsertMode then
PanelCharMode := uepIns
else
PanelCharMode := uepOvr;
CondStatusbar.Panels[0].Text := PanelXY;
CondStatusbar.Panels[1].Text := PanelCharMode;
end;
procedure TCompOptBuildMacrosFrame.StartCompletion;
function EditorRowColumnToCompletionXY(ScreenRowCol: TPoint;
AboveRow: boolean): TPoint;
begin
if not AboveRow then
inc(ScreenRowCol.Y,1);
Result:=CondSynEdit.RowColumnToPixels(ScreenRowCol);
Result:=CondSynEdit.ClientToScreen(Result);
if fSynCompletion.TheForm.Parent<>nil then
Result:=fSynCompletion.TheForm.Parent.ScreenToClient(Result);
end;
var
LogStartX: integer;
LogEndX: integer;
LogXY: TPoint;
ScreenXY: TPoint;
XY: TPoint;
Line: String;
begin
//debugln(['TCompOptBuildMacrosFrame.StartCompletion ']);
UpdateCompletionValues;
fSynCompletion.ItemList.Assign(CompletionValues);
// get row and column of word start at cursor
LogXY:=CondSynEdit.LogicalCaretXY;
CondSynEdit.GetWordBoundsAtRowCol(LogXY,LogStartX,LogEndX);
LogEndX:=Min(LogEndX,LogXY.X);
// convert text row,column to screen row,column
ScreenXY:=CondSynEdit.PhysicalToLogicalPos(Point(LogStartX,LogXY.Y));
// convert screen row,column to coordinates for the completion form
XY:=EditorRowColumnToCompletionXY(ScreenXY,false);
if XY.Y+fSynCompletion.TheForm.Height>fSynCompletion.TheForm.Parent.ClientHeight
then begin
// place completion above text
XY:=EditorRowColumnToCompletionXY(ScreenXY,true);
dec(XY.Y,fSynCompletion.TheForm.Height);
end;
// show completion box
fSynCompletion.AddEditor(CondSynEdit);
Line:=CondSynEdit.LineText;
fSynCompletion.Execute(copy(Line,LogStartX,LogEndX-LogStartX),XY.X,XY.Y);
end;
procedure TCompOptBuildMacrosFrame.UpdateCompletionValues;
function HasWord(const aName: string): Boolean;
var
i: Integer;
s: string;
p: LongInt;
begin
for i:=0 to CompletionValues.Count-1 do begin
s:=CompletionValues[i];
p:=System.Pos(#9,s);
if p>0 then
s:=copy(s,1,p-1);
if SysUtils.CompareText(s,aName)=0 then exit(true);
end;
Result:=false;
end;
procedure AddKeyword(aName: string);
begin
CompletionValues.Add(aName);
end;
procedure AddWord(aName: string);
begin
aName:=dbgstr(aName);
if aName='' then exit;
if HasWord(aName) then exit;
CompletionValues.Add(aName);
end;
procedure AddVar(aName, aValue: string);
var
s: String;
begin
aName:=dbgstr(aName);
if aName='' then exit;
if HasWord(aName) then exit;
s:=dbgstr(aValue);
if length(s)>50 then s:=copy(s,1,50)+'...';
s:=aName+#9+aValue;
CompletionValues.Add(s);
end;
var
Node: TAVLTreeNode;
V: PCTCfgScriptVariable;
s: String;
p: PChar;
AtomStart: PChar;
Macro: TLazBuildMacro;
pcov: TParsedCompilerOptString;
pcouv: TParsedCompilerOptString;
i: Integer;
j: Integer;
begin
CompletionValues.Clear;
// add default variables with values
Node:=DefaultVariables.Tree.FindLowest;
while Node<>nil do begin
V:=PCTCfgScriptVariable(Node.Data);
AddVar(V^.Name,GetCTCSVariableAsString(V));
Node:=DefaultVariables.Tree.FindSuccessor(Node);
end;
// add keywords and operands
AddKeyword('if');
AddKeyword('then');
AddKeyword('else');
AddKeyword('begin');
AddKeyword('end');
AddKeyword('not');
AddKeyword('and');
AddKeyword('or');
AddKeyword('xor');
AddKeyword('undefine');
AddKeyword('defined');
AddKeyword('undefined');
AddKeyword('integer');
AddKeyword('int64');
AddKeyword('string');
AddKeyword('true');
AddKeyword('false');
// add IDE functions
AddWord('GetIDEValue(''OS'')');
AddWord('GetIDEValue(''CPU'')');
AddWord('GetIDEValue(''SrcOS'')');
AddWord('GetIDEValue(''SrcOS2'')');
AddWord('GetIDEValue(''LCLWidgetType'')');
AddWord('GetEnv(''USER'')');
AddWord('GetEnv(''HOME'')');
// add result variables
for pcov:=low(ParsedCompilerOptsVars) to high(ParsedCompilerOptsVars) do
AddWord(ParsedCompilerOptsVars[pcov]);
if FIsPackage then
for pcouv:=low(ParsedCompilerOptsUsageVars) to high(ParsedCompilerOptsUsageVars) do
AddWord(ParsedCompilerOptsUsageVars[pcouv]);
// add build macros and values
if BuildMacros<>nil then begin
for i:=0 to BuildMacros.Count-1 do
begin
Macro:=BuildMacros[i];
AddWord(Macro.Identifier);
for j:=0 to Macro.Values.Count-1 do
AddWord(Macro.Values[j]);
end;
end;
// add words in text
s:=CondSynEdit.Lines.Text;
if s<>'' then begin
p:=PChar(s);
repeat
AtomStart:=p;
while (AtomStart^<>#0) and not IsIdentStartChar[AtomStart^] do
inc(AtomStart);
if (AtomStart^=#0) then break;
p:=AtomStart;
while IsIdentChar[p^] do inc(p);
AddWord(copy(s,AtomStart-PChar(s)+1,p-AtomStart));
until false;
end;
// sort alphabetically
TStringList(FCompletionValues).Sort;
// push recently used words upwards
for i:=CompletionHistory.Count-1 downto 0 do begin
j:=CompletionValues.IndexOf(CompletionHistory[i]);
if j>0 then
CompletionValues.Move(j,0);
end;
// set index
for i:=0 to CompletionValues.Count-1 do
CompletionValues.Objects[i]:=TObject({%H-}Pointer(i));
//debugln(['TCompOptBuildMacrosFrame.UpdateCompletionValues ',CompletionValues.Text]);
end;
function TCompOptBuildMacrosFrame.GetCondCursorWord: string;
var
XY: TPoint;
StartX: integer;
EndX: integer;
Line: string;
begin
XY:=CondSynEdit.LogicalCaretXY;
if (XY.Y>=1) and (XY.Y<=CondSynEdit.Lines.Count) then
begin
CondSynEdit.GetWordBoundsAtRowCol(XY,StartX,EndX);
//debugln(['TCompOptBuildMacrosFrame.GetCondCursorWord ',StartX,' ',EndX,' ',XY.X]);
EndX:=Min(EndX,XY.X);
Line := CondSynEdit.Lines[XY.Y - 1];
Result:= Copy(Line, StartX, EndX - StartX);
end else
Result:='';
//debugln(['TCompOptBuildMacrosFrame.GetCondCursorWord "',Result,'"']);
end;
constructor TCompOptBuildMacrosFrame.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FCompletionValues:=TStringList.Create;
FCompletionHistory:=TStringList.Create;
fDefaultVariables:=TCTCfgScriptVariables.Create;
FBuildMacros:=TIDEBuildMacros.Create(nil);
fEngine:=TIDECfgScriptEngine.Create;
MacrosGroupBox.Caption:=lisIDEMacros;
BuildMacrosTreeView.Images := IDEImages.Images_24;
@ -974,34 +494,13 @@ begin
lisHintADefaultValueCanBeDefinedInTheConditionals;
BuildMacroDescriptionLabel.Caption:=lisCodeToolsDefsDescription;
ConditionalsGroupBox.Caption:=lisConditionals;
CondSynEdit.OnStatusChange:=@CondSynEditStatusChange;
BMAddMacroSpeedButton.LoadGlyphFromLazarusResource('laz_add');
BMAddMacroValueSpeedButton.LoadGlyphFromLazarusResource('laz_add');
BMDeleteMacroSpeedButton.LoadGlyphFromLazarusResource('laz_delete');
fSynCompletion:=TSynCompletion.Create(Self);
fSynCompletion.TheForm.Parent:=Self;
fSynCompletion.OnExecute:=@fSynCompletionExecute;
fSynCompletion.OnCancel:=@fSynCompletionCancel;
fSynCompletion.OnValidate:=@fSynCompletionValidate;
fSynCompletion.OnSearchPosition:=@fSynCompletionSearchPosition;
fSynCompletion.OnKeyCompletePrefix:=@fSynCompletionKeyCompletePrefix;
fSynCompletion.OnUTF8KeyPress:=@fSynCompletionUTF8KeyPress;
fSynCompletion.OnKeyNextChar:=@fSynCompletionKeyNextChar;
fSynCompletion.OnKeyPrevChar:=@fSynCompletionKeyPrevChar;
fSynCompletion.OnKeyDelete:=@fSynCompletionKeyDelete;
fSynCompletion.OnKeyDown:=@fSynCompletionKeyDown;
end;
destructor TCompOptBuildMacrosFrame.Destroy;
begin
FreeAndNil(FCompletionHistory);
FreeAndNil(FCompletionValues);
FreeAndNil(fDefaultVariables);
FreeAndNil(fEngine);
FreeAndNil(FBuildMacros);
inherited Destroy;
end;
@ -1033,33 +532,13 @@ begin
end;
procedure TCompOptBuildMacrosFrame.LoadFromOptions(Options: TBaseCompilerOptions);
var
Vars: TCTCfgScriptVariables;
begin
FIsPackage:=Options is TPkgCompilerOptions;
BuildMacros:=Options.BuildMacros as TIDEBuildMacros;
Vars:=GetBuildMacroValues(Options,false);
if Vars<>nil then
DefaultVariables.Assign(Vars)
else
DefaultVariables.Clear;
CondSynEdit.Lines.Text:=Options.Conditionals;
if FHighlighter=nil then
begin
FHighlighter := TPreviewPasSyn.Create(Self);
CondSynEdit.Highlighter:=FHighlighter;
end;
EditorOpts.ReadHighlighterSettings(FHighlighter, '');
EditorOpts.GetSynEditSettings(CondSynEdit);
UpdateStatusBar;
end;
procedure TCompOptBuildMacrosFrame.SaveToOptions(Options: TBaseCompilerOptions);
begin
(Options.BuildMacros as TIDEBuildMacros).Assign(BuildMacros);
Options.Conditionals:=CondSynEdit.Lines.Text;
end;
initialization

View File

@ -1,27 +1,29 @@
inherited CompilerOtherOptionsFrame: TCompilerOtherOptionsFrame
Height = 486
Width = 553
ClientHeight = 486
ClientWidth = 553
object CompilerOtherOptionsFrame: TCompilerOtherOptionsFrame
Left = 0
Height = 446
Top = 0
Width = 594
ClientHeight = 446
ClientWidth = 594
TabOrder = 0
DesignLeft = 434
DesignTop = 276
object grpConfigFile: TGroupBox[0]
object grpConfigFile: TGroupBox
Left = 0
Height = 97
Height = 114
Top = 0
Width = 553
Width = 594
Align = alTop
AutoSize = True
Caption = 'grpConfigFile'
ClientHeight = 79
ClientWidth = 549
ClientHeight = 97
ClientWidth = 590
TabOrder = 0
object chkConfigFile: TCheckBox
Left = 6
Height = 17
Height = 24
Top = 6
Width = 537
Width = 578
Align = alTop
BorderSpacing.Around = 6
Caption = 'chkConfigFile'
@ -29,9 +31,9 @@ inherited CompilerOtherOptionsFrame: TCompilerOtherOptionsFrame
end
object chkCustomConfigFile: TCheckBox
Left = 6
Height = 17
Top = 29
Width = 537
Height = 24
Top = 36
Width = 578
Align = alTop
BorderSpacing.Around = 6
Caption = 'chkCustomConfigFile'
@ -40,31 +42,31 @@ inherited CompilerOtherOptionsFrame: TCompilerOtherOptionsFrame
end
object edtConfigPath: TEdit
Left = 6
Height = 21
Top = 52
Width = 537
Height = 25
Top = 66
Width = 578
Align = alTop
BorderSpacing.Around = 6
TabOrder = 2
Text = 'edtConfigPath'
end
end
object grpCustomOptions: TGroupBox[1]
object grpCustomOptions: TGroupBox
Left = 0
Height = 383
Top = 103
Width = 553
Align = alClient
Height = 170
Top = 120
Width = 594
Align = alTop
BorderSpacing.Top = 6
Caption = 'grpCustomOptions'
ClientHeight = 365
ClientWidth = 549
ClientHeight = 153
ClientWidth = 590
TabOrder = 1
object memCustomOptions: TMemo
Left = 6
Height = 353
Height = 141
Top = 6
Width = 537
Width = 578
Align = alClient
BorderSpacing.Around = 6
ParentShowHint = False
@ -72,4 +74,680 @@ inherited CompilerOtherOptionsFrame: TCompilerOtherOptionsFrame
TabOrder = 0
end
end
object ConditionalsGroupBox: TGroupBox
Left = 0
Height = 151
Top = 295
Width = 594
Align = alClient
Caption = 'ConditionalsGroupBox'
ClientHeight = 134
ClientWidth = 590
TabOrder = 2
inline CondSynEdit: TSynEdit
Left = 0
Height = 115
Top = 0
Width = 590
Align = alClient
Font.Height = 9
Font.Name = '-misc-dejavu sans mono-*-*-*-*-*-*-*-*-*-*-iso10646-1'
Font.Pitch = fpFixed
Font.Quality = fqNonAntialiased
ParentColor = False
ParentFont = False
TabOrder = 0
OnKeyPress = CondSynEditKeyPress
Gutter.Width = 51
Gutter.MouseActions = <
item
ClickCount = ccAny
ClickDir = cdDown
Command = emcOnMainGutterClick
end
item
Button = mbRight
Command = emcContextMenu
end>
RightGutter.Width = 0
RightGutter.MouseActions = <
item
ClickCount = ccAny
ClickDir = cdDown
Command = emcOnMainGutterClick
end
item
Button = mbRight
Command = emcContextMenu
end>
Keystrokes = <
item
Command = ecUp
ShortCut = 38
end
item
Command = ecSelUp
ShortCut = 8230
end
item
Command = ecScrollUp
ShortCut = 16422
end
item
Command = ecDown
ShortCut = 40
end
item
Command = ecSelDown
ShortCut = 8232
end
item
Command = ecScrollDown
ShortCut = 16424
end
item
Command = ecLeft
ShortCut = 37
end
item
Command = ecSelLeft
ShortCut = 8229
end
item
Command = ecWordLeft
ShortCut = 16421
end
item
Command = ecSelWordLeft
ShortCut = 24613
end
item
Command = ecRight
ShortCut = 39
end
item
Command = ecSelRight
ShortCut = 8231
end
item
Command = ecWordRight
ShortCut = 16423
end
item
Command = ecSelWordRight
ShortCut = 24615
end
item
Command = ecPageDown
ShortCut = 34
end
item
Command = ecSelPageDown
ShortCut = 8226
end
item
Command = ecPageBottom
ShortCut = 16418
end
item
Command = ecSelPageBottom
ShortCut = 24610
end
item
Command = ecPageUp
ShortCut = 33
end
item
Command = ecSelPageUp
ShortCut = 8225
end
item
Command = ecPageTop
ShortCut = 16417
end
item
Command = ecSelPageTop
ShortCut = 24609
end
item
Command = ecLineStart
ShortCut = 36
end
item
Command = ecSelLineStart
ShortCut = 8228
end
item
Command = ecEditorTop
ShortCut = 16420
end
item
Command = ecSelEditorTop
ShortCut = 24612
end
item
Command = ecLineEnd
ShortCut = 35
end
item
Command = ecSelLineEnd
ShortCut = 8227
end
item
Command = ecEditorBottom
ShortCut = 16419
end
item
Command = ecSelEditorBottom
ShortCut = 24611
end
item
Command = ecToggleMode
ShortCut = 45
end
item
Command = ecCopy
ShortCut = 16429
end
item
Command = ecPaste
ShortCut = 8237
end
item
Command = ecDeleteChar
ShortCut = 46
end
item
Command = ecCut
ShortCut = 8238
end
item
Command = ecDeleteLastChar
ShortCut = 8
end
item
Command = ecDeleteLastChar
ShortCut = 8200
end
item
Command = ecDeleteLastWord
ShortCut = 16392
end
item
Command = ecUndo
ShortCut = 32776
end
item
Command = ecRedo
ShortCut = 40968
end
item
Command = ecLineBreak
ShortCut = 13
end
item
Command = ecSelectAll
ShortCut = 16449
end
item
Command = ecCopy
ShortCut = 16451
end
item
Command = ecBlockIndent
ShortCut = 24649
end
item
Command = ecLineBreak
ShortCut = 16461
end
item
Command = ecInsertLine
ShortCut = 16462
end
item
Command = ecDeleteWord
ShortCut = 16468
end
item
Command = ecBlockUnindent
ShortCut = 24661
end
item
Command = ecPaste
ShortCut = 16470
end
item
Command = ecCut
ShortCut = 16472
end
item
Command = ecDeleteLine
ShortCut = 16473
end
item
Command = ecDeleteEOL
ShortCut = 24665
end
item
Command = ecUndo
ShortCut = 16474
end
item
Command = ecRedo
ShortCut = 24666
end
item
Command = ecGotoMarker0
ShortCut = 16432
end
item
Command = ecGotoMarker1
ShortCut = 16433
end
item
Command = ecGotoMarker2
ShortCut = 16434
end
item
Command = ecGotoMarker3
ShortCut = 16435
end
item
Command = ecGotoMarker4
ShortCut = 16436
end
item
Command = ecGotoMarker5
ShortCut = 16437
end
item
Command = ecGotoMarker6
ShortCut = 16438
end
item
Command = ecGotoMarker7
ShortCut = 16439
end
item
Command = ecGotoMarker8
ShortCut = 16440
end
item
Command = ecGotoMarker9
ShortCut = 16441
end
item
Command = ecSetMarker0
ShortCut = 24624
end
item
Command = ecSetMarker1
ShortCut = 24625
end
item
Command = ecSetMarker2
ShortCut = 24626
end
item
Command = ecSetMarker3
ShortCut = 24627
end
item
Command = ecSetMarker4
ShortCut = 24628
end
item
Command = ecSetMarker5
ShortCut = 24629
end
item
Command = ecSetMarker6
ShortCut = 24630
end
item
Command = ecSetMarker7
ShortCut = 24631
end
item
Command = ecSetMarker8
ShortCut = 24632
end
item
Command = ecSetMarker9
ShortCut = 24633
end
item
Command = EcFoldLevel1
ShortCut = 41009
end
item
Command = EcFoldLevel2
ShortCut = 41010
end
item
Command = EcFoldLevel1
ShortCut = 41011
end
item
Command = EcFoldLevel1
ShortCut = 41012
end
item
Command = EcFoldLevel1
ShortCut = 41013
end
item
Command = EcFoldLevel6
ShortCut = 41014
end
item
Command = EcFoldLevel7
ShortCut = 41015
end
item
Command = EcFoldLevel8
ShortCut = 41016
end
item
Command = EcFoldLevel9
ShortCut = 41017
end
item
Command = EcFoldLevel0
ShortCut = 41008
end
item
Command = EcFoldCurrent
ShortCut = 41005
end
item
Command = EcUnFoldCurrent
ShortCut = 41003
end
item
Command = EcToggleMarkupWord
ShortCut = 32845
end
item
Command = ecNormalSelect
ShortCut = 24654
end
item
Command = ecColumnSelect
ShortCut = 24643
end
item
Command = ecLineSelect
ShortCut = 24652
end
item
Command = ecTab
ShortCut = 9
end
item
Command = ecShiftTab
ShortCut = 8201
end
item
Command = ecMatchBracket
ShortCut = 24642
end
item
Command = ecColSelUp
ShortCut = 40998
end
item
Command = ecColSelDown
ShortCut = 41000
end
item
Command = ecColSelLeft
ShortCut = 40997
end
item
Command = ecColSelRight
ShortCut = 40999
end
item
Command = ecColSelPageDown
ShortCut = 40994
end
item
Command = ecColSelPageBottom
ShortCut = 57378
end
item
Command = ecColSelPageUp
ShortCut = 40993
end
item
Command = ecColSelPageTop
ShortCut = 57377
end
item
Command = ecColSelLineStart
ShortCut = 40996
end
item
Command = ecColSelLineEnd
ShortCut = 40995
end
item
Command = ecColSelEditorTop
ShortCut = 57380
end
item
Command = ecColSelEditorBottom
ShortCut = 57379
end>
MouseActions = <
item
ShiftMask = [ssShift, ssAlt]
ClickDir = cdDown
Command = emcStartSelections
MoveCaret = True
end
item
Shift = [ssShift]
ShiftMask = [ssShift, ssAlt]
ClickDir = cdDown
Command = emcStartSelections
MoveCaret = True
Option = 1
end
item
Shift = [ssAlt]
ShiftMask = [ssShift, ssAlt]
ClickDir = cdDown
Command = emcStartColumnSelections
MoveCaret = True
end
item
Shift = [ssShift, ssAlt]
ShiftMask = [ssShift, ssAlt]
ClickDir = cdDown
Command = emcStartColumnSelections
MoveCaret = True
Option = 1
end
item
Button = mbRight
Command = emcContextMenu
end
item
ClickCount = ccDouble
ClickDir = cdDown
Command = emcSelectWord
MoveCaret = True
end
item
ClickCount = ccTriple
ClickDir = cdDown
Command = emcSelectLine
MoveCaret = True
end
item
ClickCount = ccQuad
ClickDir = cdDown
Command = emcSelectPara
MoveCaret = True
end
item
Button = mbMiddle
ClickDir = cdDown
Command = emcPasteSelection
MoveCaret = True
end
item
Shift = [ssCtrl]
ShiftMask = [ssShift, ssAlt, ssCtrl]
Command = emcMouseLink
end>
MouseSelActions = <
item
ClickDir = cdDown
Command = emcStartDragMove
end>
Lines.Strings = (
'CondSynEdit'
)
VisibleSpecialChars = [vscSpace, vscTabAtLast]
SelectedColor.FrameEdges = sfeAround
SelectedColor.BackPriority = 50
SelectedColor.ForePriority = 50
SelectedColor.FramePriority = 50
SelectedColor.BoldPriority = 50
SelectedColor.ItalicPriority = 50
SelectedColor.UnderlinePriority = 50
SelectedColor.StrikeOutPriority = 50
IncrementColor.FrameEdges = sfeAround
HighlightAllColor.FrameEdges = sfeAround
BracketHighlightStyle = sbhsBoth
BracketMatchColor.Background = clNone
BracketMatchColor.Foreground = clNone
BracketMatchColor.FrameEdges = sfeAround
BracketMatchColor.Style = [fsBold]
FoldedCodeColor.Background = clNone
FoldedCodeColor.Foreground = clGray
FoldedCodeColor.FrameColor = clGray
FoldedCodeColor.FrameEdges = sfeAround
MouseLinkColor.Background = clNone
MouseLinkColor.Foreground = clBlue
MouseLinkColor.FrameEdges = sfeAround
LineHighlightColor.Background = clNone
LineHighlightColor.Foreground = clNone
LineHighlightColor.FrameEdges = sfeAround
OnChange = CondSynEditChange
OnProcessUserCommand = CondSynEditProcessUserCommand
inline SynLeftGutterPartList1: TSynGutterPartList
object SynGutterMarks1: TSynGutterMarks
Width = 24
MouseActions = <>
end
object SynGutterLineNumber1: TSynGutterLineNumber
Width = 11
MouseActions = <>
MarkupInfo.Background = clBtnFace
MarkupInfo.Foreground = clNone
MarkupInfo.FrameEdges = sfeAround
DigitCount = 2
ShowOnlyLineNumbersMultiplesOf = 1
ZeroStart = False
LeadingZeros = False
end
object SynGutterChanges1: TSynGutterChanges
Width = 4
MouseActions = <>
ModifiedColor = 59900
SavedColor = clGreen
end
object SynGutterSeparator1: TSynGutterSeparator
Width = 2
MouseActions = <>
MarkupInfo.Background = clWhite
MarkupInfo.Foreground = clGray
MarkupInfo.FrameEdges = sfeAround
end
object SynGutterCodeFolding1: TSynGutterCodeFolding
MouseActions = <
item
Button = mbRight
Command = emcCodeFoldContextMenu
end
item
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = emcCodeFoldCollaps
end
item
Shift = [ssShift]
ShiftMask = [ssShift]
Button = mbMiddle
ClickCount = ccAny
ClickDir = cdDown
Command = emcCodeFoldCollaps
Option = 1
end
item
ClickCount = ccAny
ClickDir = cdDown
Command = emcNone
end>
MarkupInfo.Background = clNone
MarkupInfo.Foreground = clGray
MarkupInfo.FrameEdges = sfeAround
MouseActionsExpanded = <
item
ClickCount = ccAny
ClickDir = cdDown
Command = emcCodeFoldCollaps
end>
MouseActionsCollapsed = <
item
Shift = [ssCtrl]
ShiftMask = [ssCtrl]
ClickCount = ccAny
ClickDir = cdDown
Command = emcCodeFoldExpand
end
item
ShiftMask = [ssCtrl]
ClickCount = ccAny
ClickDir = cdDown
Command = emcCodeFoldExpand
Option = 1
end>
end
end
end
object CondStatusbar: TStatusBar
Left = 0
Height = 19
Top = 115
Width = 590
Panels = <
item
Width = 80
end
item
Width = 50
end
item
Width = 50
end>
SimplePanel = False
end
end
object ConditionalsSplitter: TSplitter
Cursor = crVSplit
Left = 0
Height = 5
Top = 290
Width = 594
Align = alTop
ResizeAnchor = akTop
end
end

View File

@ -1,13 +1,41 @@
unit compiler_other_options;
{***************************************************************************
* *
* 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. *
* *
***************************************************************************
Abstract:
Frame to edit custom options and conditionals of compiler options
(project+packages).
}
unit Compiler_Other_Options;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
LCLProc, IDEOptionsIntf, IDEDialogs, Project, CompilerOptions,
LazarusIDEStrConsts;
Classes, SysUtils, math, AVL_Tree, LazLogger, FileUtil,
Forms, Controls, Graphics, Dialogs, StdCtrls, LCLProc, ComCtrls, LCLType,
ExtCtrls,
CodeToolsCfgScript, KeywordFuncLists,
SynEdit, SynEditKeyCmds, SynCompletion,
IDEOptionsIntf, CompOptsIntf,
IDEDialogs, IDECommands, Project, CompilerOptions, LazarusIDEStrConsts,
SourceSynEditor, EditorOptions, PackageDefs;
type
@ -16,22 +44,70 @@ type
TCompilerOtherOptionsFrame = class(TAbstractIDEOptionsEditor)
chkConfigFile: TCheckBox;
chkCustomConfigFile: TCheckBox;
ConditionalsSplitter: TSplitter;
edtConfigPath: TEdit;
grpConfigFile: TGroupBox;
grpCustomOptions: TGroupBox;
memCustomOptions: TMemo;
ConditionalsGroupBox: TGroupBox;
CondStatusbar: TStatusBar;
CondSynEdit: TSynEdit;
procedure chkCustomConfigFileClick(Sender: TObject);
procedure CondSynEditChange(Sender: TObject);
procedure CondSynEditKeyPress(Sender: TObject; var Key: char);
procedure CondSynEditProcessUserCommand(Sender: TObject;
var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer);
procedure CondSynEditStatusChange(Sender: TObject;
Changes: TSynStatusChanges);
procedure fSynCompletionCancel(Sender: TObject);
procedure fSynCompletionExecute(Sender: TObject);
procedure fSynCompletionKeyCompletePrefix(Sender: TObject);
procedure fSynCompletionKeyDelete(Sender: TObject);
procedure fSynCompletionKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure fSynCompletionKeyNextChar(Sender: TObject);
procedure fSynCompletionKeyPrevChar(Sender: TObject);
procedure fSynCompletionSearchPosition(var Position: integer);
procedure fSynCompletionUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
procedure fSynCompletionValidate(Sender: TObject; KeyChar: TUTF8Char;
Shift: TShiftState);
private
FCompOptions: TBaseCompilerOptions;
FIdleConnected: Boolean;
FIsPackage: boolean;
FOptions: TBaseCompilerOptions;
FHasProjectCompilerOpts: boolean;
FCompletionHistory: TStrings;
FCompletionValues: TStrings;
FDefaultVariables: TCTCfgScriptVariables;
FHighlighter: TIDESynFreePasSyn;
FStatusMessage: string;
fEngine: TIDECfgScriptEngine;
fSynCompletion: TSynCompletion;
procedure SetIdleConnected(AValue: Boolean);
procedure SetStatusMessage(const AValue: string);
procedure StartCompletion;
procedure UpdateCompletionValues;
function GetCondCursorWord: string;
procedure UpdateMessages;
procedure UpdateStatusBar;
procedure OnIdle(Sender: TObject; var Done: Boolean);
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
function Check: Boolean; override;
function GetTitle: string; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
property StatusMessage: string read FStatusMessage write SetStatusMessage;
property DefaultVariables: TCTCfgScriptVariables read FDefaultVariables;
property CompletionValues: TStrings read FCompletionValues;
property CompletionHistory: TStrings read FCompletionHistory;
property IdleConnected: Boolean read FIdleConnected write SetIdleConnected;
property IsPackage: boolean read FIsPackage;
property CompOptions: TBaseCompilerOptions read FCompOptions;
end;
implementation
@ -45,10 +121,469 @@ begin
edtConfigPath.Enabled := chkCustomConfigFile.Checked;
end;
procedure TCompilerOtherOptionsFrame.CondSynEditChange(Sender: TObject);
begin
UpdateStatusBar;
IdleConnected:=true;
end;
procedure TCompilerOtherOptionsFrame.CondSynEditKeyPress(Sender: TObject;
var Key: char);
begin
//debugln(['TCompilerOtherOptionsFrame.CondSynEditKeyPress ',ord(Key)]);
end;
procedure TCompilerOtherOptionsFrame.CondSynEditProcessUserCommand(
Sender: TObject; var Command: TSynEditorCommand; var AChar: TUTF8Char;
Data: pointer);
begin
if (Command=ecWordCompletion) or (Command=ecIdentCompletion) then
StartCompletion;
end;
procedure TCompilerOtherOptionsFrame.CondSynEditStatusChange(Sender: TObject;
Changes: TSynStatusChanges);
begin
if fSynCompletion.TheForm.Visible then
begin
//debugln(['TCompilerOtherOptionsFrame.CondSynEditStatusChange ']);
fSynCompletion.CurrentString := GetCondCursorWord;
end;
UpdateStatusBar;
end;
procedure TCompilerOtherOptionsFrame.fSynCompletionCancel(Sender: TObject);
begin
//debugln(['TCompilerOtherOptionsFrame.fSynCompletionCancel ',fSynCompletion.TheForm.Visible]);
if fSynCompletion.TheForm.Visible then
fSynCompletion.Deactivate;
fSynCompletion.RemoveEditor(CondSynEdit);
end;
procedure TCompilerOtherOptionsFrame.fSynCompletionExecute(Sender: TObject);
begin
//debugln(['TCompilerOtherOptionsFrame.fSynCompletionExecute ']);
end;
procedure TCompilerOtherOptionsFrame.fSynCompletionKeyCompletePrefix(
Sender: TObject);
begin
//debugln(['TCompilerOtherOptionsFrame.fSynCompletionKeyCompletePrefix ToDo']);
end;
procedure TCompilerOtherOptionsFrame.fSynCompletionKeyDelete(Sender: TObject);
begin
//debugln(['TCompilerOtherOptionsFrame.fSynCompletionKeyDelete']);
end;
procedure TCompilerOtherOptionsFrame.fSynCompletionKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
//debugln(['TCompilerOtherOptionsFrame.fSynCompletionKeyDown ']);
if Key=VK_BACK then
begin
Key:=VK_UNKNOWN;
if fSynCompletion.CurrentString<>'' then
CondSynEdit.CommandProcessor(ecDeleteLastChar,#0,nil);
end;
end;
procedure TCompilerOtherOptionsFrame.fSynCompletionKeyNextChar(Sender: TObject);
var
XY: TPoint;
StartX: integer;
EndX: integer;
Line: string;
begin
XY:=CondSynEdit.LogicalCaretXY;
if XY.Y>CondSynEdit.Lines.Count then exit;
CondSynEdit.GetWordBoundsAtRowCol(XY,StartX,EndX);
if EndX<=XY.X then exit;
Line := CondSynEdit.Lines[XY.Y - 1];
inc(XY.X,UTF8CharacterLength(@Line[XY.X-1]));
CondSynEdit.LogicalCaretXY:=XY;
end;
procedure TCompilerOtherOptionsFrame.fSynCompletionKeyPrevChar(Sender: TObject);
var
XY: TPoint;
StartX: integer;
EndX: integer;
Line: string;
begin
XY:=CondSynEdit.LogicalCaretXY;
if XY.Y>CondSynEdit.Lines.Count then exit;
CondSynEdit.GetWordBoundsAtRowCol(XY,StartX,EndX);
if StartX>=XY.X then exit;
Line := CondSynEdit.Lines[XY.Y - 1];
XY.X:=UTF8FindNearestCharStart(PChar(Line),length(Line),XY.X-2)+1;
CondSynEdit.LogicalCaretXY:=XY;
end;
procedure TCompilerOtherOptionsFrame.fSynCompletionSearchPosition(
var Position: integer);
var
sl: TStringList;
Prefix: String;
s: string;
i: Integer;
begin
//debugln(['TCompilerOtherOptionsFrame.fSynCompletionSearchPosition "',fSynCompletion.CurrentString,'"']);
Prefix:=fSynCompletion.CurrentString;
sl:=TStringList.Create;
try
Position:=-1;
for i:=0 to CompletionValues.Count-1 do
begin
s:=CompletionValues[i];
if SysUtils.CompareText(Prefix,copy(s,1,length(Prefix)))<>0 then continue;
if (Position<0) or (length(Prefix)=length(s)) then
Position:=sl.Count;
sl.AddObject(s,TObject({%H-}Pointer(i)));
end;
fSynCompletion.ItemList.Assign(sl);
finally
sl.Free;
end;
end;
procedure TCompilerOtherOptionsFrame.fSynCompletionUTF8KeyPress(Sender: TObject;
var UTF8Key: TUTF8Char);
begin
//debugln(['TCompilerOtherOptionsFrame.fSynCompletionUTF8KeyPress ']);
end;
procedure TCompilerOtherOptionsFrame.fSynCompletionValidate(Sender: TObject;
KeyChar: TUTF8Char; Shift: TShiftState);
var
i: LongInt;
s: string;
p: LongInt;
TxtXY: TPoint;
TxtStartX: integer;
TxtEndX: integer;
begin
//debugln(['TCompilerOtherOptionsFrame.fSynCompletionValidate ']);
i:=fSynCompletion.Position;
if (i>=0) and (i<fSynCompletion.ItemList.Count) then begin
i:=PtrUInt(fSynCompletion.ItemList.Objects[i]);
if (i>=0) and (i<CompletionValues.Count) then begin
s:=CompletionValues[i];
p:=System.Pos(#9,s);
if p>0 then s:=copy(s,1,p-1);
TxtXY:=CondSynEdit.LogicalCaretXY;
CondSynEdit.GetWordBoundsAtRowCol(TxtXY,TxtStartX,TxtEndX);
CondSynEdit.BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCompilerOtherOptionsFrame.fSynCompletionValidate'){$ENDIF};
try
CondSynEdit.BlockBegin:=Point(TxtStartX,TxtXY.Y);
CondSynEdit.BlockEnd:=Point(TxtEndX,TxtXY.Y);
CondSynEdit.SelText:=s;
finally
CondSynEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCompilerOtherOptionsFrame.fSynCompletionValidate'){$ENDIF};
end;
FCompletionHistory.Insert(0,s);
if FCompletionHistory.Count>100 then
FCompletionHistory.Delete(FCompletionHistory.Count-1);
end;
end;
fSynCompletion.Deactivate;
end;
procedure TCompilerOtherOptionsFrame.SetStatusMessage(const AValue: string);
begin
if FStatusMessage=AValue then exit;
FStatusMessage:=AValue;
CondStatusbar.Panels[2].Text := FStatusMessage;
end;
procedure TCompilerOtherOptionsFrame.SetIdleConnected(AValue: Boolean);
begin
if FIdleConnected=AValue then exit;
FIdleConnected:=AValue;
if FIdleConnected then
Application.AddOnIdleHandler(@OnIdle)
else
Application.RemoveOnIdleHandler(@OnIdle);
end;
procedure TCompilerOtherOptionsFrame.StartCompletion;
function EditorRowColumnToCompletionXY(ScreenRowCol: TPoint;
AboveRow: boolean): TPoint;
begin
if not AboveRow then
inc(ScreenRowCol.Y,1);
Result:=CondSynEdit.RowColumnToPixels(ScreenRowCol);
Result:=CondSynEdit.ClientToScreen(Result);
if fSynCompletion.TheForm.Parent<>nil then
Result:=fSynCompletion.TheForm.Parent.ScreenToClient(Result);
end;
var
LogStartX: integer;
LogEndX: integer;
LogXY: TPoint;
ScreenXY: TPoint;
XY: TPoint;
Line: String;
begin
//debugln(['TCompOptBuildMacrosFrame.StartCompletion ']);
UpdateCompletionValues;
fSynCompletion.ItemList.Assign(CompletionValues);
// get row and column of word start at cursor
LogXY:=CondSynEdit.LogicalCaretXY;
CondSynEdit.GetWordBoundsAtRowCol(LogXY,LogStartX,LogEndX);
LogEndX:=Min(LogEndX,LogXY.X);
// convert text row,column to screen row,column
ScreenXY:=CondSynEdit.PhysicalToLogicalPos(Point(LogStartX,LogXY.Y));
// convert screen row,column to coordinates for the completion form
XY:=EditorRowColumnToCompletionXY(ScreenXY,false);
if XY.Y+fSynCompletion.TheForm.Height>fSynCompletion.TheForm.Parent.ClientHeight
then begin
// place completion above text
XY:=EditorRowColumnToCompletionXY(ScreenXY,true);
dec(XY.Y,fSynCompletion.TheForm.Height);
end;
// show completion box
fSynCompletion.AddEditor(CondSynEdit);
Line:=CondSynEdit.LineText;
fSynCompletion.Execute(copy(Line,LogStartX,LogEndX-LogStartX),XY.X,XY.Y);
end;
procedure TCompilerOtherOptionsFrame.UpdateCompletionValues;
function HasWord(const aName: string): Boolean;
var
i: Integer;
s: string;
p: LongInt;
begin
for i:=0 to CompletionValues.Count-1 do begin
s:=CompletionValues[i];
p:=System.Pos(#9,s);
if p>0 then
s:=copy(s,1,p-1);
if SysUtils.CompareText(s,aName)=0 then exit(true);
end;
Result:=false;
end;
procedure AddKeyword(aName: string);
begin
CompletionValues.Add(aName);
end;
procedure AddWord(aName: string);
begin
aName:=dbgstr(aName);
if aName='' then exit;
if HasWord(aName) then exit;
CompletionValues.Add(aName);
end;
procedure AddVar(aName, aValue: string);
var
s: String;
begin
aName:=dbgstr(aName);
if aName='' then exit;
if HasWord(aName) then exit;
s:=dbgstr(aValue);
if length(s)>50 then s:=copy(s,1,50)+'...';
s:=aName+#9+aValue;
CompletionValues.Add(s);
end;
var
Node: TAVLTreeNode;
V: PCTCfgScriptVariable;
s: String;
p: PChar;
AtomStart: PChar;
pcov: TParsedCompilerOptString;
pcouv: TParsedCompilerOptString;
i: Integer;
j: Integer;
Macro: TLazBuildMacro;
begin
CompletionValues.Clear;
// add default variables with values
Node:=DefaultVariables.Tree.FindLowest;
while Node<>nil do begin
V:=PCTCfgScriptVariable(Node.Data);
AddVar(V^.Name,GetCTCSVariableAsString(V));
Node:=DefaultVariables.Tree.FindSuccessor(Node);
end;
// add keywords and operands
AddKeyword('if');
AddKeyword('then');
AddKeyword('else');
AddKeyword('begin');
AddKeyword('end');
AddKeyword('not');
AddKeyword('and');
AddKeyword('or');
AddKeyword('xor');
AddKeyword('undefine');
AddKeyword('defined');
AddKeyword('undefined');
AddKeyword('integer');
AddKeyword('int64');
AddKeyword('string');
AddKeyword('true');
AddKeyword('false');
// add IDE functions
AddWord('GetIDEValue(''OS'')');
AddWord('GetIDEValue(''CPU'')');
AddWord('GetIDEValue(''SrcOS'')');
AddWord('GetIDEValue(''SrcOS2'')');
AddWord('GetIDEValue(''LCLWidgetType'')');
AddWord('GetEnv(''USER'')');
AddWord('GetEnv(''HOME'')');
// add result variables
for pcov:=low(ParsedCompilerOptsVars) to high(ParsedCompilerOptsVars) do
AddWord(ParsedCompilerOptsVars[pcov]);
if FIsPackage then
for pcouv:=low(ParsedCompilerOptsUsageVars) to high(ParsedCompilerOptsUsageVars) do
AddWord(ParsedCompilerOptsUsageVars[pcouv]);
// add build macros and values
if CompOptions.BuildMacros<>nil then begin
for i:=0 to CompOptions.BuildMacros.Count-1 do
begin
Macro:=CompOptions.BuildMacros[i];
AddWord(Macro.Identifier);
for j:=0 to Macro.Values.Count-1 do
AddWord(Macro.Values[j]);
end;
end;
// add words in text
s:=CondSynEdit.Lines.Text;
if s<>'' then begin
p:=PChar(s);
repeat
AtomStart:=p;
while (AtomStart^<>#0) and not IsIdentStartChar[AtomStart^] do
inc(AtomStart);
if (AtomStart^=#0) then break;
p:=AtomStart;
while IsIdentChar[p^] do inc(p);
AddWord(copy(s,AtomStart-PChar(s)+1,p-AtomStart));
until false;
end;
// sort alphabetically
TStringList(FCompletionValues).Sort;
// push recently used words upwards
for i:=CompletionHistory.Count-1 downto 0 do begin
j:=CompletionValues.IndexOf(CompletionHistory[i]);
if j>0 then
CompletionValues.Move(j,0);
end;
// set index
for i:=0 to CompletionValues.Count-1 do
CompletionValues.Objects[i]:=TObject({%H-}Pointer(i));
//debugln(['TCompOptBuildMacrosFrame.UpdateCompletionValues ',CompletionValues.Text]);
end;
function TCompilerOtherOptionsFrame.GetCondCursorWord: string;
var
XY: TPoint;
StartX: integer;
EndX: integer;
Line: string;
begin
XY:=CondSynEdit.LogicalCaretXY;
if (XY.Y>=1) and (XY.Y<=CondSynEdit.Lines.Count) then
begin
CondSynEdit.GetWordBoundsAtRowCol(XY,StartX,EndX);
//debugln(['TCompOptBuildMacrosFrame.GetCondCursorWord ',StartX,' ',EndX,' ',XY.X]);
EndX:=Min(EndX,XY.X);
Line := CondSynEdit.Lines[XY.Y - 1];
Result:= Copy(Line, StartX, EndX - StartX);
end else
Result:='';
//debugln(['TCompOptBuildMacrosFrame.GetCondCursorWord "',Result,'"']);
end;
procedure TCompilerOtherOptionsFrame.UpdateMessages;
begin
fEngine.Variables.Assign(DefaultVariables);
fEngine.Execute(CondSynEdit.Lines.Text,1);
if fEngine.ErrorCount>0 then begin
StatusMessage:=fEngine.GetErrorStr(0);
end else begin
StatusMessage:=lisNoErrors;
end;
end;
procedure TCompilerOtherOptionsFrame.UpdateStatusBar;
var
PanelCharMode: String;
PanelXY: String;
begin
PanelXY := Format(' %6d:%4d',[CondSynEdit.CaretY,CondSynEdit.CaretX]);
if CondSynEdit.InsertMode then
PanelCharMode := uepIns
else
PanelCharMode := uepOvr;
CondStatusbar.Panels[0].Text := PanelXY;
CondStatusbar.Panels[1].Text := PanelCharMode;
end;
procedure TCompilerOtherOptionsFrame.OnIdle(Sender: TObject; var Done: Boolean);
begin
IdleConnected:=false;
UpdateMessages;
end;
constructor TCompilerOtherOptionsFrame.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FOptions := nil;
FCompletionValues:=TStringList.Create;
FCompletionHistory:=TStringList.Create;
fDefaultVariables:=TCTCfgScriptVariables.Create;
fEngine:=TIDECfgScriptEngine.Create;
ConditionalsGroupBox.Caption:=lisConditionals;
CondSynEdit.OnStatusChange:=@CondSynEditStatusChange;
fSynCompletion:=TSynCompletion.Create(Self);
fSynCompletion.TheForm.Parent:=Self;
fSynCompletion.OnExecute:=@fSynCompletionExecute;
fSynCompletion.OnCancel:=@fSynCompletionCancel;
fSynCompletion.OnValidate:=@fSynCompletionValidate;
fSynCompletion.OnSearchPosition:=@fSynCompletionSearchPosition;
fSynCompletion.OnKeyCompletePrefix:=@fSynCompletionKeyCompletePrefix;
fSynCompletion.OnUTF8KeyPress:=@fSynCompletionUTF8KeyPress;
fSynCompletion.OnKeyNextChar:=@fSynCompletionKeyNextChar;
fSynCompletion.OnKeyPrevChar:=@fSynCompletionKeyPrevChar;
fSynCompletion.OnKeyDelete:=@fSynCompletionKeyDelete;
fSynCompletion.OnKeyDown:=@fSynCompletionKeyDown;
end;
destructor TCompilerOtherOptionsFrame.Destroy;
begin
FreeAndNil(FCompletionHistory);
FreeAndNil(FCompletionValues);
FreeAndNil(fDefaultVariables);
FreeAndNil(fEngine);
inherited Destroy;
end;
function TCompilerOtherOptionsFrame.Check: Boolean;
@ -106,11 +641,13 @@ begin
end;
procedure TCompilerOtherOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
var
Vars: TCTCfgScriptVariables;
begin
if FOptions = nil then
FOptions := AOptions as TBaseCompilerOptions;
FHasProjectCompilerOpts := (AOptions is TProjectCompilerOptions);
with AOptions as TBaseCompilerOptions do
FCompOptions:=AOptions as TBaseCompilerOptions;
FIsPackage:=CompOptions is TPkgCompilerOptions;
with CompOptions do
begin
chkConfigFile.Checked := not DontUseConfigFile;
chkCustomConfigFile.Checked := CustomConfigFile;
@ -118,17 +655,39 @@ begin
edtConfigPath.Text := ConfigFilePath;
memCustomOptions.Text := CustomOptions;
end;
Vars:=GetBuildMacroValues(CompOptions,false);
if Vars<>nil then
DefaultVariables.Assign(Vars)
else
DefaultVariables.Clear;
CondSynEdit.Lines.Text:=CompOptions.Conditionals;
if FHighlighter=nil then
begin
FHighlighter := TPreviewPasSyn.Create(Self);
CondSynEdit.Highlighter:=FHighlighter;
end;
EditorOpts.ReadHighlighterSettings(FHighlighter, '');
EditorOpts.GetSynEditSettings(CondSynEdit);
UpdateStatusBar;
end;
procedure TCompilerOtherOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
var
CurOptions: TBaseCompilerOptions;
begin
with AOptions as TBaseCompilerOptions do
CurOptions:=AOptions as TBaseCompilerOptions;
with CurOptions do
begin
DontUseConfigFile := not chkConfigFile.Checked;
CustomConfigFile := chkCustomConfigFile.Checked;
ConfigFilePath := edtConfigPath.Text;
CustomOptions := memCustomOptions.Text;
end;
CurOptions.Conditionals:=CondSynEdit.Lines.Text;
end;
class function TCompilerOtherOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;

View File

@ -515,8 +515,9 @@
<Filename Value="frames/compiler_other_options.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="CompilerOtherOptionsFrame"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Frame"/>
<UnitName Value="compiler_other_options"/>
<UnitName Value="Compiler_Other_Options"/>
</Unit64>
<Unit65>
<Filename Value="frames/compiler_inherited_options.pas"/>
@ -762,7 +763,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="include"/>
<OtherUnitFiles Value="frames;../converter;../debugger;../debugger/frames;../packager;../designer;../packager/frames;../ide"/>
<OtherUnitFiles Value="frames;../converter;../debugger;../debugger/frames;../packager;../designer;../packager/frames;../ide;frames;frames"/>
<UnitOutputDirectory Value="$(LazarusDir)/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)"/>
</SearchPaths>
<Other>

View File

@ -131,7 +131,7 @@ uses
// project compiler option frames
compiler_path_options, compiler_parsing_options, compiler_codegen_options,
compiler_linking_options, compiler_verbosity_options, compiler_messages_options,
compiler_other_options, compiler_compilation_options, compiler_buildmacro_options,
Compiler_Other_Options, compiler_compilation_options, compiler_buildmacro_options,
Compiler_ModeMatrix,
// package option frames
package_usage_options, package_description_options, package_integration_options,