Hack to show level-dependent folded colors

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Hack to show level-dependent folded colors

Herbert Sitz
One of the unpleasant aspects of VimOutliner is the unprettiness that comes about when levels are collapsed and you lose the level-dependent coloring, since all folded levels show with same color.  This is a limitation in the current VIM source, but I did a bit of  hacking and the fix to allow level-dependent collapsed fold highlighting was surprisingly easy.  I've never programmed in C/C++ before (mostly have just used Delphi/ObjectPascal and some scripting languages) and I was able to do it without much problem.  Added 15 or 20 lines -- mostly a big switch statement --, changed references in a few others, that's it.  Then added the new highlighting groups (for FoldLevels 1 through 9) to my vo_dark colors definition file, and that was it.

I believe the visual cues from color highlighting are important to the outlining experience.  Without the patch it is ugly and confusing to have all collapsed levels shown using same color in VimOutliner.

Anyway, you can take a look at a screenshot of the results here:
http://www.plainspokenfinancial.com/screenshot.png

If anyone's interested I can clean up the source hack and get you a diff, and post exact instructions on how to do change your color file.
Reply | Threaded
Open this post in threaded view
|

Re: Hack to show level-dependent folded colors

David J Patrick-2
hsitz wrote:
>
> I believe the visual cues from color highlighting are important to the
> outlining experience.  Without the patch it is ugly and confusing to have
> all collapsed levels shown using same color in VimOutliner.
>
> Anyway, you can take a look at a screenshot of the results here:
> http://www.plainspokenfinancial.com/screenshot.png
very nice !
>
> If anyone's interested I can clean up the source hack and get you a diff,
> and post exact instructions on how to do change your color file.
I, for one, think this is an instant must-have,
thanks,
djp

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: Hack to show level-dependent folded colors

Noel Henson
In reply to this post by Herbert Sitz
On Thursday 15 January 2009, hsitz wrote:

> One of the unpleasant aspects of VimOutliner is the unprettiness that
> comes about when levels are collapsed and you lose the level-dependent
> coloring, since all folded levels show with same color.  This is a
> limitation in the current VIM source, but I did a bit of  hacking and
> the fix to allow level-dependent collapsed fold highlighting was
> surprisingly easy.  I've never programmed in C/C++ before (mostly have
> just used Delphi/ObjectPascal and some scripting languages) and I was
> able to do it without much problem. Added 15 or 20 lines -- mostly a big
> switch statement --, changed references in a few others, that's it.
> Then added the new highlighting groups (for FoldLevels 1 through 9) to
> my vo_dark colors definition file, and that was it.
>
> I believe the visual cues from color highlighting are important to the
> outlining experience.  Without the patch it is ugly and confusing to
> have all collapsed levels shown using same color in VimOutliner.
>
> Anyway, you can take a look at a screenshot of the results here:
> http://www.plainspokenfinancial.com/screenshot.png
>
> If anyone's interested I can clean up the source hack and get you a
> diff, and post exact instructions on how to do change your color file.

I'm interested in what you have come up with. I tried to do that years ago
by continuously rewriting the syntax highlighting for closed folds. It
would sometime work but mostly not, especially when opening and closing
folds when there are already visible closed folds.

I'll check out what you have done.

Noel

--

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com Chips, firmware and embedded systems
  www.vimoutliner.org Work fast. Think well.

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: Hack to show level-dependent folded colors

John Porubek
In reply to this post by Herbert Sitz
On Thu, Jan 15, 2009 at 12:58 PM, hsitz <[hidden email]> wrote:

>
> One of the unpleasant aspects of VimOutliner is the unprettiness that comes
> about when levels are collapsed and you lose the level-dependent coloring,
> since all folded levels show with same color.  This is a limitation in the
> current VIM source, but I did a bit of  hacking and the fix to allow
> level-dependent collapsed fold highlighting was surprisingly easy.  I've
> never programmed in C/C++ before (mostly have just used Delphi/ObjectPascal
> and some scripting languages) and I was able to do it without much problem.
> Added 15 or 20 lines -- mostly a big switch statement --, changed references
> in a few others, that's it.  Then added the new highlighting groups (for
> FoldLevels 1 through 9) to my vo_dark colors definition file, and that was
> it.
>
> I believe the visual cues from color highlighting are important to the
> outlining experience.  Without the patch it is ugly and confusing to have
> all collapsed levels shown using same color in VimOutliner.
>
> Anyway, you can take a look at a screenshot of the results here:
> http://www.plainspokenfinancial.com/screenshot.png
>
> If anyone's interested I can clean up the source hack and get you a diff,
> and post exact instructions on how to do change your color file.
> --
> View this message in context: http://www.nabble.com/Hack-to-show-level-dependent-folded-colors-tp21483288p21483288.html
> Sent from the Vim - Outliner mailing list archive at Nabble.com.
>
> _______________________________________________
> VimOutliner mailing list
> [hidden email]
> http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
>

I'd be interested also in finding out more about what you've
accomplished with your source hack and changes to the color file.

Thanks for posting it.

John
_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: Hack to show level-dependent folded colors

Steve Litt
In reply to this post by Herbert Sitz
On Thursday 15 January 2009 12:58:35 pm hsitz wrote:

> One of the unpleasant aspects of VimOutliner is the unprettiness that comes
> about when levels are collapsed and you lose the level-dependent coloring,
> since all folded levels show with same color.  This is a limitation in the
> current VIM source, but I did a bit of  hacking and the fix to allow
> level-dependent collapsed fold highlighting was surprisingly easy.  I've
> never programmed in C/C++ before (mostly have just used Delphi/ObjectPascal
> and some scripting languages) and I was able to do it without much problem.
> Added 15 or 20 lines -- mostly a big switch statement --, changed
> references in a few others, that's it.  Then added the new highlighting
> groups (for FoldLevels 1 through 9) to my vo_dark colors definition file,
> and that was it.
>
> I believe the visual cues from color highlighting are important to the
> outlining experience.  Without the patch it is ugly and confusing to have
> all collapsed levels shown using same color in VimOutliner.
>
> Anyway, you can take a look at a screenshot of the results here:
> http://www.plainspokenfinancial.com/screenshot.png
>
> If anyone's interested I can clean up the source hack and get you a diff,
> and post exact instructions on how to do change your color file.

Is there a way you could link whether or not your hack does its thing to the
state of a Vim variable? I've become very accustomed to using the green color
as a cue that the line is folded. As a matter of fact, it's my only cue other
than the (15 lines) designation, because I don't have that leader with a plus
sign.

I'm not sure whether I'd prefer all folded stuff green, or whether I'd prefer
it colored like the rest of its level. Also, I might want to switch back and
forth between the two. If you had your hack use the state of "mylevelcolors"
to decide whether to color by level, then I could turn it on like this:

:set mylevelcolors=1

or off like this:

:set mylevelcolors=0

Having never looked at Vim source, I have no idea how hard it would be to add
a setable variable, and having never seen the patch I don't know how hard it
would be to have it turned on and off by the setable variable, but if it
could be done, that would be wonderful.

Thanks

STeveT
Steve Litt
Recession Relief Package
http://www.recession-relief.US

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: Hack to show level-dependent folded colors

Herbert Sitz
In reply to this post by Noel Henson
Noel Henson wrote
I'm interested in what you have come up with. I tried to do that years ago
by continuously rewriting the syntax highlighting for closed folds. It
would sometime work but mostly not, especially when opening and closing
folds when there are already visible closed folds.

I'll check out what you have done.

Noel
Noel -- Thanks, I would appreciate that.  I've posted a zip with the changes that can be downloaded here:
http://www.plainspokenfinancial.com/vim-level-highlight-change.zip

Would anyone who tries to use these files please let me know whether you have success or failure in compiling changes into your version?  I'm using the vim source from the subversion server at sourceforge for vim7.  See info at http://vim.sourceforge.net/subversion.php

The changes were very straightforward, only hard part was grokking the structure of the program.  It turned out to be built to easily accommodate this sort of change.  The original coders probably just didn't realize the need or thought having highlight for different levels would be overkill.

Regards,

Herb
Reply | Threaded
Open this post in threaded view
|

Re: Hack to show level-dependent folded colors

Herbert Sitz
In reply to this post by Steve Litt
Steve Litt wrote
Is there a way you could link whether or not your hack does its thing to the
state of a Vim variable? I've become very accustomed to using the green color
as a cue that the line is folded. As a matter of fact, it's my only cue other
than the (15 lines) designation, because I don't have that leader with a plus
sign.
Thanks

STeveT
Steve -- Unless you change your color files to take advantage of the new fold level groups there won't be any change at all in the way your vim-outliner works.  Not sure of easiest way to toggle between settings; I assume it would be to just create two color files and toggle between them.

The change to Vim makes available 9 new highlighting groups, 'FoldLevel1' to 'FoldLevel9' that you can assign separate highlighting to in the color file, like this:
-----------------------------
" colors for folded sections
hi Folded guifg=white guibg=black ctermfg=white ctermbg=black
hi FoldLevel1 gui=bold guifg=magenta guibg=black ctermfg=lightmagenta ctermbg=black
hi FoldLevel2 gui=bold guifg=cyan guibg=black ctermfg=lightcyan ctermbg=black
[. . . ]
----------------------

The group 'Folded' is the only one that existed before, and all levels used that highlight info.  The new 'FoldLevel1' is actually for level 2 highlighting, 'FoldLevel2' for level 3, etc., so I probably made a mistake in naming.

I constructed my highlight coloring to match the highlighting of OL1 .. OL9 tags, but added a 'gui=bold' section so that there is a (small) visual cue for folded sections, even from the same color.  You could tweak it any way you want to give visual cues.  Maybe someone can tell me:  Are we limited to the literal color designations in the highlight commands, or can we specify a precise color somehow, like 'guifg=#00f'?

--  Herb

Reply | Threaded
Open this post in threaded view
|

Re: Hack to show level-dependent folded colors

Herbert Sitz
In reply to this post by Steve Litt
Steve Litt wrote
Is there a way you could link whether or not your hack does its thing to the
state of a Vim variable?
[. . ]
Having never looked at Vim source, I have no idea how hard it would be to add
a setable variable, and having never seen the patch I don't know how hard it
would be to have it turned on and off by the setable variable, but if it
could be done, that would be wonderful.

Thanks

STeveT
Steve -- Whoops, sorry, I realized I didn't even respond to your question about adding a Vim variable to control this.  I'm sure there is a way, but I have no idea offhand how it's done.  As a Vim newbie I'm already staggered by the number of options and settings, trying to wade my way through things.

But like I tried to show, the change does not just automatically use the outline level color to do the fold.  You have complete control over what color you will use to highlight open outline headings and folded headings, mix and match as you want.

-- Herb
Reply | Threaded
Open this post in threaded view
|

Re: Hack to show level-dependent folded colors

John Porubek
In reply to this post by Herbert Sitz
On Thu, Jan 15, 2009 at 5:24 PM, hsitz <[hidden email]> wrote:

>
>
> Noel Henson wrote:
>>
>> I'm interested in what you have come up with. I tried to do that years ago
>> by continuously rewriting the syntax highlighting for closed folds. It
>> would sometime work but mostly not, especially when opening and closing
>> folds when there are already visible closed folds.
>>
>> I'll check out what you have done.
>>
>> Noel
>>
> Noel -- Thanks, I would appreciate that.  I've posted a zip with the changes
> that can be downloaded here:
> http://www.plainspokenfinancial.com/vim-level-highlight-change.zip
>
> Would anyone who tries to use these files please let me know whether you
> have success or failure in compiling changes into your version?  I'm using
> the vim source from the subversion server at sourceforge for vim7.  See info
> at http://vim.sourceforge.net/subversion.php
>
> The changes were very straightforward, only hard part was grokking the
> structure of the program.  It turned out to be built to easily accommodate
> this sort of change.  The original coders probably just didn't realize the
> need or thought having highlight for different levels would be overkill.
>
> Regards,
>
> Herb
> --
> View this message in context: http://www.nabble.com/Hack-to-show-level-dependent-folded-colors-tp21483288p21488180.html
> Sent from the Vim - Outliner mailing list archive at Nabble.com.
>
> _______________________________________________
> VimOutliner mailing list
> [hidden email]
> http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
>

Ouch! I hadn't picked up on the fact that this required a recompile of
the Vim source. I could probably muddle through that under Linux, but
my initial impression is that it would be a PITA under Windows. If
someone else makes a patched Windows version, could you make it
available to the group? Perhaps Bram (and | or whoever else is
involved in producing new releases) could be persuaded to incorporate
these changes in the next release.

John
_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: Hack to show level-dependent folded colors

Herbert Sitz
In reply to this post by Herbert Sitz
hsitz wrote
I constructed my highlight coloring to match the highlighting of OL1 .. OL9 tags, but added a 'gui=bold' section so that there is a (small) visual cue for folded sections, even from the same color.  You could tweak it any way you want to give visual cues.
. . .
Maybe someone can tell me:  Are we limited to the literal color designations in the highlight commands, or can we specify a precise color somehow, like 'guifg=#00f'?
I answered my own question.  The docs say you can enter a highlight of this form, at least for gui colors:

    :highlight Comment guifg=#11f0c3 guibg=#ff00ff
 
So it would be possible to make the visual cue more obvious even while retaining similar colors.  For example, expanded heading might have color of full red (#ff0000), while collapsed heading has less  bright red (e.g., #bb0000).

Also, remember that you can also specify italics or underline if you like those as cues.
Reply | Threaded
Open this post in threaded view
|

Re: Hack to show level-dependent folded colors

Noel Henson
In reply to this post by John Porubek
On Thursday 15 January 2009, John Porubek wrote:

> On Thu, Jan 15, 2009 at 5:24 PM, hsitz <[hidden email]> wrote:
> > Noel Henson wrote:
> >> I'm interested in what you have come up with. I tried to do that
> >> years ago by continuously rewriting the syntax highlighting for
> >> closed folds. It would sometime work but mostly not, especially when
> >> opening and closing folds when there are already visible closed
> >> folds.
> >>
> >> I'll check out what you have done.
> >>
> >> Noel
> >
> > Noel -- Thanks, I would appreciate that.  I've posted a zip with the
> > changes that can be downloaded here:
> > http://www.plainspokenfinancial.com/vim-level-highlight-change.zip
> >
> > Would anyone who tries to use these files please let me know whether
> > you have success or failure in compiling changes into your version?
> > I'm using the vim source from the subversion server at sourceforge for
> > vim7.  See info at http://vim.sourceforge.net/subversion.php
> >
> > The changes were very straightforward, only hard part was grokking the
> > structure of the program.  It turned out to be built to easily
> > accommodate this sort of change.  The original coders probably just
> > didn't realize the need or thought having highlight for different
> > levels would be overkill.
> >
> > Regards,
> >
> > Herb
> > --
> > View this message in context:
> > http://www.nabble.com/Hack-to-show-level-dependent-folded-colors-tp214
> >83288p21488180.html Sent from the Vim - Outliner mailing list archive
> > at Nabble.com.
> >
> > _______________________________________________
> > VimOutliner mailing list
> > [hidden email]
> > http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
>
> Ouch! I hadn't picked up on the fact that this required a recompile of
> the Vim source. I could probably muddle through that under Linux, but
> my initial impression is that it would be a PITA under Windows. If
> someone else makes a patched Windows version, could you make it
> available to the group? Perhaps Bram (and | or whoever else is
> involved in producing new releases) could be persuaded to incorporate
> these changes in the next release.
>
> John
> _______________________________________________
> VimOutliner mailing list
> [hidden email]
> http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner

I had actually looked into this. A slight modification of vim's syntax
highlighting code to provide different highlighting options for different
levels of folding. hsitz code is cleaner than what I had in mind. He has
done a good job though I think it could use a bit of refinement. Perhaps,
as a group, we could refine it to vim's standards for patches and get it
included in the next release of vim. Bram has a very good system for voting
for feature inclusion in vim releases. Perhaps it is time for us VO users
        to contribute to a project that has provided us such a great
        platform over the years.

Noel

--

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com Chips, firmware and embedded systems
  www.vimoutliner.org Work fast. Think well.


_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner