Commit Graph

2565 Commits

Author SHA1 Message Date
Kim Silkebækken cff4fcdd88 Fix segment padding
The padding argument has been removed and is now handled automatically.
Segments without dividers are not padded anymore.

This was necessary to ensure that segments are rendered correctly when
cropping segments (overriding the padding argument screwed up the
padding for segments without dividers and without padding).
2012-11-14 22:42:37 +01:00
Kim Silkebækken 89375b5c6a Fix issues with terminal renderer 2012-11-14 20:49:04 +01:00
Kim Silkebækken 94cd934268 Simplify filler rendering 2012-11-14 20:48:07 +01:00
Kim Silkebækken bef6c430ad Update vim statusline example
Now the vim statusline example does everything in Python, so the python
example isn't required anymore.
2012-11-14 20:45:47 +01:00
Kim Silkebækken b5d72afb7b Create dynamic vim statusline example
This example only does a single type of highlighting (normal mode) but
demonstrates nicely how rendering a statusline with Python could work.
This also utilizes the new width functionality to crop away less
important segment if the window is too small, and do the padding with
Python instead of using vim's split segment.

Some optimization will probably be necessary, as calling Python for each
statusline redraw is quite expensive. A solution could be evaluating the
segments in Python once and then calculating the width and crop away/pad
the segments, and then sending the statusline with unevaluated segments
to vim for rendering without calling Python. Only some events (like
CursorHold, InsertEnter/InsertLeave, etc.) would trigger a re-render
with Python, a recalculation of the width and cropping/padding.
2012-11-14 20:30:02 +01:00
Kim Silkebækken d3bace24ec Improve the Segment class and rendering
The Segment class has been given two new properties: priority and
filler. The render method has been given a width argument.

If the width argument is specified when rendering a segment and the
rendered segments are too wide, segments are dropped in order of
priority, with the lowest priority (highest number) being dropped first
and any segment with priority < 0 is kept, regardless of the specified
width.

If the width argument is specified along with one or more filler
segments, the filler segments will pad the remaining space with space
characters until the desired width has been reached.

The handling of segment attributes has also been improved by lazily
looking up the correct attributes in the segment tree when it's being
rendered.

Finally, the rendering code itself has been improved a bit with less
code duplication and much more readable code.
2012-11-14 12:02:49 +01:00
Kim Silkebækken 21a48e997a Move vimscript hl statement generation to vim renderer 2012-11-12 13:11:19 +01:00
Kim Silkebækken f47dc4bffd Change wording: separator -> divider 2012-11-08 15:01:47 +01:00
Kim Silkebækken b461ab1358 Create basic vim segment renderer
This commit also includes a basic proof-of-concept demo for creating vim
statuslines. When creating vim statuslines you basically need to first
create the statusline the same way as the terminal demo, use the vim
renderer and then afterwards loop through the collected highlight groups
in the vim renderer and write those as vim highlight statements.

Vim obviously needs a ton of wrapper code to make everything work
properly (separate modes, callbacks, all that stuff) so the current demo
only shows some basic statusline highlighting.
2012-11-08 14:05:48 +01:00
Kim Silkebækken 20892b14d8 Fix default segment attribute value 2012-11-08 14:05:16 +01:00
Kim Silkebækken 59a760c3c6 Join the fg/bg/attr methods of the renderers
This change joins the fg/bg/attr methods into a single hl method in the
renderers. This provides the same functionality, and it simplifies the
terminal rendering by being able to join all the attributes into one
escape sequence.

It's also a necessary change for the vim renderer, as this renderer
needs to log all the highlighting and create separate highlighting
classes for every single color and attribute combination. The only way
to do this is to have a single highlighting method.
2012-11-08 13:16:22 +01:00
Kim Silkebækken ffbdcc0f75 Fix soft separator issue with vim divider segments 2012-11-08 12:51:15 +01:00
Kim Silkebækken 99ded1d0c6 Add vim statusline example
This is currently rendered with the terminal renderer, and is just
a simple proof-of-concept of how vim statuslines can be defined with the
Python API.
2012-11-08 12:44:46 +01:00
Kim Silkebækken cf88b086c0 Add initial project files 2012-11-08 12:23:57 +01:00
Kim Silkebækken adb67e1e1f Initial commit 2012-11-08 11:12:49 +01:00