Add hotkeys to copy submission permalink and submission url

This commit is contained in:
Josue Ortega
2017-04-17 15:16:27 -06:00
parent 967f352081
commit 7a2d248875
4 changed files with 28 additions and 0 deletions

View File

@@ -57,6 +57,8 @@ https://github.com/michael-lazar/rtv
o : Open the submission or comment url
SPACE : Fold or expand the selected comment tree
b : Display urls with urlview
y : Copy submission permalink to clipboard
Y : Copy submission link to clipboard
[Prompt]
The `/` prompt accepts subreddits in the following formats

View File

@@ -5,6 +5,7 @@ import os
import sys
import time
import curses
import pyperclip
from functools import wraps
import six
@@ -318,6 +319,28 @@ class Page(object):
message = 'New Messages' if inbox > 0 else 'No New Messages'
self.term.show_notification(message)
@PageController.register(Command('COPY_SUBMISSION_PERMALINK'))
def copy_submission_permalink(self):
"""
Copies submission permalink to OS clipboard
"""
data = self.get_selected_item()
url = data.get('permalink')
if url is not None:
pyperclip.copy(url)
@PageController.register(Command('COPY_SUBMISSION_URL'))
def copy_post_permalink(self):
"""
Copies submission url to OS clipboard
"""
data = self.get_selected_item()
url = data.get('url')
if url is not None:
pyperclip.copy(url)
def clear_input_queue(self):
"""
Clear excessive input caused by the scroll wheel or holding down a key

View File

@@ -118,6 +118,8 @@ INBOX = i
REFRESH = r, <KEY_F5>
PROMPT = /
SAVE = w
COPY_SUBMISSION_PERMALINK = y
COPY_SUBMISSION_URL = Y
; Submission page
SUBMISSION_TOGGLE_COMMENT = 0x20

View File

@@ -11,6 +11,7 @@ install_requires = [
'kitchen',
'requests >=2.4.0', # https://github.com/michael-lazar/rtv/issues/325
'six',
'pyperclip'
]
tests_require = [