diff --git a/components/codetools/expreval.pas b/components/codetools/expreval.pas index 9d804def08..939e158b79 100644 --- a/components/codetools/expreval.pas +++ b/components/codetools/expreval.pas @@ -73,6 +73,8 @@ type property ErrorPosition:integer read ErrorPos; property OnChange: TOnValuesChanged read FOnChange write FOnChange; function Items(Index: integer): string; + function Names(Index: integer): string; + function Values(Index: integer): string; procedure Append(const Variable, Value: string); procedure Prepend(const Variable, Value: string); procedure Clear; @@ -220,6 +222,16 @@ begin Result:=FNames[Index]+'='+FValues[Index]; end; +function TExpressionEvaluator.Names(Index: integer): string; +begin + Result:=FNames[Index]; +end; + +function TExpressionEvaluator.Values(Index: integer): string; +begin + Result:=FValues[Index]; +end; + procedure TExpressionEvaluator.Append(const Variable, Value: string); begin Variables[Variable]:=Variables[Variable]+Value; diff --git a/ide/codetoolsdefines.pas b/ide/codetoolsdefines.pas index d179f1caab..4a90940eb6 100644 --- a/ide/codetoolsdefines.pas +++ b/ide/codetoolsdefines.pas @@ -156,7 +156,6 @@ type procedure ValueNoteBookResize(Sender: TObject); procedure DefineTreeViewMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X,Y: integer); - procedure RefreshPreview; // exit menu procedure SaveAndExitMenuItemClick(Sender: TObject); @@ -581,13 +580,7 @@ end; procedure TCodeToolsDefinesEditor.OpenPreviewMenuItemClick(Sender: TObject); begin - //if DefinePreview=nil then begin - // DefinePreview:=TCodeToolsDefinesPreview.Create(Self); - // DefinePreview.DefineTree:=DefineTree; - // DefinePreview.Show; - //end; - //RefreshPreview; - //BringWindowToTop(DefinePreview.Handle); + ShowCodeToolsDefinesValuesDialog(DefineTree,''); end; procedure TCodeToolsDefinesEditor.InsertFPCProjectDefinesTemplateMenuItemClick( @@ -957,12 +950,6 @@ begin end; end; -procedure TCodeToolsDefinesEditor.RefreshPreview; -begin - //if DefinePreview=nil then exit; - //DefinePreview.ShowDefines; -end; - procedure TCodeToolsDefinesEditor.CreateComponents; procedure CreateWinControl(var AWinControl: TWinControl; @@ -1227,12 +1214,12 @@ begin ConvertActionMenuItem[i].OnClick:=@ConvertActionMenuItemClick; // tools - {AddMenuItem(ToolsMenuItem,'ToolsMenuItem','Tools',nil); - AddMenuItem(OpenPreviewMenuItem,'OpenPreviewMenuItem','Open Preview', + AddMenuItem(ToolsMenuItem, 'ToolsMenuItem', lisCTDefsTools, nil); + AddMenuItem(OpenPreviewMenuItem, 'OpenPreviewMenuItem', lisCTDefsOpenPreview, ToolsMenuItem); OpenPreviewMenuItem.OnClick:=@OpenPreviewMenuItemClick; - AddMenuItem(ShowMacroListMenuItem,'ShowMacroListMenuItem','Show Macros', + {AddMenuItem(ShowMacroListMenuItem,'ShowMacroListMenuItem','Show Macros', ToolsMenuItem);} // templates diff --git a/ide/codetoolsdefpreview.lfm b/ide/codetoolsdefpreview.lfm index c1ea4e459f..6d68ea9464 100644 --- a/ide/codetoolsdefpreview.lfm +++ b/ide/codetoolsdefpreview.lfm @@ -1,11 +1,419 @@ -object Form2: TForm2 - CAPTION = 'Form2' +object CodeToolsDefinesDialog: TCodeToolsDefinesDialog + CAPTION = 'CodeToolsDefinesDialog' CLIENTHEIGHT = 451 CLIENTWIDTH = 463 + ONCLOSE = CodeToolsDefinesDialogCLOSE + ONCREATE = CodeToolsDefinesDialogCREATE HORZSCROLLBAR.PAGE = 464 VERTSCROLLBAR.PAGE = 452 LEFT = 423 HEIGHT = 451 TOP = 228 WIDTH = 463 + object DirectoryGroupbox: TGROUPBOX + ALIGN = altop + CAPTION = 'DirectoryGroupbox' + CLIENTHEIGHT = 31 + CLIENTWIDTH = 459 + PARENTCTL3D = False + TABORDER = 0 + ONRESIZE = DirectoryGroupboxRESIZE + HEIGHT = 48 + WIDTH = 463 + object DirectoryCombobox: TCOMBOBOX + MAXLENGTH = 0 + PARENTCTL3D = False + TABORDER = 0 + TABSTOP = True + TEXT = 'DirectoryCombobox' + ONCHANGE = DirectoryComboboxCHANGE + LEFT = 6 + HEIGHT = 25 + TOP = 1 + WIDTH = 360 + end + object DirectoryBrowseButton: TBUTTON + CAPTION = '...' + TABSTOP = True + TABORDER = 1 + ONCLICK = DirectoryBrowseButtonCLICK + LEFT = 375 + HEIGHT = 26 + TOP = 1 + WIDTH = 31 + end + end + object ValuesListview: TLISTVIEW + ALIGN = alclient + COLUMNS = <> + VIEWSTYLE = vsreport + ONSELECTITEM = ValuesListviewSELECTITEM + HEIGHT = 272 + TOP = 48 + WIDTH = 463 + end + object ValueGroupbox: TGROUPBOX + ALIGN = albottom + ANCHORS = [akleft, akbottom] + CAPTION = 'Value' + CLIENTHEIGHT = 85 + CLIENTWIDTH = 459 + PARENTCTL3D = False + TABORDER = 2 + HEIGHT = 102 + TOP = 320 + WIDTH = 463 + object ValueSynedit: TSYNEDIT + ALIGN = alclient + COLOR = 16777215 + FONT.HEIGHT = -15 + FONT.NAME = 'courier' + HEIGHT = 85 + NAME = 'ValueSynedit' + PARENTCTL3D = False + TABORDER = 0 + WIDTH = 459 + GUTTER.VISIBLE = False + KEYSTROKES = < + item + COMMAND = 3 + SHORTCUT = 38 + end + item + COMMAND = 103 + SHORTCUT = 8230 + end + item + COMMAND = 211 + SHORTCUT = 16422 + end + item + COMMAND = 4 + SHORTCUT = 40 + end + item + COMMAND = 104 + SHORTCUT = 8232 + end + item + COMMAND = 212 + SHORTCUT = 16424 + end + item + COMMAND = 1 + SHORTCUT = 37 + end + item + COMMAND = 101 + SHORTCUT = 8229 + end + item + COMMAND = 5 + SHORTCUT = 16421 + end + item + COMMAND = 105 + SHORTCUT = 24613 + end + item + COMMAND = 2 + SHORTCUT = 39 + end + item + COMMAND = 102 + SHORTCUT = 8231 + end + item + COMMAND = 6 + SHORTCUT = 16423 + end + item + COMMAND = 106 + SHORTCUT = 24615 + end + item + COMMAND = 10 + SHORTCUT = 34 + end + item + COMMAND = 110 + SHORTCUT = 8226 + end + item + COMMAND = 14 + SHORTCUT = 16418 + end + item + COMMAND = 114 + SHORTCUT = 24610 + end + item + COMMAND = 9 + SHORTCUT = 33 + end + item + COMMAND = 109 + SHORTCUT = 8225 + end + item + COMMAND = 13 + SHORTCUT = 16417 + end + item + COMMAND = 113 + SHORTCUT = 24609 + end + item + COMMAND = 7 + SHORTCUT = 36 + end + item + COMMAND = 107 + SHORTCUT = 8228 + end + item + COMMAND = 15 + SHORTCUT = 16420 + end + item + COMMAND = 115 + SHORTCUT = 24612 + end + item + COMMAND = 8 + SHORTCUT = 35 + end + item + COMMAND = 108 + SHORTCUT = 8227 + end + item + COMMAND = 16 + SHORTCUT = 16419 + end + item + COMMAND = 116 + SHORTCUT = 24611 + end + item + COMMAND = 223 + SHORTCUT = 45 + end + item + COMMAND = 201 + SHORTCUT = 16429 + end + item + COMMAND = 604 + SHORTCUT = 8237 + end + item + COMMAND = 502 + SHORTCUT = 46 + end + item + COMMAND = 603 + SHORTCUT = 8238 + end + item + COMMAND = 501 + SHORTCUT = 8 + end + item + COMMAND = 501 + SHORTCUT = 8200 + end + item + COMMAND = 504 + SHORTCUT = 16392 + end + item + COMMAND = 601 + SHORTCUT = 32776 + end + item + COMMAND = 602 + SHORTCUT = 40968 + end + item + COMMAND = 509 + SHORTCUT = 13 + end + item + COMMAND = 199 + SHORTCUT = 16449 + end + item + COMMAND = 201 + SHORTCUT = 16451 + end + item + COMMAND = 610 + SHORTCUT = 24649 + end + item + COMMAND = 509 + SHORTCUT = 16461 + end + item + COMMAND = 510 + SHORTCUT = 16462 + end + item + COMMAND = 503 + SHORTCUT = 16468 + end + item + COMMAND = 611 + SHORTCUT = 24661 + end + item + COMMAND = 604 + SHORTCUT = 16470 + end + item + COMMAND = 603 + SHORTCUT = 16472 + end + item + COMMAND = 507 + SHORTCUT = 16473 + end + item + COMMAND = 506 + SHORTCUT = 24665 + end + item + COMMAND = 601 + SHORTCUT = 16474 + end + item + COMMAND = 602 + SHORTCUT = 24666 + end + item + COMMAND = 301 + SHORTCUT = 16432 + end + item + COMMAND = 302 + SHORTCUT = 16433 + end + item + COMMAND = 303 + SHORTCUT = 16434 + end + item + COMMAND = 304 + SHORTCUT = 16435 + end + item + COMMAND = 305 + SHORTCUT = 16436 + end + item + COMMAND = 306 + SHORTCUT = 16437 + end + item + COMMAND = 307 + SHORTCUT = 16438 + end + item + COMMAND = 308 + SHORTCUT = 16439 + end + item + COMMAND = 309 + SHORTCUT = 16440 + end + item + COMMAND = 310 + SHORTCUT = 16441 + end + item + COMMAND = 351 + SHORTCUT = 24624 + end + item + COMMAND = 352 + SHORTCUT = 24625 + end + item + COMMAND = 353 + SHORTCUT = 24626 + end + item + COMMAND = 354 + SHORTCUT = 24627 + end + item + COMMAND = 355 + SHORTCUT = 24628 + end + item + COMMAND = 356 + SHORTCUT = 24629 + end + item + COMMAND = 357 + SHORTCUT = 24630 + end + item + COMMAND = 358 + SHORTCUT = 24631 + end + item + COMMAND = 359 + SHORTCUT = 24632 + end + item + COMMAND = 360 + SHORTCUT = 24633 + end + item + COMMAND = 231 + SHORTCUT = 24654 + end + item + COMMAND = 232 + SHORTCUT = 24643 + end + item + COMMAND = 233 + SHORTCUT = 24652 + end + item + COMMAND = 612 + SHORTCUT = 9 + end + item + COMMAND = 613 + SHORTCUT = 8201 + end + item + COMMAND = 250 + SHORTCUT = 24642 + end> + LINES.Strings = ( + 'ValueSynedit' + ) + OPTIONS = [eoautoindent, eobrackethighlight, eoshowctrlmouselinks, eodragdropediting, eoscrollpasteol, eoshowscrollhint, eosmarttabs, eotabstospaces, eotrimtrailingspaces] + READONLY = True + CURSOR = 65532 + HEIGHT = 85 + WIDTH = 459 + end + end + object CloseButton: TBUTTON + ANCHORS = [akleft, akbottom] + ALIGN = albottom + MODALRESULT = 2 + CAPTION = 'CloseButton' + TABSTOP = True + TABORDER = 3 + HEIGHT = 29 + TOP = 422 + WIDTH = 463 + end end diff --git a/ide/codetoolsdefpreview.lrs b/ide/codetoolsdefpreview.lrs index dead7ed19b..5fe1896484 100644 --- a/ide/codetoolsdefpreview.lrs +++ b/ide/codetoolsdefpreview.lrs @@ -1,7 +1,76 @@ { This is an automatically generated lazarus resource file } -LazarusResources.Add('TForm2','FORMDATA',[ - 'TPF0'#6'TForm2'#5'Form2'#7'CAPTION'#6#5'Form2'#12'CLIENTHEIGHT'#3#195#1#11'C' - +'LIENTWIDTH'#3#207#1#18'HORZSCROLLBAR.PAGE'#3#208#1#18'VERTSCROLLBAR.PAGE'#3 - +#196#1#4'LEFT'#3#167#1#6'HEIGHT'#3#195#1#3'TOP'#3#228#0#5'WIDTH'#3#207#1#0#0 +LazarusResources.Add('TCodeToolsDefinesDialog','FORMDATA',[ + 'TPF0'#23'TCodeToolsDefinesDialog'#22'CodeToolsDefinesDialog'#7'CAPTION'#6#22 + +'CodeToolsDefinesDialog'#12'CLIENTHEIGHT'#3#195#1#11'CLIENTWIDTH'#3#207#1#7 + +'ONCLOSE'#7#27'CodeToolsDefinesDialogCLOSE'#8'ONCREATE'#7#28'CodeToolsDefine' + +'sDialogCREATE'#18'HORZSCROLLBAR.PAGE'#3#208#1#18'VERTSCROLLBAR.PAGE'#3#196#1 + +#4'LEFT'#3#167#1#6'HEIGHT'#3#195#1#3'TOP'#3#228#0#5'WIDTH'#3#207#1#0#9'TGROU' + +'PBOX'#17'DirectoryGroupbox'#5'ALIGN'#7#5'altop'#7'CAPTION'#6#17'DirectoryGr' + +'oupbox'#12'CLIENTHEIGHT'#2#31#11'CLIENTWIDTH'#3#203#1#11'PARENTCTL3D'#8#8'T' + +'ABORDER'#2#0#8'ONRESIZE'#7#23'DirectoryGroupboxRESIZE'#6'HEIGHT'#2'0'#5'WID' + +'TH'#3#207#1#0#9'TCOMBOBOX'#17'DirectoryCombobox'#9'MAXLENGTH'#2#0#11'PARENT' + +'CTL3D'#8#8'TABORDER'#2#0#7'TABSTOP'#9#4'TEXT'#6#17'DirectoryCombobox'#8'ONC' + +'HANGE'#7#23'DirectoryComboboxCHANGE'#4'LEFT'#2#6#6'HEIGHT'#2#25#3'TOP'#2#1#5 + +'WIDTH'#3'h'#1#0#0#7'TBUTTON'#21'DirectoryBrowseButton'#7'CAPTION'#6#3'...'#7 + +'TABSTOP'#9#8'TABORDER'#2#1#7'ONCLICK'#7#26'DirectoryBrowseButtonCLICK'#4'LE' + +'FT'#3'w'#1#6'HEIGHT'#2#26#3'TOP'#2#1#5'WIDTH'#2#31#0#0#0#9'TLISTVIEW'#14'Va' + +'luesListview'#5'ALIGN'#7#8'alclient'#7'COLUMNS'#14#0#9'VIEWSTYLE'#7#8'vsrep' + +'ort'#12'ONSELECTITEM'#7#24'ValuesListviewSELECTITEM'#6'HEIGHT'#3#16#1#3'TOP' + +#2'0'#5'WIDTH'#3#207#1#0#0#9'TGROUPBOX'#13'ValueGroupbox'#5'ALIGN'#7#8'albot' + +'tom'#7'ANCHORS'#11#6'akleft'#8'akbottom'#0#7'CAPTION'#6#5'Value'#12'CLIENTH' + +'EIGHT'#2'U'#11'CLIENTWIDTH'#3#203#1#11'PARENTCTL3D'#8#8'TABORDER'#2#2#6'HEI' + +'GHT'#2'f'#3'TOP'#3'@'#1#5'WIDTH'#3#207#1#0#8'TSYNEDIT'#12'ValueSynedit'#5'A' + +'LIGN'#7#8'alclient'#5'COLOR'#4#255#255#255#0#11'FONT.HEIGHT'#2#241#9'FONT.N' + +'AME'#6#7'courier'#6'HEIGHT'#2'U'#4'NAME'#6#12'ValueSynedit'#11'PARENTCTL3D' + +#8#8'TABORDER'#2#0#5'WIDTH'#3#203#1#14'GUTTER.VISIBLE'#8#10'KEYSTROKES'#14#1 + +#7'COMMAND'#2#3#8'SHORTCUT'#2'&'#0#1#7'COMMAND'#2'g'#8'SHORTCUT'#3'& '#0#1#7 + +'COMMAND'#3#211#0#8'SHORTCUT'#3'&@'#0#1#7'COMMAND'#2#4#8'SHORTCUT'#2'('#0#1#7 + +'COMMAND'#2'h'#8'SHORTCUT'#3'( '#0#1#7'COMMAND'#3#212#0#8'SHORTCUT'#3'(@'#0#1 + +#7'COMMAND'#2#1#8'SHORTCUT'#2'%'#0#1#7'COMMAND'#2'e'#8'SHORTCUT'#3'% '#0#1#7 + +'COMMAND'#2#5#8'SHORTCUT'#3'%@'#0#1#7'COMMAND'#2'i'#8'SHORTCUT'#3'%`'#0#1#7 + +'COMMAND'#2#2#8'SHORTCUT'#2''''#0#1#7'COMMAND'#2'f'#8'SHORTCUT'#3''' '#0#1#7 + +'COMMAND'#2#6#8'SHORTCUT'#3'''@'#0#1#7'COMMAND'#2'j'#8'SHORTCUT'#3'''`'#0#1#7 + +'COMMAND'#2#10#8'SHORTCUT'#2'"'#0#1#7'COMMAND'#2'n'#8'SHORTCUT'#3'" '#0#1#7 + +'COMMAND'#2#14#8'SHORTCUT'#3'"@'#0#1#7'COMMAND'#2'r'#8'SHORTCUT'#3'"`'#0#1#7 + +'COMMAND'#2#9#8'SHORTCUT'#2'!'#0#1#7'COMMAND'#2'm'#8'SHORTCUT'#3'! '#0#1#7'C' + +'OMMAND'#2#13#8'SHORTCUT'#3'!@'#0#1#7'COMMAND'#2'q'#8'SHORTCUT'#3'!`'#0#1#7 + +'COMMAND'#2#7#8'SHORTCUT'#2'$'#0#1#7'COMMAND'#2'k'#8'SHORTCUT'#3'$ '#0#1#7'C' + +'OMMAND'#2#15#8'SHORTCUT'#3'$@'#0#1#7'COMMAND'#2's'#8'SHORTCUT'#3'$`'#0#1#7 + +'COMMAND'#2#8#8'SHORTCUT'#2'#'#0#1#7'COMMAND'#2'l'#8'SHORTCUT'#3'# '#0#1#7'C' + +'OMMAND'#2#16#8'SHORTCUT'#3'#@'#0#1#7'COMMAND'#2't'#8'SHORTCUT'#3'#`'#0#1#7 + +'COMMAND'#3#223#0#8'SHORTCUT'#2'-'#0#1#7'COMMAND'#3#201#0#8'SHORTCUT'#3'-@'#0 + +#1#7'COMMAND'#3'\'#2#8'SHORTCUT'#3'- '#0#1#7'COMMAND'#3#246#1#8'SHORTCUT'#2 + +'.'#0#1#7'COMMAND'#3'['#2#8'SHORTCUT'#3'. '#0#1#7'COMMAND'#3#245#1#8'SHORTCU' + +'T'#2#8#0#1#7'COMMAND'#3#245#1#8'SHORTCUT'#3#8' '#0#1#7'COMMAND'#3#248#1#8'S' + +'HORTCUT'#3#8'@'#0#1#7'COMMAND'#3'Y'#2#8'SHORTCUT'#4#8#128#0#0#0#1#7'COMMAND' + +#3'Z'#2#8'SHORTCUT'#4#8#160#0#0#0#1#7'COMMAND'#3#253#1#8'SHORTCUT'#2#13#0#1#7 + +'COMMAND'#3#199#0#8'SHORTCUT'#3'A@'#0#1#7'COMMAND'#3#201#0#8'SHORTCUT'#3'C@' + +#0#1#7'COMMAND'#3'b'#2#8'SHORTCUT'#3'I`'#0#1#7'COMMAND'#3#253#1#8'SHORTCUT'#3 + +'M@'#0#1#7'COMMAND'#3#254#1#8'SHORTCUT'#3'N@'#0#1#7'COMMAND'#3#247#1#8'SHORT' + +'CUT'#3'T@'#0#1#7'COMMAND'#3'c'#2#8'SHORTCUT'#3'U`'#0#1#7'COMMAND'#3'\'#2#8 + +'SHORTCUT'#3'V@'#0#1#7'COMMAND'#3'['#2#8'SHORTCUT'#3'X@'#0#1#7'COMMAND'#3#251 + +#1#8'SHORTCUT'#3'Y@'#0#1#7'COMMAND'#3#250#1#8'SHORTCUT'#3'Y`'#0#1#7'COMMAND' + +#3'Y'#2#8'SHORTCUT'#3'Z@'#0#1#7'COMMAND'#3'Z'#2#8'SHORTCUT'#3'Z`'#0#1#7'COMM' + +'AND'#3'-'#1#8'SHORTCUT'#3'0@'#0#1#7'COMMAND'#3'.'#1#8'SHORTCUT'#3'1@'#0#1#7 + +'COMMAND'#3'/'#1#8'SHORTCUT'#3'2@'#0#1#7'COMMAND'#3'0'#1#8'SHORTCUT'#3'3@'#0 + +#1#7'COMMAND'#3'1'#1#8'SHORTCUT'#3'4@'#0#1#7'COMMAND'#3'2'#1#8'SHORTCUT'#3'5' + +'@'#0#1#7'COMMAND'#3'3'#1#8'SHORTCUT'#3'6@'#0#1#7'COMMAND'#3'4'#1#8'SHORTCUT' + +#3'7@'#0#1#7'COMMAND'#3'5'#1#8'SHORTCUT'#3'8@'#0#1#7'COMMAND'#3'6'#1#8'SHORT' + +'CUT'#3'9@'#0#1#7'COMMAND'#3'_'#1#8'SHORTCUT'#3'0`'#0#1#7'COMMAND'#3'`'#1#8 + +'SHORTCUT'#3'1`'#0#1#7'COMMAND'#3'a'#1#8'SHORTCUT'#3'2`'#0#1#7'COMMAND'#3'b' + +#1#8'SHORTCUT'#3'3`'#0#1#7'COMMAND'#3'c'#1#8'SHORTCUT'#3'4`'#0#1#7'COMMAND'#3 + +'d'#1#8'SHORTCUT'#3'5`'#0#1#7'COMMAND'#3'e'#1#8'SHORTCUT'#3'6`'#0#1#7'COMMAN' + +'D'#3'f'#1#8'SHORTCUT'#3'7`'#0#1#7'COMMAND'#3'g'#1#8'SHORTCUT'#3'8`'#0#1#7'C' + +'OMMAND'#3'h'#1#8'SHORTCUT'#3'9`'#0#1#7'COMMAND'#3#231#0#8'SHORTCUT'#3'N`'#0 + +#1#7'COMMAND'#3#232#0#8'SHORTCUT'#3'C`'#0#1#7'COMMAND'#3#233#0#8'SHORTCUT'#3 + +'L`'#0#1#7'COMMAND'#3'd'#2#8'SHORTCUT'#2#9#0#1#7'COMMAND'#3'e'#2#8'SHORTCUT' + ,#3#9' '#0#1#7'COMMAND'#3#250#0#8'SHORTCUT'#3'B`'#0#0#13'LINES.Strings'#1#6#12 + +'ValueSynedit'#0#7'OPTIONS'#11#12'eoautoindent'#18'eobrackethighlight'#20'eo' + +'showctrlmouselinks'#17'eodragdropediting'#15'eoscrollpasteol'#16'eoshowscro' + +'llhint'#11'eosmarttabs'#14'eotabstospaces'#20'eotrimtrailingspaces'#0#8'REA' + +'DONLY'#9#6'CURSOR'#4#252#255#0#0#6'HEIGHT'#2'U'#5'WIDTH'#3#203#1#0#0#0#7'TB' + +'UTTON'#11'CloseButton'#7'ANCHORS'#11#6'akleft'#8'akbottom'#0#5'ALIGN'#7#8'a' + +'lbottom'#11'MODALRESULT'#2#2#7'CAPTION'#6#11'CloseButton'#7'TABSTOP'#9#8'TA' + +'BORDER'#2#3#6'HEIGHT'#2#29#3'TOP'#3#166#1#5'WIDTH'#3#207#1#0#0#0 ]); diff --git a/ide/codetoolsdefpreview.pas b/ide/codetoolsdefpreview.pas index def15ad981..22eff20f24 100644 --- a/ide/codetoolsdefpreview.pas +++ b/ide/codetoolsdefpreview.pas @@ -5,19 +5,213 @@ unit CodeToolsDefPreview; interface uses - Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs; + Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, + Buttons, ComCtrls, SynEdit, DefineTemplates, ExprEval, LazarusIDEStrConsts, + FileCtrl, InputHistory; type - TForm2 = class(TForm) + TCodeToolsDefinesDialog = class(TForm) + CloseButton: TBUTTON; + DirectoryBrowseButton: TBUTTON; + DirectoryCombobox: TCOMBOBOX; + DirectoryGroupbox: TGROUPBOX; + ValueSynedit: TSYNEDIT; + ValueGroupbox: TGROUPBOX; + ValuesListview: TLISTVIEW; + procedure CodeToolsDefinesDialogCLOSE(Sender: TObject; + var Action: TCloseAction); + procedure CodeToolsDefinesDialogCREATE(Sender: TObject); + procedure DirectoryBrowseButtonCLICK(Sender: TObject); + procedure DirectoryComboboxCHANGE(Sender: TObject); + procedure DirectoryGroupboxRESIZE(Sender: TObject); + procedure ValuesListviewSELECTITEM(Sender: TObject; Item: TListItem; + Selected: Boolean); private + FDefineTree: TDefineTree; + procedure SetDefineTree(const AValue: TDefineTree); + procedure UpdateValues; + procedure UpdateValue; + procedure ClearValues; + procedure SetComboBox(AComboBox: TComboBox; const NewText: string); public + property DefineTree: TDefineTree read FDefineTree write SetDefineTree; end; -var - Form2: TForm2; + +function ShowCodeToolsDefinesValuesDialog(ADefineTree: TDefineTree; + const InitialDirectory: string): TModalresult; implementation +function ShowCodeToolsDefinesValuesDialog(ADefineTree: TDefineTree; + const InitialDirectory: string): TModalresult; +var + CodeToolsDefinesDialog: TCodeToolsDefinesDialog; +begin + CodeToolsDefinesDialog:=TCodeToolsDefinesDialog.Create(Application); + if InitialDirectory<>'' then + CodeToolsDefinesDialog.SetComboBox(CodeToolsDefinesDialog.DirectoryCombobox, + InitialDirectory); + CodeToolsDefinesDialog.DefineTree:=ADefineTree; + Result:=CodeToolsDefinesDialog.ShowModal; + CodeToolsDefinesDialog.Free; +end; + +{ TCodeToolsDefinesDialog } + +procedure TCodeToolsDefinesDialog.DirectoryGroupboxRESIZE(Sender: TObject); +var + x: Integer; +begin + with DirectoryCombobox do + SetBounds(0,0,Parent.ClientWidth-30,Height); + x:=DirectoryCombobox.Width; + with DirectoryBrowseButton do + SetBounds(x,0,Parent.ClientWidth-x,DirectoryCombobox.Height); +end; + +procedure TCodeToolsDefinesDialog.ValuesListviewSELECTITEM(Sender: TObject; + Item: TListItem; Selected: Boolean); +begin + UpdateValue; +end; + +procedure TCodeToolsDefinesDialog.SetDefineTree(const AValue: TDefineTree); +begin + if FDefineTree=AValue then exit; + FDefineTree:=AValue; + UpdateValues; +end; + +procedure TCodeToolsDefinesDialog.UpdateValues; +var + Dir: String; + Defines: TExpressionEvaluator; + i: Integer; + ListItem: TListItem; + Value: String; +begin + Dir:=TrimFilename(DirectoryCombobox.Text); + if FilenameIsAbsolute(Dir) then + if (DefineTree=nil) or (not FilenameIsAbsolute(Dir)) then begin + ClearValues; + exit; + end; + Defines:=DefineTree.GetDefinesForDirectory(Dir,false); + ValuesListview.BeginUpdate; + for i:=0 to Defines.Count-1 do begin + if ValuesListview.Items.Count<=i then + ListItem:=ValuesListview.Items.Add + else + ListItem:=ValuesListview.Items[i]; + ListItem.Caption:=Defines.Names(i); + Value:=copy(Defines.Values(i),1,100); + if ListItem.SubItems.Count<1 then + ListItem.SubItems.Add(Value) + else + ListItem.SubItems[0]:=Value; + end; + while ValuesListview.Items.Count>Defines.Count do + ValuesListview.Items.Delete(ValuesListview.Items.Count-1); + ValuesListview.EndUpdate; + UpdateValue; +end; + +procedure TCodeToolsDefinesDialog.UpdateValue; +var + VariableName: String; + Dir: String; + Defines: TExpressionEvaluator; + Value: string; +begin + Dir:=TrimFilename(DirectoryCombobox.Text); + if (ValuesListview.Selected=nil) or (DefineTree=nil) + or (not FilenameIsAbsolute(Dir)) then begin + ValueGroupbox.Caption:=lisCTDefnoVariableSelected; + ValueSynedit.Lines.Text:=''; + end else begin + VariableName:=ValuesListview.Selected.Caption; + ValueGroupbox.Caption:=Format(lisCTDefVariable, [VariableName]); + Defines:=DefineTree.GetDefinesForDirectory(Dir,false); + Value:=Defines.Variables[VariableName]; + ValueSynedit.Lines.Text:=Value; + end; +end; + +procedure TCodeToolsDefinesDialog.ClearValues; +begin + ValuesListview.Items.Clear; +end; + +procedure TCodeToolsDefinesDialog.SetComboBox(AComboBox: TComboBox; + const NewText: string); +var + i: Integer; +begin + i:=AComboBox.Items.IndexOf(NewText); + if i<0 then + AComboBox.Items.Add(NewText) + else + AComboBox.ItemIndex:=i; + AComboBox.Text:=NewText; +end; + +procedure TCodeToolsDefinesDialog.CodeToolsDefinesDialogCREATE(Sender: TObject); +var + ListColumn: TListColumn; +begin + Caption:=lisCTDefCodeToolsDirectoryValues; + + ListColumn:=ValuesListview.Columns.Add; + ListColumn.Caption:=lisCTDefVariableName; + ListColumn.Width:=150; + ListColumn:=ValuesListview.Columns.Add; + ListColumn.Caption:=dlgRunOValue; + + DirectoryGroupbox.Caption:=lisCodeToolsDefsInsertBehindDirectory; + CloseButton.Caption:=lisMenuClose; + + DirectoryCombobox.Items.Assign( + InputHistories.HistoryLists.GetList(hlCodeToolsDirectories,true)); + if DirectoryCombobox.Items.Count>0 then + DirectoryCombobox.ItemIndex:=0 + else + DirectoryCombobox.Text:=''; +end; + +procedure TCodeToolsDefinesDialog.CodeToolsDefinesDialogCLOSE(Sender: TObject; + var Action: TCloseAction); +begin + InputHistories.HistoryLists.GetList(hlCodeToolsDirectories,true).Assign( + DirectoryCombobox.Items); +end; + +procedure TCodeToolsDefinesDialog.DirectoryBrowseButtonCLICK(Sender: TObject); +var + OpenDialog: TOpenDialog; + Filename: string; +begin + OpenDialog:=TSelectDirectoryDialog.Create(Application); + try + InputHistories.ApplyFileDialogSettings(OpenDialog); + OpenDialog.Title:=lisCTDefChooseDirectory; + OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist]; + if OpenDialog.Execute then begin + Filename:=CleanAndExpandFilename(OpenDialog.Filename); + SetComboBox(DirectoryCombobox,Filename); + UpdateValues; + end; + InputHistories.StoreFileDialogSettings(OpenDialog); + finally + OpenDialog.Free; + end; +end; + +procedure TCodeToolsDefinesDialog.DirectoryComboboxCHANGE(Sender: TObject); +begin + UpdateValues; +end; + initialization {$I codetoolsdefpreview.lrs} diff --git a/ide/inputhistory.pas b/ide/inputhistory.pas index 250143e8c2..059890ca84 100644 --- a/ide/inputhistory.pas +++ b/ide/inputhistory.pas @@ -47,6 +47,7 @@ const hlMakeResourceStringSections = 'MakeResourceStringSections'; hlMakeResourceStringPrefixes = 'MakeResourceStringPrefixes'; hlMakeResourceStringLengths = 'MakeResourceStringLengths'; + hlCodeToolsDirectories = 'CodeToolsDirectories'; type TFileDialogSettings = record diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 52e3c08ef4..d81d01b45f 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -28,7 +28,7 @@ *************************************************************************** } { - Note: All resource strings should be prefixed with 'lis' + Note: All resource strings should be prefixed with 'lis' (Lazarus IDE String) } unit LazarusIDEStrConsts; @@ -1384,6 +1384,8 @@ resourcestring lisCodeToolsDefsIfNDef = 'IfNDef'; lisCodeToolsDefsElseIf = 'ElseIf'; lisCodeToolsDefsElse = 'Else'; + lisCTDefsTools = 'Tools'; + lisCTDefsOpenPreview = 'Open Preview'; lisCodeToolsDefsInsertTemplate = 'Insert Template'; lisCodeToolsDefsInsertFreePascalProjectTe = 'Insert Free Pascal Project ' +'Template'; @@ -1506,6 +1508,7 @@ resourcestring lisUIDPathsReadOnly = 'Paths (Read Only)'; lisUIDSrc = 'Src'; lisUIDOk = 'Ok'; + lisUIShowCodeToolsValues = 'Show CodeTools Values'; // unit editor lisUEErrorInRegularExpression = 'Error in regular expression'; @@ -2170,11 +2173,7 @@ resourcestring lisProjInspRemovedRequiredPackages = 'Removed required packages'; lisProjInspProjectInspector = 'Project Inspector - %s'; - - // --------------------------------------------------------// - // Menu editor -> form captions, labels and context menu --// - // --------------------------------------------------------// - + // menu editor lisMenuEditorMenuEditor = 'Menu Editor'; lisMenuEditorSelectMenu = 'Select Menu:'; lisMenuEditorSelectTemplate = 'Select Template:'; @@ -2192,11 +2191,7 @@ resourcestring lisMenuEditorSaveAsTemplate = 'Save As Template...'; lisMenuEditorDeleteFromTemplate = 'Delete From Template...'; - // --------------------------------// - // Menu editor -> menu templates --// - // --------------------------------// - - //Standard File menu + // Standard File menu lisMenuTemplateDescriptionStandardFileMenu = 'Standard File Menu'; lisMenuTemplateFile = 'File'; lisMenuTemplateNew = 'New'; @@ -2207,7 +2202,7 @@ resourcestring lisMenuTemplateClose = 'Close'; lisMenuTemplateExit = 'Exit'; - //Standard Edit menu + // Standard Edit menu lisMenuTemplateDescriptionStandardEditMenu = 'Standard Edit Menu'; lisMenuTemplateEdit = 'Edit'; lisMenuTemplateUndo = 'Undo'; @@ -2218,13 +2213,22 @@ resourcestring lisMenuTemplateFind = 'Find'; lisMenuTemplateFindNext = 'Find Next'; - //Standard Help menu + // Standard Help menu lisMenuTemplateDescriptionStandardHelpMenu = 'Standard Help Menu'; lisMenuTemplateHelp = 'Help'; lisMenuTemplateContents = 'Contents'; lisMenuTemplateTutorial = 'Tutorial'; lisMenuTemplateAbout = 'About'; + + // character map lisCharacterMap = 'Character Map'; + + // codetools defines value dialog + lisCTDefChooseDirectory = 'Choose Directory'; + lisCTDefCodeToolsDirectoryValues = 'CodeTools Directory Values'; + lisCTDefVariable = 'Variable: %s'; + lisCTDefnoVariableSelected = ''; + lisCTDefVariableName = 'Variable Name'; implementation end. diff --git a/ide/unitinfodlg.pp b/ide/unitinfodlg.pp index bb0d29318a..f82966e980 100644 --- a/ide/unitinfodlg.pp +++ b/ide/unitinfodlg.pp @@ -28,7 +28,7 @@ interface uses Classes, SysUtils, Controls, StdCtrls, Forms, Buttons, ExtCtrls, IDEProcs, - LazarusIDEStrConsts; + LazarusIDEStrConsts, CodeToolsDefPreview, CodeToolManager; type TUnitInfoDlg = class(TFORM) @@ -55,6 +55,8 @@ type IncludePathEdit: TEdit; SrcPathLabel: TLabel; SrcPathEdit: TEdit; + CodeToolsDefsButton: TButton; + procedure CodeToolsDefsButtonClick(Sender: TObject); procedure PathsGroupBoxResize(Sender: TObject); procedure UnitInfoDlgResize(Sender: TObject); procedure OkButtonClick(Sender:TObject); @@ -337,14 +339,26 @@ begin Width:=Parent.ClientWidth-Left-2; end; + CodeToolsDefsButton:=TButton.Create(Self); + with CodeToolsDefsButton do begin + Name:='CodeToolsDefsButton'; + Parent:=Self; + Left:=Parent.ClientWidth-260; + Top:=Parent.ClientHeight-33; + Width:=150; + Height:=25; + Caption:=lisUIShowCodeToolsValues; + OnClick:=@CodeToolsDefsButtonClick; + end; + OkButton:=TButton.Create(Self); with OkButton do begin Name:='OkButton'; Parent:=Self; - Top:=Parent.ClientHeight-33; + Top:=CodeToolsDefsButton.Top; Width:=75; Height:=25; - Left:=(Self.ClientWidth-Width) div 2; + Left:=Parent.ClientWidth-100; Caption:=lisUIDOk; Default:=true; OnClick:=@OkButtonClick; @@ -376,12 +390,12 @@ end; procedure TUnitInfoDlg.setLines(const str:string); begin - outlines.caption:=str; + outlines.caption:=str; end; procedure TUnitInfoDlg.setPath(const str:string); begin - outpath.caption:=str; + outpath.caption:=str; end; procedure TUnitInfoDlg.setIncludedBy(const IncludedBy: string); @@ -494,11 +508,18 @@ begin Width:=Self.ClientWidth-2*Left; end; - with OkButton do begin + with CodeToolsDefsButton do begin + Left:=Parent.ClientWidth-260; Top:=Parent.ClientHeight-33; + Width:=150; + Height:=25; + end; + + with OkButton do begin + Top:=CodeToolsDefsButton.Top; Width:=75; Height:=25; - Left:=(Self.ClientWidth-Width) div 2; + Left:=Parent.ClientWidth-100; end; end; @@ -538,6 +559,12 @@ begin end; end; +procedure TUnitInfoDlg.CodeToolsDefsButtonClick(Sender: TObject); +begin + ShowCodeToolsDefinesValuesDialog(CodeToolBoss.DefineTree, + ExtractFilePath(FFilePath)); +end; + procedure TUnitInfoDlg.OkButtonClick(Sender:TObject); begin ModalResult:=mrOk;