diff --git a/ide/codemacroprompt.pas b/ide/codemacroprompt.pas index 3e77be7a45..a894a19126 100644 --- a/ide/codemacroprompt.pas +++ b/ide/codemacroprompt.pas @@ -223,7 +223,12 @@ const end else begin // normal macro -> substitute NewValue:=''; - if not Macro.GetValue(MacroValue,nil,SrcEdit,NewValue,ErrMsg) then exit; + try + if not Macro.GetValue(MacroValue,nil,SrcEdit,NewValue,ErrMsg) then + exit; + except + exit; + end; MacroValue:=NewValue; end; end else begin diff --git a/ide/codetemplatesdlg.pas b/ide/codetemplatesdlg.pas index c86f5d45ea..d30ff4798f 100644 --- a/ide/codetemplatesdlg.pas +++ b/ide/codetemplatesdlg.pas @@ -145,6 +145,16 @@ function CodeMakroProcedureName(const Parameter: string; InteractiveValue: TPersistent; SrcEdit: TSourceEditorInterface; var Value, ErrorMsg: string): boolean; +function CodeMakroDate(const Parameter: string; InteractiveValue: TPersistent; + SrcEdit: TSourceEditorInterface; + var Value, ErrorMsg: string): boolean; +function CodeMakroTime(const Parameter: string; InteractiveValue: TPersistent; + SrcEdit: TSourceEditorInterface; + var Value, ErrorMsg: string): boolean; +function CodeMakroDateTime(const Parameter: string; + InteractiveValue: TPersistent; + SrcEdit: TSourceEditorInterface; + var Value, ErrorMsg: string): boolean; const CodeTemplatesMenuRootName = 'CodeTemplates'; @@ -337,6 +347,37 @@ begin debugln('CodeMakroProcedureName ',Value); end; +function CodeMakroDate(const Parameter: string; InteractiveValue: TPersistent; + SrcEdit: TSourceEditorInterface; var Value, ErrorMsg: string): boolean; +begin + if Parameter<>'' then + Value:=FormatDateTime(Parameter,Now) + else + Value:=DateToStr(Now); + Result:=true; +end; + +function CodeMakroTime(const Parameter: string; InteractiveValue: TPersistent; + SrcEdit: TSourceEditorInterface; var Value, ErrorMsg: string): boolean; +begin + if Parameter<>'' then + Value:=FormatDateTime(Parameter,Now) + else + Value:=TimeToStr(Now); + Result:=true; +end; + +function CodeMakroDateTime(const Parameter: string; + InteractiveValue: TPersistent; SrcEdit: TSourceEditorInterface; var Value, + ErrorMsg: string): boolean; +begin + if Parameter<>'' then + Value:=FormatDateTime(Parameter,Now) + else + Value:=DateTimeToStr(Now); + Result:=true; +end; + procedure RegisterStandardCodeTemplatesMenuItems; var Path: string; @@ -392,6 +433,15 @@ begin RegisterCodeMacro('ProcedureName','insert procedure name', 'Insert name of current procedure', @CodeMakroProcedureName,nil); + RegisterCodeMacro('Date','insert date', + 'Insert date. Optional: format string', + @CodeMakroDate,nil); + RegisterCodeMacro('Time','insert time', + 'Insert time. Optional: format string', + @CodeMakroTime,nil); + RegisterCodeMacro('DateTime','insert date and time', + 'Insert date and time. Optional: format string', + @CodeMakroDateTime,nil); end; { TCodeTemplateEditForm } diff --git a/lcl/interfaces/gtk/gtkwsstdctrls.pp b/lcl/interfaces/gtk/gtkwsstdctrls.pp index 017f922ac0..a06760f8cd 100644 --- a/lcl/interfaces/gtk/gtkwsstdctrls.pp +++ b/lcl/interfaces/gtk/gtkwsstdctrls.pp @@ -625,8 +625,6 @@ end; function TGtkWSCustomComboBox.GetItemIndex( const ACustomComboBox: TCustomComboBox): integer; -var - CurText : string; begin //DebugLn('TGtkWSCustomComboBox.GetItemIndex ',DbgSName(ACustomComboBox),' ',GetWidgetDebugReport(PGtkWidget(ACustomComboBox.Handle))); Result:=GetComboBoxItemIndex(ACustomComboBox);