mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-12 00:28:18 +02:00
- stores edited data with unix line ending
- converts retrieved data from XML file to native line ending - errors and short elements are now also supported - some unnescesary updating is now prevented From Darius git-svn-id: trunk@7692 -
This commit is contained in:
parent
c727146b87
commit
fd1a7b2358
@ -1,5 +1,5 @@
|
|||||||
object LazDocForm: TLazDocForm
|
object LazDocForm: TLazDocForm
|
||||||
ActiveControl = TabSheet1
|
ActiveControl = ErrorsTabSheet
|
||||||
Caption = 'LazDoc editor'
|
Caption = 'LazDoc editor'
|
||||||
ClientHeight = 195
|
ClientHeight = 195
|
||||||
ClientWidth = 753
|
ClientWidth = 753
|
||||||
@ -12,15 +12,31 @@ object LazDocForm: TLazDocForm
|
|||||||
Top = 506
|
Top = 506
|
||||||
Width = 753
|
Width = 753
|
||||||
object PageControl: TPageControl
|
object PageControl: TPageControl
|
||||||
ActivePage = TabSheet1
|
ActivePage = ErrorsTabSheet
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabIndex = 0
|
TabIndex = 2
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
TabPosition = tpBottom
|
TabPosition = tpBottom
|
||||||
Height = 195
|
Height = 195
|
||||||
Width = 753
|
Width = 753
|
||||||
object TabSheet1: TTabSheet
|
object ShortTabSheet: TTabSheet
|
||||||
Caption = 'TabSheet1'
|
Caption = 'ShortTabSheet'
|
||||||
|
ClientHeight = 169
|
||||||
|
ClientWidth = 745
|
||||||
|
Height = 169
|
||||||
|
Width = 745
|
||||||
|
object ShortEdit: TEdit
|
||||||
|
Align = alTop
|
||||||
|
BorderSpacing.OnChange = nil
|
||||||
|
OnChange = DescrMemoChange
|
||||||
|
TabOrder = 0
|
||||||
|
Text = 'ShortEdit'
|
||||||
|
Height = 23
|
||||||
|
Width = 745
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object DescrTabSheet: TTabSheet
|
||||||
|
Caption = 'DescrTabSheet'
|
||||||
ClientHeight = 169
|
ClientHeight = 169
|
||||||
ClientWidth = 745
|
ClientWidth = 745
|
||||||
Height = 169
|
Height = 169
|
||||||
@ -32,6 +48,32 @@ object LazDocForm: TLazDocForm
|
|||||||
Font.Height = -12
|
Font.Height = -12
|
||||||
Font.Name = 'Courier New'
|
Font.Name = 'Courier New'
|
||||||
Font.Pitch = fpFixed
|
Font.Pitch = fpFixed
|
||||||
|
Lines.Strings = (
|
||||||
|
'DescrMemo'
|
||||||
|
)
|
||||||
|
OnChange = DescrMemoChange
|
||||||
|
TabOrder = 0
|
||||||
|
Height = 169
|
||||||
|
Width = 745
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object ErrorsTabSheet: TTabSheet
|
||||||
|
Caption = 'ErrorsTabSheet'
|
||||||
|
ClientHeight = 169
|
||||||
|
ClientWidth = 745
|
||||||
|
Height = 169
|
||||||
|
Width = 745
|
||||||
|
object ErrorsMemo: TMemo
|
||||||
|
Align = alClient
|
||||||
|
BorderSpacing.OnChange = nil
|
||||||
|
Font.CharSet = ANSI_CHARSET
|
||||||
|
Font.Color = clBlack
|
||||||
|
Font.Height = -12
|
||||||
|
Font.Name = 'Courier New'
|
||||||
|
Font.Pitch = fpFixed
|
||||||
|
Lines.Strings = (
|
||||||
|
'ErrorsMemo'
|
||||||
|
)
|
||||||
OnChange = DescrMemoChange
|
OnChange = DescrMemoChange
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
Height = 169
|
Height = 169
|
||||||
@ -39,11 +81,4 @@ object LazDocForm: TLazDocForm
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object OpenDialog1: TOpenDialog
|
|
||||||
Title = 'Open existing file'
|
|
||||||
FilterIndex = 0
|
|
||||||
Title = 'Open existing file'
|
|
||||||
left = 29
|
|
||||||
top = 720
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -1,19 +1,29 @@
|
|||||||
{ This is an automatically generated lazarus resource file }
|
{ This is an automatically generated lazarus resource file }
|
||||||
|
|
||||||
LazarusResources.Add('TLazDocForm','FORMDATA',[
|
LazarusResources.Add('TLazDocForm','FORMDATA',[
|
||||||
'TPF0'#11'TLazDocForm'#10'LazDocForm'#13'ActiveControl'#7#9'TabSheet1'#7'Capt'
|
'TPF0'#11'TLazDocForm'#10'LazDocForm'#13'ActiveControl'#7#14'ErrorsTabSheet'#7
|
||||||
+'ion'#6#13'LazDoc editor'#12'ClientHeight'#3#195#0#11'ClientWidth'#3#241#2#8
|
+'Caption'#6#13'LazDoc editor'#12'ClientHeight'#3#195#0#11'ClientWidth'#3#241
|
||||||
+'OnCreate'#7#10'FormCreate'#13'PixelsPerInch'#2'`'#18'HorzScrollBar.Page'#3
|
+#2#8'OnCreate'#7#10'FormCreate'#13'PixelsPerInch'#2'`'#18'HorzScrollBar.Page'
|
||||||
+#240#2#18'VertScrollBar.Page'#3#194#0#4'Left'#3#245#0#6'Height'#3#195#0#3'To'
|
+#3#240#2#18'VertScrollBar.Page'#3#194#0#4'Left'#3#245#0#6'Height'#3#195#0#3
|
||||||
+'p'#3#250#1#5'Width'#3#241#2#0#12'TPageControl'#11'PageControl'#10'ActivePag'
|
+'Top'#3#250#1#5'Width'#3#241#2#0#12'TPageControl'#11'PageControl'#10'ActiveP'
|
||||||
+'e'#7#9'TabSheet1'#5'Align'#7#8'alClient'#8'TabIndex'#2#0#8'TabOrder'#2#0#11
|
+'age'#7#14'ErrorsTabSheet'#5'Align'#7#8'alClient'#8'TabIndex'#2#2#8'TabOrder'
|
||||||
+'TabPosition'#7#8'tpBottom'#6'Height'#3#195#0#5'Width'#3#241#2#0#9'TTabSheet'
|
+#2#0#11'TabPosition'#7#8'tpBottom'#6'Height'#3#195#0#5'Width'#3#241#2#0#9'TT'
|
||||||
+#9'TabSheet1'#7'Caption'#6#9'TabSheet1'#12'ClientHeight'#3#169#0#11'ClientWi'
|
+'abSheet'#13'ShortTabSheet'#7'Caption'#6#13'ShortTabSheet'#12'ClientHeight'#3
|
||||||
+'dth'#3#233#2#6'Height'#3#169#0#5'Width'#3#233#2#0#5'TMemo'#9'DescrMemo'#5'A'
|
+#169#0#11'ClientWidth'#3#233#2#6'Height'#3#169#0#5'Width'#3#233#2#0#5'TEdit'
|
||||||
+'lign'#7#8'alClient'#12'Font.CharSet'#7#12'ANSI_CHARSET'#10'Font.Color'#7#7
|
+#9'ShortEdit'#5'Align'#7#5'alTop'#22'BorderSpacing.OnChange'#13#8'OnChange'#7
|
||||||
+'clBlack'#11'Font.Height'#2#244#9'Font.Name'#6#11'Courier New'#10'Font.Pitch'
|
+#15'DescrMemoChange'#8'TabOrder'#2#0#4'Text'#6#9'ShortEdit'#6'Height'#2#23#5
|
||||||
+#7#7'fpFixed'#8'OnChange'#7#15'DescrMemoChange'#8'TabOrder'#2#0#6'Height'#3
|
+'Width'#3#233#2#0#0#0#9'TTabSheet'#13'DescrTabSheet'#7'Caption'#6#13'DescrTa'
|
||||||
+#169#0#5'Width'#3#233#2#0#0#0#0#11'TOpenDialog'#11'OpenDialog1'#5'Title'#6#18
|
+'bSheet'#12'ClientHeight'#3#169#0#11'ClientWidth'#3#233#2#6'Height'#3#169#0#5
|
||||||
+'Open existing file'#11'FilterIndex'#2#0#5'Title'#6#18'Open existing file'#4
|
+'Width'#3#233#2#0#5'TMemo'#9'DescrMemo'#5'Align'#7#8'alClient'#12'Font.CharS'
|
||||||
+'left'#2#29#3'top'#3#208#2#0#0#0
|
+'et'#7#12'ANSI_CHARSET'#10'Font.Color'#7#7'clBlack'#11'Font.Height'#2#244#9
|
||||||
|
+'Font.Name'#6#11'Courier New'#10'Font.Pitch'#7#7'fpFixed'#13'Lines.Strings'#1
|
||||||
|
+#6#9'DescrMemo'#0#8'OnChange'#7#15'DescrMemoChange'#8'TabOrder'#2#0#6'Height'
|
||||||
|
+#3#169#0#5'Width'#3#233#2#0#0#0#9'TTabSheet'#14'ErrorsTabSheet'#7'Caption'#6
|
||||||
|
+#14'ErrorsTabSheet'#12'ClientHeight'#3#169#0#11'ClientWidth'#3#233#2#6'Heigh'
|
||||||
|
+'t'#3#169#0#5'Width'#3#233#2#0#5'TMemo'#10'ErrorsMemo'#5'Align'#7#8'alClient'
|
||||||
|
+#22'BorderSpacing.OnChange'#13#12'Font.CharSet'#7#12'ANSI_CHARSET'#10'Font.C'
|
||||||
|
+'olor'#7#7'clBlack'#11'Font.Height'#2#244#9'Font.Name'#6#11'Courier New'#10
|
||||||
|
+'Font.Pitch'#7#7'fpFixed'#13'Lines.Strings'#1#6#10'ErrorsMemo'#0#8'OnChange'
|
||||||
|
+#7#15'DescrMemoChange'#8'TabOrder'#2#0#6'Height'#3#169#0#5'Width'#3#233#2#0#0
|
||||||
|
+#0#0#0
|
||||||
]);
|
]);
|
||||||
|
@ -54,21 +54,26 @@ type
|
|||||||
TFPDocNode = record
|
TFPDocNode = record
|
||||||
Short: String;
|
Short: String;
|
||||||
Descr: String;
|
Descr: String;
|
||||||
|
Errors: String;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TLazDocForm }
|
{ TLazDocForm }
|
||||||
|
|
||||||
TLazDocForm = class(TForm)
|
TLazDocForm = class(TForm)
|
||||||
DescrMemo: TMemo;
|
DescrMemo: TMemo;
|
||||||
OpenDialog1: TOpenDialog;
|
ShortEdit: TEdit;
|
||||||
|
ErrorsMemo: TMemo;
|
||||||
PageControl: TPageControl;
|
PageControl: TPageControl;
|
||||||
TabSheet1: TTabSheet;
|
DescrTabSheet: TTabSheet;
|
||||||
|
ErrorsTabSheet: TTabSheet;
|
||||||
|
ShortTabSheet: TTabSheet;
|
||||||
procedure DescrMemoChange(Sender: TObject);
|
procedure DescrMemoChange(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
FDocFileName: String;
|
FDocFileName: String;
|
||||||
FCurrentElement: String;
|
FCurrentElement: String;
|
||||||
|
FLastElement: String;
|
||||||
procedure SetDocFileName(Value: String);
|
procedure SetDocFileName(Value: String);
|
||||||
function NodeByName(ElementName: String): TDOMNode;
|
function NodeByName(ElementName: String): TDOMNode;
|
||||||
function GetFirstChildValue(n: TDOMNode): String;
|
function GetFirstChildValue(n: TDOMNode): String;
|
||||||
@ -119,7 +124,9 @@ begin
|
|||||||
ReadXMLFile(doc, FDocFileName);
|
ReadXMLFile(doc, FDocFileName);
|
||||||
|
|
||||||
//clear all element editors/viewers
|
//clear all element editors/viewers
|
||||||
|
ShortEdit.Clear;
|
||||||
DescrMemo.Clear;
|
DescrMemo.Clear;
|
||||||
|
ErrorsMemo.Clear;
|
||||||
|
|
||||||
SetCaption;
|
SetCaption;
|
||||||
|
|
||||||
@ -136,9 +143,16 @@ begin
|
|||||||
|
|
||||||
with PageControl do
|
with PageControl do
|
||||||
begin
|
begin
|
||||||
Page[0].Caption := 'Description';
|
Page[0].Caption := 'Short';
|
||||||
|
Page[1].Caption := 'Description';
|
||||||
|
Page[2].Caption := 'Errors';
|
||||||
PageIndex := 0;
|
PageIndex := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
//clear all element editors/viewers
|
||||||
|
ShortEdit.Clear;
|
||||||
|
DescrMemo.Clear;
|
||||||
|
ErrorsMemo.Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLazDocForm.NodeByName(ElementName: String): TDOMNode;
|
function TLazDocForm.NodeByName(ElementName: String): TDOMNode;
|
||||||
@ -147,6 +161,15 @@ var
|
|||||||
begin
|
begin
|
||||||
Result := Nil;
|
Result := Nil;
|
||||||
|
|
||||||
|
if not Assigned(doc) then
|
||||||
|
begin
|
||||||
|
{$ifdef dbgLazDoc}
|
||||||
|
DebugLn('TLazDocForm.NodeByName: document is not set');
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
//get first node
|
//get first node
|
||||||
n := doc.FindNode('fpdoc-descriptions');
|
n := doc.FindNode('fpdoc-descriptions');
|
||||||
|
|
||||||
@ -219,12 +242,9 @@ begin
|
|||||||
|
|
||||||
if S = 'descr' then
|
if S = 'descr' then
|
||||||
Result.Descr := GetFirstChildValue(Node);
|
Result.Descr := GetFirstChildValue(Node);
|
||||||
//else if S='errors' then
|
|
||||||
//FErrorsNode:=Node.NodeValue
|
if S='errors' then
|
||||||
//else if S='seealso' then
|
Result.Errors := GetFirstChildValue(Node);
|
||||||
//FSeeAlsoNode:=Node.NodeValue
|
|
||||||
//else if S='example' then
|
|
||||||
//FExampleNodes.Add(n);
|
|
||||||
end;
|
end;
|
||||||
Node := Node.NextSibling;
|
Node := Node.NextSibling;
|
||||||
end;
|
end;
|
||||||
@ -240,7 +260,7 @@ begin
|
|||||||
ypos := startpos.y;
|
ypos := startpos.y;
|
||||||
|
|
||||||
result := '';
|
result := '';
|
||||||
while (src[ypos][xpos] <> '(') and (src[ypos][xpos] <> ';') do
|
while (src[ypos][xpos] <> '(') and (src[ypos][xpos] <> ';') and (src[ypos][xpos] <> ':') do
|
||||||
begin
|
begin
|
||||||
Result := Result + src[ypos][xpos];
|
Result := Result + src[ypos][xpos];
|
||||||
Inc(xpos);
|
Inc(xpos);
|
||||||
@ -303,6 +323,7 @@ procedure TLazDocForm.UpdateLazDoc(source: TStrings; pos: TPoint);
|
|||||||
var
|
var
|
||||||
dn: TFPDocNode;
|
dn: TFPDocNode;
|
||||||
n: TDOMNode;
|
n: TDOMNode;
|
||||||
|
EnabledState: boolean;
|
||||||
begin
|
begin
|
||||||
if not Assigned(doc) then
|
if not Assigned(doc) then
|
||||||
begin
|
begin
|
||||||
@ -317,20 +338,50 @@ begin
|
|||||||
|
|
||||||
SetCaption;
|
SetCaption;
|
||||||
|
|
||||||
|
//do not continue if FCurrentElement=FLastElement
|
||||||
|
//or FCurrentElement is empty (J. Reyes)
|
||||||
|
if (FCurrentElement = FLastElement) or (FCurrentElement = '') then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
FLastElement := FCurrentElement;
|
||||||
|
|
||||||
n := NodeByName(FCurrentElement);
|
n := NodeByName(FCurrentElement);
|
||||||
|
|
||||||
DescrMemo.Enabled := Assigned(n);
|
EnabledState := Assigned(n);
|
||||||
|
|
||||||
|
ShortEdit.Enabled := True;
|
||||||
|
DescrMemo.Enabled := True;
|
||||||
|
ErrorsMemo.Enabled := True;
|
||||||
|
|
||||||
|
//detach the update method, because changing the text already
|
||||||
|
//commits to XML. Fix later, hack now ;)
|
||||||
|
ShortEdit.OnChange := nil;
|
||||||
|
DescrMemo.OnChange := nil;
|
||||||
|
ErrorsMemo.OnChange := nil;
|
||||||
|
|
||||||
if Assigned(n) then
|
if Assigned(n) then
|
||||||
begin
|
begin
|
||||||
dn := ElementFromNode(n);
|
dn := ElementFromNode(n);
|
||||||
|
|
||||||
DescrMemo.Lines.Text := dn.Descr;
|
ShortEdit.Text := dn.Short;
|
||||||
|
DescrMemo.Lines.Text := ConvertLineEndings(dn.Descr);
|
||||||
|
ErrorsMemo.Lines.Text := ConvertLineEndings(dn.Errors);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
ShortEdit.Text := NODOCUMENTATION;
|
||||||
DescrMemo.Lines.Text := NODOCUMENTATION;
|
DescrMemo.Lines.Text := NODOCUMENTATION;
|
||||||
|
ErrorsMemo.Lines.Text := NODOCUMENTATION;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
//attach the update method again
|
||||||
|
ShortEdit.OnChange := @DescrMemoChange;
|
||||||
|
DescrMemo.OnChange := @DescrMemoChange;
|
||||||
|
ErrorsMemo.OnChange := @DescrMemoChange;
|
||||||
|
|
||||||
|
ShortEdit.Enabled := EnabledState;
|
||||||
|
DescrMemo.Enabled := EnabledState;
|
||||||
|
ErrorsMemo.Enabled := EnabledState;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazDocForm.DescrMemoChange(Sender: TObject);
|
procedure TLazDocForm.DescrMemoChange(Sender: TObject);
|
||||||
@ -351,16 +402,43 @@ begin
|
|||||||
begin
|
begin
|
||||||
S := n.NodeName;
|
S := n.NodeName;
|
||||||
|
|
||||||
if S = 'descr' then
|
if S = 'short' then
|
||||||
begin
|
begin
|
||||||
if not Assigned(n.FirstChild) then
|
if not Assigned(n.FirstChild) then
|
||||||
begin
|
begin
|
||||||
child := doc.CreateTextNode(DescrMemo.Text);
|
child := doc.CreateTextNode(ShortEdit.Text);
|
||||||
n.AppendChild(child);
|
n.AppendChild(child);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
n.FirstChild.NodeValue := DescrMemo.Text;
|
n.FirstChild.NodeValue := ShortEdit.Text;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if S = 'descr' then
|
||||||
|
begin
|
||||||
|
DescrMemo.Lines.Delimiter := #10;
|
||||||
|
|
||||||
|
if not Assigned(n.FirstChild) then
|
||||||
|
begin
|
||||||
|
child := doc.CreateTextNode(DescrMemo.Lines.DelimitedText);
|
||||||
|
n.AppendChild(child);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
n.FirstChild.NodeValue := DescrMemo.Lines.DelimitedText;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if S = 'errors' then
|
||||||
|
begin
|
||||||
|
ErrorsMemo.Lines.Delimiter := #10;
|
||||||
|
|
||||||
|
if not Assigned(n.FirstChild) then
|
||||||
|
begin
|
||||||
|
child := doc.CreateTextNode(ErrorsMemo.Lines.DelimitedText);
|
||||||
|
n.AppendChild(child);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
n.FirstChild.NodeValue :=ErrorsMemo.Lines.DelimitedText;
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
n := n.NextSibling;
|
n := n.NextSibling;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user