Author Topic: Change bar feature in scintilla  (Read 26928 times)

Offline gryphon

  • Multiple posting newcomer
  • *
  • Posts: 15
Change bar feature in scintilla
« on: September 19, 2008, 12:00:16 am »
I stumbled across this link (after a LOT of searching). It is a patched version of scintilla that provides a changebar feature in the margin like in Visual Studio.
http://groups.google.com/group/scintilla-interest/browse_thread/thread/2e5e1b82350886cc/adea77152522a434?lnk=gst&q=change#adea77152522a434

- maybe it's old news however I think it would be nice to try to build against this patched version to see the effect. It could be a very nice addition to CodeBlocks. I had planned to post this after I'd tried that but I haven't found the time yet. I know a couple of you have been playing with building against the latest scintilla code so I thought at least some of you may be interested in trying this.

gryphon

Offline gryphon

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Change bar feature in scintilla
« Reply #1 on: November 15, 2008, 02:50:11 am »
I finally got a chance to look at this again tonight. I've been able to build codeblocks using this modified scintilla source and the change bars work quite well (from my limited testing). I'm trying to do a bit more testing and collate a patch of the necessary changes to to enable this (assuming it is stable enough for use). In the meantime however I've attached two images showing the change bars in action. A yellow bar for unsaved changes and a green bar for saved changes.

gryphon

[attachment deleted by admin]
« Last Edit: November 15, 2008, 02:56:11 am by gryphon »

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Change bar feature in scintilla
« Reply #2 on: November 15, 2008, 08:43:27 am »
Looks cool. Can you post a patch to Berlios? :)
Be a part of the solution, not a part of the problem.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Change bar feature in scintilla
« Reply #3 on: November 15, 2008, 09:07:03 am »
That's a pretty nice feature of other IDEs, and it's lovely you're working on implementing it for Code::Blocks. I have to use Visual C++ at the office, and, everytime I see that bar, I wish Code::Blocks had it too.

Something I've noticed in Visual C++ is that if I try to compile something that produces compiling errors, I can modify the code, and when I double click on the error, it takes into account modified lines to take me to the right new line in the source where the error really happens. In other words, if I have an error in line 1234, but I delete 10 lines before that one, when I double click on the error in the errors window, which still points to 1234, it'll actually take me to line 1224. However, that's something that would have to be implemented in a different place, not in this plugin.

Have you considered telling Scintilla guys about it? It'd be nice to have that patch applied upstream too.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: Change bar feature in scintilla
« Reply #4 on: November 15, 2008, 09:42:38 am »
this is great. Bring the patch on :-)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Change bar feature in scintilla
« Reply #5 on: November 15, 2008, 08:42:49 pm »
I just created a patch against the new-scintilla-branch.

I think patching the (older) scintilla version in trunk is much more difficult, because the patch gryphon has found is against scintilla 1.7.5 and we use 1.7.7 in scintilla branch, but 1.6.x in trunk.

I uploaded it to my server ( http://apt.jenslody.de/patches/scintilla_changebar.patch ).
I'm not sure if I should commit it to the scintilla-branch, because I did (could) not test it much.

At the moment it can not be turned on or off, and the colours are not configurable.

It's tested under linux (debian 64bit) and windows.

Unfortunately the patch changes the colour of the second margin.
I don't know why, because I did not go deeper into the code, but I hope I will find the time to do so (maybe this evening/night).

Offline gryphon

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Change bar feature in scintilla
« Reply #6 on: November 15, 2008, 09:43:01 pm »
Ok, I've uploaded a patch here:
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=2596&group_id=5358

Hopefully the patch will work for everyone.

A couple of points about the patch:
  • The scintilla changebar patch itself was not written by me, but by Neil Hodgson as you can see from the first post in this thread.
  • The changebar markers are placed in their own margin to prevent overlapping of markers.
  • Currently the changebar is placed as the last margin, after the folding margin. This is a little different than how it appears in C++Builder and Visual C++. I did it this way as it also solved another problem I commonly have - I often want to select a line of text by draggingat the left of the line. With the folding margin there I often click inside it and fold the text rather than selecting it. With the changebar margin I now have a 4 pixel wide strip I can select lines from. Of course if folding was only activated when clicking on a '+' or '-' this would not be so much of an issue. I haven't investigated if that behaviour can be achieved for not.
  • Making the margin orders configurable would not be a problem and currently in the patch the ordering of the changebar margin and the folding margin is controlled by two constants making swapping their order at compile time easy.
  • The comments associated with the changebar patch indicated that the code is a memory hog and it is unlikely to be integrated into scintilla anytime soon. As such I think it would be sensible to further enhance the changebar patch to make it optional. I'd hope that would make it more likely for this to make it into scintilla. Once optional there would be opportunities to improve the changebar feature as part of scintilla itself. Separating the changebar code out further would also allow us to patch scintilla as appropriate with the changebar code even if it was not going to become part of scintilla. Or at least until it was efficient enough to become so.

gryphon

Offline gryphon

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Change bar feature in scintilla
« Reply #7 on: November 15, 2008, 09:55:07 pm »
@Jens: Thanks for trying this! (my previous post crossed your last one as I was busy doing other things in-between writing it)

Yes I had thought about the differing versions of scintilla. My intention was to provide a patch against 1.7.7 of scintilla after I had cleaned it up. Please have a look at the patch I added to berlios to see what you think. It might be a straightforward merge.

Of course my patch in berlios is against trunk which means most of the changebar patch is actually a patch to 1.7.5 from the scintilla trunk version. With my limited testing I have not encountered any big issues but I am sure those more familiar with scintilla will be able to identify problems. Otherwise my patch against trunk seems ok.

About the margin colours (and other related issues you'll find): Have a look at how I patched the cbeditor.cpp and other codeblocks files (I think that was the main one). I think enabling the feature in codeblocks works ok and I have not had any issues so far.

Configuring, turning on and off and colour customisation, are definitely worth exploring. I didn't add that to the patch I put up to keep it smaller, I'd say though we'd really want to have that (see my comments in the previous post also).

Finally (and OT) - something I've been meaning to do for a long time: Thank you very much for you debian repository, it's been incredibly useful for me ever since you first started it  :)

gryphon
« Last Edit: November 15, 2008, 10:02:47 pm by gryphon »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Change bar feature in scintilla
« Reply #8 on: November 15, 2008, 10:26:12 pm »
Finally (and OT) - something I've been meaning to do for a long time: Thank you very much for you debian repository, it's been incredibly useful for me ever since you first started it  :)

Many thanks  :D

You did not change the value of wxSCI_MASK_FOLDERS to the changed value of SC_MASK_FOLDERS, otherwise you would have two changebars, one in its own margin and one inside the folder-margin.
I have to subtract the changebar-masks from wxSCI_MASK_FOLDERS for the folding mask.

But I guess the own margin is better. And it's a good idea to place it at last, because I sometimes have the same problem then you (folding instead of marking text).
If the colurs are configurable, there should be no problems with the standard-colour for "Highlight line under caret" (lightyellow).

I think the order of the margins can be hardcoded.

If it would be possible to switch the changebar off and on at runtime and to clear the history of the actual editor from the context-menu it would be really great.
I think that it should be possible, but needs some investigation, to do it "the right way".

Offline gryphon

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Change bar feature in scintilla
« Reply #9 on: November 15, 2008, 11:21:25 pm »
You did not change the value of wxSCI_MASK_FOLDERS to the changed value of SC_MASK_FOLDERS, otherwise you would have two changebars, one in its own margin and one inside the folder-margin.
I have to subtract the changebar-masks from wxSCI_MASK_FOLDERS for the folding mask.

Good catch! I missed that, though I had to try this to see what you mean. What is the preferred approach?

1. Leave wxSCI_MASK_FOLDERS as 0xFE000000 and no need to negate the change-bar masks (as the current patch does), or,
2. Update wxSCI_MASK_FOLDERS to the new value of 0xFF800000 and then negate the change-bar masks when setting the folding masks? I guess the original scintilla patch thought mimicking VS by default was the best approach.

My feeling is we should use the value of SC_MASK_FOLDERS from 1.7.7 (whatever that is) and perhaps add a SC_MASK_CHANGEBAR which ORs the two changebar masks together.

If you think I need to make a change to the patch regarding this let me know.

But I guess the own margin is better. And it's a good idea to place it at last, because I sometimes have the same problem then you (folding instead of marking text).
If the colurs are configurable, there should be no problems with the standard-colour for "Highlight line under caret" (lightyellow).

Glad I'm not the only one who hits that problem :) Making the colours configurable should be straightforward. If you don't beat me to it I'll have a go at adding that.

If it would be possible to switch the changebar off and on at runtime and to clear the history of the actual editor from the context-menu it would be really great.
I think that it should be possible, but needs some investigation, to do it "the right way".

Yeah, I think that's true. I've only begun digging deeper into the scintilla code today so haven't really got a feel yet of how to do that. I guess I should start by diff'ing against 1.7.7 to get a feel for how invasive the changebar patch actually is.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Change bar feature in scintilla
« Reply #10 on: November 15, 2008, 11:45:09 pm »
Yeah, I think that's true. I've only begun digging deeper into the scintilla code today so haven't really got a feel yet of how to do that. I guess I should start by diff'ing against 1.7.7 to get a feel for how invasive the changebar patch actually is.

You can either do that or download the patch from my server, it's a patch against 1.7.7 (used for C::B's new-scintilla-branch).
Your patch is against trunk and the scintilla used there is an 1.6.x-version as far as I know, so there are many, many differences, for example to the lexers, that should not be needed for the change bar.

You can download C::B with scintilla 1.7.7, which is not (yet) in trunk with svn from 
Code
svn://svn.berlios.de/codeblocks/branches/scintilla
it should work on linux and windows and will soon (?) be merged with trunk. The scintilla-branch is uptodate, and contains some smal improvements, due to newer (better) indicatiors (used for "Highlight occurrences" and "Incremental Search").

One cause I worked with the newer scintilla is because it will most likely be committed to trunk the next time (no exact timeline, but no problems so far).
« Last Edit: November 15, 2008, 11:51:01 pm by jens »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Change bar feature in scintilla
« Reply #11 on: November 16, 2008, 03:31:54 pm »
I'm not sure if I should commit it to the scintilla-branch, because I did (could) not test it much.
Please don't atm. We can do it in another branch later. :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

mariocup

  • Guest
Re: Change bar feature in scintilla
« Reply #12 on: November 16, 2008, 11:37:37 pm »
Quote
But I guess the own margin is better. And it's a good idea to place it at last, because I sometimes have the same problem then you (folding instead of marking text).

I know that problem folding instead of marking text. Therefore I use the following workaround: If you enable the display of line numbers you can select lines by clicking with the mouse button in the left margin next to the displayed line numbers and then it won't happen that you select a folding point.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Change bar feature in scintilla
« Reply #13 on: November 17, 2008, 03:48:14 pm »
I uploaded it to my server ( http://apt.jenslody.de/patches/scintilla_changebar.patch ).
This does not work for me at all. Either "patch" crashes "unexpectedly" or it fails patching ~80% of the hunks.
Can you try to create the patch again, please?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Change bar feature in scintilla
« Reply #14 on: November 17, 2008, 07:23:42 pm »
I uploaded it to my server ( http://apt.jenslody.de/patches/scintilla_changebar.patch ).
This does not work for me at all. Either "patch" crashes "unexpectedly" or it fails patching ~80% of the hunks.
Can you try to create the patch again, please?!

Hi Martin,

try http://apt.jenslody.de/patches/scintilla_changebar_new.patch, that should work.
The other patch only applies if you ignore changes to whitespace. I don't know why. It's created with "svn diff", and the newer one with the diff-tool from commandline.

The new patch is slightly modified compared to the first one (using an own margin for the changebar).