Set terminal title to reflect current page

This commit is contained in:
woorst
2016-06-30 09:38:12 -05:00
parent fb837bafc7
commit aa27647f59

View File

@@ -11,6 +11,7 @@ from kitchen.text.display import textual_width
from . import docs
from .objects import Controller, Color, Command
from .exceptions import TemporaryFileError
from .__version__ import __version__
def logged_in(f):
@@ -282,6 +283,11 @@ class Page(object):
sub_name = self.content.name.replace('/r/front', 'Front Page')
self.term.add_line(window, sub_name, 0, 0)
# Set the terminal title
title = sub_name + ' - rtv {0}'.format(__version__)
sys.stdout.write('\x1b]2;{0}\x07'.format(title))
sys.stdout.flush()
if self.reddit.user is not None:
# The starting position of the name depends on if we're converting
# to ascii or not
@@ -415,4 +421,4 @@ class Page(object):
n_rows, _ = window.getmaxyx()
for row in range(n_rows):
window.chgat(row, 0, 1, attribute)
window.chgat(row, 0, 1, attribute)