Git Product home page Git Product logo

telephone-line's Introduction

Telepone Line

Telephone Line is a new implementation of Powerline with a few new features that set it apart from the existing Emacs implementations: easier customization and antialiased separators.

Antialiased Separators

First off, this is how they look

./screenshots/abs.png

Classic powerline, called “abs” (you’ll see why later).

./screenshots/cubed.png

Spacemacs’ default separator, called “cubed”.

./screenshots/gradient.png

A gradient separator.

./screenshots/to_the_right.png

You can use two right separators instead of a left and right, if you want.

Each of these separators is defined programmatically (the existing powerline.el does something more along the lines of templating), being created from two potentially user-defined functions – but more on that later. For now, just enjoy their pixels-wot-have-intermediate-colors

Easy Customization

The screenshots above aren’t the default configuration; it’s all defined in my dotfiles.

Here’s the relevant section:

(setq telephone-line-lhs
        '((evil   . (telephone-line-evil-tag-segment))
          (accent . (telephone-line-vc-segment
                     telephone-line-erc-modified-channels-segment
                     telephone-line-process-segment))
          (nil    . (telephone-line-minor-mode-segment
                     telephone-line-buffer-segment))))
(setq telephone-line-rhs
        '((evil   . (telephone-line-airline-position-segment))
          (accent . (telephone-line-major-mode-segment))
          (nil    . (telephone-line-misc-info-segment))))

…That’s it. That’s essentially all there is to creating a theme.

Now, as a caveat, this makes things like the spacemacs theme harder to create (it could still be done, maybe with a closure that returns left/right alternating separators). However, it addresses most of my issues with the existing solutions.

Separator Customization

I mentioned before that the separators are defined in terms of two functions. Here’s the way that works:

Imagine the cross-section of the mode-line as a number line, ranging from -height/2 to +height/2. The first function is applied across this number line to get the shape of the separator. Here’s the most famous separator, defined as 2*abs(x).

-4 |       *
-3 |     *
-2 |   *
-1 | *
 0 +
 1 | *
 2 |   *
 3 |     *
 4 |       *

There you go – a separator. However, we still need another piece. That second function I mentioned determines the fill – the difference between a solid separator and a hollow one.

This isn’t the sort of function I’d expect to get much customization out of, but there are 3 included ones. The first makes a hollow separator, which looks more-or-less like the ASCII art above. The second provides a fill:

-4 |       *
-3 |     *--
-2 |   *----
-1 | *------
 0 +--------
 1 | *------
 2 |   *----
 3 |     *--
 4 |       *

The third one is a special thing that ignores the first function entirely and just produces the same output regardless of the input. It’s used to make the gradient separator.

Choice of separator can be customized as well, by changing the values of telephone-line-{primary,secondary}-{left,right}-separator. This should be a function which accepts two faces or colors (if provided faces, the built-in separators use the background field) and returns a propertized image. The separators can be defined independently of one another – feel free to use a nominally left separator for your rhs, or mix two different types of separators.

Separator Types

You probably also noticed from the screenshots that there are in fact two types of separator on either side of the mode-line. The way this works involves the lhs/rhs alists.

Basically, lists of segment functions associated to a color symbol are rendered into a ‘supersegment’. Supersegments are separated by primary separators. Internally, non-nil segment-functions are rendered into ‘subsegments’. Subsegments are separated by secondary separators.

Primary separators are static – the customization I showed will always produce 4 primary separators. Secondaries depend upon the subsegments state, so there could be anywhere from 0-3 in my config.

Package structure

  • telephone-line.el: Stuff for setting up the mode-line
  • telephone-line-separators.el: Separator definitions
  • telephone-line-segments.el: Segment definitions
  • telephone-line-utils.el: Functions strictly for defining new Separators and Segments

If you just want the separators, you can just require that. It does depend upon utils, however.

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.