Giter Club home page Giter Club logo

powerline's Introduction

powerline

Emacs version of the Vim powerline.

This is a proposed version 2.0 of the original Emacs Powerline which is a fork of vim-powerline.

This version has utf-8 support enabled. The utf-8 separators will display a unicode character properly under mintty for example - as long as you have patched fonts installed.

By default, any terminal mode emacs will use the utf-8 separators.

Installation

(require 'powerline)
(powerline-default-theme)

The second line customizes mode-line-format according to the default theme.

There are five builtin themes:

  • powerline-default-theme
  • powerline-center-theme
  • powerline-center-evil-theme
  • powerline-vim-theme
  • powerline-nano-theme

You can revert back to the original value of mode-line-format that was being used when powerline was loaded using powerline-revert.

Faces

The faces that powerline uses for the builtin themes are powerline-active1 and powerline-active2 for the active modeline, and powerline-inactive1 ande powerline-inactive2 for the inactive modelines. If you create your own theme, you can add as many faces as you want and pass those faces to the corresponding powerline-* functions when creating your mode-line-format.

Custom Themes

Please look over the powerline-default-theme and powerline-center-theme in powerline-themes.el for examples of themes that involve different justifications of modeline text.

You can write your own powerline theme by simply setting your own mode-line-format to be an evaluation (:eval) of the powerline functions. Notice in powerline-default-theme the let* defines two lists: lhs and rhs which are exactly the lists that define what goes on the left and right sides of the modeline. The powerline-center-theme demonstrates how to center justify part of the modeline and defines an additional center list which is exactly the modeline components to be displayed in the middle section.

In most circumstances you should only need to modify the builtin themes unless you are trying to do a particularly unique layout.

Explanation

This theme does some tricks to improve performance and get all the text justified properly. First, it sets lhs and rhs to a list of powerline sections. You can easily re-utilize builtin modeline formatting by adding it as a raw powerline section. For example,

(powerline-raw mode-line-mule-info nil 'l)

would add the formatting defined in mode-line-mule-info to the modeline as it appears in the default modeline.

The last line of this is what actually puts it all together, by concatonating the lhs, some "fill" space, and rhs. This must be done to ensure that the padding in between the left and right sections properly fills the modeline.

Improvements from this rewrite:

  • Cleaner code.
  • Try to simply be a library that provides functions for generating a mode-line
  • Make right-aligned text actually be flush against the right side.
  • Separators are designed to dynamically size their height based on the font settings.
  • Separators spread their width to the nearest character width. (This is required to make right-aligned text actually be right-aligned)

Implementing New Separators

The function should return an XPM image created using the create-image function.

There is a function called memoize that will help make calling the function multiple times with the same parameters be much quicker by caching the return value.

Each divider should have the signature: (face1 face2 &optional height)

face1 : the left-hand face

face2 : the right-hand face

height : specifies the height of the XPM, most of time this is (font-char-height)

Separators should consider the height when they are created so that the mode-line can change sizes based on the font height.

powerline's People

Contributors

milkypostman avatar deb0ch avatar tarsius avatar abo-abo avatar katspaugh avatar mrbliss avatar apierz avatar anuragm avatar greenrecyclebin avatar dewdrops avatar sellout avatar jasonm23 avatar joewreschnig avatar joca-bt avatar mattfidler avatar prakashk avatar punchagan avatar purcell avatar mallt avatar mineo avatar mituharu avatar yewton avatar c-alpha avatar justbur avatar locksten avatar momomo5717 avatar ustcscgy avatar 3macs avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.