mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 12:20:25 +02:00
* Fixed editing of See Also links with link text. Abstracted link editor, plus some cosmetic fixes.
git-svn-id: trunk@28539 -
This commit is contained in:
parent
efb3fc218d
commit
9909540c02
@ -120,7 +120,7 @@ Type
|
||||
Procedure DoAddSeeAlso(Sender : TObject);
|
||||
Procedure DoEditSeeAlso(Sender : TObject);
|
||||
Procedure DoDeleteSeeAlso(Sender : TObject);
|
||||
Function EditLink(Var Value : String) : Boolean;
|
||||
Function EditLink(Var Value,ALinkText : String) : Boolean;
|
||||
Public
|
||||
Constructor Create (AOwner : TComponent); override;
|
||||
Destructor Destroy; override;
|
||||
@ -143,6 +143,33 @@ implementation
|
||||
|
||||
uses frmexample, frmLink, StrUtils, LCLProc, FrmMain;
|
||||
|
||||
Function JoinLinkText(L,T : String): String;
|
||||
begin
|
||||
Result:=L;
|
||||
If (T<>'') then
|
||||
Result:=Result+'|'+T;
|
||||
end;
|
||||
|
||||
Procedure SplitLinkText(LT : String; Var L,T : String);
|
||||
|
||||
Var
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
P:=Pos('|',LT);
|
||||
If (P=0) then
|
||||
begin
|
||||
L:=LT;
|
||||
T:='';
|
||||
end
|
||||
else
|
||||
begin
|
||||
T:=LT;
|
||||
L:=Copy(LT,1,P-1);
|
||||
Delete(T,1,P);
|
||||
end;
|
||||
end;
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TCustomElementEditor }
|
||||
@ -361,6 +388,7 @@ begin
|
||||
Align:=alTop;
|
||||
Height:=50;
|
||||
OnEnter:=@OnEnterControl;
|
||||
OnDblClick:=@DoEditSeeAlso;
|
||||
end;
|
||||
FSPlit3:=TSplitter.Create(Self);
|
||||
With FSplit3 do
|
||||
@ -548,7 +576,7 @@ begin
|
||||
While N<>Nil do
|
||||
begin
|
||||
If IsLinkNode(N) then
|
||||
FSeeAlso.Items.Add(TDomElement(N)['id']);
|
||||
FSeeAlso.Items.Add(JoinLinkText(TDomElement(N)['id'],NodeToString(TDomElement(N))));
|
||||
N:=N.NextSibling;
|
||||
end;
|
||||
end;
|
||||
@ -596,6 +624,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Function TElementEditor.CurrentXML : String;
|
||||
|
||||
Function GetNodeString(NodeName,Value : String) : String;
|
||||
@ -609,8 +638,8 @@ Function TElementEditor.CurrentXML : String;
|
||||
end;
|
||||
|
||||
Var
|
||||
I : Integer;
|
||||
S : String;
|
||||
I,P : Integer;
|
||||
S,L,LT : String;
|
||||
|
||||
begin
|
||||
Result:='';
|
||||
@ -621,8 +650,17 @@ begin
|
||||
Result:=Result+GetNodeString('errors',trim(FErrorsMemo.Text));
|
||||
S:='';
|
||||
for I:=0 to FSeeAlso.Items.Count-1 do
|
||||
if Trim(FSeeAlso.Items[i])<>'' then
|
||||
S:=S+'<link id="'+Trim(FSeeAlso.Items[i])+'"/>';
|
||||
begin
|
||||
LT:=Trim(FSeeAlso.Items[i]);
|
||||
if (LT<>'') then
|
||||
begin
|
||||
SplitLinkText(LT,L,LT);
|
||||
If (LT<>'') then
|
||||
S:=S+'<link id="'+L+'">'+LT+'</link>'
|
||||
else
|
||||
S:=S+'<link id="'+L+'"/>';
|
||||
end;
|
||||
end;
|
||||
Result:=Result+GetNodeString('seealso',S);
|
||||
S:='';
|
||||
for I:=0 to FExamples.Items.Count-1 do
|
||||
@ -873,24 +911,29 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Function TElementEditor.EditLink(Var Value : String) : Boolean;
|
||||
Function TElementEditor.EditLink(Var Value,ALinkText : String) : Boolean;
|
||||
|
||||
begin
|
||||
With TLinkForm.Create(Self) do
|
||||
try
|
||||
Caption:=SInsertLink;
|
||||
If Assigned(OnGetElementList) then
|
||||
begin
|
||||
CBTarget.Items.BeginUpdate;
|
||||
Links.BeginUpdate;
|
||||
Try
|
||||
OnGetElementList(CBTarget.Items);
|
||||
OnGetElementList(Links);
|
||||
Finally
|
||||
CBTarget.Items.EndUpdate;
|
||||
Links.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
CBTarget.Text:=Value;
|
||||
Link:=Value;
|
||||
LinkText:=ALinkText;
|
||||
Result:=ShowModal=mrOK;
|
||||
If Result then
|
||||
begin
|
||||
Value:=CBTarget.Text;
|
||||
ALinkText:=LinkText;
|
||||
end;
|
||||
Finally
|
||||
Free;
|
||||
end;
|
||||
@ -899,13 +942,15 @@ end;
|
||||
procedure TElementEditor.DoAddSeeAlso(Sender: TObject);
|
||||
|
||||
Var
|
||||
S : String;
|
||||
S,T : String;
|
||||
|
||||
begin
|
||||
if Sender=nil then ;
|
||||
S:='';
|
||||
If EditLink(S) then
|
||||
T:='';
|
||||
If EditLink(S,T) then
|
||||
begin
|
||||
S:=JoinLinkText(S,T);
|
||||
if FSeeAlso.Items.IndexOf(S)<0 then
|
||||
begin
|
||||
FSeeAlso.Items.Add(S);
|
||||
@ -917,18 +962,25 @@ end;
|
||||
procedure TElementEditor.DoEditSeeAlso(Sender: TObject);
|
||||
|
||||
Var
|
||||
S : String;
|
||||
S,T : String;
|
||||
P : Integer;
|
||||
|
||||
begin
|
||||
if Sender=nil then ;
|
||||
With FSeeAlso do
|
||||
begin
|
||||
If (ItemIndex>=0) then
|
||||
S:=Items[ItemIndex]
|
||||
else
|
||||
S:='';
|
||||
If EditLink(S) then
|
||||
begin
|
||||
SplitLinkText(Items[ItemIndex],S,T);
|
||||
end
|
||||
else
|
||||
begin
|
||||
S:='';
|
||||
T:='';
|
||||
end;
|
||||
If EditLink(S,T) then
|
||||
begin
|
||||
S:=JoinLinkText(S,T);
|
||||
If (ItemIndex>=0) then
|
||||
Items[ItemIndex]:=S
|
||||
else
|
||||
|
@ -15,9 +15,9 @@ object LinkForm: TLinkForm
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 6
|
||||
Height = 18
|
||||
Height = 19
|
||||
Top = 6
|
||||
Width = 85
|
||||
Width = 73
|
||||
BorderSpacing.Around = 6
|
||||
Caption = '&Link target'
|
||||
FocusControl = CBTarget
|
||||
@ -29,11 +29,11 @@ object LinkForm: TLinkForm
|
||||
AnchorSideTop.Control = CBTarget
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 18
|
||||
Top = 65
|
||||
Width = 72
|
||||
Height = 19
|
||||
Top = 63
|
||||
Width = 58
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'LELinkText'
|
||||
Caption = 'Link text'
|
||||
Layout = tlCenter
|
||||
ParentColor = False
|
||||
end
|
||||
@ -44,8 +44,8 @@ object LinkForm: TLinkForm
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 29
|
||||
Top = 30
|
||||
Height = 26
|
||||
Top = 31
|
||||
Width = 422
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoComplete = True
|
||||
@ -62,8 +62,8 @@ object LinkForm: TLinkForm
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 29
|
||||
Top = 89
|
||||
Height = 26
|
||||
Top = 88
|
||||
Width = 422
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
@ -71,9 +71,18 @@ object LinkForm: TLinkForm
|
||||
end
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 40
|
||||
Top = 137
|
||||
Height = 36
|
||||
Top = 141
|
||||
Width = 428
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.Caption = '&OK'
|
||||
HelpButton.Name = 'HelpButton'
|
||||
HelpButton.Caption = '&Help'
|
||||
CloseButton.Name = 'CloseButton'
|
||||
CloseButton.Caption = '&Close'
|
||||
CloseButton.Enabled = False
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.Caption = 'Cancel'
|
||||
TabOrder = 2
|
||||
ShowButtons = [pbOK, pbCancel, pbHelp]
|
||||
end
|
||||
|
@ -40,9 +40,18 @@ type
|
||||
LLinkTarget: TLabel;
|
||||
LELinkText: TLabel;
|
||||
private
|
||||
function GetL: TStrings;
|
||||
function GetLL: String;
|
||||
function GetLT: String;
|
||||
procedure SetL(const AValue: TStrings);
|
||||
procedure SetLL(const AValue: String);
|
||||
procedure SetLT(const AValue: String);
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
Property Links : TStrings Read GetL Write SetL;
|
||||
property Link : String Read GetLL Write SetLL;
|
||||
Property LinkText : String Read GetLT Write SetLT;
|
||||
end;
|
||||
|
||||
var
|
||||
@ -52,5 +61,37 @@ implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TLinkForm }
|
||||
|
||||
function TLinkForm.GetL: TStrings;
|
||||
begin
|
||||
Result:=CBTarget.Items;
|
||||
end;
|
||||
|
||||
function TLinkForm.GetLL: String;
|
||||
begin
|
||||
Result:=CBTarget.Text;
|
||||
end;
|
||||
|
||||
function TLinkForm.GetLT: String;
|
||||
begin
|
||||
Result:=ELinkText.Text;
|
||||
end;
|
||||
|
||||
procedure TLinkForm.SetL(const AValue: TStrings);
|
||||
begin
|
||||
CBTarget.Items.Assign(AValue);
|
||||
end;
|
||||
|
||||
procedure TLinkForm.SetLL(const AValue: String);
|
||||
begin
|
||||
CBTarget.Text:=AValue;
|
||||
end;
|
||||
|
||||
procedure TLinkForm.SetLT(const AValue: String);
|
||||
begin
|
||||
ELinkText.Text:=AValue;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -757,7 +757,7 @@ begin
|
||||
With S do
|
||||
begin
|
||||
cmd:=cmdMakeSkel+' ';
|
||||
cmd:=cmd+format('--input=''%s %s''',[Inputfile,Additionaloptions]);
|
||||
cmd:=cmd+format('"--input=%s %s"',[Inputfile,Additionaloptions]);
|
||||
cmd:=cmd+' --output='+OutputFile;
|
||||
cmd:=cmd+' --package='+PackageName;
|
||||
If DisableErrors then
|
||||
@ -879,15 +879,15 @@ begin
|
||||
With TLinkForm.Create(Self) do
|
||||
Try
|
||||
Caption:=SInsertLink;
|
||||
ELinkText.Text:=CurrentEditor.CurrentSelection;
|
||||
CBTarget.Items.BeginUpdate;
|
||||
Link:=CurrentEditor.CurrentSelection;
|
||||
Links.BeginUpdate;
|
||||
Try
|
||||
CurrentEditor.GetElementList(CBTarget.Items);
|
||||
CurrentEditor.GetElementList(Links);
|
||||
Finally
|
||||
CBTarget.Items.EndUpdate;
|
||||
Links.EndUpdate;
|
||||
end;
|
||||
If ShowModal=mrOK Then
|
||||
CurrentEditor.InsertLink(CBTarget.Text, ELinkText.Text);
|
||||
CurrentEditor.InsertLink(Link,LinkText);
|
||||
Finally
|
||||
free;
|
||||
end;
|
||||
|
@ -1,14 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="7"/>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InIDEConfig"/>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=""/>
|
||||
<Title Value="LazDocEditor"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
@ -21,8 +20,11 @@
|
||||
<UseVersionInfo Value="True"/>
|
||||
<MinorVersionNr Value="9"/>
|
||||
<RevisionNr Value="29"/>
|
||||
<StringTable Comments="" CompanyName="Lazarus team" FileDescription="Lazarus documents editor" FileVersion="0.9.29.0" InternalName="LazDE" LegalCopyright="" LegalTrademarks="" OriginalFilename="LazDE" ProductName="" ProductVersion=""/>
|
||||
<StringTable CompanyName="Lazarus team" FileDescription="Lazarus documents editor" InternalName="LazDE" OriginalFilename="LazDE" ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
@ -165,14 +167,19 @@
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<Version Value="9"/>
|
||||
<Target>
|
||||
<Filename Value="lazde"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)/"/>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Other>
|
||||
<ConfigFile>
|
||||
<StopAfterErrCount Value="10"/>
|
||||
|
Loading…
Reference in New Issue
Block a user