Merge branch 'master' into vimb_browser
This commit is contained in:
@@ -23,7 +23,7 @@ Considerations
|
||||
|
||||
- If you're adding a new feature, try to include a few test cases.
|
||||
See the section below on setting up your test environment
|
||||
- If you tried, but you **ABSOLUTELY CAN'T** get the tests to run, it's ok
|
||||
- If you tried, but you can't get the tests running in your environment, it's ok
|
||||
- If you are unsure about anything, ask!
|
||||
|
||||
Submitting a pull request
|
||||
@@ -70,7 +70,7 @@ This both speeds up the tests and helps to maintain consistency across runs.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ pip install pytest vcrpy --upgrade
|
||||
$ pip install rtv[test]
|
||||
|
||||
2. Set your ``$PYTHONPATH`` to point to the directory of your RTV repository.
|
||||
|
||||
@@ -92,11 +92,11 @@ This both speeds up the tests and helps to maintain consistency across runs.
|
||||
4. By default, the cassettes will act as read-only.
|
||||
If you have written a new test and would like to record a cassette, you must provide your own refresh token.
|
||||
The easiest thing to do is to use the token generated by RTV when you log in.
|
||||
This is usually stored as *~/.config/rtv/refresh-token*.
|
||||
This is usually stored as *~/.local/share/rtv/refresh-token*.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ python -m pytest ~/code/rtv/tests/ --record-mode once --refresh-token ~/.config/rtv/refresh-token
|
||||
$ python -m pytest ~/code/rtv/tests/ --record-mode once --refresh-token ~/.local/share/rtv/refresh-token
|
||||
================================ test session starts ================================
|
||||
platform linux -- Python 3.4.0, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
|
||||
rootdir: ~/code/rtv/, inifile:
|
||||
|
||||
@@ -5,3 +5,4 @@ include README.md
|
||||
include LICENSE
|
||||
include rtv.1
|
||||
include rtv/templates/*
|
||||
include rtv/themes/*
|
||||
|
||||
71
README.md
71
README.md
@@ -3,7 +3,7 @@
|
||||
</h1>
|
||||
|
||||
<p align="center">
|
||||
RTV provides an interface to view and interact with reddit from your terminal.<br>
|
||||
RTV provides a terminal interface to view and interact with reddit.<br>
|
||||
It's compatible with most terminal emulators on Linux and macOS.
|
||||
</p>
|
||||
|
||||
@@ -107,7 +107,7 @@ Press <kbd>/</kbd> to open the navigation prompt, where you can type things like
|
||||
- ``/u/multi-mod/m/art``
|
||||
- ``/domain/github.com``
|
||||
|
||||
See [CONTROLS](https://github.com/michael-lazar/rtv/blob/master/CONTROLS.rst) for the full list of commands.
|
||||
See [CONTROLS](CONTROLS.rst) for the full list of commands.
|
||||
|
||||
## Settings
|
||||
|
||||
@@ -115,7 +115,7 @@ See [CONTROLS](https://github.com/michael-lazar/rtv/blob/master/CONTROLS.rst) fo
|
||||
|
||||
Configuration files are stored in the ``{HOME}/.config/rtv/`` directory.
|
||||
|
||||
Check out [rtv.cfg](https://github.com/michael-lazar/rtv/blob/master/rtv/templates/rtv.cfg) for the full list of configurable options. You can clone this file into your home directory by running:
|
||||
Check out [rtv.cfg](rtv/templates/rtv.cfg) for the full list of configurable options. You can clone this file into your home directory by running:
|
||||
|
||||
```bash
|
||||
$ rtv --copy-config
|
||||
@@ -135,7 +135,7 @@ A mailcap file allows you to associate different MIME media types, like ``image/
|
||||
$ rtv --copy-mailcap
|
||||
```
|
||||
|
||||
This template contains examples for common MIME types that work with popular reddit websites like *imgur*, *youtube*, and *gfycat*. Open the mailcap template and follow the [instructions](https://github.com/michael-lazar/rtv/blob/master/rtv/templates/mailcap) listed inside.
|
||||
This template contains examples for common MIME types that work with popular reddit websites like *imgur*, *youtube*, and *gfycat*. Open the mailcap template and follow the [instructions](rtv/templates/mailcap) listed inside.
|
||||
|
||||
Once you've setup your mailcap file, enable it by launching rtv with the ``rtv --enable-media`` flag (or set it in your **rtv.cfg**)
|
||||
|
||||
@@ -162,78 +162,41 @@ The default programs that RTV interacts with can be configured through environme
|
||||
</table>
|
||||
|
||||
### Clipboard
|
||||
RTV supports copying submission links to the OS clipboard.
|
||||
On macOS this is supported out of the box.
|
||||
|
||||
RTV supports copying submission links to the OS clipboard. On macOS this is supported out of the box.
|
||||
On Linux systems you will need to install either [xsel](http://www.vergenet.net/~conrad/software/xsel/) or [xclip](https://sourceforge.net/projects/xclip/).
|
||||
|
||||
## Themes
|
||||
|
||||
### Usage
|
||||
|
||||
Use the ``--theme`` flag to select a theme (or set it in your **rtv.cfg**):
|
||||
|
||||
```bash
|
||||
$ rtv --theme=papercolor
|
||||
```
|
||||
|
||||
You can view the list of built-in and installed themes with the ``--list-themes`` flag:
|
||||
|
||||
```bash
|
||||
$ rtv --list-themes
|
||||
|
||||
Installed (~/.config/rtv/themes/):
|
||||
(empty)
|
||||
|
||||
Presets:
|
||||
molokai [requires 256 colors]
|
||||
papercolor [requires 256 colors]
|
||||
solarized-dark [requires 256 colors]
|
||||
solarized-light [requires 256 colors]
|
||||
|
||||
Built-in:
|
||||
default [requires 8 colors]
|
||||
monochrome [requires 0 colors]
|
||||
```
|
||||
|
||||
Inside of RTV, the <kbd>F2</kbd> & <kbd>F3</kbd> keys can also be used to preview the available themes.
|
||||
|
||||
### Preview
|
||||
Themes can be used to customize the look and feel of RTV
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<p><strong>Default</strong><br>
|
||||
Uses the terminal's preset 16 color palette</p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_default.png"></img>
|
||||
</td>
|
||||
<td align="center">
|
||||
<p><strong>Monochrome</strong><br>
|
||||
Fallback for terminals that don't support colors</p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_monochrome.png"></img>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<p><strong>Solarized Dark</strong></p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_solarized_dark.png"></img>
|
||||
<img src="resources/theme_solarized_dark.png"></img>
|
||||
</td>
|
||||
<td align="center">
|
||||
<p><strong>Solarized Light</strong></p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_solarized_light.png"></img>
|
||||
<img src="resources/theme_solarized_light.png"></img>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<p><strong>Papercolor</strong></p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_papercolor.png"></img>
|
||||
<img src="resources/theme_papercolor.png"></img>
|
||||
</td>
|
||||
<td align="center">
|
||||
<p><strong>Molokai</strong></p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_molokai.png"></img>
|
||||
<img src="resources/theme_molokai.png"></img>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
List installed themes with ``--list-themes`` command, and select one with ``--theme``. You can also set the theme permenantly in your [rtv.cfg](rtv/templates/rtv.cfg) file. You can use the <kbd>F2</kbd> & <kbd>F3</kbd> keys inside of RTV to preview themes.
|
||||
|
||||
For instructions on writing and installing your own themes, see [THEMES.md](THEMES.md).
|
||||
|
||||
## FAQ
|
||||
|
||||
<details>
|
||||
@@ -282,8 +245,8 @@ Inside of RTV, the <kbd>F2</kbd> & <kbd>F3</kbd> keys can also be used to previe
|
||||
## Contributing
|
||||
All feedback and suggestions are welcome, just post an issue!
|
||||
|
||||
Before writing any code, please read the [Contributor Guidelines](https://github.com/michael-lazar/rtv/blob/master/CONTRIBUTING.rst).
|
||||
Before writing any code, please read the [Contributor Guidelines](CONTRIBUTING.rst).
|
||||
|
||||
## License
|
||||
This project is distributed under the [MIT](https://github.com/michael-lazar/rtv/blob/master/LICENSE) license.
|
||||
This project is distributed under the [MIT](LICENSE) license.
|
||||
|
||||
|
||||
217
THEMES.md
217
THEMES.md
@@ -1,85 +1,77 @@
|
||||
# Themes
|
||||
|
||||
Different themes can be used to customize the look and feel of RTV.
|
||||
They control the color and special attributes (bold, underline, etc.) of
|
||||
every text element drawn on the screen.
|
||||
## Installing Themes
|
||||
|
||||
## Usage
|
||||
You can install custom themes by copying them into your **~/.config/rtv/themes/**
|
||||
directory. The name of the theme will match the name of the file.
|
||||
|
||||
Use the ``--theme`` flag to select a theme:
|
||||
|
||||
```bash
|
||||
$ rtv --theme=papercolor
|
||||
```
|
||||
$ cp my-custom-theme.cfg ~/.config/rtv/themes/
|
||||
$ rtv --theme my-custom-theme
|
||||
```
|
||||
|
||||
You can also view a list of built-in and installed themes by using the ``--list-themes`` flag:
|
||||
If you've created a cool theme and would like to share it with the community,
|
||||
please submit a pull request!
|
||||
|
||||
```bash
|
||||
$ rtv --list-themes
|
||||
## A quick primer on ANSI colors
|
||||
|
||||
Installed (~/.config/rtv/themes/):
|
||||
(empty)
|
||||
Color support on modern terminals can be split into 4 categories:
|
||||
|
||||
Presets:
|
||||
molokai [requires 256 colors]
|
||||
papercolor [requires 256 colors]
|
||||
solarized-dark [requires 256 colors]
|
||||
solarized-light [requires 256 colors]
|
||||
1. No support for colors
|
||||
2. 8 system colors - Black, Red, Green, Yellow, Blue, Magenta,
|
||||
Cyan, and White
|
||||
3. 16 system colors - Everything above + bright variations
|
||||
4. 256 extended colors - Everything above + 6x6x6 color palette + 24 greyscale colors
|
||||
|
||||
Built-in:
|
||||
default [requires 8 colors]
|
||||
monochrome [requires 0 colors]
|
||||
<p align="center">
|
||||
<img alt="terminal colors" src="resources/terminal_colors.png"/>
|
||||
<br><i>The 256 terminal color codes, image from <a href=https://github.com/eikenb/terminal_colors>https://github.com/eikenb/terminal_colors</a></i>
|
||||
</p>
|
||||
|
||||
The 16 system colors, along with the default foreground and background,
|
||||
can usually be customized through your terminal's profile settings. The
|
||||
6x6x6 color palette and grayscale colors are constant RGB values across
|
||||
all terminals. RTV's default theme only uses the 8 primary system colors,
|
||||
which is why it matches the "look and feel" of the terminal that you're
|
||||
running it in.
|
||||
|
||||
<p align="center">
|
||||
<img alt="iTerm preferences" src="resources/iterm_preferences.png"/>
|
||||
<br><i>Setting the 16 system colors in iTerm preferences</i>
|
||||
</p>
|
||||
|
||||
The curses library determines your terminal's color support by reading your
|
||||
environment's ``$TERM`` variable, and looking up your terminal's
|
||||
capabilities in the [terminfo](https://linux.die.net/man/5/terminfo)
|
||||
database. You can emulate this behavior by using the ``tput`` command:
|
||||
|
||||
```
|
||||
bash$ export TERM=xterm
|
||||
bash$ tput colors
|
||||
8
|
||||
bash$ export TERM=xterm-256color
|
||||
bash$ tput colors
|
||||
256
|
||||
bash$ export TERM=vt220
|
||||
bash$ tput colors
|
||||
-1
|
||||
```
|
||||
|
||||
Custom themes can be installed by copying them into the **{HOME}/.config/rtv/themes/** folder.
|
||||
In general you should not be setting your ``$TERM`` variable manually,
|
||||
it will be set automatically by you terminal. Often, problems with
|
||||
terminal colors can be traced back to somebody hardcoding
|
||||
``TERM=xterm-256color`` in their .bashrc file.
|
||||
|
||||
The <kbd>F2</kbd> & <kbd>F3</kbd> keys can be used to cycle through themes from within RTV.
|
||||
## Understanding RTV Themes
|
||||
|
||||
## Preview
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<p><strong>Default</strong><br>
|
||||
Uses the terminal's preset 16 color palette</p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_default.png"></img>
|
||||
</td>
|
||||
<td align="center">
|
||||
<p><strong>Monochrome</strong><br>
|
||||
Fallback for terminals that don't support colors</p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_monochrome.png"></img>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<p><strong>Solarized Dark</strong></p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_solarized_dark.png"></img>
|
||||
</td>
|
||||
<td align="center">
|
||||
<p><strong>Solarized Light</strong></p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_solarized_light.png"></img>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<p><strong>Papercolor</strong></p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_papercolor.png"></img>
|
||||
</td>
|
||||
<td align="center">
|
||||
<p><strong>Molokai</strong></p>
|
||||
<img src="https://github.com/michael-lazar/rtv/blob/themes/resources/theme_molokai.png"></img>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Designing a theme
|
||||
Here's an example of what an RTV theme file looks like:
|
||||
|
||||
```
|
||||
[theme]
|
||||
;<element> = <foreground> <background> <attributes>
|
||||
Normal = default default -
|
||||
Selected = - - -
|
||||
SelectedCursor = - - reverse
|
||||
Normal = default default normal
|
||||
Selected = default default normal
|
||||
SelectedCursor = default default reverse
|
||||
|
||||
TitleBar = cyan - bold+reverse
|
||||
OrderBar = yellow - bold
|
||||
@@ -126,3 +118,100 @@ Link = blue - underline
|
||||
LinkSeen = magenta - underline
|
||||
UserFlair = yellow - bold
|
||||
```
|
||||
|
||||
Every piece of text drawn on the screen is assigned to an ``<element>``,
|
||||
which has three properties:
|
||||
|
||||
- ``<foreground>``: The text color
|
||||
- ``<background>``: The background color
|
||||
- ``<attributes>``: Additional text attributes, like bold or underlined
|
||||
|
||||
### Colors
|
||||
|
||||
The ``<foreground>`` and ``<background>`` properties can be set to any the following values:
|
||||
|
||||
- ``default``, which means use the terminal's default foreground or background color.
|
||||
- The 16 system colors:
|
||||
<p>
|
||||
<table>
|
||||
<tr><td>black</td><td>dark_gray</td></tr>
|
||||
<tr><td>red</td></td><td>bright_red</td></tr>
|
||||
<tr><td>green</td></td><td>bright_green</td></tr>
|
||||
<tr><td>yellow</td></td><td>bright_yellow</td></tr>
|
||||
<tr><td>blue</td></td><td>bright_blue</td></tr>
|
||||
<tr><td>magenta</td></td><td>bright_magenta</td></tr>
|
||||
<tr><td>cyan</td></td><td>bright_cyan</td></tr>
|
||||
<tr><td>light_gray</td></td><td>white</td></tr>
|
||||
</table>
|
||||
</p>
|
||||
- ``ansi_{n}``, where n is between 0 and 255. These will map to their
|
||||
corresponding ANSI colors (see the figure above).
|
||||
- Hex RGB codes, like ``#0F0F0F``, which will be converted to their nearest
|
||||
ANSI color. This is generally not recommended because the conversion process
|
||||
downscales the color resolution and the resulting colors will look "off".
|
||||
|
||||
### Attributes
|
||||
|
||||
The ``<attributes>`` property can be set to any of the following values:
|
||||
|
||||
- ``normal``, ``bold``, ``underline``, or ``standout``.
|
||||
- ``reverse`` will swap the foreground and background colors.
|
||||
|
||||
Attributes can be mixed together using the + symbol. For example,
|
||||
``bold+underline`` will make the text bold and underlined.
|
||||
|
||||
### Modifiers
|
||||
|
||||
RTV themes use special "modifer" elements to define the default
|
||||
application style. This allows you to do things like set the default
|
||||
background color without needing to set ``<background>`` on every
|
||||
single element. The three modifier elements are:
|
||||
|
||||
- ``Normal`` - The default modifier that applies to all text elements.
|
||||
- ``Selected`` - Applies to text elements that are highlighted on the page.
|
||||
- ``SelectedCursor`` - Like ``Selected``, but only applies to ``CursorBlock``
|
||||
and ``CursorBar{n}`` elements.
|
||||
|
||||
When an element is marked with a ``-`` token, it means inherit the
|
||||
attribute value from the relevant modifier. This is best explained
|
||||
through an example:
|
||||
|
||||
```
|
||||
[theme]
|
||||
;<element> = <foreground> <background> <attributes>
|
||||
Normal = ansi_241 ansi_230 normal
|
||||
Selected = ansi_241 ansi_254 normal
|
||||
SelectedCursor = ansi_241 ansi_254 bold+reverse
|
||||
|
||||
Link = ansi_33 - underline
|
||||
```
|
||||
|
||||
<p align="center">
|
||||
<img src="resources/theme_modifiers.png"/>
|
||||
<br><i>The default solarized-light theme</i>
|
||||
</p>
|
||||
|
||||
In the snippet above, the ``Link`` element has its background color set
|
||||
to the ``-`` token. This means that it will inherit it's background
|
||||
from either the ``Normal`` (light yellow) or the ``Selected`` (light grey)
|
||||
element, depending on if it's selected or not.
|
||||
|
||||
Compare this with what happens when the ``Link`` background is explicitly set to ``ansi_230``:
|
||||
|
||||
```
|
||||
[theme]
|
||||
;<element> = <foreground> <background> <attributes>
|
||||
Normal = ansi_241 ansi_230 normal
|
||||
Selected = ansi_241 ansi_254 normal
|
||||
SelectedCursor = ansi_241 ansi_254 bold+reverse
|
||||
|
||||
Link = ansi_33 ansi_230 underline
|
||||
```
|
||||
|
||||
<p align="center">
|
||||
<img src="resources/theme_modifiers_2.png"/>
|
||||
<br><i>The Link element hard-coded to ansi_230</i>
|
||||
</p>
|
||||
|
||||
In this case, the ``Link`` background stays yellow even when the link is
|
||||
selected by the cursor.
|
||||
|
||||
BIN
resources/iterm_preferences.png
Normal file
BIN
resources/iterm_preferences.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 111 KiB |
BIN
resources/terminal_colors.png
Normal file
BIN
resources/terminal_colors.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
BIN
resources/theme_modifiers.png
Normal file
BIN
resources/theme_modifiers.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 55 KiB |
BIN
resources/theme_modifiers_2.png
Normal file
BIN
resources/theme_modifiers_2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 55 KiB |
@@ -20,12 +20,13 @@ TEMPLATES = os.path.join(PACKAGE, 'templates')
|
||||
DEFAULT_CONFIG = os.path.join(TEMPLATES, 'rtv.cfg')
|
||||
DEFAULT_MAILCAP = os.path.join(TEMPLATES, 'mailcap')
|
||||
DEFAULT_THEMES = os.path.join(PACKAGE, 'themes')
|
||||
XDG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.join(HOME, '.config'))
|
||||
CONFIG = os.path.join(XDG_HOME, 'rtv', 'rtv.cfg')
|
||||
XDG_CONFIG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.join(HOME, '.config'))
|
||||
XDG_DATA_HOME = os.getenv('XDG_DATA_HOME', os.path.join(HOME, '.local', 'share'))
|
||||
CONFIG = os.path.join(XDG_CONFIG_HOME, 'rtv', 'rtv.cfg')
|
||||
MAILCAP = os.path.join(HOME, '.mailcap')
|
||||
TOKEN = os.path.join(XDG_HOME, 'rtv', 'refresh-token')
|
||||
HISTORY = os.path.join(XDG_HOME, 'rtv', 'history.log')
|
||||
THEMES = os.path.join(XDG_HOME, 'rtv', 'themes')
|
||||
TOKEN = os.path.join(XDG_DATA_HOME, 'rtv', 'refresh-token')
|
||||
HISTORY = os.path.join(XDG_DATA_HOME, 'rtv', 'history.log')
|
||||
THEMES = os.path.join(XDG_CONFIG_HOME, 'rtv', 'themes')
|
||||
|
||||
|
||||
def build_parser():
|
||||
|
||||
@@ -303,17 +303,20 @@ class SubredditPage(Page):
|
||||
offset = 0 if not inverted else -(data['n_rows'] - n_rows)
|
||||
|
||||
n_title = len(data['split_title'])
|
||||
for row, text in enumerate(data['split_title'], start=offset):
|
||||
if data['url_full'] in self.config.history:
|
||||
attr = self.term.attr('SubmissionTitleSeen')
|
||||
else:
|
||||
attr = self.term.attr('SubmissionTitle')
|
||||
for row, text in enumerate(data['split_title'], start=offset):
|
||||
if row in valid_rows:
|
||||
self.term.add_line(win, text, row, 1, attr)
|
||||
|
||||
row = n_title + offset
|
||||
if data['url_full'] in self.config.history:
|
||||
attr = self.term.attr('LinkSeen')
|
||||
else:
|
||||
attr = self.term.attr('Link')
|
||||
if row in valid_rows:
|
||||
if data['url_full'] in self.config.history:
|
||||
attr = self.term.attr('LinkSeen')
|
||||
else:
|
||||
attr = self.term.attr('Link')
|
||||
self.term.add_line(win, '{url}'.format(**data), row, 1, attr)
|
||||
|
||||
row = n_title + offset + 1
|
||||
|
||||
32
rtv/theme.py
32
rtv/theme.py
@@ -54,9 +54,9 @@ class Theme(object):
|
||||
# can only use the 8 basic colors with the default color as the background
|
||||
DEFAULT_THEME = {
|
||||
'modifiers': {
|
||||
'Normal': (-1, -1, None),
|
||||
'Selected': (None, None, None),
|
||||
'SelectedCursor': (None, None, curses.A_REVERSE),
|
||||
'Normal': (-1, -1, curses.A_NORMAL),
|
||||
'Selected': (-1, -1, curses.A_NORMAL),
|
||||
'SelectedCursor': (-1, -1, curses.A_REVERSE),
|
||||
},
|
||||
'page': {
|
||||
'TitleBar': (curses.COLOR_CYAN, None, curses.A_BOLD | curses.A_REVERSE),
|
||||
@@ -103,6 +103,7 @@ class Theme(object):
|
||||
'SubmissionSubreddit': (curses.COLOR_YELLOW, None, None),
|
||||
'SubmissionText': (None, None, None),
|
||||
'SubmissionTitle': (None, None, curses.A_BOLD),
|
||||
'SubmissionTitleSeen': (None, None, None),
|
||||
'Upvote': (curses.COLOR_GREEN, None, curses.A_BOLD),
|
||||
'Link': (curses.COLOR_BLUE, None, curses.A_UNDERLINE),
|
||||
'LinkSeen': (curses.COLOR_MAGENTA, None, curses.A_UNDERLINE),
|
||||
@@ -160,6 +161,18 @@ class Theme(object):
|
||||
elements[key] = (None, None, None)
|
||||
|
||||
self._set_fallback(elements, 'Normal', (-1, -1, curses.A_NORMAL))
|
||||
self._set_fallback(elements, 'Selected', 'Normal')
|
||||
self._set_fallback(elements, 'SelectedCursor', 'Normal')
|
||||
|
||||
# Create the "Selected" versions of elements, which are prefixed with
|
||||
# the @ symbol. For example, "@CommentText" represents how comment
|
||||
# text is formatted when it is highlighted by the cursor.
|
||||
for name in self.DEFAULT_THEME['normal']:
|
||||
dest = '@{0}'.format(name)
|
||||
self._set_fallback(elements, name, 'Selected', dest)
|
||||
for name in self.DEFAULT_THEME['cursor']:
|
||||
dest = '@{0}'.format(name)
|
||||
self._set_fallback(elements, name, 'SelectedCursor', dest)
|
||||
|
||||
# Fill in the ``None`` values for all of the elements with normal text
|
||||
for name in self.DEFAULT_THEME['normal']:
|
||||
@@ -169,19 +182,6 @@ class Theme(object):
|
||||
for name in self.DEFAULT_THEME['page']:
|
||||
self._set_fallback(elements, name, 'Normal')
|
||||
|
||||
# Create the "Selected" versions of elements, which are prefixed with
|
||||
# the @ symbol. For example, "@CommentText" represents how comment
|
||||
# text is formatted when it is highlighted by the cursor.
|
||||
for name in self.DEFAULT_THEME['normal']:
|
||||
dest = '@{0}'.format(name)
|
||||
self._set_fallback(elements, 'Selected', name, dest)
|
||||
for name in self.DEFAULT_THEME['cursor']:
|
||||
dest = '@{0}'.format(name)
|
||||
self._set_fallback(elements, 'SelectedCursor', name, dest)
|
||||
|
||||
self._set_fallback(elements, 'Selected', 'Normal')
|
||||
self._set_fallback(elements, 'SelectedCursor', 'Normal')
|
||||
|
||||
self.elements = elements
|
||||
|
||||
if self.use_color:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[theme]
|
||||
;<element> = <foreground> <background> <attributes>
|
||||
Normal = default default -
|
||||
Selected = - - -
|
||||
SelectedCursor = - - reverse
|
||||
Normal = default default normal
|
||||
Selected = default default normal
|
||||
SelectedCursor = default default reverse
|
||||
|
||||
TitleBar = cyan - bold+reverse
|
||||
OrderBar = yellow - bold
|
||||
@@ -44,6 +44,7 @@ SubmissionFlair = red - -
|
||||
SubmissionSubreddit = yellow - -
|
||||
SubmissionText = - - -
|
||||
SubmissionTitle = - - bold
|
||||
SubmissionTitleSeen = - - -
|
||||
Upvote = green - bold
|
||||
Link = blue - underline
|
||||
LinkSeen = magenta - underline
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
|
||||
[theme]
|
||||
;<element> = <foreground> <background> <attributes>
|
||||
Normal = ansi_252 ansi_234 -
|
||||
Selected = - ansi_236 -
|
||||
SelectedCursor = - - bold+reverse
|
||||
Normal = ansi_252 ansi_234 normal
|
||||
Selected = ansi_252 ansi_236 normal
|
||||
SelectedCursor = ansi_252 ansi_234 bold+reverse
|
||||
|
||||
TitleBar = ansi_81 - bold+reverse
|
||||
OrderBar = ansi_244 ansi_235 -
|
||||
@@ -67,6 +67,7 @@ SubmissionFlair = ansi_197 - -
|
||||
SubmissionSubreddit = ansi_222 - -
|
||||
SubmissionText = - - -
|
||||
SubmissionTitle = - - bold
|
||||
SubmissionTitleSeen = - - -
|
||||
Upvote = ansi_154 - bold
|
||||
Link = ansi_67 - underline
|
||||
LinkSeen = ansi_141 - underline
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
|
||||
[theme]
|
||||
;<element> = <foreground> <background> <attributes>
|
||||
Normal = ansi_238 ansi_255 -
|
||||
Selected = - ansi_254 -
|
||||
SelectedCursor = - - bold+reverse
|
||||
Normal = ansi_238 ansi_255 normal
|
||||
Selected = ansi_238 ansi_254 normal
|
||||
SelectedCursor = ansi_238 ansi_255 bold+reverse
|
||||
|
||||
TitleBar = ansi_24 - bold+reverse
|
||||
OrderBar = ansi_25 - bold
|
||||
@@ -65,6 +65,7 @@ SubmissionFlair = ansi_162 - bold
|
||||
SubmissionSubreddit = ansi_166 - bold
|
||||
SubmissionText = - - -
|
||||
SubmissionTitle = - - bold
|
||||
SubmissionTitleSeen = - - -
|
||||
Upvote = ansi_28 - bold
|
||||
Link = ansi_24 - underline
|
||||
LinkSeen = ansi_91 - underline
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
[theme]
|
||||
;<element> = <foreground> <background> <attributes>
|
||||
Normal = ansi_244 ansi_234 -
|
||||
Selected = - ansi_235 -
|
||||
SelectedCursor = - ansi_235 bold+reverse
|
||||
Normal = ansi_244 ansi_234 normal
|
||||
Selected = ansi_244 ansi_235 normal
|
||||
SelectedCursor = ansi_244 ansi_235 bold+reverse
|
||||
|
||||
TitleBar = ansi_37 - bold+reverse
|
||||
OrderBar = ansi_245 - bold
|
||||
@@ -34,10 +34,10 @@ NoticeError = ansi_160 - bold
|
||||
NoticeSuccess = ansi_64 - bold
|
||||
|
||||
CursorBlock = ansi_240 - -
|
||||
CursorBar1 = ansi_125 - bold
|
||||
CursorBar2 = ansi_160 - bold
|
||||
CursorBar3 = ansi_61 - bold
|
||||
CursorBar4 = ansi_37 - bold
|
||||
CursorBar1 = ansi_125 - -
|
||||
CursorBar2 = ansi_160 - -
|
||||
CursorBar3 = ansi_61 - -
|
||||
CursorBar4 = ansi_37 - -
|
||||
|
||||
CommentAuthor = ansi_33 - bold
|
||||
CommentAuthorSelf = ansi_64 - bold
|
||||
@@ -63,6 +63,7 @@ SubmissionFlair = ansi_160 - -
|
||||
SubmissionSubreddit = ansi_166 - -
|
||||
SubmissionText = - - -
|
||||
SubmissionTitle = ansi_245 - bold
|
||||
SubmissionTitleSeen = - - -
|
||||
Upvote = ansi_64 - bold
|
||||
Link = ansi_33 - underline
|
||||
LinkSeen = ansi_61 - underline
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
[theme]
|
||||
;<element> = <foreground> <background> <attributes>
|
||||
Normal = ansi_241 ansi_230 -
|
||||
Selected = - ansi_254 -
|
||||
SelectedCursor = - ansi_254 bold+reverse
|
||||
Normal = ansi_241 ansi_230 normal
|
||||
Selected = ansi_241 ansi_254 normal
|
||||
SelectedCursor = ansi_241 ansi_254 bold+reverse
|
||||
|
||||
TitleBar = ansi_37 - bold+reverse
|
||||
OrderBar = ansi_245 - bold
|
||||
@@ -34,10 +34,10 @@ NoticeError = ansi_160 - bold
|
||||
NoticeSuccess = ansi_64 - bold
|
||||
|
||||
CursorBlock = ansi_245 - -
|
||||
CursorBar1 = ansi_125 - bold
|
||||
CursorBar2 = ansi_160 - bold
|
||||
CursorBar3 = ansi_61 - bold
|
||||
CursorBar4 = ansi_37 - bold
|
||||
CursorBar1 = ansi_125 - -
|
||||
CursorBar2 = ansi_160 - -
|
||||
CursorBar3 = ansi_61 - -
|
||||
CursorBar4 = ansi_37 - -
|
||||
|
||||
CommentAuthor = ansi_33 - bold
|
||||
CommentAuthorSelf = ansi_64 - bold
|
||||
@@ -63,6 +63,7 @@ SubmissionFlair = ansi_160 - bold
|
||||
SubmissionSubreddit = ansi_166 - bold
|
||||
SubmissionText = - - -
|
||||
SubmissionTitle = ansi_240 - bold
|
||||
SubmissionTitleSeen = - - -
|
||||
Upvote = ansi_64 - bold
|
||||
Link = ansi_33 - underline
|
||||
LinkSeen = ansi_61 - underline
|
||||
|
||||
2
setup.py
2
setup.py
@@ -59,7 +59,7 @@ setuptools.setup(
|
||||
'rtv.packages.praw'
|
||||
],
|
||||
package_data={
|
||||
'rtv': ['templates/*'],
|
||||
'rtv': ['templates/*', 'themes/*'],
|
||||
'rtv.packages.praw': ['praw.ini']
|
||||
},
|
||||
data_files=[("share/man/man1", ["rtv.1"])],
|
||||
|
||||
@@ -40,7 +40,7 @@ for name in ['vcr.matchers', 'vcr.stubs']:
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption('--record-mode', dest='record_mode', default='none')
|
||||
parser.addoption('--refresh-token', dest='refresh_token',
|
||||
default='~/.config/rtv/refresh-token')
|
||||
default='~/.local/share/rtv/refresh-token')
|
||||
|
||||
|
||||
class MockStdscr(mock.MagicMock):
|
||||
|
||||
@@ -102,7 +102,11 @@ def test_theme_element_selected_attributes():
|
||||
# the ones defined in "Selected". Because "Selected" defines
|
||||
# a foreground and a background color, they will override the
|
||||
# ones that "Link" had defined.
|
||||
assert theme.elements['@Link'] == (2, 3, curses.A_REVERSE)
|
||||
# assert theme.elements['@Link'] == (2, 3, curses.A_REVERSE)
|
||||
|
||||
# I can't remember why the above rule was implemented, so I reverted it
|
||||
assert theme.elements['@Link'] == (5, 3, curses.A_REVERSE)
|
||||
|
||||
assert '@Normal' not in theme.elements
|
||||
assert '@Selected' not in theme.elements
|
||||
assert '@TitleBar' not in theme.elements
|
||||
|
||||
Reference in New Issue
Block a user