cmdhistory: Make History more modular.
This commit is contained in:
parent
dffed93fee
commit
7063f2445c
@ -19,10 +19,10 @@
|
||||
|
||||
"""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.log import statusbar as logger
|
||||
from qutebrowser.utils.log import misc as logger
|
||||
|
||||
|
||||
class HistoryEmptyError(Exception):
|
||||
@ -49,9 +49,13 @@ class History:
|
||||
_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
|
||||
history = QCoreApplication.instance().cmd_history.data
|
||||
if history is None:
|
||||
self._history = []
|
||||
else:
|
||||
|
@ -20,7 +20,7 @@
|
||||
"""The commandline in the statusbar."""
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtWidgets import QSizePolicy
|
||||
from PyQt5.QtWidgets import QSizePolicy, QApplication
|
||||
from PyQt5.QtGui import QValidator
|
||||
|
||||
import qutebrowser.keyinput.modeman as modeman
|
||||
@ -81,7 +81,7 @@ class Command(MinimalLineEdit):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.cursor_part = 0
|
||||
self.history = History()
|
||||
self.history = History(QApplication.instance().cmd_history.data)
|
||||
self._validator = _CommandValidator(self)
|
||||
self._empty_item_idx = None
|
||||
self.setValidator(self._validator)
|
||||
|
Loading…
Reference in New Issue
Block a user