Added urlview keybinding

1.  A shortcut of 'b' was used as the default binding for passing
comment body text to urlview (this is similar to the default of C-b in
the 'mutt' text email client)
2.  The `comment_urlview` SubmissionController function was added to
recieve the SUBMISSION_OPEN_IN_URLVIEWER keypress request.
3.  The `open_urlview` terminal function was added to handle the urlview
request.  It passes the comment body data to urlview via a Popen
process.
4.  A test case was added to ensure this new code path is executed
5.  Small formatting changes, mostly line length
This commit is contained in:
Matt Smith
2016-07-04 22:42:30 -07:00
committed by Matt Smith
parent fb837bafc7
commit 749ad11171
9 changed files with 343 additions and 9 deletions

View File

@@ -349,7 +349,8 @@ class Terminal(object):
'Browser exited with status=%s' % code)
time.sleep(0.01)
else:
raise exceptions.BrowserError('Timeout opening browser')
raise exceptions.BrowserError(
'Timeout opening browser')
finally:
# Can't check the loader exception because the oauth module
# supersedes this loader and we need to always kill the
@@ -438,6 +439,20 @@ class Terminal(object):
else:
_logger.info('File deleted: %s', filepath)
def open_urlview(self, data):
urlview = os.getenv('RTV_URLVIEWER') or 'urlview'
try:
with self.suspend():
p = subprocess.Popen([urlview],
stdin=subprocess.PIPE)
try:
p.communicate(input=six.b(data))
except KeyboardInterrupt:
p.terminate()
except OSError:
self.show_notification(
'Could not open urls with {}'.format(urlview))
def text_input(self, window, allow_resize=False):
"""
Transform a window into a text box that will accept user input and loop
@@ -574,4 +589,4 @@ class Terminal(object):
break
out = '\n'.join(stack)
return out
return out