Commit Graph

2452 Commits

Author SHA1 Message Date
Kim Silkebækken 157fff0834 Update default colorscheme 2012-12-06 17:00:59 +01:00
Kim Silkebækken a0b0d15b8f Update default theme 2012-12-06 15:55:57 +01:00
Kim Silkebækken 5d2214db52 Make the examples work with the new project structure 2012-12-06 15:07:41 +01:00
Kim Silkebækken 1cb6aeab0d Create renderer property for Powerline class 2012-12-06 15:07:41 +01:00
Kim Silkebækken 636f1719fb Only drop segments whose contents are None 2012-12-06 15:07:34 +01:00
Kim Silkebækken 11ee10851c Move segment rendering to the Renderer class
This commit also updates the extension renderers so that they work
correctly with the Renderer class.
2012-12-06 14:23:24 +01:00
Kim Silkebækken 8b94e253dd Add default colorscheme skeleton 2012-12-05 17:57:17 +01:00
Kim Silkebækken bcde4f6293 Add default vim theme 2012-12-05 17:56:19 +01:00
Kim Silkebækken d72265cabb Add colorscheme/theme placeholders 2012-12-05 17:46:04 +01:00
Kim Silkebækken d4d84a4346 Move mksegment out of core 2012-12-05 17:35:21 +01:00
Kim Silkebækken 4d225179d0 Reorganize files 2012-12-05 16:37:18 +01:00
Kim Silkebækken 091840ac67 Fix terminal prompt example 2012-11-26 16:18:26 +01:00
Kim Silkebækken 07b23f5418 Add tmux statusline example 2012-11-26 16:18:15 +01:00
Kim Silkebækken 6a1912aece Add tmux segment renderer 2012-11-26 16:18:06 +01:00
Kim Silkebækken 6a9bb45157 Fix hard divider rendering issue
Hard dividers (for segments with different background colors) are now
always drawn, regardless of the draw_divider option, because it looks
horrible when segments with different bg colors don't have a divider
between them.

This resolves an issue with the filename and modified flag
in the default theme where the filename segment had to set the
draw_divider flag based on the contents of the modified flag to be
rendered correctly.
2012-11-26 15:14:39 +01:00
Kim Silkebækken 34da25418c Add short presentation to README 2012-11-26 09:17:28 +01:00
Kim Silkebækken e18f3fab75 Fix mode segment 2012-11-23 19:03:58 +01:00
Kim Silkebækken 0f5a497834 Add initial vim binding functions and segments
Each segment is a function that can accept parameters like the branch or
readonly symbol for overriding the defaults.
2012-11-23 17:27:31 +01:00
Kim Silkebækken 3be7dc2a40 Merge branch 'feature/extended-vim-example' into develop 2012-11-21 12:23:49 +01:00
Kim Silkebækken addb7ccf73 Fix various rendering issues
Another rendering pass is necessary before calculating the filler
segment's lengths, because center segments may lose their separators
after removing low-priority segments.

Some unicode and variable assignment issues has been resolved so
everything renders correctly.
2012-11-21 12:21:01 +01:00
Kim Silkebækken 1d3c259070 Improve rendering performance
This change removes the Segment class as this takes forever to remove
from the segment array when removing low-priority segments. It has
instead been replaced by a wrapper function that works the same and
returns a working dict of all segment properties.

The regex substitution bottleneck in the vim example has been fixed by
using a single-character percent placeholder in vim segments which is
later replaced with a double percent using str.replace().
2012-11-21 11:33:10 +01:00
Kim Silkebækken f4e3d01d07 Improve rendering performance
This commit almost doubles the segment rendering performance. This is
accomplished by caching a lot of data like highlighting groups, moving
some calculations out of loops, and by performing less function calls
overall.

When a width is specified the main speed improvement comes from avoiding
rendering the raw segments over and over until the statusline is short
enough. Instead, the raw rendering is stored as a segment property and
the combined length of all these renderings is used when removing
low-priority segments instead. This results in a maximum of two
rendering passes.

Some "less pythonic" solutions have been chosen some places for
performance reasons, e.g. joining strings instead of appending and
joining lists.

Overall this commit appears to make the performance equal or better than
the legacy vimscript implementation. Later optimizations (in particular
finding another method than remove() for removing low-priority segments)
may make this version of Powerline far superior both in terms of
functionality and performance.
2012-11-21 09:57:16 +01:00
Kim Silkebækken 6c5316a058 Make vim example work with split and inactive windows
This commit introduces a bunch of changes. Most importantly, it ensures
that split windows and inactive windows work as expected. This is
accomplished with some clever workarounds for vim's statusline
limitations.

Vim statuslines evaluated using the %! statusline item are always
evaluated in the buffer context and not in the statusline's owner
window's context, and this made the previous implementation show the
same statusline for all windows. The only way to ensure that the correct
statusline is rendered to the correct window is to walk through all
windows, and setting the statuslines with a reference to the current
window number every time the current window is changed. This is
accomplished by a set of BufEnter, BufLeave, etc. autocommands.

The Syntastic segment has been temporarily removed due to errors when
referencing the statusline function before Syntastic has been loaded.
2012-11-20 21:22:21 +01:00
Kim Silkebækken a532da4834 Fix issues with the terminal prompt example 2012-11-17 16:42:34 +01:00
Kim Silkebækken 08695540da Handle remainder whitespace for filler segments
When more than one filler segment is specified it may sometimes be
a remainder when calculating the amount of whitespace. divmod() is used
to retrieve the remainder, which is added as whitespace to the first
filler segment.
2012-11-17 12:41:08 +01:00
Kim Silkebækken 90763f1fec Improve unicode handling of rendered segments 2012-11-17 12:35:22 +01:00
Kim Silkebækken 4cb0559be4 Fix whitespace issues so pyflakes doesn't complain 2012-11-17 12:21:24 +01:00
ZyX 0f6d24b1e8 Made it work on older vims 2012-11-17 14:08:38 +03:59
ZyX 708306c6ba Avoid invoking vim parser as much as possible in case vim is recent enough 2012-11-17 13:58:28 +03:59
Kim Silkebækken 572df1ded0 Fix filename issues in vim example 2012-11-16 17:16:30 +01:00
Kim Silkebækken 1d1021992f Update vim and terminal examples
The examples have been moved into their own directory. The vim example
now uses pyeval() and vim.bindeval() and loads the Python file through
an import (so it gets compiled) for speed improvements.
2012-11-16 17:05:55 +01:00
Kim Silkebækken cbf8d16ed8 Ignore empty segments that aren't filler segments 2012-11-16 12:55:09 +01:00
Kim Silkebækken 2ea555b2dd Rewrite core code to only allow a single-dimensional segment array
The segment tree seemed like a good idea at the time, but for the core
code it's probably best to do a single-dimensional array and instead
have some duplicated data (common segment attributes). By removing the
tree structured segments the code is much simpler to understand and use,
and probably quite a bit faster.

If a tree structure is wanted for ease of configuration, it could easily
be supported in the JSON config files for vim statuslines, and then
letting the vim statusline code flatten the configuration into
a single-dimensional array for rendering.
2012-11-16 12:43:23 +01:00
Kim Silkebækken 5abfdaeef8 Add unicode stuff for Python 2
Powerline will probably only be Python 2 in the foreseeable future
because of poor Python 3 support in applications like vim, so this
small change ensures correct unicode behavior in Python 2.
2012-11-15 13:35:11 +01:00
Kim Silkebækken 804447d04d Update vim statusline example 2012-11-15 13:32:14 +01:00
Kim Silkebækken ba73083641 Remove get_hl_statements from vim renderer 2012-11-15 13:31:42 +01:00
Kim Silkebækken e99b1f1753 Fix vim statusline example 2012-11-14 22:42:42 +01:00
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