IDE: added insert todo dialog from wile64 and added compilation test for special chars in search paths

git-svn-id: trunk@12393 -
This commit is contained in:
mattias 2007-10-09 12:20:41 +00:00
parent da1f0df41a
commit b1c8d7a530
9 changed files with 257 additions and 4 deletions

3
.gitattributes vendored
View File

@ -1917,6 +1917,9 @@ ide/startlazarus.rc svneol=native#text/plain
ide/sysvaruseroverridedlg.lfm svneol=native#text/plain
ide/sysvaruseroverridedlg.lrs svneol=native#text/plain
ide/sysvaruseroverridedlg.pas svneol=native#text/pascal
ide/tododlg.lfm svneol=native#text/plain
ide/tododlg.lrs svneol=native#text/plain
ide/tododlg.pas svneol=native#text/plain
ide/todolist.lfm svneol=native#text/plain
ide/todolist.lrs svneol=native#text/plain
ide/todolist.pp svneol=native#text/pascal

View File

@ -73,6 +73,7 @@ type
procedure SetMacroList(const AValue: TTransferMacroList);
procedure SetOptions(const AValue: TCompilerOptions);
procedure SetMsgDirectory(Index: integer; const CurDir: string);
function CheckSpecialCharsInPath(const Title, Path: string): TModalResult;
function CheckCompilerExecutable(const CompilerFilename: string): TModalResult;
function CheckAmbiguousFPCCfg(const CompilerFilename: string): TModalResult;
function CheckCompilerConfig(const CompilerFilename: string;
@ -142,6 +143,67 @@ begin
FDirectories[Index]:=CurDir;
end;
function TCheckCompilerOptsDlg.CheckSpecialCharsInPath(const Title, Path: string
): TModalResult;
procedure AddStr(var s: string; const Addition: string);
begin
if s='' then
s:='contains: '
else
s:=s+', ';
s:=s+Addition;
end;
var
i: Integer;
HasSpaces: Boolean;
HasSpecialChars: Boolean;
HasNonASCII: Boolean;
HasWrongPathDelim: Boolean;
HasUnusualChars: Boolean;
HasNewLine: Boolean;
Warning: String;
ErrorMsg: String;
begin
HasSpaces:=false;
HasSpecialChars:=false;
HasNonASCII:=false;
HasWrongPathDelim:=false;
HasUnusualChars:=false;
HasNewLine:=false;
for i:=1 to length(Path) do begin
case Path[i] of
#10,#13: HasNewLine:=true;
#0..#8,#11,#12,#14..#31: HasSpecialChars:=true;
#9,' ': HasSpaces:=true;
'/','\': if Path[i]<>PathDelim then HasWrongPathDelim:=true;
'@','#','$','&','*','(',')','[',']','+','~','<','>','?','|': HasUnusualChars:=true;
#128..#255: HasNonASCII:=true;
end;
end;
Warning:='';
ErrorMsg:='';
if HasSpaces then AddStr(Warning,'spaces');
if HasSpecialChars then AddStr(ErrorMsg,'special characters');
if HasNonASCII then AddStr(Warning,'non ASCII');
if HasWrongPathDelim then AddStr(Warning,'wrong path delimiter');
if HasUnusualChars then AddStr(Warning,'unusual characters');
if HasNewLine then AddStr(ErrorMsg,'unusual characters');
if Warning<>'' then
AddWarning(Title+' '+Warning);
if ErrorMsg<>'' then begin
Result:=QuestionDlg('Invalid search path',Title+' '+ErrorMsg,mtError,
[mrIgnore,'Skip',mrAbort],0);
end else begin
if Warning='' then
Result:=mrOk
else
Result:=mrIgnore;
end;
end;
function TCheckCompilerOptsDlg.CheckCompilerExecutable(
const CompilerFilename: string): TModalResult;
var
@ -156,7 +218,7 @@ begin
Result:=QuestionDlg('Invalid compiler',
'The compiler "'+CompilerFilename+'" is not an executable file.'#13
+'Details: '+E.Message,
mtError,[mrCancel,'Skip',mrAbort],0);
mtError,[mrIgnore,'Skip',mrAbort],0);
exit;
end;
end;
@ -171,7 +233,7 @@ begin
'There are several FreePascal Compilers in your path.'#13#13
+CompilerFiles.Text+#13
+'Maybe you forgot to delete an old compiler?',
mtWarning,[mbCancel,mbIgnore],0);
mtWarning,[mbAbort,mbIgnore],0);
if Result<>mrIgnore then exit;
end;
@ -715,6 +777,7 @@ var
FPC_PPUs: TStrings;
TargetUnitPath: String;
Target_PPUs: TStrings;
cp: TParsedCompilerOptString;
begin
Result:=mrCancel;
if Test<>cotNone then exit;
@ -724,6 +787,17 @@ begin
FPC_PPUs:=nil;
Target_PPUs:=nil;
try
// check for special characters in search paths
for cp:=Low(TParsedCompilerOptString) to High(TParsedCompilerOptString) do
begin
if cp in ParsedCompilerSearchPaths then begin
Result:=CheckSpecialCharsInPath(
copy(ParsedCompilerOptStringNames[cp],5,100),
Options.ParsedOpts.GetParsedValue(cp));
if not (Result in [mrOk,mrIgnore]) then exit;
end;
end;
CompilerFilename:=Options.ParsedOpts.GetParsedValue(pcosCompilerPath);
// check compiler filename
@ -748,7 +822,7 @@ begin
Result:=CheckForAmbiguousPPUs(FPC_PPUs);
if not (Result in [mrOk,mrIgnore]) then exit;
// check if unit paths do not contain sources
// check if FPC unit paths do not contain sources
Result:=CheckFPCUnitPathsContainSources(FPCCfgUnitPath);
if not (Result in [mrOk,mrIgnore]) then exit;
@ -768,6 +842,10 @@ begin
Result:=CheckCompileBogusFile(CompilerFilename);
if not (Result in [mrOk,mrIgnore]) then exit;
// ToDo: check if search paths of packages/projects intersects
// ToDo: check ppu checksums and versions
if OutputListbox.Items.Count=0 then
AddMsg('All tests succeeded.','',-1);

View File

@ -1474,6 +1474,7 @@ resourcestring
+'system seems to use it.%sThat means non ASCII characters will probably '
+'be shown incorrect.%sYou can select another font in the editor options.';
lisUEDoNotSho = 'Do not show this message again.';
uemInsertTodo = 'Insert Todo';
// Form designer
lisInvalidMultiselection = 'Invalid multiselection';

View File

@ -206,6 +206,7 @@ type
procedure mnuEditInsertUsernameClick(Sender: TObject);
procedure mnuEditInsertDateTimeClick(Sender: TObject);
procedure mnuEditInsertChangeLogEntryClick(Sender: TObject);
procedure mnuInsertTodo(Sender: TObject);
// search menu
procedure mnuSearchFindInFiles(Sender: TObject);
@ -1590,6 +1591,7 @@ begin
SourceNotebook.OnEditorPropertiesClicked := @mnuEnvEditorOptionsClicked;
SourceNotebook.OnFindDeclarationClicked := @OnSrcNotebookFindDeclaration;
SourceNotebook.OnInitIdentCompletion :=@OnSrcNotebookInitIdentCompletion;
SourceNotebook.OnInsertTodoClicked := @mnuInsertTodo;
SourceNotebook.OnShowCodeContext :=@OnSrcNotebookShowCodeContext;
SourceNotebook.OnJumpToHistoryPoint := @OnSrcNotebookJumpToHistoryPoint;
SourceNotebook.OnMovingPage := @OnSrcNotebookMovingPage;
@ -13143,6 +13145,11 @@ begin
DoSourceEditorCommand(ecInsertChangeLogEntry);
end;
procedure TMainIDE.mnuInsertTodo(Sender: TObject);
begin
DoSourceEditorCommand(ecInsertTodo);
end;
procedure TMainIDE.mnuSearchFindInFiles(Sender: TObject);
begin
DoFindInFiles;

49
ide/tododlg.lfm Normal file
View File

@ -0,0 +1,49 @@
object TodoDialog: TTodoDialog
Left = 363
Height = 257
Top = 216
Width = 400
HorzScrollBar.Page = 399
VertScrollBar.Page = 256
ActiveControl = OkButton
Caption = 'Insert Todo'
ClientHeight = 257
ClientWidth = 400
object TodoLabel: TLabel
Left = 16
Height = 14
Top = 8
Width = 27
Caption = 'Text:'
FocusControl = TodoMemo
ParentColor = False
end
object OkButton: TButton
Left = 112
Height = 25
Top = 208
Width = 75
BorderSpacing.InnerBorder = 4
Caption = 'Ok'
ModalResult = 1
TabOrder = 1
end
object CancelButton: TButton
Left = 208
Height = 25
Top = 208
Width = 75
BorderSpacing.InnerBorder = 4
Caption = 'Cancel'
ModalResult = 2
TabOrder = 2
end
object TodoMemo: TMemo
Left = 16
Height = 168
Top = 24
Width = 368
ScrollBars = ssAutoBoth
TabOrder = 0
end
end

16
ide/tododlg.lrs Normal file
View File

@ -0,0 +1,16 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TTodoDialog','FORMDATA',[
'TPF0'#11'TTodoDialog'#10'TodoDialog'#4'Left'#3'k'#1#6'Height'#3#1#1#3'Top'#3
+#216#0#5'Width'#3#144#1#18'HorzScrollBar.Page'#3#143#1#18'VertScrollBar.Page'
+#3#0#1#13'ActiveControl'#7#8'OkButton'#7'Caption'#6#11'Insert Todo'#12'Clien'
+'tHeight'#3#1#1#11'ClientWidth'#3#144#1#0#6'TLabel'#9'TodoLabel'#4'Left'#2#16
+#6'Height'#2#14#3'Top'#2#8#5'Width'#2#27#7'Caption'#6#5'Text:'#12'FocusContr'
+'ol'#7#8'TodoMemo'#11'ParentColor'#8#0#0#7'TButton'#8'OkButton'#4'Left'#2'p'
+#6'Height'#2#25#3'Top'#3#208#0#5'Width'#2'K'#25'BorderSpacing.InnerBorder'#2
+#4#7'Caption'#6#2'Ok'#11'ModalResult'#2#1#8'TabOrder'#2#1#0#0#7'TButton'#12
+'CancelButton'#4'Left'#3#208#0#6'Height'#2#25#3'Top'#3#208#0#5'Width'#2'K'#25
+'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#6'Cancel'#11'ModalResult'#2#2#8
+'TabOrder'#2#2#0#0#5'TMemo'#8'TodoMemo'#4'Left'#2#16#6'Height'#3#168#0#3'Top'
+#2#24#5'Width'#3'p'#1#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#0#0#0#0
]);

65
ide/tododlg.pas Normal file
View File

@ -0,0 +1,65 @@
{
***************************************************************************
* *
* 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. *
* *
***************************************************************************
}
unit ToDoDlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TTodoDialog }
TTodoDialog = class(TForm)
OkButton: TButton;
CancelButton: TButton;
TodoLabel: TLabel;
TodoMemo: TMemo;
private
{ private declarations }
public
{ public declarations }
end;
function ShowTodoDialog(TodoMessage: TStrings): Boolean;
implementation
{ TTodoDialog }
function ShowTodoDialog(TodoMessage: TStrings): Boolean;
var
TodoDialog: TTodoDialog;
begin
TodoDialog:=TTodoDialog.Create(nil);
Result:=TodoDialog.ShowModal = mrOk;
If Result and (TodoMessage <> nil) Then TodoMessage.Assign(TodoDialog.TodoMemo.Lines);
TodoDialog.Free;
end;
initialization
{$I tododlg.lrs}
end.

View File

@ -60,7 +60,7 @@ uses
CodeTemplatesDlg,
SortSelectionDlg, EncloseSelectionDlg, DiffDialog, ConDef, InvertAssignTool,
SourceEditProcs, SourceMarks, CharacterMapDlg, frmSearch, LazDocFrm,
BaseDebugManager, Debugger, MainIntf;
BaseDebugManager, Debugger, MainIntf, TodoDlg;
type
TSourceNotebook = class;
@ -265,6 +265,7 @@ type
procedure InsertLGPLNotice(CommentType: TCommentType);
procedure InsertModifiedLGPLNotice(CommentType: TCommentType);
procedure InsertUsername;
procedure InsertTodo;
procedure InsertDateTime;
procedure InsertChangeLogEntry;
procedure InsertCVSKeyword(const AKeyWord: string);
@ -435,6 +436,7 @@ type
procedure FindNextWordOccurrenceClicked(Sender: TObject);
procedure FindPrevWordOccurrenceClicked(Sender: TObject);
procedure FindInFilesClicked(Sender: TObject);
procedure InsertTodoClicked(Sender: TObject);
procedure MoveEditorLeftClicked(Sender: TObject);
procedure MoveEditorRightClicked(Sender: TObject);
procedure NotebookPageChanged(Sender: TObject);
@ -472,6 +474,7 @@ type
FOnEditorVisibleChanged: TNotifyEvent;
FOnFindDeclarationClicked: TNotifyEvent;
FOnInitIdentCompletion: TOnInitIdentCompletion;
FOnInsertTodoClicked: TNotifyEvent;
FOnShowCodeContext: TOnShowCodeContext;
FOnJumpToHistoryPoint: TOnJumpToHistoryPoint;
FOnMovingPage: TOnMovingPage;
@ -740,6 +743,8 @@ type
read FOnFindDeclarationClicked write FOnFindDeclarationClicked;
property OnInitIdentCompletion: TOnInitIdentCompletion
read FOnInitIdentCompletion write FOnInitIdentCompletion;
property OnInsertTodoClicked: TNotifyEvent
read FOnInsertTodoClicked write FOnInsertTodoClicked;
property OnShowCodeContext: TOnShowCodeContext
read FOnShowCodeContext write FOnShowCodeContext;
property OnJumpToHistoryPoint: TOnJumpToHistoryPoint
@ -820,6 +825,7 @@ var
SrcEditMenuFindIdentifierReferences: TIDEMenuCommand;
SrcEditMenuExtractProc: TIDEMenuCommand;
SrcEditMenuInvertAssignment: TIDEMenuCommand;
SrcEditMenuInsertTodo: TIDEMenuCommand;
SrcEditMenuMoveEditorLeft: TIDEMenuCommand;
SrcEditMenuMoveEditorRight: TIDEMenuCommand;
SrcEditMenuReadOnly: TIDEMenuCommand;
@ -827,6 +833,7 @@ var
SrcEditMenuShowUnitInfo: TIDEMenuCommand;
SrcEditMenuEditorProperties: TIDEMenuCommand;
procedure RegisterStandardSourceEditorMenuItems;
@ -965,6 +972,9 @@ begin
SrcEditMenuInvertAssignment:=RegisterIDEMenuCommand(AParent,
'InvertAssignment',uemInvertAssignment);
SrcEditMenuInsertTodo:=RegisterIDEMenuCommand(SourceEditorMenuRoot,
'InsertTodo',uemInsertTodo);
// register the Flags section
SrcEditMenuSectionFlags:=RegisterIDEMenuSection(SourceEditorMenuRoot,
'Flags section');
@ -979,6 +989,7 @@ begin
SrcEditMenuSectionHighlighter:=RegisterIDEMenuSection(AParent,'Highlighter');
SrcEditMenuEditorProperties:=RegisterIDEMenuCommand(AParent,
'EditorProperties',uemEditorProperties);
end;
{ TSourceEditor }
@ -1546,6 +1557,9 @@ Begin
ecInsertDateTime:
InsertDateTime;
ecInsertTodo:
InsertTodo;
ecInsertChangeLogEntry:
InsertChangeLogEntry;
@ -1885,6 +1899,17 @@ begin
FEditor.SelText:=GetCurrentUserName;
end;
procedure TSourceEditor.InsertTodo;
Var
TodoMsg: TStrings;
begin
if ReadOnly then Exit;
TodoMsg:= TStringList.Create;
if ShowTodoDialog(TodoMsg) then
FEditor.SelText:=CommentText('TODO: '+TodoMsg.Text, comtPascal);
TodoMsg.Free;
end;
procedure TSourceEditor.InsertDateTime;
begin
if ReadOnly then Exit;
@ -3937,6 +3962,8 @@ begin
SrcEditMenuMoveEditorLeft.OnClick:=@MoveEditorLeftClicked;
SrcEditMenuMoveEditorRight.OnClick:=@MoveEditorRightClicked;
SrcEditMenuInsertTodo.OnClick:=@InsertTodoClicked;
SrcEditMenuCompleteCode.OnClick:=@CompleteCodeMenuItemClick;
SrcEditMenuEncloseSelection.OnClick:=@EncloseSelectionMenuItemClick;
SrcEditMenuExtractProc.OnClick:=@ExtractProcMenuItemClick;
@ -4854,6 +4881,12 @@ begin
SrcEdit.DoEditorExecuteCommand(ecFindInFiles);
end;
procedure TSourceNotebook.InsertTodoClicked(Sender: TObject);
begin
if Assigned(FOnInsertTodoClicked) then
FOnInsertTodoClicked(Sender);
end;
Procedure TSourceNotebook.CutClicked(Sender: TObject);
var ActSE: TSourceEditor;
begin

View File

@ -120,6 +120,7 @@ const
ecInsertCVSRevision = ecFirstLazarus + 92;
ecInsertCVSSource = ecFirstLazarus + 93;
ecInsertModifiedLGPLNotice= ecFirstLazarus + 94;
ecInsertTodo = ecFirstLazarus + 95;
// source tools
ecWordCompletion = ecFirstLazarus + 100;