Sign in Join

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

Mailing lists / lazarus / 2009-05

[Fwd: A few hacky patches (resent)]

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Martin

Just as a confirmation that I have them, and will look through them asap.

I was until yesterday for yet unknown reasons unable to get the list mails

Martin

Paul Ishenin wrote 63 lines
G'day all, Just for information I've attached some patches I apply to my local tree and use in an application I'm working on. These are not any form of an example of how to write good code, they are gross hacks that have "evolved" as lazarus has evolved over the last 9 months or so and I adapt them as required as the code changes under me. If anyone finds any of the bits useful, I'm more than happy to clean them up and work with the relative authors to make them acceptable to the general code base. Conversely, I've maintained them in my own tree for 9 months and I'm happy to keep doing so. I'm also very open to suggestions as to how I might achieve my desired results without having to hack the codebase. laz-find.patch : This adds an extra checkbox and set member to the find/replace dialogs to allow selection of "entire scope" as a search parameter. laz-synpatch-005.patch This is a gross hack, but it allows clicking *anywhere* on the grey fold line in the gutter to fold that particular level of routine. I have some procedures that are very long and it's nice to be able to click on that line from the bottom of the procedure and have it fold up on me. laz-synpatch-007.patch This is another gross hack, but in a highlighter I've written I use this to enable me to ensure the remainder of a line is painted in the right background colour. Synedit calls this "GetLineRemainder" routine (if assigned in the highlighter) to get the colour the remainder of the line is to be painted after it has finished painting all its tokens. Without this I was getting odd line remainders when I scrolled often. With this I get perfection every time. laz-synpatch-008.patch And the final gross hack. I store the folded status of each open file in my overall project file. The easy way for me to do this is in a sequential comma delimited list of line numbers that are folded. This routine "DumpFolds" gives me a string which is a comma delimited list of all the lines that are folded. Then when I reload the project I can simply fold those lines in reverse order to get precisely the folds I had previously. On another note, recent work by Martin Friebe and Paul Ishenin has rendered three other gross hacks I've had in my tree irrelevant :) Regards, Brad

Reply by email

Martin Friebe
to Martin
Show quoted text 8 lines
> > laz-synpatch-005.patch > This is a gross hack, but it allows clicking *anywhere* on the grey > fold line in the gutter to fold > that particular level of routine. I have some procedures that are > very long and it's nice to be able > to click on that line from the bottom of the procedure and have it > fold up on me.

Makes me wonder, how it integrates, with the ability to configure which mouse button triggers which action

Also the code to do it already exist (Synedit line 6236) for the keyboard shortcut:

Show quoted text 8 lines
EcFoldCurrent: begin CY := FFoldedLinesView.ExpandedLineForBlockAtLine(CaretY); if CY > 0 then begin FFoldedLinesView.FoldAtTextIndex(CY-1); SetCaretXY(Point(1, CY)); end; end;

Lastly, this can be done already via the context menu too (contextmenu over the foldline)

=> The idea for such a shortcut is good, need to think about if this is done in a good way currently....

-----

Show quoted text 11 lines
> > laz-synpatch-007.patch > This is another gross hack, but in a highlighter I've written I use > this to enable me to ensure the > remainder of a line is painted in the right background colour. > Synedit calls this "GetLineRemainder" > routine (if assigned in the highlighter) to get the colour the > remainder of the line is to be > painted after it has finished painting all its tokens. Without this I > was getting odd line > remainders when I scrolled often. With this I get perfection every time.
         with fTextDrawer do
           if MarkupInfo = nil

what if markup onfo is assigned, but doesnt change the bg color? (leaves it to default )

Show quoted text 11 lines
> > laz-synpatch-008.patch > And the final gross hack. I store the folded status of each open file > in my overall project file. > The easy way for me to do this is in a sequential comma delimited > list of line numbers that are > folded. This routine "DumpFolds" gives me a string which is a comma > delimited list of all the lines > that are folded. Then when I reload the project I can simply fold > those lines in reverse order to > get precisely the folds I had previously.

Hm, I ll think about it. I had the idea of somekind of checksum, to allow detection of changed text....

Also, just line-number does not work: There can be 2 or more folds starting the same line, and vie the context menu you can fold any of them.

Show quoted text 8 lines
> > On another note, recent work by Martin Friebe and Paul Ishenin has > rendered three other gross hacks > I've had in my tree irrelevant :) > > Regards, > Brad

Reply by email

Martin Friebe
to Martin Friebe
Martin Friebe wrote 29 lines
>> >> laz-synpatch-005.patch >> This is a gross hack, but it allows clicking *anywhere* on the grey >> fold line in the gutter to fold >> that particular level of routine. I have some procedures that are >> very long and it's nice to be able >> to click on that line from the bottom of the procedure and have it >> fold up on me. Makes me wonder, how it integrates, with the ability to configure which mouse button triggers which action Also the code to do it already exist (Synedit line 6236) for the keyboard shortcut: > EcFoldCurrent: > begin > CY := FFoldedLinesView.ExpandedLineForBlockAtLine(CaretY); > if CY > 0 then begin > FFoldedLinesView.FoldAtTextIndex(CY-1); > SetCaretXY(Point(1, CY)); > end; > end; Lastly, this can be done already via the context menu too (contextmenu over the foldline) => The idea for such a shortcut is good, need to think about if this is done in a good way currently....

It mast be optional too (via config) and IMHO not enabled by default.

It is too easy to click by accident, if you try t select a block from position 1 of a line....

Reply by email

Brad Campbell
to Martin Friebe: Makes me wonder, how it integrates, with the ability to configure which mouse button…
Martin Friebe wrote 8 lines
>> >> laz-synpatch-005.patch >> This is a gross hack, but it allows clicking *anywhere* on the grey >> fold line in the gutter to fold Makes me wonder, how it integrates, with the ability to configure which mouse button triggers which action

It probably doesn't, but in my application it provides a very simple interface to fold up a long routine, and as I only have one level and one type of fold it does the job.

Also the code to do it already exist (Synedit line 6236) for the keyboard shortcut:

Ahh, nice. I'll look at simplifying my hack then :)

=> The idea for such a shortcut is good, need to think about if this is done in a good way currently....

The way I've done it is less than optimal, but it provides the user interface that I need.

Show quoted text 6 lines
with fTextDrawer do if MarkupInfo = nil what if markup onfo is assigned, but doesnt change the bg color? (leaves it to default )

I don't use any kind of markup info, so I've not come across this issue.

Also, just line-number does not work: There can be 2 or more folds starting the same line, and vie the context menu you can fold any of them.

In my application it works fine as I only have one type of fold and they can't be nested :) Always happy to try and extend it in a way that works for everybody though.

Thanks for the feedback :)

Food for thought in any case.

Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Martin

Brad Campbell wrote

Show quoted text 12 lines
laz-synpatch-007.patch This is another gross hack, but in a highlighter I've written I use this to enable me to ensure the remainder of a line is painted in the right background colour. Synedit calls this "GetLineRemainder" routine (if assigned in the highlighter) to get the colour the remainder of the line is to be painted after it has finished painting all its tokens. Without this I was getting odd line remainders when I scrolled often. With this I get perfection every time.

Not really a "gross" hack.

It slightly goes out of the current functionality of a highlighter => which so far is/was a token based highlighter. Line highlighting was reserved for Markup modules.

However this is/was more be evolution as specific design. It is quite reasonable to say that some text-formats/languages want to use full line markup to highlight language features. (Pascal uses Divider-Lines instead). It also does not interfere with any other functionality, and requires very little modifications.

I have integrated this patch in Lazarus (rev 20243).

A few modifications:
Function has been renamed to have "Attribute" in name: GetEndOfLineAttribute The parts in SynEdit have been changed to be more in line with other code, and obey other features too.

Also note, that:
- the part in SynEdit may change in the future, but should continue to obey the attribute returned.
- May in future obey underline or Frame color or new features. It is therefore important to set those correctly (clNone)

Best Regards
Martin

Reply by email

Brad Campbell
to Martin
Martin wrote 9 lines
However this is/was more be evolution as specific design. It is quite reasonable to say that some text-formats/languages want to use full line markup to highlight language features. (Pascal uses Divider-Lines instead). It also does not interfere with any other functionality, and requires very little modifications. I have integrated this patch in Lazarus (rev 20243).

Thanks Martin, that's one more patch I can drop from my tree :)

Regards,
Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Martin Friebe
to Martin: Just as a confirmation that I have them, and will look through them asap. I was until…
Show quoted text 8 lines
> laz-synpatch-005.patch > This is a gross hack, but it allows clicking *anywhere* on the grey > fold line in the gutter to fold > that particular level of routine. I have some procedures that are > very long and it's nice to be able > to click on that line from the bottom of the procedure and have it > fold up on me.

Just to let you know, do not worry about redoing your patch. I am working on related items, and will include a solution.

Martin

Reply by email

Martin Friebe
to Martin Friebe

You should now be able to configure your synedit in the desired manner.

In order to be able to click the "line" below a "[-]" sign add the following config
Menu=>environments=>options=>editor=>mouse

Select "FoldTree" (the first entry in gutter) => this will catch any click anywhere in the fold part of the gutter; so if you do not want the click to act or act the same way on [+] / [-] symbols, then override the config in the sub-nodes.

- Add an entry to catch the desired click (left, single or any, down)
- Command Fold
- Mode: Current node (The minimum enclosing node)

if desired decide to move the caret

It is also possible to add config, so you can click at a "begin" or whatever actual text opens a fold area => and it will fold this node: Mode: At Caret of course this must be a click on the text, not gutter Best Regards Martin Martin Friebe wrote: > >>> laz-synpatch-005.patch >>> This is a gross hack, but it allows clicking *anywhere* on the grey >>> fold line in the gutter to fold >>> that particular level of routine. I have some procedures that are >>> very long and it's nice to be able >>> to click on that line from the bottom of the procedure and have it >>> fold up on me. >> > > Just to let you know, do not worry about redoing your patch. I am > working on related items, and will include a solution. > > Martin > > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email