Board index » cppbuilder » TRichEdit/TMemo derived Syntax Highlighting

TRichEdit/TMemo derived Syntax Highlighting


2003-11-12 01:11:21 PM
cppbuilder84
Well, this'll be my first component if I finish writing it :P
I'm fairly new to C++, I taught myself. I've tried scouring the internet for
something I need, but to no avail.
I need to write/get my hands on a component like TMemo/TRichEdit that can
change the formatting of a set of custom keywords. It also needs to be able
to change the formatting of words enclosed in quotes or some other symbol
("", <>, '', etc.)
Could someone help me please? Keep in mind that I don't know that much C++
:$
-- Jeremy
 
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Jeremy" < XXXX@XXXXX.COM >wrote in message
Quote
I need to write/get my hands on a component like TMemo/TRichEdit
that can change the formatting of a set of custom keywords. It also
needs to be able to change the formatting of words enclosed in quotes
or some other symbol ("", <>, '', etc.)
What you are asking for is syntax highlighting, something neither TMemo or
TRichEdit are suited for. There are plenty of third-party components that
are specifically written for, and optimized for, syntax highlighting. You
should have a look at some of them, such as TSynEdit at
synedit.sourceforge.net
Gambit
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Jeremy" < XXXX@XXXXX.COM >wrote in message
news:3fb2298e$ XXXX@XXXXX.COM ...

>I need to write/get my hands on a component like TMemo/TRichEdit
>that can change the formatting of a set of custom keywords. It also
>needs to be able to change the formatting of words enclosed in quotes
>or some other symbol ("", <>, '', etc.)

What you are asking for is syntax highlighting, something neither TMemo or
TRichEdit are suited for. There are plenty of third-party components that
are specifically written for, and optimized for, syntax highlighting. You
should have a look at some of them, such as TSynEdit at
synedit.sourceforge.net


Gambit


Thankyou so much :D
 

{smallsort}

Re:TRichEdit/TMemo derived Syntax Highlighting

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Jeremy" < XXXX@XXXXX.COM >wrote in message
news:3fb2298e$ XXXX@XXXXX.COM ...

>I need to write/get my hands on a component like TMemo/TRichEdit
>that can change the formatting of a set of custom keywords. It also
>needs to be able to change the formatting of words enclosed in quotes
>or some other symbol ("", <>, '', etc.)

What you are asking for is syntax highlighting, something neither TMemo or
TRichEdit are suited for. There are plenty of third-party components that
are specifically written for, and optimized for, syntax highlighting. You
should have a look at some of them, such as TSynEdit at
synedit.sourceforge.net


Gambit


Hmm, whenever I try to install that package (bcb6) it comes up with a bunch
of errors:
[Pascal Hint] SynEdit.pas(6137): Value assigned to 'SpaceCount3' never used
[Pascal Error] SynMacroRecorder.pas(375): Undeclared identifier:
'sListIndexError'
[Pascal Error] SynMacroRecorder.pas(375): There is no overloaded version of
'Error' that can be called with these arguments
[Pascal Fatal Error] SynEditReg.pas(58): Could not compile used unit
'SynMacroRecorder.pas'
[Linker Fatal Error] Fatal: Unable to open file 'SYNEDITREG.OBJ'
I get this with all packages I have tried to install so far. Any clues?
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Jeremy" < XXXX@XXXXX.COM >wrote in message
Quote
[Pascal Hint] SynEdit.pas(6137): Value assigned to 'SpaceCount3'
never used
That is not an error.
Quote
[Pascal Error] SynMacroRecorder.pas(375): Undeclared identifier:
'sListIndexError'
There must have been changes since the last time I downloaded TSynEdit. My
copy of SynMacroRecorder has no references to sListIndexError at all. In
fact, there is no reference to it anywhere in any of the component sources.
I am using SynEdit v1.04 myself. I see that there is a v1.1 available now,
so I will have to go look at it.
Quote
[Pascal Error] SynMacroRecorder.pas(375): There is no overloaded
version of 'Error' that can be called with these arguments
Since I do not have the latest sources to look at, I cannot comment on that.
Quote
[Pascal Fatal Error] SynEditReg.pas(58): Could not compile used
unit 'SynMacroRecorder.pas'
That is just a side-effect of the above.
Quote
[Linker Fatal Error] Fatal: Unable to open file 'SYNEDITREG.OBJ'
That is just a side-effect of the above.
Gambit
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Jeremy" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>[Pascal Hint] SynEdit.pas(6137): Value assigned to 'SpaceCount3'
>never used

That is not an error.

>[Pascal Error] SynMacroRecorder.pas(375): Undeclared identifier:
>'sListIndexError'

There must have been changes since the last time I downloaded TSynEdit.
My
copy of SynMacroRecorder has no references to sListIndexError at all. In
fact, there is no reference to it anywhere in any of the component
sources.
I am using SynEdit v1.04 myself. I see that there is a v1.1 available
now,
so I will have to go look at it.

>[Pascal Error] SynMacroRecorder.pas(375): There is no overloaded
>version of 'Error' that can be called with these arguments

Since I do not have the latest sources to look at, I cannot comment on
that.

>[Pascal Fatal Error] SynEditReg.pas(58): Could not compile used
>unit 'SynMacroRecorder.pas'

That is just a side-effect of the above.

>[Linker Fatal Error] Fatal: Unable to open file 'SYNEDITREG.OBJ'

That is just a side-effect of the above.


Gambit


Sorry for the excessive double-posts, but thanks :) If you want to talk to
me on msn, it's XXXX@XXXXX.COM .
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Jeremy" < XXXX@XXXXX.COM >wrote in message
Quote
[Pascal Error] SynMacroRecorder.pas(375): Undeclared
identifier: 'sListIndexError'
That line should work fine, assuming the RTLConsts unit is being included.
From the source, it looks like it is trying to, but further investigation
shows that the author did not set up his conditionals correctly. The code
is only including RTLConsts under Delphi 6+, not BCB at all.
To fix it, go to the "uses" clause at the top of the "implementation"
section and try changing the following line on line 256:
{$IFDEF SYN_DELPHI_6_UP}
To this instead:
{$IFDEF SYN_COMPILER_6_UP}
Now RTLConsts should be included correctly, and sLineIndexError defined as
expected.
Quote
[Pascal Error] SynMacroRecorder.pas(375): There is no
overloaded version of 'Error' that can be called with these
arguments
That is a side-effect of above. Once sListIndexError is defined correctly,
that line should compile fine as well.
Gambit
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Jeremy" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>[Pascal Error] SynMacroRecorder.pas(375): Undeclared
>identifier: 'sListIndexError'

That line should work fine, assuming the RTLConsts unit is being included.
From the source, it looks like it is trying to, but further investigation
shows that the author did not set up his conditionals correctly. The code
is only including RTLConsts under Delphi 6+, not BCB at all.

To fix it, go to the "uses" clause at the top of the "implementation"
section and try changing the following line on line 256:

{$IFDEF SYN_DELPHI_6_UP}

To this instead:

{$IFDEF SYN_COMPILER_6_UP}

Now RTLConsts should be included correctly, and sLineIndexError defined as
expected.

>[Pascal Error] SynMacroRecorder.pas(375): There is no
>overloaded version of 'Error' that can be called with these
>arguments

That is a side-effect of above. Once sListIndexError is defined
correctly,
that line should compile fine as well.


Gambit


YESS!! :D:D:D thankyou so much!! *hugs and hugs and hugs :)*
Now I can finally get started... :)
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Jeremy" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>[Pascal Error] SynMacroRecorder.pas(375): Undeclared
>identifier: 'sListIndexError'

That line should work fine, assuming the RTLConsts unit is being included.
From the source, it looks like it is trying to, but further investigation
shows that the author did not set up his conditionals correctly. The code
is only including RTLConsts under Delphi 6+, not BCB at all.

To fix it, go to the "uses" clause at the top of the "implementation"
section and try changing the following line on line 256:

{$IFDEF SYN_DELPHI_6_UP}

To this instead:

{$IFDEF SYN_COMPILER_6_UP}

Now RTLConsts should be included correctly, and sLineIndexError defined as
expected.

>[Pascal Error] SynMacroRecorder.pas(375): There is no
>overloaded version of 'Error' that can be called with these
>arguments

That is a side-effect of above. Once sListIndexError is defined
correctly,
that line should compile fine as well.


Gambit


Does it not have custom syntax highlighting?
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Jeremy" < XXXX@XXXXX.COM >wrote in message
Quote
Does it not have custom syntax highlighting?
Highlighting is performed via the Highlighter property, which you need to
assign to a TSynCustomHighlighter-descendant parser component. TSynEdit
comes with several dozen premade parsers. If you want to do custom parsing,
then have a look at the existing TSynGeneralSyn component, or alternatively
write your own parser component. That is one of the key highlights of the
TSynEdit component architecture - the ability to write your own parsers and
plug them in easily.
Gambit
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Jeremy" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>Does it not have custom syntax highlighting?

Highlighting is performed via the Highlighter property, which you need to
assign to a TSynCustomHighlighter-descendant parser component. TSynEdit
comes with several dozen premade parsers. If you want to do custom
parsing,
then have a look at the existing TSynGeneralSyn component, or
alternatively
write your own parser component. That is one of the key highlights of the
TSynEdit component architecture - the ability to write your own parsers
and
plug them in easily.


Gambit


Interesting. What I can't work out is how exactly to use the component. Why
isn't there any documentation? :@ Grr...
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Jeremy" < XXXX@XXXXX.COM >wrote in message
Quote
Interesting. What I can't work out is how exactly to use the
component. Why isn't there any documentation?
There is, well sort of. It is inside the source code itself. If you go
back to the SynEdit website, you will see this blurb:
"The SynEdit sources are being commented to be compatible with the
program pasdoc (pasdoc.sourceforge.net/)."
If you then look at the PasDoc website, it describes itself as the
following:
"The purpose of PasDoc is to document Object Pascal / Delphi source code
from comments within the source code."
Gambit
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote
There is, well sort of. It is inside the source code itself.
In the meantime, you'll just have to play around with the component to see
what all it does. Once you get the hang of the basics, it actually is not a
difficult component to use. I use several instances of it in my project (a
source code viewer), and find the SynEdit components quite flexible and
powerful.
Gambit
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in
message
news:3fb70fc7$ XXXX@XXXXX.COM ...

>There is, well sort of. It is inside the source code itself.

In the meantime, you'll just have to play around with the component to see
what all it does. Once you get the hang of the basics, it actually is not
a
difficult component to use. I use several instances of it in my project
(a
source code viewer), and find the SynEdit components quite flexible and
powerful.


Gambit


The problem is, I don't know how to _use_ it. How do I attach it to an edit
or a memo component? How do I _use_ it?
 

Re:TRichEdit/TMemo derived Syntax Highlighting

"Jeremy" < XXXX@XXXXX.COM >wrote in message
Quote
How do I attach it to an edit or a memo component?
You don't, because TSynEdit and TSynMemo are already the actual edit
components. You do not use them with the standard TEdit/TMemo components at
all. TSynEdit/TSynMemo are replacement components, not companion
components. They do everything that the standard controls do, with syntax
highlighting, search/replace, gutters, etc/ built right in. So, what
exactly is there left to understand? Drop a TSynMemo on the form, then drop
a syntax parser component onto the form (such as TSynHighlighterCpp), and
then assign the parser to the SynMemo's Highlighter property. That's all.
Whenever you load/type C++ code into the memo, it will automatically be
highlighted appropriately. You can then use TSynHighlighterCpp's properties
to fine-tune the formatting, colors, etc. as desired. Beyond that, just
look at the SynMemo's header file to see what else it supports. There is a
lot in there to learn from. It is not a complicated component, it just has
a lot of little individual functionalities built into it.
Gambit