IDE: build modes: value

git-svn-id: trunk@23104 -
This commit is contained in:
mattias 2009-12-12 16:52:54 +00:00
parent c64b628c67
commit f5604c0e91
4 changed files with 76 additions and 26 deletions

View File

@ -701,8 +701,8 @@ var
begin
// get values from dialog
// build
BuildWorkingDir:=Trim(SpecialCharsToSpaces(BuildWorkDirCombobox.Text));
BuildCommand:=Trim(SpecialCharsToSpaces(BuildCommandMemo.Lines.Text));
BuildWorkingDir:=SpecialCharsToSpaces(BuildWorkDirCombobox.Text,true);
BuildCommand:=SpecialCharsToSpaces(BuildCommandMemo.Lines.Text,true);
BuildScanForFPCMsg:=BuildScanForFPCMsgCheckbox.Checked;
BuildScanForMakeMsg:=BuildScanForMakeMsgCheckbox.Checked;
BuildScan:=[];
@ -713,8 +713,8 @@ begin
AlwaysBuildBeforeRun:=AlwaysCompileFirstCheckbox.Checked;
RunFlags:=[];
if AlwaysBuildBeforeRun then Include(RunFlags,idedrfBuildBeforeRun);
RunWorkingDir:=Trim(SpecialCharsToSpaces(RunWorkDirCombobox.Text));
RunCommand:=Trim(SpecialCharsToSpaces(RunCommandMemo.Lines.Text));
RunWorkingDir:=SpecialCharsToSpaces(RunWorkDirCombobox.Text,true);
RunCommand:=SpecialCharsToSpaces(RunCommandMemo.Lines.Text,true);
// set values to directivelist
//DebugLn(['TBuildFileDialog.WriteDirectiveList ']);

View File

@ -1004,7 +1004,7 @@ begin
// custom options
CurCustomOptions:=InheritedOptionStrings[icoCustomOptions];
if CurCustomOptions<>'' then
Result := Result + ' ' + SpecialCharsToSpaces(CurCustomOptions);
Result := Result + ' ' + SpecialCharsToSpaces(CurCustomOptions,true);
end;
function MergeLinkerOptions(const OldOptions, AddOptions: string): string;
@ -2098,7 +2098,7 @@ begin
if Result='' then exit;
// eliminate line breaks
Result:=SpecialCharsToSpaces(Result);
Result:=SpecialCharsToSpaces(Result,true);
end;
function TBaseCompilerOptions.GetOptionsForCTDefines: string;
@ -3498,7 +3498,7 @@ begin
BaseDirectory:=GetParsedValue(pcosBaseDir);
s:=TrimSearchPath(s,BaseDirectory);
end else if Option=pcosCustomOptions then begin
s:=SpecialCharsToSpaces(s);
s:=SpecialCharsToSpaces(s,true);
end;
Result:=s;
end;
@ -3933,11 +3933,13 @@ function TBuildModeGraph.FixModeName(const ModeName: string;
var
CurMode: TBuildMode;
begin
Result:=false;
if s='' then exit;
if (CheckToo<>nil) and (SysUtils.CompareText(CheckToo.Name,s)=0) then
exit(false);
exit;
CurMode:=FindModeWithName(s);
if (CurMode<>nil) and (CurMode<>Ignore) then
exit(false);
exit;
Result:=true;
end;
@ -3945,14 +3947,7 @@ var
i: Integer;
Prefix: String;
begin
Result:=ModeName;
if Result<>'' then
Result:=copy(Result,1,strlen(PChar(Result)));
if Result<>'' then
UTF8FixBroken(PChar(Result));
for i:=length(Result) downto 1 do
if Result[i] in [#0..#31,#127] then
System.Delete(Result,i,1);
Result:=SpecialCharsToSpaces(ModeName,true);
if NameOk(Result) then exit;
Prefix:=Result;
i:=0;

View File

@ -25,8 +25,10 @@ unit BuildModesEditor;
interface
uses
Classes, SysUtils, Controls, FileUtil, LResources, Forms, Grids, Menus,
ComCtrls, CompilerOptions, IDEImagesIntf;
Classes, SysUtils, LCLProc, Controls, FileUtil, LResources, Forms, Grids,
Menus, ComCtrls,
IDEImagesIntf,
CompilerOptions, IDEProcs;
type
@ -59,6 +61,8 @@ type
protected
function ValidateEntry(const ACol,ARow:Integer; const OldValue:string;
var NewValue:string): boolean; override;
function ValidateCell(const ACol, ARow: Integer;
var NewValue:string): boolean;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
@ -87,6 +91,7 @@ type
end;
function BuildModeFlagTypeCaptions(f: TBuildModeFlagType): string;
function CaptionToBuildModeFlagType(s: string): TBuildModeFlagType;
implementation
@ -103,6 +108,17 @@ begin
end;
end;
function CaptionToBuildModeFlagType(s: string): TBuildModeFlagType;
begin
if s='' then exit(bmftNone);
for Result:=low(Result) to high(Result) do
if SysUtils.CompareText(s,BuildModeFlagTypeCaptions(Result))=0 then exit;
if IsValidIdent(s) then
Result:=bmftSetVariable
else
Result:=bmftNone;
end;
{ TBuildModesGrid }
function TBuildModesGrid.GetModeRows(Index: integer): TBuildModeGridRow;
@ -166,18 +182,48 @@ end;
function TBuildModesGrid.ValidateEntry(const ACol, ARow: Integer;
const OldValue: string; var NewValue: string): boolean;
var
CurMode: TBuildModeGridRow;
begin
//DebugLn(['TBuildModesGrid.ValidateEntry ',aCol]);
Result:=inherited ValidateEntry(aCol, aRow, OldValue, NewValue);
if not Result then exit;
Result:=ValidateCell(ACol,ARow,NewValue);
end;
function TBuildModesGrid.ValidateCell(const ACol, ARow: Integer;
var NewValue: string): boolean;
var
CurMode: TBuildModeGridRow;
TypeCol: Integer;
ValueCol: Integer;
FlagType: TBuildModeFlagType;
begin
Result:=true;
if (aRow>=1) and (aRow<=ModeRowCount) then begin
CurMode:=ModeRows[aRow-1];
TypeCol:=GroupModeCount+1;
ValueCol:=TypeCol+1;
//DebugLn(['TBuildModesGrid.ValidateCell aCol=',acol,' aRow=',arow,' ValueCol=',ValueCol]);
if aCol=0 then begin
// set new mode name
NewValue:=Graph.FixModeName(NewValue,CurMode.Mode);
CurMode.Mode.Name:=NewValue;
end else begin
end else if ACol=TypeCol then begin
NewValue:=SpecialCharsToSpaces(NewValue,true);
FlagType:=CaptionToBuildModeFlagType(NewValue);
if (CurMode.Flag=nil) and (FlagType<>bmftNone) then begin
// create flag
CurMode.FFlag:=CurMode.Mode.AddFlag(FlagType,'','');
end else if CurMode.Flag<>nil then
// set new FlagType
CurMode.Flag.FlagType:=FlagType;
end else if ACol=ValueCol then begin
NewValue:=SpecialCharsToSpaces(NewValue,true);
if (CurMode.Flag=nil) or (CurMode.Flag.FlagType=bmftNone) then
// no flag => no value
NewValue:=''
else
// set new value
CurMode.Flag.Value:=NewValue;
end;
end;
end;

View File

@ -208,7 +208,7 @@ function BinaryStrToText(const s: string): string;
function SplitString(const s: string; Delimiter: char): TStrings;
procedure SplitString(const s: string; Delimiter: char; AddTo: TStrings;
ClearList: boolean = true);
function SpecialCharsToSpaces(const s: string): string;
function SpecialCharsToSpaces(const s: string; FixUTF8: boolean): string;
function SpecialCharsToHex(const s: string): string;
function LineBreaksToDelimiter(const s: string; Delimiter: char): string;
function LineBreaksToSystemLineBreaks(const s: string): string;
@ -1579,15 +1579,24 @@ end;
{-------------------------------------------------------------------------------
function SpecialCharsToSpaces(const s: string): string;
Converts illegal characters to spaces.
Trim leading and trailing spaces.
-------------------------------------------------------------------------------}
function SpecialCharsToSpaces(const s: string): string;
function SpecialCharsToSpaces(const s: string; FixUTF8: boolean): string;
var
i: Integer;
begin
Result:=s;
for i:=1 to length(Result) do
if Result[i]<' ' then Result[i]:=' ';
if Result[i] in [#0..#31,#127] then Result[i]:=' ';
if Result='' then exit;
if FixUTF8 then begin
Result:=copy(Result,1,strlen(PChar(Result)));
if Result='' then exit;
UniqueString(Result);
UTF8FixBroken(PChar(Result));
end;
if (Result[1]=' ') or (Result[length(Result)]=' ') then
Result:=Trim(Result);
end;