Add --no-flash option to rtv, fixes #478
This commit is contained in:
@@ -80,6 +80,9 @@ def build_parser():
|
|||||||
help='Open external links using programs defined in the mailcap config')
|
help='Open external links using programs defined in the mailcap config')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-V', '--version', action='version', version='rtv '+__version__)
|
'-V', '--version', action='version', version='rtv '+__version__)
|
||||||
|
parser.add_argument(
|
||||||
|
'--no-flash', dest='flash', action='store_const', const=False,
|
||||||
|
help='Disable screen flashing')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@@ -264,7 +267,8 @@ class Config(object):
|
|||||||
'oauth_redirect_port': partial(config.getint, 'rtv'),
|
'oauth_redirect_port': partial(config.getint, 'rtv'),
|
||||||
'oauth_scope': lambda x: rtv[x].split(','),
|
'oauth_scope': lambda x: rtv[x].split(','),
|
||||||
'max_comment_cols': partial(config.getint, 'rtv'),
|
'max_comment_cols': partial(config.getint, 'rtv'),
|
||||||
'hide_username': partial(config.getboolean, 'rtv')
|
'hide_username': partial(config.getboolean, 'rtv'),
|
||||||
|
'flash': partial(config.getboolean, 'rtv')
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, func in params.items():
|
for key, func in params.items():
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ ascii = False
|
|||||||
; Turn on monochrome mode to disable color.
|
; Turn on monochrome mode to disable color.
|
||||||
monochrome = False
|
monochrome = False
|
||||||
|
|
||||||
|
; Flash when an invalid action is executed.
|
||||||
|
flash = True
|
||||||
|
|
||||||
; Enable debugging by logging all HTTP requests and errors to the given file.
|
; Enable debugging by logging all HTTP requests and errors to the given file.
|
||||||
;log = /tmp/rtv.log
|
;log = /tmp/rtv.log
|
||||||
|
|
||||||
|
|||||||
@@ -118,12 +118,14 @@ class Terminal(object):
|
|||||||
self._display = display
|
self._display = display
|
||||||
return self._display
|
return self._display
|
||||||
|
|
||||||
@staticmethod
|
def flash(self):
|
||||||
def flash():
|
|
||||||
"""
|
"""
|
||||||
Flash the screen to indicate that an action was invalid.
|
Flash the screen to indicate that an action was invalid.
|
||||||
"""
|
"""
|
||||||
|
if self.config['flash']:
|
||||||
return curses.flash()
|
return curses.flash()
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def curs_set(val):
|
def curs_set(val):
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ def test_config_get_args():
|
|||||||
'--copy-config',
|
'--copy-config',
|
||||||
'--enable-media',
|
'--enable-media',
|
||||||
'--theme', 'molokai',
|
'--theme', 'molokai',
|
||||||
'--list-themes']
|
'--list-themes',
|
||||||
|
'--no-flash']
|
||||||
|
|
||||||
with mock.patch('sys.argv', ['rtv']):
|
with mock.patch('sys.argv', ['rtv']):
|
||||||
config_dict = Config.get_args()
|
config_dict = Config.get_args()
|
||||||
@@ -115,6 +116,7 @@ def test_config_get_args():
|
|||||||
assert config['enable_media'] is True
|
assert config['enable_media'] is True
|
||||||
assert config['theme'] == 'molokai'
|
assert config['theme'] == 'molokai'
|
||||||
assert config['list_themes'] is True
|
assert config['list_themes'] is True
|
||||||
|
assert config['flash'] is False
|
||||||
|
|
||||||
|
|
||||||
def test_config_link_deprecated():
|
def test_config_link_deprecated():
|
||||||
@@ -148,7 +150,8 @@ def test_config_from_file():
|
|||||||
'enable_media': True,
|
'enable_media': True,
|
||||||
'max_comment_cols': 150,
|
'max_comment_cols': 150,
|
||||||
'hide_username': True,
|
'hide_username': True,
|
||||||
'theme': 'molokai'}
|
'theme': 'molokai',
|
||||||
|
'flash': True}
|
||||||
|
|
||||||
bindings = {
|
bindings = {
|
||||||
'REFRESH': 'r, <KEY_F5>',
|
'REFRESH': 'r, <KEY_F5>',
|
||||||
|
|||||||
@@ -93,6 +93,13 @@ def test_terminal_functions(terminal):
|
|||||||
terminal.stdscr.addch.assert_called_with(3, 5, 'ch', 'attr')
|
terminal.stdscr.addch.assert_called_with(3, 5, 'ch', 'attr')
|
||||||
|
|
||||||
|
|
||||||
|
def test_terminal_no_flash(terminal):
|
||||||
|
|
||||||
|
terminal.config['flash'] = False
|
||||||
|
terminal.flash()
|
||||||
|
assert not curses.flash.called
|
||||||
|
|
||||||
|
|
||||||
def test_terminal_clean_ascii(terminal):
|
def test_terminal_clean_ascii(terminal):
|
||||||
|
|
||||||
terminal.config['ascii'] = True
|
terminal.config['ascii'] = True
|
||||||
|
|||||||
Reference in New Issue
Block a user