mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 21:41:35 +02:00
ideintf: fix some issues in the MaskEdit property editor by Bart Broersma (issue #0014771)
git-svn-id: trunk@22712 -
This commit is contained in:
parent
f8a182a252
commit
273a363d3d
@ -187,45 +187,49 @@ end;
|
|||||||
|
|
||||||
procedure TMaskEditorForm.CharactersForBlankEditChange(Sender: TObject);
|
procedure TMaskEditorForm.CharactersForBlankEditChange(Sender: TObject);
|
||||||
var
|
var
|
||||||
I:integer;
|
S:string;
|
||||||
S1:string;
|
SL: Boolean;
|
||||||
|
BC: Char;
|
||||||
begin
|
begin
|
||||||
S1:=InputMaskEdit.Text;
|
SplitMask(InputMaskEdit.Text, S, SL, BC);
|
||||||
if (CharactersForBlanksEdit.Text<>'') then
|
if (CharactersForBlanksEdit.Text<>'') and (Length(S) > 0) then
|
||||||
begin
|
begin
|
||||||
I:=NPos(';', S1, 2);
|
BC := CharactersForBlanksEdit.Text[1];
|
||||||
if (I>0) and (I<Length(S1)) then
|
if SL then InputMaskEdit.Text:=S + MaskFieldSeparator + '1' + MaskFieldSeparator + BC
|
||||||
begin
|
else InputMaskEdit.Text:=S + MaskFieldSeparator + MaskNoSave + MaskFieldSeparator + BC;
|
||||||
S1[i+1]:=CharactersForBlanksEdit.Text[1];
|
end
|
||||||
InputMaskEdit.Text:=S1;
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
ReConstructEditMask
|
ReConstructEditMask
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TMaskEditorForm.SplitMask(AMask : String; Out MaskText : String; Out SaveLiterals : Boolean; Out BlankChar : Char) : Boolean;
|
Function TMaskEditorForm.SplitMask(AMask : String; Out MaskText : String; Out SaveLiterals : Boolean; Out BlankChar : Char) : Boolean;
|
||||||
|
|
||||||
Var
|
|
||||||
P : Integer;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
P:=Pos(';',AMask);
|
//Code modified to use same logic as in TCustomMaskEdit
|
||||||
If (P=0) then
|
BlankChar := DefaultBlank;
|
||||||
P:=Length(AMask)+1;
|
SaveLiterals := True;
|
||||||
MaskText:=Copy(AMask,1,P-1);
|
if (Length(AMask) >= 4) and (AMask[Length(AMask)-1] = MaskFieldSeparator) and
|
||||||
Delete(AMask,1,P);
|
(AMask[Length(AMask)-3] = MaskFieldSeparator) and
|
||||||
P:=Pos(';',AMask);
|
(AMask[Length(AMask)-2] <> cMask_SpecialChar) and
|
||||||
Result:=(P>0);
|
//Length = 4 is OK (AMask = ";1;_" for example), but if Length > 4 there must be no escape charater in front
|
||||||
If Not Result then
|
((Length(AMask) = 4) or ((Length(AMask) > 4) and (AMask[Length(AMask)-4] <> cMask_SpecialChar))) then
|
||||||
P:=Length(AMask)+1;
|
begin
|
||||||
SaveLiterals:=StrToIntDef(Copy(AMask,1,P-1),0)=1;
|
BlankChar := AMask[Length(AMask)];
|
||||||
Delete(AMask,1,P);
|
SaveLiterals := (AMask[Length(AMask)-2] <> MaskNosave);
|
||||||
If Length(AMask)>0 then
|
Result := True;
|
||||||
BlankChar:=AMask[1]
|
System.Delete(AMask,Length(AMask)-3,4);
|
||||||
else
|
end
|
||||||
BlankChar:='_';
|
//If not both SaveLiterals and BlankChar are specified, then see if only SaveLiterals is specified
|
||||||
|
else if (Length(AMask) >= 2) and (AMask[Length(AMask)-1] = MaskFieldSeparator) and
|
||||||
|
//Length = 2 is OK, but if Length > 2 there must be no escape charater in front
|
||||||
|
((Length(AMask) = 2) or ((Length(AMask) > 2) and (AMask[Length(AMask)-2] <> cMask_SpecialChar))) then
|
||||||
|
begin
|
||||||
|
SaveLiterals := (AMask[Length(AMask)] <> MaskNoSave);
|
||||||
|
Result := True;
|
||||||
|
//Remove this bit from Mask
|
||||||
|
System.Delete(AMask,Length(AMask)-1,2);
|
||||||
|
end;
|
||||||
|
MaskText := AMask;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TMaskEditorForm.ConstructEditmask : String;
|
Function TMaskEditorForm.ConstructEditmask : String;
|
||||||
@ -239,7 +243,10 @@ begin
|
|||||||
SplitMask(InputMaskEdit.Text,S,L,B);
|
SplitMask(InputMaskEdit.Text,S,L,B);
|
||||||
If (CharactersForBlanksEdit.Text<>'') then
|
If (CharactersForBlanksEdit.Text<>'') then
|
||||||
B:=CharactersForBlanksEdit.Text[1];
|
B:=CharactersForBlanksEdit.Text[1];
|
||||||
Result:=Format('%s;%d;%s',[S,ord(SaveLiteralCheckBox.checked),B]);
|
if (Length(S) = 0) then
|
||||||
|
Result := ''
|
||||||
|
else
|
||||||
|
Result:=Format('%s'+MaskFieldSeparator+'%d'+MaskFieldSeparator+'%s',[S,ord(SaveLiteralCheckBox.checked),B]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMaskEditorForm.ReConstructEditmask;
|
procedure TMaskEditorForm.ReConstructEditmask;
|
||||||
|
Loading…
Reference in New Issue
Block a user