fixed TMemo.WordWrap

git-svn-id: trunk@4060 -
This commit is contained in:
mattias 2003-04-15 08:54:27 +00:00
parent 74214654f9
commit 088d4e7233
13 changed files with 442 additions and 92 deletions

View File

@ -79,8 +79,11 @@ ResourceString
ctsUnknownSectionKeyword = 'unknown section keyword %s found';
ctsIllegalQualifier = 'illegal qualifier %s found';
ctsUnexpectedEndOfSource = 'unexpected end of source';
ctsEndofSourceExpectedButAtomFound = 'expected end., but %s found';
ctsPointStartAt = '. start at ';
ctsUnexpectedKeywordInAsmBlock = 'unexpected keyword "%s" in asm block found';
ctsUnexpectedKeywordInBeginEndBlock =
'unexpected keyword "%s" in begin..end found';
ctsUnexpectedKeywordWhileReadingBackwards =
'unexpected keyword "%s" found while reading blocks backwards';
ctsWordNotFound = '"%s" not found';

View File

@ -841,6 +841,7 @@ begin
Add('RECORD',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('RESOURCESTRING',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('PROCEDURE',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('FUNCTION',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('SET',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('TYPE',{$ifdef FPC}@{$endif}AllwaysTrue);
Add('UNIT',{$ifdef FPC}@{$endif}AllwaysTrue);

View File

@ -120,6 +120,7 @@ type
procedure RaiseStringExpectedButAtomFound(const s: string);
procedure RaiseUnexpectedKeyWord;
procedure RaiseIllegalQualifier;
procedure RaiseEndOfSourceExpected;
protected
procedure InitExtraction;
function GetExtraction: string;
@ -171,6 +172,7 @@ type
procedure BuildClassVarTypeKeyWordFunctions; virtual;
procedure BuildClassInterfaceKeyWordFunctions; virtual;
function UnexpectedKeyWord: boolean;
function EndOfSourceExpected: boolean;
// read functions
function ReadTilProcedureHeadEnd(ParseAttr: TParseProcHeadAttributes;
var HasForwardModifier: boolean): boolean;
@ -409,7 +411,7 @@ begin
Add('BEGIN',{$ifdef FPC}@{$endif}KeyWordFuncBeginEnd);
Add('ASM',{$ifdef FPC}@{$endif}KeyWordFuncBeginEnd);
DefaultKeyWordFunction:={$ifdef FPC}@{$endif}UnexpectedKeyWord;
DefaultKeyWordFunction:={$ifdef FPC}@{$endif}EndOfSourceExpected;
end;
end;
@ -496,6 +498,12 @@ begin
SaveRaiseExceptionFmt(ctsUnexpectedKeyword,[GetAtom]);
end;
function TPascalParserTool.EndOfSourceExpected: boolean;
begin
Result:=false;
RaiseEndOfSourceExpected;
end;
procedure TPascalParserTool.BuildTree(OnlyInterfaceNeeded: boolean);
begin
{$IFDEF MEM_CHECK}CheckHeap('TBasicCodeTool.BuildTree A '+IntToStr(GetMem_Cnt));{$ENDIF}
@ -1941,6 +1949,12 @@ var BlockType: TEndBlockType;
SaveRaiseExceptionFmt(ctsUnexpectedKeywordInAsmBlock,[GetAtom]);
end;
procedure RaiseUnexpectedKeyWordInBeginEndBlock;
begin
SaveRaiseExceptionWithBlockStartHint(
Format(ctsUnexpectedKeywordInBeginEndBlock,[GetAtom]));
end;
begin
Result:=true;
TryType:=ttNone;
@ -2012,7 +2026,7 @@ begin
if UnexpectedKeyWordInBeginBlock.DoItUppercase(UpperSrc,
CurPos.StartPos,CurPos.EndPos-CurPos.StartPos)
then
RaiseUnexpectedKeyWord;
RaiseUnexpectedKeyWordInBeginEndBlock;
end;
end;
@ -3346,6 +3360,11 @@ begin
SaveRaiseExceptionFmt(ctsIllegalQualifier,[GetAtom]);
end;
procedure TPascalParserTool.RaiseEndOfSourceExpected;
begin
SaveRaiseExceptionFmt(ctsEndofSourceExpectedButAtomFound,[GetAtom]);
end;
procedure TPascalParserTool.InitExtraction;
begin
if ExtractMemStream=nil then

View File

@ -55,16 +55,49 @@ type
icoCustomOptions
);
TInheritedCompilerOptions = set of TInheritedCompilerOption;
{ TParsedCompilerOptions }
TParsedCompilerOptString = (
pcosBaseDir,
pcosUnitPath,
pcosIncludePath,
pcosObjectPath,
pcosLibraryPath,
pcosLinkerOptions,
pcosCustomOptions,
pcosOutputDir,
pcosCompilerPath
);
TParsedCompilerOptStrings = set of TParsedCompilerOptString;
TParsedCompilerOptions = class
public
UnparsedValues: array[TParsedCompilerOptString] of string;
ParsedValues: array[TParsedCompilerOptString] of string;
ParsedStamp: array[TParsedCompilerOptString] of integer;
constructor Create;
function GetParsedValue(Option: TParsedCompilerOptString): string;
procedure SetUnparsedValue(Option: TParsedCompilerOptString;
const NewValue: string);
procedure Clear;
end;
TParseStringEvent =
function(Options: TParsedCompilerOptions;
const UnparsedValue: string): string of object;
{ TBaseCompilerOptions }
TBaseCompilerOptions = class(TObject)
TBaseCompilerOptions = class
private
fOwner: TObject;
FModified: boolean;
FOnModified: TNotifyEvent;
fOptionsString: String;
FParsedOpts: TParsedCompilerOptions;
xmlconfig: TXMLConfig;
fXMLFile: String;
@ -148,6 +181,13 @@ type
fAdditionalConfigFile: Boolean;
fConfigFilePath: String;
fCustomOptions: string;
procedure SetCompilerPath(const AValue: String);
procedure SetCustomOptions(const AValue: string);
procedure SetIncludeFiles(const AValue: String);
procedure SetLibraries(const AValue: String);
procedure SetLinkerOptions(const AValue: String);
procedure SetOtherUnitFiles(const AValue: String);
procedure SetUnitOutputDir(const AValue: string);
protected
procedure LoadTheCompilerOptions(const Path: string); virtual;
procedure SaveTheCompilerOptions(const Path: string); virtual;
@ -172,14 +212,15 @@ type
function ParseOptions(const Delim, Switch, OptionStr: string): string;
function GetXMLConfigPath: String; virtual;
function CreateTargetFilename(const MainSourceFileName: string): string; virtual;
function GetInheritedOption(Option: TInheritedCompilerOption): string;
procedure GetInheritedCompilerOptions(var OptionsList: TList); virtual;
function GetOwnerName: string; virtual;
function GetBaseDirectory: string; virtual;
public
{ Properties }
property Owner: TObject read fOwner write fOwner;
property Modified: boolean read FModified write SetModified;
property OnModified: TNotifyEvent read FOnModified write FOnModified;
property ParsedOpts: TParsedCompilerOptions read FParsedOpts;
property XMLFile: String read fXMLFile write fXMLFile;
property TargetFilename: String read fTargetFilename write fTargetFilename;
@ -187,11 +228,11 @@ type
property Loaded: Boolean read fLoaded write fLoaded;
// search paths:
property IncludeFiles: String read fIncludeFiles write fIncludeFiles;
property Libraries: String read fLibraries write fLibraries;
property OtherUnitFiles: String read fOtherUnitFiles write fOtherUnitFiles;
property CompilerPath: String read fCompilerPath write fCompilerPath;
property UnitOutputDirectory: string read fUnitOutputDir write fUnitOutputDir;
property IncludeFiles: String read fIncludeFiles write SetIncludeFiles;
property Libraries: String read fLibraries write SetLibraries;
property OtherUnitFiles: String read fOtherUnitFiles write SetOtherUnitFiles;
property CompilerPath: String read fCompilerPath write SetCompilerPath;
property UnitOutputDirectory: string read fUnitOutputDir write SetUnitOutputDir;
property LCLWidgetType: string read fLCLWidgetType write fLCLWidgetType;
// parsing:
@ -235,7 +276,7 @@ type
property StripSymbols: Boolean read fStripSymbols write fStripSymbols;
property LinkStyle: Integer read fLinkStyle write fLinkStyle;
property PassLinkerOptions: Boolean read fPassLinkerOpt write fPassLinkerOpt;
property LinkerOptions: String read fLinkerOptions write fLinkerOptions;
property LinkerOptions: String read fLinkerOptions write SetLinkerOptions;
// messages:
property ShowErrors: Boolean read fShowErrors write fShowErrors;
@ -264,7 +305,7 @@ type
property DontUseConfigFile: Boolean read fDontUseConfigFile write fDontUseConfigFile;
property AdditionalConfigFile: Boolean read fAdditionalConfigFile write fAdditionalConfigFile;
property ConfigFilePath: String read fConfigFilePath write fConfigFilePath;
property CustomOptions: string read fCustomOptions write fCustomOptions;
property CustomOptions: string read fCustomOptions write SetCustomOptions;
end;
@ -282,6 +323,7 @@ type
FLinkerOptions: string;
FObjectPath: string;
fOwner: TObject;
FParsedOpts: TParsedCompilerOptions;
FUnitPath: string;
procedure SetCustomOptions(const AValue: string);
procedure SetIncludePath(const AValue: string);
@ -296,6 +338,7 @@ type
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
function GetOwnerName: string; virtual;
function GetBaseDirectory: string; virtual;
public
property Owner: TObject read fOwner;
property UnitPath: string read FUnitPath write SetUnitPath;
@ -304,6 +347,7 @@ type
property LibraryPath: string read FLibraryPath write SetLibraryPath;
property LinkerOptions: string read FLinkerOptions write SetLinkerOptions;
property CustomOptions: string read FCustomOptions write SetCustomOptions;
property ParsedOpts: TParsedCompilerOptions read FParsedOpts;
end;
@ -502,13 +546,37 @@ type
property ReadOnly: boolean read FReadOnly write SetReadOnly;
end;
var
frmCompilerOptions: TfrmCompilerOptions;
ParseStamp: integer;
OnParseString: TParseStringEvent;
procedure IncreaseParseStamp;
function ParseString(Options: TParsedCompilerOptions;
const UnparsedValue: string): string;
implementation
const
Config_Filename = 'compileroptions.xml';
MaxParsedStamp = $7fffffff;
MinParsedStamp = -$7fffffff;
InvalidParsedStamp = MinParsedStamp-1;
procedure IncreaseParseStamp;
begin
if ParseStamp<MaxParsedStamp then
inc(ParseStamp)
else
ParseStamp:=MinParsedStamp;
end;
function ParseString(Options: TParsedCompilerOptions;
const UnparsedValue: string): string;
begin
Result:=OnParseString(Options,UnparsedValue);
end;
{------------------------------------------------------------------------------
TBaseCompilerOptions Constructor
@ -516,8 +584,8 @@ const
constructor TBaseCompilerOptions.Create(TheOwner: TObject);
begin
inherited Create;
Assert(False, 'Trace:Compiler Options Class Created');
fOwner:=TheOwner;
FParsedOpts:=TParsedCompilerOptions.Create;
Clear;
end;
@ -526,6 +594,7 @@ end;
------------------------------------------------------------------------------}
destructor TBaseCompilerOptions.Destroy;
begin
FreeThenNil(FParsedOpts);
inherited Destroy;
end;
@ -579,9 +648,61 @@ begin
fLoaded := true;
end;
{------------------------------------------------------------------------------}
{ TfrmCompilerOptions LoadTheCompilerOptions }
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------
procedure TBaseCompilerOptions.SetIncludeFiles(const AValue: String);
------------------------------------------------------------------------------}
procedure TBaseCompilerOptions.SetIncludeFiles(const AValue: String);
begin
if fIncludeFiles=AValue then exit;
fIncludeFiles:=AValue;
ParsedOpts.SetUnparsedValue(pcosIncludePath,fIncludeFiles);
end;
procedure TBaseCompilerOptions.SetCompilerPath(const AValue: String);
begin
if fCompilerPath=AValue then exit;
fCompilerPath:=AValue;
ParsedOpts.SetUnparsedValue(pcosCompilerPath,fCompilerPath);
end;
procedure TBaseCompilerOptions.SetCustomOptions(const AValue: string);
begin
if fCustomOptions=AValue then exit;
fCustomOptions:=AValue;
ParsedOpts.SetUnparsedValue(pcosCustomOptions,fCustomOptions);
end;
procedure TBaseCompilerOptions.SetLibraries(const AValue: String);
begin
if fLibraries=AValue then exit;
fLibraries:=AValue;
ParsedOpts.SetUnparsedValue(pcosLibraryPath,fLibraries);
end;
procedure TBaseCompilerOptions.SetLinkerOptions(const AValue: String);
begin
if fLinkerOptions=AValue then exit;
fLinkerOptions:=AValue;
ParsedOpts.SetUnparsedValue(pcosLinkerOptions,fLinkerOptions);
end;
procedure TBaseCompilerOptions.SetOtherUnitFiles(const AValue: String);
begin
if fOtherUnitFiles=AValue then exit;
fOtherUnitFiles:=AValue;
ParsedOpts.SetUnparsedValue(pcosUnitPath,fOtherUnitFiles);
end;
procedure TBaseCompilerOptions.SetUnitOutputDir(const AValue: string);
begin
if fUnitOutputDir=AValue then exit;
fUnitOutputDir:=AValue;
ParsedOpts.SetUnparsedValue(pcosOutputDir,fUnitOutputDir);
end;
{------------------------------------------------------------------------------
TfrmCompilerOptions LoadTheCompilerOptions
------------------------------------------------------------------------------}
procedure TBaseCompilerOptions.LoadTheCompilerOptions(const Path: string);
var
p: String;
@ -835,12 +956,6 @@ begin
end;
end;
function TBaseCompilerOptions.GetInheritedOption(
Option: TInheritedCompilerOption): string;
begin
Result:='';
end;
procedure TBaseCompilerOptions.GetInheritedCompilerOptions(
var OptionsList: TList);
begin
@ -855,6 +970,14 @@ begin
Result:='This compiler options object has no owner';
end;
{------------------------------------------------------------------------------
function TBaseCompilerOptions.GetBaseDirectory: string;
------------------------------------------------------------------------------}
function TBaseCompilerOptions.GetBaseDirectory: string;
begin
Result:='';
end;
{------------------------------------------------------------------------------
TBaseCompilerOptions MakeOptionsString
------------------------------------------------------------------------------}
@ -1448,11 +1571,11 @@ begin
FModified := false;
// search paths
fIncludeFiles := '';
fLibraries := '';
fOtherUnitFiles := '';
fCompilerPath := '$(CompPath)';
fUnitOutputDir := '';
IncludeFiles := '';
Libraries := '';
OtherUnitFiles := '';
CompilerPath := '$(CompPath)';
UnitOutputDirectory := '';
fLCLWidgetType := 'gtk';
// parsing
@ -1493,7 +1616,7 @@ begin
fStripSymbols := false;
fLinkStyle := 1;
fPassLinkerOpt := false;
fLinkerOptions := '';
LinkerOptions := '';
// messages
fShowErrors := true;
@ -1519,7 +1642,7 @@ begin
fDontUseConfigFile := false;
fAdditionalConfigFile := false;
fConfigFilePath := './fpc.cfg';
fCustomOptions := '';
CustomOptions := '';
end;
procedure TBaseCompilerOptions.Assign(CompOpts: TBaseCompilerOptions);
@ -1528,11 +1651,11 @@ begin
fLoaded := CompOpts.fLoaded;
// Search Paths
fIncludeFiles := CompOpts.fIncludeFiles;
fLibraries := CompOpts.fLibraries;
fOtherUnitFiles := CompOpts.fOtherUnitFiles;
fCompilerPath := CompOpts.fCompilerPath;
fUnitOutputDir := CompOpts.fUnitOutputDir;
IncludeFiles := CompOpts.fIncludeFiles;
Libraries := CompOpts.fLibraries;
OtherUnitFiles := CompOpts.fOtherUnitFiles;
CompilerPath := CompOpts.fCompilerPath;
UnitOutputDirectory := CompOpts.fUnitOutputDir;
fLCLWidgetType := CompOpts.fLCLWidgetType;
// Parsing
@ -1575,7 +1698,7 @@ begin
fStripSymbols := CompOpts.fStripSymbols;
fLinkStyle := CompOpts.fLinkStyle;
fPassLinkerOpt := CompOpts.fPassLinkerOpt;
fLinkerOptions := CompOpts.fLinkerOptions;
LinkerOptions := CompOpts.fLinkerOptions;
// Messages
fShowErrors := CompOpts.fShowErrors;
@ -1601,7 +1724,7 @@ begin
fDontUseConfigFile := CompOpts.fDontUseConfigFile;
fAdditionalConfigFile := CompOpts.fAdditionalConfigFile;
fConfigFilePath := CompOpts.fConfigFilePath;
fCustomOptions := CompOpts.fCustomOptions;
CustomOptions := CompOpts.fCustomOptions;
end;
function TBaseCompilerOptions.IsEqual(CompOpts: TBaseCompilerOptions): boolean;
@ -3489,46 +3612,54 @@ procedure TAdditionalCompilerOptions.SetCustomOptions(const AValue: string);
begin
if FCustomOptions=AValue then exit;
FCustomOptions:=AValue;
ParsedOpts.SetUnparsedValue(pcosCustomOptions,fCustomOptions);
end;
procedure TAdditionalCompilerOptions.SetIncludePath(const AValue: string);
begin
if FIncludePath=AValue then exit;
FIncludePath:=AValue;
ParsedOpts.SetUnparsedValue(pcosIncludePath,FIncludePath);
end;
procedure TAdditionalCompilerOptions.SetLibraryPath(const AValue: string);
begin
if FLibraryPath=AValue then exit;
FLibraryPath:=AValue;
ParsedOpts.SetUnparsedValue(pcosLibraryPath,FLibraryPath);
end;
procedure TAdditionalCompilerOptions.SetLinkerOptions(const AValue: string);
begin
if FLinkerOptions=AValue then exit;
FLinkerOptions:=AValue;
ParsedOpts.SetUnparsedValue(pcosLinkerOptions,fLinkerOptions);
end;
procedure TAdditionalCompilerOptions.SetObjectPath(const AValue: string);
begin
if FObjectPath=AValue then exit;
FObjectPath:=AValue;
ParsedOpts.SetUnparsedValue(pcosObjectPath,FObjectPath);
end;
procedure TAdditionalCompilerOptions.SetUnitPath(const AValue: string);
begin
if FUnitPath=AValue then exit;
FUnitPath:=AValue;
ParsedOpts.SetUnparsedValue(pcosUnitPath,FUnitPath);
end;
constructor TAdditionalCompilerOptions.Create(TheOwner: TObject);
begin
fOwner:=TheOwner;
FParsedOpts:=TParsedCompilerOptions.Create;
Clear;
end;
destructor TAdditionalCompilerOptions.Destroy;
begin
FreeThenNil(FParsedOpts);
inherited Destroy;
end;
@ -3573,6 +3704,11 @@ begin
Result:='Has no owner';
end;
function TAdditionalCompilerOptions.GetBaseDirectory: string;
begin
Result:='';
end;
{ TCompilerOptions }
procedure TCompilerOptions.Clear;
@ -3580,5 +3716,42 @@ begin
inherited Clear;
end;
{ TParsedCompilerOptions }
constructor TParsedCompilerOptions.Create;
begin
Clear;
end;
function TParsedCompilerOptions.GetParsedValue(Option: TParsedCompilerOptString
): string;
begin
if ParsedStamp[Option]<>ParseStamp then begin
ParsedValues[Option]:=ParseString(Self,UnparsedValues[Option]);
// make filename absolute
// ToDo
ParsedStamp[Option]:=ParseStamp;
end;
Result:=ParsedValues[Option];
end;
procedure TParsedCompilerOptions.SetUnparsedValue(
Option: TParsedCompilerOptString; const NewValue: string);
begin
ParsedStamp[Option]:=InvalidParsedStamp;
UnparsedValues[Option]:=NewValue;
end;
procedure TParsedCompilerOptions.Clear;
var
Option: TParsedCompilerOptString;
begin
for Option:=Low(TParsedCompilerOptString) to High(TParsedCompilerOptString) do
ParsedStamp[Option]:=InvalidParsedStamp;
end;
initialization
ParseStamp:=0;
end.

View File

@ -44,7 +44,7 @@ uses
Buttons, Menus, ComCtrls, Spin, ProjectDefs, Project, SysUtils, FileCtrl,
Controls, Graphics, ExtCtrls, Dialogs, LazConf, CompReg, CodeToolManager,
Splash, ObjectInspector, PropEdits, SynEditKeyCmds, OutputFilter, IDEDefs,
MsgView, EnvironmentOpts, EditorOptions, IDEComp, FormEditor,
MsgView, EnvironmentOpts, EditorOptions, IDEComp, FormEditor, CompilerOptions,
KeyMapping, IDEProcs, UnitEditor, Debugger, IDEOptionDefs, CodeToolsDefines;
type
@ -335,6 +335,8 @@ type
procedure LoadMenuShortCuts; virtual;
public
ToolStatus: TIDEToolStatus;
CurrentParsedCompilerOption: TParsedCompilerOptions;
function FindUnitFile(const AFilename: string): string; virtual; abstract;
procedure GetCurrentUnit(var ActiveSourceEditor:TSourceEditor;
var ActiveUnitInfo:TUnitInfo); virtual; abstract;

View File

@ -76,7 +76,7 @@ const
implementation
const SeparatorLine = '----------------------------';
const SeparatorLine = '---------------------------------------------';
{ TMessagesView }
@ -94,12 +94,11 @@ Begin
With MessageView do Begin
Parent:= Self;
Align:= alClient;
Visible:= true;
end;
end;
Name := NonModalIDEWindowNames[nmiwMessagesViewName];
ALayout:=EnvironmentOptions.IDEWindowLayoutList.
ItemByEnum(nmiwMessagesViewName);
ItemByEnum(nmiwMessagesViewName);
ALayout.Form:=TForm(Self);
ALayout.Apply;
end;

View File

@ -200,6 +200,23 @@ type
//---------------------------------------------------------------------------
{ TProjectCompilerOptions }
TProjectCompilerOptions = class(TCompilerOptions)
private
FOwnerProject: TProject;
public
constructor Create(TheProject: TProject);
function GetOwnerName: string; override;
function GetBaseDirectory: string; override;
public
property OwnerProject: TProject read FOwnerProject;
end;
{ TProject }
TProjectType = // for a description see ProjectTypeDescriptions below
(ptApplication, ptProgram, ptCustomProgram);
TProjectFlag = (pfSaveClosedUnits, pfSaveOnlyProjectUnits);
@ -227,7 +244,7 @@ type
fActiveEditorIndexAtStart: integer;
FAutoCreateForms: boolean;
fBookmarks: TProjectBookmarkList;
fCompilerOptions: TCompilerOptions;
fCompilerOptions: TProjectCompilerOptions;
fIconPath: String;
fJumpHistory: TProjectJumpHistory;
fLastReadLPIFilename: string;
@ -347,7 +364,7 @@ type
property AutoCreateForms: boolean
read FAutoCreateForms write FAutoCreateForms;
property Bookmarks: TProjectBookmarkList read fBookmarks write fBookmarks;
property CompilerOptions: TCompilerOptions
property CompilerOptions: TProjectCompilerOptions
read fCompilerOptions write fCompilerOptions;
property FirstAutoRevertLockedUnit: TUnitInfo read fFirstAutoRevertLockedUnit;
property FirstLoadedUnit: TUnitInfo read fFirstLoadedUnit;
@ -1039,7 +1056,7 @@ begin
fActiveEditorIndexAtStart := -1;
FAutoCreateForms := true;
fBookmarks := TProjectBookmarkList.Create;
fCompilerOptions := TCompilerOptions.Create(Self);
fCompilerOptions := TProjectCompilerOptions.Create(Self);
FFlags:=DefaultProjectFlags;
fIconPath := '';
fJumpHistory:=TProjectJumpHistory.Create;
@ -2290,12 +2307,34 @@ begin
end;
{ TProjectCompilerOptions }
constructor TProjectCompilerOptions.Create(TheProject: TProject);
begin
inherited Create(TheProject);
fOwnerProject:=TheProject;
end;
function TProjectCompilerOptions.GetOwnerName: string;
begin
Result:=OwnerProject.Title;
if Result='' then Result:=ExtractFilename(OwnerProject.ProjectInfoFile);
end;
function TProjectCompilerOptions.GetBaseDirectory: string;
begin
Result:=OwnerProject.ProjectDirectory;
end;
end.
{
$Log$
Revision 1.105 2003/04/15 08:54:27 mattias
fixed TMemo.WordWrap
Revision 1.104 2003/04/14 18:03:47 mattias
implemented inherited compiler options

View File

@ -32,6 +32,12 @@
$Path(filename) - equal to ExtractFilePath
$Name(filename) - equal to ExtractFileName
$NameOnly(filename) - equal to ExtractFileName but without extension.
$MakeDir(filename) - append path delimiter
$MakeFile(filename) - chomp path delimiter
$Trim(filename) - equal to TrimFilename
ToDo:
sort items to accelerate find
}
unit TransferMacros;
@ -40,7 +46,7 @@ unit TransferMacros;
interface
uses Classes, SysUtils;
uses Classes, SysUtils, FileCtrl;
type
TTransferMacro = class;
@ -77,6 +83,7 @@ type
function MF_NameOnly(const Filename:string; var Abort: boolean):string; virtual;
function MF_MakeDir(const Filename:string; var Abort: boolean):string; virtual;
function MF_MakeFile(const Filename:string; var Abort: boolean):string; virtual;
function MF_Trim(const Filename:string; var Abort: boolean):string; virtual;
public
constructor Create;
destructor Destroy; override;
@ -90,12 +97,14 @@ type
function SubstituteStr(var s:string): boolean; virtual;
property OnSubstitution: TOnSubstitution
read fOnSubstitution write fOnSubstitution;
function FindByName(MacroName: string): TTransferMacro; virtual;
function FindByName(const MacroName: string): TTransferMacro; virtual;
end;
implementation
var
IsIdentChar: array[char] of boolean;
{ TTransferMacro }
@ -180,6 +189,14 @@ var MacroStart,MacroEnd: integer;
MacroName, MacroStr, MacroParam: string;
AMacro: TTransferMacro;
Handled, Abort: boolean;
OldMacroLen: Integer;
NewMacroEnd: Integer;
NewMacroLen: Integer;
BehindMacroLen: Integer;
NewString: String;
InFrontOfMacroLen: Integer;
NewStringLen: Integer;
NewStringPos: Integer;
function SearchBracketClose(Position:integer): integer;
var BracketClose:char;
@ -211,20 +228,22 @@ begin
MacroEnd:=MacroStart+1;
while (MacroEnd<=length(s))
and (s[MacroEnd] in ['a'..'z','A'..'Z','0'..'9','_']) do
and (IsIdentCHar[s[MacroEnd]]) do
inc(MacroEnd);
MacroName:=copy(s,MacroStart+1,MacroEnd-MacroStart-1);
if (MacroEnd<length(s)) and (s[MacroEnd] in ['(','{']) then begin
MacroEnd:=SearchBracketClose(MacroEnd)+1;
if MacroEnd>length(s)+1 then break;
MacroStr:=copy(s,MacroStart,MacroEnd-MacroStart);
OldMacroLen:=MacroEnd-MacroStart;
MacroStr:=copy(s,MacroStart,OldMacroLen);
// Macro found
Handled:=false;
Abort:=false;
if MacroName<>'' then begin
// Macro function -> substitute macro parameter first
MacroParam:=copy(MacroStr,length(MacroName)+3
,length(MacroStr)-length(MacroName)-3);
MacroParam:=copy(MacroStr,length(MacroName)+3,
length(MacroStr)-length(MacroName)-3);
if not SubstituteStr(MacroParam) then begin
Result:=false;
exit;
@ -247,7 +266,7 @@ begin
end;
end else begin
// Macro variable
MacroStr:=copy(s,MacroStart+2,MacroEnd-MacroStart-3);
MacroStr:=copy(s,MacroStart+2,OldMacroLen-3);
AMacro:=FindByName(MacroStr);
if Assigned(fOnSubstitution) then
fOnSubstitution(AMacro,MacroStr,Handled,ABort);
@ -263,8 +282,30 @@ begin
if not Handled then
MacroStr:='(unknown macro: '+MacroStr+')';
end;
s:=copy(s,1,MacroStart-1)+MacroStr+copy(s,MacroEnd,length(s)-MacroEnd+1);
MacroEnd:=MacroStart+length(MacroStr);
NewMacroEnd:=MacroStart+length(MacroStr);
NewMacroLen:=length(MacroStr);
InFrontOfMacroLen:=MacroStart-1;
BehindMacroLen:=length(s)-MacroEnd+1;
NewString:='';
NewStringLen:=InFrontOfMacroLen+NewMacroLen+BehindMacroLen;
if NewStringLen>0 then begin
SetLength(NewString,NewStringLen);
NewStringPos:=1;
if InFrontOfMacroLen>0 then begin
Move(s[1],NewString[NewStringPos],InFrontOfMacroLen);
inc(NewStringPos,InFrontOfMacroLen);
end;
if NewMacroLen>0 then begin
Move(MacroStr[1],NewString[NewStringPos],NewMacroLen);
inc(NewStringPos,NewMacroLen);
end;
if BehindMacroLen>0 then begin
Move(s[MacroEnd],NewString[NewStringPos],BehindMacroLen);
inc(NewStringPos,BehindMacroLen);
end;
end;
s:=NewString;
MacroEnd:=NewMacroEnd;
end;
MacroStart:=MacroEnd;
until false;
@ -279,12 +320,14 @@ begin
end;
end;
function TTransferMacroList.FindByName(MacroName: string): TTransferMacro;
var i:integer;
function TTransferMacroList.FindByName(const MacroName: string): TTransferMacro;
var
i:integer;
Cnt: Integer;
begin
MacroName:=lowercase(MacroName);
for i:=0 to Count-1 do
if MacroName=lowercase(Items[i].Name) then begin
Cnt:=Count;
for i:=0 to Cnt-1 do
if AnsiCompareText(MacroName,Items[i].Name)=0 then begin
Result:=Items[i];
exit;
end;
@ -340,5 +383,22 @@ begin
Result:=LeftStr(Result,length(Filename)-ChompLen);
end;
function TTransferMacroList.MF_Trim(const Filename: string; var Abort: boolean
): string;
begin
Result:=TrimFilename(Filename);
end;
procedure InternalInit;
var
c: char;
begin
for c:=Low(char) to High(char) do begin
IsIdentChar[c]:=c in ['a'..'z','A'..'Z','0'..'9','_'];
end;
end;
initialization
InternalInit;
end.

View File

@ -72,18 +72,27 @@ begin
Lines.Clear;
end;
{------------------------------------------------------------------------------
procedure TCustomMemo.SetHorzScrollBar(const AValue: TMemoScrollBar);
------------------------------------------------------------------------------}
procedure TCustomMemo.SetHorzScrollBar(const AValue: TMemoScrollBar);
begin
if FHorzScrollBar=AValue then exit;
FHorzScrollBar:=AValue;
end;
{------------------------------------------------------------------------------
procedure TCustomMemo.SetVertScrollBar(const AValue: TMemoScrollBar);
------------------------------------------------------------------------------}
procedure TCustomMemo.SetVertScrollBar(const AValue: TMemoScrollBar);
begin
if FVertScrollBar=AValue then exit;
FVertScrollBar:=AValue;
end;
{------------------------------------------------------------------------------
function TCustomMemo.StoreScrollBars: boolean;
------------------------------------------------------------------------------}
function TCustomMemo.StoreScrollBars: boolean;
begin
Result:=true;
@ -102,10 +111,7 @@ begin
end;
{------------------------------------------------------------------------------
Method: TCustomMemo.SetWordWrap
Params:
Returns:
procedure TCustomMemo.SetScrollbars(const Value : TScrollStyle);
------------------------------------------------------------------------------}
procedure TCustomMemo.SetScrollbars(const Value : TScrollStyle);
begin
@ -116,6 +122,23 @@ begin
end;
end;
{------------------------------------------------------------------------------
procedure TCustomMemo.InitializeWnd;
------------------------------------------------------------------------------}
procedure TCustomMemo.InitializeWnd;
begin
inherited InitializeWnd;
end;
{------------------------------------------------------------------------------
procedure TCustomMemo.Loaded;
------------------------------------------------------------------------------}
procedure TCustomMemo.Loaded;
begin
inherited Loaded;
CNSendMessage(LM_SETPROPERTIES, Self, nil);
end;
{------------------------------------------------------------------------------
Method: TCustomMemo.SetWordWrap
Params:
@ -126,7 +149,7 @@ procedure TCustomMemo.SetWordWrap(const Value : boolean);
begin
if Value <> FWordWrap then begin
FWordWrap := Value;
if HandleAllocated then
if HandleAllocated and (not (csLoading in ComponentState)) then
CNSendMessage(LM_SETPROPERTIES, Self, nil);
end;
end;
@ -136,6 +159,9 @@ end;
{ =============================================================================
$Log$
Revision 1.15 2003/04/15 08:54:27 mattias
fixed TMemo.WordWrap
Revision 1.14 2003/03/31 10:57:40 mattias
fixes for current fpc 1.1

View File

@ -114,17 +114,22 @@ procedure TMemoStrings.Insert(index : Integer; const S: String);
var
TempStrings: TStringList;
Cnt: Integer;
LastLine: String;
begin
If Assigned(FMemo) and (Index >= 0)
then begin
TempStrings := TStringList.Create;
TempStrings.Text := FMemo.Text;
Cnt:=TempStrings.Count;
if Index=Cnt then
CNSendMessage(LM_APPENDTEXT, FMemo, PChar(S))
else
if Index < Cnt
then begin
if Index=Cnt then begin
LastLine:=S+LineEnding;
if false and FMemo.HandleAllocated then
CNSendMessage(LM_APPENDTEXT, FMemo, PChar(LastLine))
else
FMemo.Text:=TempStrings.Text+LastLine;
end
else if Index < Cnt then
begin
TempStrings.Insert(Index, S);
FMemo.Text := TempStrings.Text;
end;
@ -137,6 +142,9 @@ end;
{ =============================================================================
$Log$
Revision 1.6 2003/04/15 08:54:27 mattias
fixed TMemo.WordWrap
Revision 1.5 2003/04/08 00:09:03 mattias
added LM_APPENDTEXT from hernan

View File

@ -513,6 +513,8 @@ type
procedure SetLines(const Value : TStrings);
procedure SetWordWrap(const Value : boolean);
procedure SetScrollBars(const Value : TScrollStyle);
procedure InitializeWnd; override;
procedure Loaded; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@ -521,7 +523,7 @@ type
public
property Lines: TStrings read FLines write SetLines;
property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars;
property WordWrap: Boolean read FWordWrap write SetWordWrap;
property WordWrap: Boolean read FWordWrap write SetWordWrap default true;
property Font : TFont read FFont write FFont;
property HorzScrollBar: TMemoScrollBar
read FHorzScrollBar write SetHorzScrollBar stored StoreScrollBars;
@ -561,6 +563,8 @@ type
{ TMemo }
TMemo = class(TCustomMemo)
protected
function WordWrapIsStored: boolean;
published
property Align;
property Anchors;
@ -573,7 +577,7 @@ type
property ScrollBars;
property Tabstop;
property Visible;
property WordWrap;
property WordWrap stored WordWrapIsStored;
property OnChange;
property OnEnter;
property OnExit;
@ -955,22 +959,22 @@ implementation
type
TSelection = record
Startpos, EndPos: Integer;
end;
TSelection = record
Startpos, EndPos: Integer;
end;
TMemoStrings = class(TStrings)
private
FMemo: TCustomMemo;
protected
function Get(Index : Integer): String; override;
function GetCount: Integer; override;
public
constructor Create(AMemo: TCustomMemo);
procedure Clear; override;
procedure Delete(index : Integer); override;
procedure Insert(index: Integer; const S: String); override;
end;
TMemoStrings = class(TStrings)
private
FMemo: TCustomMemo;
protected
function Get(Index : Integer): String; override;
function GetCount: Integer; override;
public
constructor Create(AMemo: TCustomMemo);
procedure Clear; override;
procedure Delete(index : Integer); override;
procedure Insert(index: Integer; const S: String); override;
end;
procedure Register;
begin
@ -1452,6 +1456,9 @@ end.
{ =============================================================================
$Log$
Revision 1.89 2003/04/15 08:54:27 mattias
fixed TMemo.WordWrap
Revision 1.88 2003/04/11 17:10:20 mattias
added but not implemented ComboBoxDropDown

View File

@ -270,6 +270,7 @@ type
public
constructor Create(ThePackage: TLazPackage);
function GetOwnerName: string; override;
function GetBaseDirectory: string; override;
public
property LazPackage: TLazPackage read FLazPackage write SetLazPackage;
end;
@ -1399,10 +1400,8 @@ begin
FFiles:=TList.Create;
FRemovedFiles:=TList.Create;
FCompilerOptions:=TPkgCompilerOptions.Create(Self);
FInstalled:=pitNope;
FAutoInstall:=pitNope;
FUsageOptions:=TPkgAdditionalCompilerOptions.Create(Self);
FFlags:=[lpfAutoIncrementVersionOnBuild,lpfAutoUpdate];
Clear;
end;
destructor TLazPackage.Destroy;
@ -1420,17 +1419,25 @@ procedure TLazPackage.Clear;
var
i: Integer;
begin
// break used-by dependencies
while FFirstUsedByDependency<>nil do
FFirstUsedByDependency.RemoveFromList(FFirstUsedByDependency,pdlUsedBy);
while FFirstRemovedDependency<>nil do
FFirstUsedByDependency.RequiredPackage:=nil;
// break and free removed dependencies
while FFirstRemovedDependency<>nil do begin
FFirstRemovedDependency.RequiredPackage:=nil;
FFirstRemovedDependency.RemoveFromList(FFirstRemovedDependency,pdlRequires);
while FFirstRequiredDependency<>nil do
end;
// break and free required dependencies
while FFirstRequiredDependency<>nil do begin
FFirstRequiredDependency.RequiredPackage:=nil;
FFirstRequiredDependency.RemoveFromList(FFirstRequiredDependency,pdlRequires);
end;
FAuthor:='';
FAutoInstall:=pitNope;
for i:=FComponents.Count-1 downto 0 do Components[i].Free;
FComponents.Clear;
FCompilerOptions.Clear;
fCompilerOptions.UnitOutputDirectory:='lib'+PathDelim;
FDescription:='';
FDirectory:='';
FVersion.Clear;
@ -2101,7 +2108,6 @@ end;
function TPkgCompilerOptions.GetOwnerName: string;
begin
writeln('TPkgCompilerOptions.GetOwnerName ',HexStr(Cardinal(Self),8),' ',HexStr(Cardinal(fLazPackage),8));
Result:=LazPackage.IDAsString;
end;
@ -2125,6 +2131,11 @@ begin
Result:=LazPackage.IDAsString;
end;
function TPkgAdditionalCompilerOptions.GetBaseDirectory: string;
begin
Result:=LazPackage.Directory;
end;
initialization
PackageDependencies:=TAVLTree.Create(@ComparePkgDependencyNames);

View File

@ -757,6 +757,7 @@ begin
Description:='The FCL - FreePascal Component Library provides the base classes for object pascal.';
PackageType:=lptDesignTime;
Installed:=pitStatic;
CompilerOptions.UnitOutputDirectory:='';
// add files
AddFile('inc/process.pp','Process',pftUnit,[pffHasRegisterProc],cpBase);
@ -780,6 +781,7 @@ begin
Description:='The LCL - Lazarus Component Library contains all base components for form editing.';
PackageType:=lptDesignTime;
Installed:=pitStatic;
CompilerOptions.UnitOutputDirectory:='';
// add files
AddFile('menus.pp','Menus',pftUnit,[pffHasRegisterProc],cpLCL);
@ -794,11 +796,11 @@ begin
AddFile('spin.pp','Spin',pftUnit,[pffHasRegisterProc],cpLCL);
AddFile('arrow.pp','Arrow',pftUnit,[pffHasRegisterProc],cpLCL);
AddFile('calendar.pp','Calendar',pftUnit,[pffHasRegisterProc],cpLCL);
// add unit paths
UsageOptions.UnitPath:=
'$(LazarusDir)/lcl/units;$(LazarusDir)/lcl/units/$(LCLWidgetType)';
// add requirements
AddRequiredDependency(FCLPackage.CreateDependencyForThisPkg);