2020-11-04, updated: 2024-03-12

Tested with Nyxt 2 Pre-release 4.

Tags: feature.

Powerline for Nyxt

Powerline for Nyxt

By John Mercouris

Inspired by Vim's Powerline (https://github.com/powerline/powerline), we decided to develop our own variation: Nyxt Powerline.

In Nyxt, the status area is what is typically referred to as the "modeline" in other programs. Because the "modeline" does significantly more than show the active modes, we decided to call it the "status area" (which is populated by the status buffer). The status area, because it is a buffer, can render any rich web content.

In an editor like Vim, Powerline provides pertinent information at a glance:

Similarly, in a browser like Nyxt, we've tried to provide the most important details and controls:

More than appearances

The similarities with Powerline go beyond appearances. Powerline is lauded for its customizability and extensibility. So too is Nyxt's status area extensible. You can customize it as little or as much as you like.

The four main sections of the status area are generated via five functions:

You can override any of these functions to easily change the behavior and appearance of the status area sections.

These five functions are invoked by a function titled (defun format-status (window), this function can be completely overridden or set by changing the status-formatter slot of the window class.

If you are not interested in providing your own complete status area implementation (format-status function), the default one is easily tweakable for colors, content, and appearance. A simple example involves changing how the load status is displayed.

Overriding load status

If you wanted it to display "Loaded: " instead of "" when a page is loaded you could change it in the following way:

In fact, if you didn't want Nyxt to say anything at all whether a page is loading or otherwise, you don't even have to return a value! You could simply write:

Highlighting vi insert mode

As a Vi binding user, a common thing you may wish to do is change the appearance of the status area when you toggle between command mode and execution mode.

First we need a way to tell if vi-insert-mode is active. For this, we will write a short predicate function:

Then, we take the format-status function and modify it in the following way:

We've added just three lines:

and with that we have the following result:

and the following appearance during insert mode:


We hope you've enjoyed reading about Nyxt's new status area. The possibilities for customization are endless: you could show different colors, icons, or even play sounds when different modes are active or inactive. You could show the progress of downloads, a list of bookmarks, anything you want! If the data is available, it can be shown in the status area buffer. We're eager to see what we can come up with together!

Thanks for reading :-)

Did you enjoy this article? Register for our newsletter to receive the latest hacker news from the world of Lisp and browsers!