cmdhistory: Make History more modular.

This commit is contained in:
Florian Bruhin 2014-08-07 14:39:42 +02:00
parent dffed93fee
commit 7063f2445c
2 changed files with 10 additions and 6 deletions

View File

@ -19,10 +19,10 @@
"""Command history for the status bar.""" """Command history for the status bar."""
from PyQt5.QtCore import pyqtSlot, QCoreApplication from PyQt5.QtCore import pyqtSlot
from qutebrowser.utils.usertypes import NeighborList from qutebrowser.utils.usertypes import NeighborList
from qutebrowser.utils.log import statusbar as logger from qutebrowser.utils.log import misc as logger
class HistoryEmptyError(Exception): class HistoryEmptyError(Exception):
@ -49,9 +49,13 @@ class History:
_tmphist: Temporary history for history browsing (as NeighborList) _tmphist: Temporary history for history browsing (as NeighborList)
""" """
def __init__(self): def __init__(self, history=None):
"""Constructor.
Args:
history: The initial history to set.
"""
self._tmphist = None self._tmphist = None
history = QCoreApplication.instance().cmd_history.data
if history is None: if history is None:
self._history = [] self._history = []
else: else:

View File

@ -20,7 +20,7 @@
"""The commandline in the statusbar.""" """The commandline in the statusbar."""
from PyQt5.QtCore import pyqtSignal, pyqtSlot from PyQt5.QtCore import pyqtSignal, pyqtSlot
from PyQt5.QtWidgets import QSizePolicy from PyQt5.QtWidgets import QSizePolicy, QApplication
from PyQt5.QtGui import QValidator from PyQt5.QtGui import QValidator
import qutebrowser.keyinput.modeman as modeman import qutebrowser.keyinput.modeman as modeman
@ -81,7 +81,7 @@ class Command(MinimalLineEdit):
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent) super().__init__(parent)
self.cursor_part = 0 self.cursor_part = 0
self.history = History() self.history = History(QApplication.instance().cmd_history.data)
self._validator = _CommandValidator(self) self._validator = _CommandValidator(self)
self._empty_item_idx = None self._empty_item_idx = None
self.setValidator(self._validator) self.setValidator(self._validator)