Autor Beitrag
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Mo 20.12.04 17:38 
Hallo!
Ich wollte dem User meines Proggs die möglichkeit geben, die Highlighter selbst einzustellen. damit ich das ganze Zeug nicht immer schreiben muss, habe ich folgende Fkt geschrieben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function TForm1.SetAttr: TSynHighlighterAttributes;
begin
 result:= TSynHighlighterAttributes.Create('');
 result.Foreground:= pVGColor.Color;
 result.Background:= pHGColor.Color;
 result.Style:= [];
 if cbBold.Checked then result.Style:= result.Style + [fsBold];
 if cbItalic.Checked then result.Style:= result.Style + [fsItalic];
 if cbUnderline.Checked then result.Style:= result.Style + [fsUnderline];
 if cbStrikeOut.Checked then result.Style:= result.Style + [fsStrikeOut];
end;


und dann aktualiesiere ich die Highlighter je nach ListBox / COmboBox eintrag

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
case lbElement.ItemIndex of
           0: synHLhtml.AndAttri:= SetAttr;
           1: synHLhtml.ASPAttri:= SetAttr;
           2: synHLhtml.CommentAttri:= SetAttr;
...


geht alles prima, im Vorschau synedit wird alles richtig angezeigt, aber wenn ich dann
ausblenden Delphi-Quelltext
1:
synHLhtml.SaveToFile('C:\test.hl'); // FileName geändert ;)					

aufruf, speichert er immer die Einstellungen, die der Highlighter von Anfang an hatte.

Ich versteh nun wirklich nicht, woran das liegt. Hat jmd eine Idee? NOtfalls müsste ich die Speicher- und Laderoutine selbst schreiben... *brr*


ausblenden volle Höhe gespeicherte Datei
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
[Asp]
Background=65535
Foreground=0
Style=0

[Comment]
Background=536870911
Foreground=536870911
Style=0

[Escape ampersand]
Background=536870911
Foreground=65280
Style=1

[Identifier]
Background=536870911
Foreground=536870911
Style=1

[Reserved word]
Background=536870911
Foreground=16711808
Style=1

[Space]
Background=536870911
Foreground=536870911
Style=0

[Symbol]
Background=536870911
Foreground=536870911
Style=1

[Text]
Background=536870911
Foreground=536870911
Style=0

[Unknown word]
Background=536870911
Foreground=255
Style=1

[Value]
Background=536870911
Foreground=16744448
Style=0

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
Grendel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 443

Gentoo Linux, MacOS X, Win 2000
D5 Ent, D7 Ent, Lazarus, Anjuta, MonoDevelop
BeitragVerfasst: Mo 20.12.04 18:04 
Was ist ein "SynEdit"? und von was ist deine Klasse abgeleitet?
Poste am besten mal den gesamten Quelltext der Highlighter Klasse.

Ich müsste nämlich mal sehen, was beim Zuweisen eines TSynHighlighterAttributes genau passiert.

Und mach bei der Zuweisung mal ein Assign() also
ausblenden Delphi-Quelltext
1:
2:
3:
  0: synHLhtml.AndAttri.Assign(SetAttr());  
  1: synHLhtml.ASPAttri.Assign(SetAttr());  
...


Bis neulich ...
StefanH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Mo 20.12.04 18:12 
die Klasse ist nicht von mir. und mit Assign gehts auch nicht. und außerdem geht ja alles bis auf das Speichern :twisted:

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
Grendel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 443

Gentoo Linux, MacOS X, Win 2000
D5 Ent, D7 Ent, Lazarus, Anjuta, MonoDevelop
BeitragVerfasst: Mo 20.12.04 18:17 
Ohne in die Klasse zu gucken kann ich dir leider nicht helfen.
Außerdem wäre noch immer interesant, von welcher Klasse dein Highlighter abgeleitet ist.

Bis neulich ...
Jelzin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mo 20.12.04 21:36 
Die Komponente gibts hier:
synedit.sourceforge.net/

Ist im Prinzip ein Memo, das wie ein RichEdit Zeilen farbig darstellt. Viele "Highlighter" sind vordefiniert, um z.B. Delphi-Quelltext entsprechend dem Delphi-Editor farbig anzuzeigen.

Hat wahnsinnig Power die Komponente. Find ich recht gut.

Bei der Gelegenheit verweis ich auch auf meinen Threat, bei meinem Problem konnte mir bis jetzt noch niemand weiterhelfen :cry:

www.delphi-forum.de/...ghlighten_33863.html
StefanH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Do 23.12.04 20:41 
naja, ich werd das dann wohl doch selbst schreiben :?

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
Benutzername
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 210

Win XP Pro
Delphi 7 PE, D2005 Prof. SSL
BeitragVerfasst: Do 23.12.04 22:08 
OT:
Zitat:
Bei der Gelegenheit verweis ich auch auf meinen Threat[...]


Besser nicht, denn Threat heißt soviel wie 'Drohung' ;-)
Benedikt
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 24.12.04 01:47 
Hi,

ich hab mal den von dir geposteten Quelltext ausprobiert und bin zum gleichen Ergebnis gekommen -> die Farben werden nicht abgespeichert!

Deshalb würde ich dir empfehlen das Ganze ein wenig anders, allerdings eigentlich auch praktischer zu machen:

Zuerst würde ich alle Eigenschaften der Highlighter-Komponente automatisch laden lassen, z.B. in eine ListBox (ist es ja in deinem Falle denk ich auch):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
  var i:  Integer;
begin
   for i:=0 to SynEdit1.Highlighter.AttrCount-1 do
      ListBox1.Items.Add(SynEdit1.Highlighter.Attribute[i].Name);



Und dann deine Aktualisierungsprozedur, z.B. im OnClick eines Buttons:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.Button1Click(Sender: TObject);
  var Style:  Integer;
begin
   SynEdit1.Highlighter.Attribute[ListBox1.ItemIndex].Foreground:=pVGColor.Color;
   SynEdit1.Highlighter.Attribute[ListBox1.ItemIndex].Background:=pHGColor.Color;

   if (cbBold.Checked) then
      Style:=1
   else
      Style:=0;

   if (cbItalic.Checked) then
      Style:=Style+2;
   if (cbUnderline.Checked) then
      Style:=Style+4;
   if (cbStrikeOut.Checked) then
      Style:=Style+8;

   SynEdit1.Highlighter.Attribute[ListBox1.ItemIndex].IntegerStyle:=Style;
end;



Wenn du jetzt SynEdit1.Highlighter.SaveToFile('C:\sonstwas.sonstwo'); aufrufst, müsste alles ohne Probleme funktionieren...