Adding the search term to the title bar, removing with_search argument

This commit is contained in:
Michael Lazar
2017-07-22 22:04:20 -04:00
parent 9f59d941d7
commit cc5d8a941c
9 changed files with 3584 additions and 935 deletions

View File

@@ -326,6 +326,7 @@ class SubmissionContent(Content):
self.max_indent_level = max_indent_level
self.name = submission_data['permalink']
self.order = order
self.query = None
self._loader = loader
self._submission = submission
self._submission_data = submission_data
@@ -662,6 +663,7 @@ class SubscriptionContent(Content):
self.name = name
self.order = None
self.query = None
self._loader = loader
self._subscriptions = subscriptions
self._subscription_data = []

View File

@@ -56,7 +56,7 @@ class Page(object):
self._row = 0
self._subwindows = None
def refresh_content(self, order=None, name=None, with_search=False):
def refresh_content(self, order=None, name=None):
raise NotImplementedError
def _draw_item(self, window, data, inverted):
@@ -118,7 +118,7 @@ class Page(object):
self.term.show_notification('Invalid option')
return
self.refresh_content(order=choices[ch], with_search=True)
self.refresh_content(order=choices[ch])
@PageController.register(Command('SORT_RISING'))
def sort_content_rising(self):
@@ -126,7 +126,7 @@ class Page(object):
@PageController.register(Command('SORT_NEW'))
def sort_content_new(self):
self.refresh_content(order='new', with_search=True)
self.refresh_content(order='new')
@PageController.register(Command('SORT_CONTROVERSIAL'))
def sort_content_controversial(self):
@@ -147,7 +147,7 @@ class Page(object):
self.term.show_notification('Invalid option')
return
self.refresh_content(order=choices[ch], with_search=True)
self.refresh_content(order=choices[ch])
@PageController.register(Command('MOVE_UP'))
def move_cursor_up(self):
@@ -408,6 +408,10 @@ class Page(object):
sub_name = sub_name.replace('/r/front', 'Front Page')
sub_name = sub_name.replace('/u/me', 'My Submissions')
sub_name = sub_name.replace('/u/saved', 'My Saved Submissions')
query = self.content.query
if query:
sub_name = 'Searching {0}: {1}'.format(sub_name, query)
self.term.add_line(window, sub_name, 0, 0)
# Set the terminal title

View File

@@ -63,7 +63,7 @@ class SubmissionPage(Page):
self.active = False
@SubmissionController.register(Command('REFRESH'))
def refresh_content(self, order=None, name=None, with_search=False):
def refresh_content(self, order=None, name=None):
"Re-download comments and reset the page index"
order = order or self.content.order

View File

@@ -36,12 +36,18 @@ class SubredditPage(Page):
self.toggled_subreddit = None
@SubredditController.register(Command('REFRESH'))
def refresh_content(self, order=None, name=None, with_search=False):
def refresh_content(self, order=None, name=None):
"Re-download all submissions and reset the page index"
order = order or self.content.order
# Preserve the query if staying on the current page
if name is None:
query = self.content.query
else:
query = None
name = name or self.content.name
query = self.content.query if with_search else None
# Hack to allow an order specified in the name by prompt_subreddit() to
# override the current default

View File

@@ -28,7 +28,7 @@ class SubscriptionPage(Page):
self.selected_subreddit = None
@SubscriptionController.register(Command('REFRESH'))
def refresh_content(self, order=None, name=None, with_search=False):
def refresh_content(self, order=None, name=None):
"Re-download all subscriptions and reset the page index"
# reddit.get_my_subreddits() does not support sorting by order

View File

@@ -59,7 +59,7 @@ class Terminal(object):
self.loader = LoadScreen(self)
self._display = None
self._mailcap_dict = mailcap.getcaps()
self._term = os.environ['TERM']
self._term = os.environ.get('TERM')
@property
def up_arrow(self):