Autor Beitrag
Mike_C
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: So 07.09.03 16:27 
Hi
Wie kann ich rausfinden, an welcher stelle im Text, der in einer TRichEdit-Komponente "gespeichert" ist, sich ein bestimmtes Wort befindet?

Am Beispiel meiner Anwednung wird vielleicht deutlich, was ich will.
ich will eine art Syntax-Highlighting realisieren. Dazu hab ich eine Reihe Keywords definiert, die blau eingefärbt werden sollen. Mein Problem ist, wie finde ich in einem mehrzeiligen Text die Keywords? Oder besser gesagt, wie fange ich eine Suche an einer bestimmten Stelle im Text an (z.B. am anfang einer neues Zeile)?

Mit SelStart komme ich da glaub ich nicht weiter, weil ich dazu wissen müsste, an welcher stelle im Text das gesuchte Wort steht...

Hoffentlich versteht ihr mein Problem :?
und
Hoffentlich könnt ihr mir helfen... :roll:

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Mike_C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Mo 08.09.03 12:11 
Ich glaube ich habe die Lösung gefunden...
Die beschriebung dazu ist hier
www.welnet4u.de/wf/v...churches&p=19#19

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
barfuesser
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 324



BeitragVerfasst: Mo 08.09.03 13:14 
Da es um Syntaxhighlighting geht, würde ich empfehlen, den kompletten Text zu parsen bevor er im Richedit angezeigt wird. Für den Text, der direkt im Richedit eingegeben wird, würde ich das OnChange-Ereignis abfangen, und dann nur die einzelnen Worte überprüfen.
Das bringt den Vorteil, daß nur reiner Text ohne Steueranweisungen geparst werden muß.

barfuesser
Mike_C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Mo 08.09.03 15:12 
Das ist ansich keine schlechte Idee. nur gibts dabei ein Problem:
wenn ich jetzt irgendwo im Text etwas ändere, woher weiß ich, an welcher stelle vom Text ich mich befinde? das onChangeEvent liefert mir ja keine Informationen darüber, wo sich der Textcursor befindet. und damit wären wir wieder beim ausgangsproblem. letztendlich kommt man wohl nicht drum rum das Syntax-Highlighting zeile für zeile zu machen und zwar immer wenn sich das Richedit-Feld ändert. oder geht das auch irgendwie anders???

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 08.09.03 15:15 
Mike_C hat folgendes geschrieben:
wenn ich jetzt irgendwo im Text etwas ändere, woher weiß ich, an welcher stelle vom Text ich mich befinde?

Dieser FAQ Beitrag sollte auch für das RichEdit funktionieren: ...die Zeile/Spalte in Memos lesen/setzen?

Ich würde dir allerdings die SynEdit Komponente empfehlen.

Gruß
Tino
Mike_C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Mo 08.09.03 15:27 
Hmm sieht so aus, als würde SyEdit komplettes SyntaxHighlighting mit Highlight-Templates unterstützen... nicht schlecht. ich werde sie mal ausprobieren. Danke für eure Hilfe!

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Mike_C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Mo 08.09.03 15:46 
@Tino: hast du eine lauffähige version von SynEdit? ich hab mir die komponente runtergeladen, aber ich kann das Package nicht installieren.
weißt du zufällig, wo die klassen: TFontProperty , TIntegerProperty, TClassProperty und TPropertyEditor definiert sind?

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 08.09.03 15:57 
Mike_C hat folgendes geschrieben:
weißt du zufällig, wo die klassen: [...]

DsgnIntf.pas

Gruß
Tino
Mike_C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: Mo 08.09.03 15:58 
ich hab nur eine DesignIntf aber da sind die nicht definiert

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 09.09.03 08:04 
Das kann an deinen Version 7 liegen. Aber lass doch mal dein Delphi Verzeichnis nach einen String (z. B. tFontProperty) durchsuchen. Bei der Enterprise Version sind die Sourcen ja dabei.

Gruß
Tino