added code macros date, time, datetime

git-svn-id: trunk@9039 -
This commit is contained in:
mattias 2006-03-29 09:38:14 +00:00
parent e61b7fee12
commit 142b936147
3 changed files with 56 additions and 3 deletions

View File

@ -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

View File

@ -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 }

View File

@ -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);