Allow completion to be disabled

This commit is contained in:
Florian Bruhin 2014-01-28 12:59:12 +01:00
parent 9bf7dd2bbb
commit 9c209c0cdd
3 changed files with 12 additions and 3 deletions

1
TODO
View File

@ -25,7 +25,6 @@ IPC, like dwb -x
Mode handling? Mode handling?
Bookmarks Bookmarks
sensible crash handling (exceptions, segfaults [windows?]) sensible crash handling (exceptions, segfaults [windows?])
more configuration (hide completion)
Minor features/bugs Minor features/bugs
=================== ===================

View File

@ -8,6 +8,9 @@ config = None
colordict = {} colordict = {}
default_config = { default_config = {
'general': {
'show_completion': 'true',
},
'keybind': { 'keybind': {
'o': 'open', 'o': 'open',
'O': 'tabopen', 'O': 'tabopen',

View File

@ -45,9 +45,13 @@ class CompletionView(QTreeView):
completion_models = {} completion_models = {}
append_cmd_text = pyqtSignal(str) append_cmd_text = pyqtSignal(str)
ignore_next = False ignore_next = False
enabled = True
completing = False
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent) super().__init__(parent)
self.enabled = config.config.getboolean('general', 'show_completion',
fallback=True)
self.completion_models[''] = None self.completion_models[''] = None
self.completion_models['command'] = CommandCompletionModel() self.completion_models['command'] = CommandCompletionModel()
self.model = CompletionFilterModel() self.model = CompletionFilterModel()
@ -94,13 +98,16 @@ class CompletionView(QTreeView):
# FIXME more sophisticated completions # FIXME more sophisticated completions
if ' ' in text or not text.startswith(':'): if ' ' in text or not text.startswith(':'):
self.hide() self.hide()
self.completing = False
return return
self.completing = True
self.setmodel('command') self.setmodel('command')
text = text.lstrip(':') text = text.lstrip(':')
self.model.pattern = text self.model.pattern = text
self.mark_all_items(text) self.mark_all_items(text)
self.show() if self.enabled:
self.show()
def first_item(self): def first_item(self):
cat = self.model.index(0, 0) cat = self.model.index(0, 0)
@ -133,7 +140,7 @@ class CompletionView(QTreeView):
return marks return marks
def tab_handler(self, shift): def tab_handler(self, shift):
if self.isHidden(): if not self.completing:
return return
idx = self._next_idx(shift) idx = self._next_idx(shift)
self.ignore_next = True self.ignore_next = True