Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-06

SynEdit question (IFDEF SYN_LAZARUS)

11 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin Friebe

Hi

I was just wondering, in Synedit, there are many Lazarus specific modifications. On top of this the original code (or what I believe to be the original code) is kept.
They are distinguished by "IFDEF SYNLAZ" statements.

The question is what is the reason to keep the old/original code? As far as I can see it isn't even used. Because until a week ago one of the IFDEF had its IF/ELSE blocks swapped, so the Non-Laz version would have a reference to a Method only defined in the Laz-Version. In other words until a week ago, the non-laz version afaik wouldn't even have compiled.

If anyone knows any background on this, I would be interested in hearing it. But it isn't important. I don't need the answer to archive anything, except satisfying my curiosity.

Thanks
Martin

ps.

The "swapped" ifdef I am talking about was fixed by the patch for http://bugs.freepascal.org/view.php?id=10591 (see the snipped below) The "else" was refering to ScreenRowToRow, which is declared inside a "ifdef syn_laz" block only.

Show quoted text 16 lines
--- components/synedit/synedit.pp (revision 15471) +++ components/synedit/synedit.pp (working copy) @@ -2691,8 +2691,11 @@ nC2 := nC1 + (rcClip.Right - fGutterWidth - 2 + CharWidth - 1) div CharWidth; // lines - nL1 := Max({$IFDEF SYN_LAZARUS}TopLine + rcClip.Top div fTextHeight - {$ELSE}ScreenRowToRow(rcClip.Top div fTextHeight){$ENDIF}, + nL1 := Max({$IFDEF SYN_LAZARUS} + ScreenRowToRow(rcClip.Top div fTextHeight) + {$ELSE} + TopLine + rcClip.Top div fTextHeight + {$ENDIF}, TopLine); nL2 := Min({$IFDEF SYN_LAZARUS} ScreenRowToRow((rcClip.Bottom-1) div fTextHeight+1),

Reply by email

Martin Friebe
to Mattias Gärtner

Makes sense,or well depends on how old the plans are, and how much SynEdit has moved since.
One block, that is of particular interest to me is the PaintLines.

PaintLines happens to be an IFDEF SYNLAZ over several 100 (or 1000?) lines. A complete Lazarus, and a complete Original version. IMHO an IfDef of this Size IMHO doesn't serve the protection/diff purpose very much?

I have a patch/prototype (still some cleanup on it) for a "highlight All" during search feature. Marc Weustink has a copy of this (because I had previously send other patches to him).
This will however require some changes to PaintToken. Also PaintToken appears to have several other shortcomings/bugs, which could easily be fixed/
=> but all of those would probably end up in a rewrite of PaintToken (which is why I haven't reported those issues yet)

Any feedback guiding me in this issue would be welcome. I can also (in the evening) mail my prototype and comments about it => but I don't know what/if Marc has any plans on it.

Another idea (and so far not beyond the state of an idea) is to move all TextMarking (HighlightBrackets, SpecialLines, SelectedBlock, and the new HighlightAll => features that are not SynEditHighlighter), into a new class SynEditTextMarkup. However "PaintLines" still would need changes.

Best Regards
Martin

Mattias G?rtner wrote 35 lines
Zitat von Martin Friebe : > Hi > > I was just wondering, in Synedit, there are many Lazarus specific > modifications. On top of this the original code (or what I believe to be > the original code) is kept. > They are distinguished by "IFDEF SYNLAZ" statements. > > The question is what is the reason to keep the old/original code? As far > as I can see it isn't even used. Because until a week ago one of the > IFDEF had its IF/ELSE blocks swapped, so the Non-Laz version would have > a reference to a Method only defined in the Laz-Version. In other words > until a week ago, the non-laz version afaik wouldn't even have compiled. > It was the goal that lazarus uses the code of the synedit project with some modifications. And contribute the mods back so that one version can be used for lazarus and delphi.. If the ifdefs are removed, I fear that people start code formatting and refactoring and then it will be much harder/impossible to fetch the differences. Unless you know/write a tool for that. So, it's true that the $else parts are not actively used. Mattias _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Martin Friebe
to Mattias Gärtner
Yes. And we need markers for live templates. For example some green blocks and some red blocks. The HighlightAll markers can be used for identifier references too.

Not sure what you refer too.

But it will probably work. Not necessarily with the highlight all (which is search based).

But it should be easy once I have an  SynEditTextMarkup object.
The idea is that it provides functions like
MarkupStyleAndColorAtPos( XPosInLine ) : SomeStyleInfo;
XPosOfNextMarkupChange( CurrentXPosInLine ) : integer;

Then while adding a token, to the token akku, it would be splitted (if needed) and the markup applied.
=> so any other (non Language (eg non-pascal, non-html,...)) Markup, could be done in there.

I'll post more, once I converted my current proto-type, to support this.

BestRegards
Martin

Mattias G?rtner wrote 60 lines
Zitat von Martin Friebe : > Makes sense,or well depends on how old the plans are, and how much > SynEdit has moved since. > One block, that is of particular interest to me is the PaintLines. > > PaintLines happens to be an IFDEF SYNLAZ over several 100 (or 1000?) > lines. A complete Lazarus, and a complete Original version. > IMHO an IfDef of this Size IMHO doesn't serve the protection/diff > purpose very much? > There were so many IFDEFs in that part that it was hardly readable. It reached a critical limit. > I have a patch/prototype (still some cleanup on it) for a "highlight > All" during search feature. > Cool. > Marc Weustink has a copy of this (because I > had previously send other patches to him). > This will however require some changes to PaintToken. > Also PaintToken appears to have several other shortcomings/bugs, which > could easily be fixed/ > => but all of those would probably end up in a rewrite of PaintToken > (which is why I haven't reported those issues yet) > No problem. PaintToken is an optimized function. And like most optimized functions: When adding new features, you have to rewrite it. > Any feedback guiding me in this issue would be welcome. > I can also (in the evening) mail my prototype and comments about it => > but I don't know what/if Marc has any plans on it. > > Another idea (and so far not beyond the state of an idea) is to move all > TextMarking (HighlightBrackets, SpecialLines, SelectedBlock, and the new > HighlightAll => features that are not SynEditHighlighter), into a new > class SynEditTextMarkup. However "PaintLines" still would need changes. > Yes. And we need markers for live templates. For example some green blocks and some red blocks. The HighlightAll markers can be used for identifier references too. Mattias _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Mattias Gaertner
to Martin Friebe
Show quoted text 6 lines
> Yes. And we need markers for live templates. For example some green > blocks and some red blocks. > The HighlightAll markers can be used for identifier references too. > Not sure what you refer too.

identifier: When the cursor moves over an identifier (e.g. a variable 'i'), the IDE highlights all visible 'i'.

live templates: When a code template with parameters is added the IDE adds the template and all parameter fields are highlighted. For example:

for $Prompt(1):=Low($Prompt(2)) to High($Prompt(2)) do

When the IDE adds it, it replaces the Prompt macros with markers. One color for each different Prompt macro. Then the user can fill the macros and jump with the Tab key between the fields.

Show quoted text 6 lines
But it will probably work. Not necessarily with the highlight all (which is search based). But it should be easy once I have an SynEditTextMarkup object. The idea is that it provides functions like MarkupStyleAndColorAtPos( XPosInLine ) : SomeStyleInfo;

Maybe better GetMarkupAttriAtRowCol, similar to
GetHighlighterAttriAtRowCol?

Show quoted text 6 lines
XPosOfNextMarkupChange( CurrentXPosInLine ) : integer; Then while adding a token, to the token akku, it would be splitted (if needed) and the markup applied. => so any other (non Language (eg non-pascal, non-html,...)) Markup, could be done in there.

Great.

I'll post more, once I converted my current proto-type, to support this.

Mattias

Reply by email

Martin Friebe
to Martin Friebe: Not sure what you refer too. But it will probably work. Not necessarily with the…

Ok,

I got the first version ready. It seems to run well on my system. But I would be happy about any feedback (bugs, or optimization, or design issues, or ...).

So far I have made 2 classes:
- Highlight All (which is used in Incremental search, but can be used in normal search too)
There is some room for performance optimization, but it already performs very well)
- MatchingBrackets => just moved existing code.

Further modules can be added easily.

I also thought about moving the SelectionBlock into a class of it's own (see also question "highlighter None)

A few Questions, various things I came across:

- Selecting Highlighter = NONE or Text (from editor context menu) ~None, does also disable MatchingBrackets, is that intend? Because MatchingBrackets are an option on the EditorEnviroment "General" page, and not on the "Color/Highlighter" page? ~Text does seem to be "None" but with MatchingBrackets ? or does text highlight anything else?

If None was not intend to suppress MatchingBrackets, code could be simplified, and None could pretend to paint a single (all line) token. Currently this can be done anyway. But it would;nt work, if SelectionBlock, became a TMarkup* class (as that would put the SelectBlock on the same level with Brackets.)

- The Caret positions by name:
I am aware there are 3 (is that right?) ways to reference to the caret position.
- The Char(utf8) Position in the SourceText
- The Byte Position in the Sourcetext (if all chars were 2 bytes, then thats means X = twice the CharPos)
- The Position on the Screen (uses CharPos for X ?)
- (Screen Position in Pixel)

The source refers to the Caret in Various Ways:
- CaretXY, CaretX, CaretY, GetCaretXY, fCaretX, fCaretY, ... I believe they refer to the CHAR pos ?
This is also referred to a PhysicalCaret?

- LogicalCaret, LogCarret
referring to the BYTE pos ?

* from the Synedit Source
    fCaretX: Integer;      // physical position (screen)

Is this really the position on screen, or is it the X(Char position) in the Source? (This differs if the screen is horizontally scrolled)

Best Regards
Martin

Martin Friebe wrote 98 lines
> Yes. And we need markers for live templates. For example some green blocks and > some red blocks. > The HighlightAll markers can be used for identifier references too. > > Not sure what you refer too. But it will probably work. Not necessarily with the highlight all (which is search based). But it should be easy once I have an SynEditTextMarkup object. The idea is that it provides functions like MarkupStyleAndColorAtPos( XPosInLine ) : SomeStyleInfo; XPosOfNextMarkupChange( CurrentXPosInLine ) : integer; Then while adding a token, to the token akku, it would be splitted (if needed) and the markup applied. => so any other (non Language (eg non-pascal, non-html,...)) Markup, could be done in there. I'll post more, once I converted my current proto-type, to support this. BestRegards Martin Mattias G?rtner wrote: > Zitat von Martin Friebe : > > > >> Makes sense,or well depends on how old the plans are, and how much >> SynEdit has moved since. >> One block, that is of particular interest to me is the PaintLines. >> >> PaintLines happens to be an IFDEF SYNLAZ over several 100 (or 1000?) >> lines. A complete Lazarus, and a complete Original version. >> IMHO an IfDef of this Size IMHO doesn't serve the protection/diff >> purpose very much? >> >> > There were so many IFDEFs in that part that it was hardly readable. It reached a > critical limit. > > > > >> I have a patch/prototype (still some cleanup on it) for a "highlight >> All" during search feature. >> >> > Cool. > > > >> Marc Weustink has a copy of this (because I >> had previously send other patches to him). >> This will however require some changes to PaintToken. >> Also PaintToken appears to have several other shortcomings/bugs, which >> could easily be fixed/ >> => but all of those would probably end up in a rewrite of PaintToken >> (which is why I haven't reported those issues yet) >> >> > No problem. PaintToken is an optimized function. And like most optimized > functions: When adding new features, you have to rewrite it. > > > > >> Any feedback guiding me in this issue would be welcome. >> I can also (in the evening) mail my prototype and comments about it => >> but I don't know what/if Marc has any plans on it. >> >> Another idea (and so far not beyond the state of an idea) is to move all >> TextMarking (HighlightBrackets, SpecialLines, SelectedBlock, and the new >> HighlightAll => features that are not SynEditHighlighter), into a new >> class SynEditTextMarkup. However "PaintLines" still would need changes. >> >> > Yes. And we need markers for live templates. For example some green blocks and > some red blocks. > The HighlightAll markers can be used for identifier references too. > > Mattias > > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > > _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
A non-text attachment was scrubbed...
Name: high_all.rar
Type: application/octet-stream
Size: 11283 bytes
Desc: not available
Url : http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080629/890b8abc/attachment-0001.obj

Reply by email

Mattias Gaertner
to Martin Friebe
Show quoted text 5 lines
Ok, I got the first version ready. It seems to run well on my system. But I would be happy about any feedback (bugs, or optimization, or design issues, or ...).

Strange. I get:
patch: **** malformed patch at line 68: @@ -896,6 +902,8 @@ I wonder why.

Show quoted text 19 lines
So far I have made 2 classes: - Highlight All (which is used in Incremental search, but can be used in normal search too) There is some room for performance optimization, but it already performs very well) - MatchingBrackets => just moved existing code. Further modules can be added easily. I also thought about moving the SelectionBlock into a class of it's own (see also question "highlighter None) A few Questions, various things I came across: - Selecting Highlighter = NONE or Text (from editor context menu) ~None, does also disable MatchingBrackets, is that intend? Because MatchingBrackets are an option on the EditorEnviroment "General" page, and not on the "Color/Highlighter" page?

If you have time, you can implement it for 'none' too.

~Text does seem to be "None" but with MatchingBrackets ? or does text highlight anything else?

?

Show quoted text 10 lines
If None was not intend to suppress MatchingBrackets, code could be simplified, and None could pretend to paint a single (all line) token. Currently this can be done anyway. But it would;nt work, if SelectionBlock, became a TMarkup* class (as that would put the SelectBlock on the same level with Brackets.) - The Caret positions by name: I am aware there are 3 (is that right?) ways to reference to the caret position. - The Char(utf8) Position in the SourceText

Hardly used.

- The Byte Position in the Sourcetext (if all chars were 2 bytes, then thats means X = twice the CharPos)

= LogicalCaretXY

- The Position on the Screen (uses CharPos for X ?)

Not the same as CharPos, because of tabs.
= CaretXY

- (Screen Position in Pixel)

That makes 4.

The source refers to the Caret in Various Ways: - CaretXY, CaretX, CaretY, GetCaretXY, fCaretX, fCaretY, ... I believe they refer to the CHAR pos ? This is also referred to a PhysicalCaret?

Yes.

- LogicalCaret, LogCarret referring to the BYTE pos ?

Yes.

Show quoted text 5 lines
* from the Synedit Source fCaretX: Integer; // physical position (screen) Is this really the position on screen, or is it the X(Char position) in the Source? (This differs if the screen is horizontally scrolled)

It's the screen position without scrolling.

Mattias

Reply by email

Martin Friebe
to Mattias Gaertner

Recreated the patch. The 3 *.pp files go into components/synedit/

I am looking for any feedback, that will prevent me from developing this into the wrong direction.
The current ideas/plans are:
- speed optimizations to highlight all, even so it does not curreently slow down working on my system.
there may be possibilities to limit the amount of search, if only a few lines are invalidated.
- Further rework on the PaintLine code.
Higlighter NONE, could use PaintToken too (simulating a single token for the whole line)
This would mean that brackets will be highlighted
- Moving "special lines" into a Markup class
- Moving "block selection" into a Markup class
This would simplify PaintLines. Also currently if the Block is across several HighlighterTokens, the will not join in the token accu. This would become possible.

Please also let me know, anything that would be needed before the above changes, in order to apply the change to SVN. I could then do further changes against the applied version.

If you have time, you can implement it for 'none' too.

Will do. I f I am right this will actually simplify some code. Let's see.

> ~Text does seem to be "None" but with MatchingBrackets ? or does > text highlight anything else? > ?

If you right click the source editor , and within the context menu choose the sub-menu "File settings", there is an other sub-menu "Highlighter". In addition to a list of all the highlighters from editor-enviroment, there are two entries:
-Text
-None

I haven't found anything that is highlighted by "text" except it does the brackets, which "none" does currently not. So the question is, have I missed something, or is there some other intend?

Thanks
Martin

Mattias Gaertner wrote 120 lines
On Sun, 29 Jun 2008 13:14:46 +0100 Martin Friebe wrote: > Ok, > > I got the first version ready. It seems to run well on my system. But > I would be happy about any feedback (bugs, or optimization, or design > issues, or ...). > Strange. I get: patch: **** malformed patch at line 68: @@ -896,6 +902,8 @@ I wonder why. > So far I have made 2 classes: > - Highlight All (which is used in Incremental search, but can be used > in normal search too) > There is some room for performance optimization, but it already > performs very well) > - MatchingBrackets => just moved existing code. > > Further modules can be added easily. > > I also thought about moving the SelectionBlock into a class of it's > own (see also question "highlighter None) > > > A few Questions, various things I came across: > > - Selecting Highlighter = NONE or Text (from editor context menu) > ~None, does also disable MatchingBrackets, is that intend? > Because MatchingBrackets are an option on the EditorEnviroment > "General" page, and not on the "Color/Highlighter" page? > If you have time, you can implement it for 'none' too. > ~Text does seem to be "None" but with MatchingBrackets ? or does > text highlight anything else? > ? > If None was not intend to suppress MatchingBrackets, code could be > simplified, and None could pretend to paint a single (all line) > token. Currently this can be done anyway. But it would;nt work, if > SelectionBlock, became a TMarkup* class (as that would put the > SelectBlock on the same level with Brackets.) > > - The Caret positions by name: > I am aware there are 3 (is that right?) ways to reference to the > caret position. > - The Char(utf8) Position in the SourceText > Hardly used. > - The Byte Position in the Sourcetext (if all chars were 2 bytes, > then thats means X = twice the CharPos) > = LogicalCaretXY > - The Position on the Screen (uses CharPos for X ?) > Not the same as CharPos, because of tabs. = CaretXY > - (Screen Position in Pixel) > That makes 4. > The source refers to the Caret in Various Ways: > - CaretXY, CaretX, CaretY, GetCaretXY, fCaretX, fCaretY, ... > I believe they refer to the CHAR pos ? > This is also referred to a PhysicalCaret? > Yes. > - LogicalCaret, LogCarret > referring to the BYTE pos ? > Yes. > * from the Synedit Source > fCaretX: Integer; // physical position (screen) > > Is this really the position on screen, or is it the X(Char position) > in the Source? (This differs if the screen is horizontally scrolled) > It's the screen position without scrolling. Mattias _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
A non-text attachment was scrubbed...
Name: high_all.rar
Type: application/octet-stream
Size: 12837 bytes
Desc: not available
Url : http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080707/f18183a8/attachment-0001.obj

Reply by email

Mattias Gaertner
to Martin Friebe
Recreated the patch. The 3 *.pp files go into components/synedit/

Thanks. Applied.

Show quoted text 5 lines
I am looking for any feedback, that will prevent me from developing this into the wrong direction. The current ideas/plans are: - speed optimizations to highlight all, even so it does not curreently slow down working on my system.

What operations updates the highlight all often?

Show quoted text 11 lines
there may be possibilities to limit the amount of search, if only a few lines are invalidated. - Further rework on the PaintLine code. Higlighter NONE, could use PaintToken too (simulating a single token for the whole line) This would mean that brackets will be highlighted - Moving "special lines" into a Markup class - Moving "block selection" into a Markup class This would simplify PaintLines. Also currently if the Block is across several HighlighterTokens, the will not join in the token accu. This would become possible.

IMO all are good ideas.

Show quoted text 22 lines
Please also let me know, anything that would be needed before the above changes, in order to apply the change to SVN. I could then do further changes against the applied version. > If you have time, you can implement it for 'none' too. > Will do. I f I am right this will actually simplify some code. Let's see. >> ~Text does seem to be "None" but with MatchingBrackets ? or does >> text highlight anything else? >> > ? If you right click the source editor , and within the context menu choose the sub-menu "File settings", there is an other sub-menu "Highlighter". In addition to a list of all the highlighters from editor-enviroment, there are two entries: -Text -None I haven't found anything that is highlighted by "text" except it does the brackets, which "none" does currently not. So the question is, have I missed something, or is there some other intend?

Text was intended for future use, for things that can be better done with markups. So, it can be removed.

Mattias

Reply by email

Martin Friebe
to Mattias Gaertner

Hi Mattias,

Cool, thanks.

Mattias Gaertner wrote 77 lines
On Mon, 07 Jul 2008 00:40:21 +0100 Martin Friebe wrote: > Recreated the patch. The 3 *.pp files go into components/synedit/ > Thanks. Applied. > I am looking for any feedback, that will prevent me from developing > this into the wrong direction. > The current ideas/plans are: > - speed optimizations to highlight all, even so it does not > curreently slow down working on my system. > What operations updates the highlight all often? > there may be possibilities to limit the amount of search, if only a > few lines are invalidated. > - Further rework on the PaintLine code. > Higlighter NONE, could use PaintToken too (simulating a single > token for the whole line) > This would mean that brackets will be highlighted > - Moving "special lines" into a Markup class > - Moving "block selection" into a Markup class > This would simplify PaintLines. Also currently if the Block is > across several HighlighterTokens, the will not join in the token > accu. This would become possible. > IMO all are good ideas. > Please also let me know, anything that would be needed before the > above changes, in order to apply the change to SVN. I could then do > further changes against the applied version. > > >> If you have time, you can implement it for 'none' too. >> >> > Will do. I f I am right this will actually simplify some code. Let's > see. > >>> ~Text does seem to be "None" but with MatchingBrackets ? or does >>> text highlight anything else? >>> >>> >> ? >> > If you right click the source editor , and within the context menu > choose the sub-menu "File settings", there is an other sub-menu > "Highlighter". In addition to a list of all the highlighters from > editor-enviroment, there are two entries: > -Text > -None > > I haven't found anything that is highlighted by "text" except it does > the brackets, which "none" does currently not. So the question is, > have I missed something, or is there some other intend? > Text was intended for future use, for things that can be better done with markups. So, it can be removed. Mattias _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email