[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] Need Advice on Text Editor Design
|
I have started writing my first text editor and have run into a problem.
In the document that will be edited there are macro calls which I would
eventually like to process for correctness (e.g. number of parameters is
correct for specified macro). However, within these macro calls, a user
can have inlined code sections which typically start and end with
special keywords. I would like to uniformly colorize the inlined code
section and italicize it so it is obvious it is inlined code.
A MultiLineRule seems to be a perfect fit for how to detect this section.
I don't know whether to give the section its own partition. If I give
it its own partition, it would appear that I would semantically break
the document up incorrectly as macros could be split into multiple pieces.
When I try and treat a macro as a partition and then use a
RuleBasedScanner that has a MultiLineRule to find the inlined code
section within it, editing within the inlined section doesn't work. I
am finding that the DefaultDamagerRepairer I am using has no concept of
damage to a multi-line area. When it detects a change, it creates a
damage area that it calculates from the line info (DefaultLineTracker
which gives back line start and length). This causes problems later
when we try and evaluate the damage using the RuleBasedScanner for the
macro partition. The MultiLineRule for the inlined code needs to see
both the start-sequence and end-sequence to give back the correct token.
This never happens because the damage region is restricted to one line
in the document. Thus, any change to an inlined code section causes it
to incorrectly change color and font style for that line.
When I give the inlined code its own partition, it all works fine
because the partitioner correctly processes all the lines involved after
the change.
So, the question is: how does one typically design the editor for such a
situation? Should I be using a partition or is a specialized
DamagerRepairer the correct way to go?
-- Jeff J.