One of the things that’s nice about NRSS is the ability to theme the entire thing, not only with colors but with style contingent on the status of the item being printed, the feed, or anything else.
Theming
You can set up to eight color pairs for themes. These form the basic palette with which you can draw. Colors are referred to by their NCurses terminal color code. The list looks like this.
| Color | Code |
| Black | 0 |
| Red | 1 |
| Green | 2 |
| Yellow | 3 |
| Blue | 4 |
| Magenta | 5 |
| Cyan | 6 |
| White | 7 |
You can set up a color pair by defining it in your config like so:
theme "1" "7" "0"
This will set the default colors (color pair 1) to white text on a black background. Other color pairs are used exclusively in user-defined styles.
Note on colors
Now’s a good time to note that some colors have to be “created” by applying certain attributes (mentioned below) to colors. For example, the black color, plus the bold attribute shows up as gray. Or the yellow color looks brown, until you add the bold attribute.
User defined styles
The rendering of most elements in NRSS can be modified by defining title_string, n_story_string, u_story_string, r_story_string, and reader_string. These control the feed’s header, the rendering of new, unread, and read stories, and finally, how the description is rendered in NRSS.
Each one of these has a number of escapes that it uses
Global Escapes
| Escape | Meaning |
| %1 – %8 | Turn on color pair 1 – 8 |
Title Escapes
| Escape | Meaning |
| %u | The feed’s URL |
| %i | The number of items in the feed |
| %n | The number of “new” items in the feed |
| %d | The number of unread item in the feed |
| %r | The number of items read in the feed |
| %h | The feed’s Handle |
| %t | The feed’s Title (if known) |
| %x | Returns + if the feed is collapsed, – if not |
Story Escapes
| Escape | Meaning |
| %s | The Story Title |
Reader Escapes
| Escape | Meaning |
| %d | Story Description |
| %t | Story Title |
| %h | Feed Handle |
As such, if you wanted a very minimal, no interesting colors, nothing setup, you could do the following.
title_string "%h" n_story_string "%s" u_story_string "%s" r_story_string "%s" reader_string "%h\n%d"
But that wouldn’t be much fun, would it? So let’s say that you want the separate story types above to be colored differently. Then you could define color pairs 2, 3, and 4 and do something simple:
n_story_string "%2%s%1" u_story_string "%3%s%1" r_story_string "%4%s%1"
Which would at least get you some color.
Attributes
In addition to color, you can also apply attributes to the text. For example, bold or underlined text. It’s probably good to note that terminals support these on their own terms, so using attributes may not give you a consistent look across different terminal types. Anyway, the available attributes are as follow:
Attribute escapes.
| Escape | Meaning |
| %B | Toggle Bold |
| %U | Toggle Underline |
| %S | Toggle Standout |
| %R | Toggle Reverse Video |
| %D | Toggle Dim |
So let’s enhance the previous example a little further. Let’s simply make the new stories bold, the unread stories underlined.
n_story_string "%B%2%s%1%B" u_story_string "%U%3%s%1%U" r_story_string "%4%s%1"
That’s much better. But there’s still one more element of the equation that needs to be added for a fully functional style.
Ternaries
Ternaries comprise the way that NRSS can interpret some parts of a style string and not others. In fact, this is how NRSS renders the cursor. There is no built in cursor, only something that differentiates a selected item from an unselected item in a ternary.
The basic syntax is just like a C ternary, it starts with the escape followed by a set of parentheses with the two results in it. Like this:
%?x(rendered if true:rendered if false)
There are a number of conditions that a ternary can use depending on what style string you’re changing.
Title Ternaries
| Conditional | State |
| %?x | False if the feed is collapsed |
| %?s | True if the feed is selected |
Story Conditionals
| Conditional | State |
| %?b | True if this is the first item visible |
| %?e | True if this is the last item visible |
| %?s | True if this item is selected |
| %?f | True if this item’s feed is selected |
Let’s use a ternary to change the way that the default title above looks depending on whether it’s expanded or not:
title_string "%h%?x(+:-)"
Now, if the feed is expanded it will read “Slashdot -”, but it’s it’s collapsed it will read “Slashdot +”. The default NRSS style’s cursor is created with the following ternary that we’ll add to our new title string.
title_string "%?s(>: ) %h%?x(+:-)"
Beautiful. You can get some very elaborate styles based on these rules. For example, a style that would put a three character unicode bracket on the left size of the feeds would look like this:
n_story_string "%?s(⟾: ) %?e(⎝:%?b(⎛:⎜)) %?s(%2%B%|%s%|%B:%2%|%s%|)%1" u_story_string "%?s(⟾: ) %?e(⎝:%?b(⎛:⎜)) %?s(%3%B%|%s%|%B:%3%|%s%|)%1" r_story_string "%?s(⟾: ) %?e(⎝:%?b(⎛:⎜)) %?s(%4%B%|%s%|%B:%4%|%s%|)%1"
In the meantime, be creative and if you generate a really cool look, send it to me (jjm2n4 at umr dot edu) and I’ll put up a screenshot using it.