diff --git a/qutebrowser/app.py b/qutebrowser/app.py index ed2736fe5..4c7410f81 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -13,6 +13,7 @@ def main(): kp.set_cmd_text.connect(mw.status.cmd.set_cmd) mw.status.cmd.got_cmd.connect(cp.parse) mw.status.cmd.got_cmd.connect(mw.setFocus) + cp.error.connect(mw.status.disp_error) cmds.cmd_dict['open'].signal.connect(mw.tabs.openurl) cmds.cmd_dict['tabopen'].signal.connect(mw.tabs.tabopen) cmds.cmd_dict['quit'].signal.connect(QApplication.closeAllWindows) # FIXME diff --git a/qutebrowser/commands.py b/qutebrowser/commands.py index e5c99b555..97de17d28 100644 --- a/qutebrowser/commands.py +++ b/qutebrowser/commands.py @@ -12,11 +12,17 @@ def register_all(): cls.bind() class CommandParser(QObject): + error = pyqtSignal(str) + def parse(self, text): parts = text.strip().split() cmd = parts[0] argv = parts[1:] - obj = cmd_dict[cmd] + try: + obj = cmd_dict[cmd] + except KeyError: + self.error.emit("{}: no such command".format(cmd)) + return try: obj.check(argv) except TypeError: diff --git a/qutebrowser/widgets/statusbar.py b/qutebrowser/widgets/statusbar.py index 5e8a2fd02..43486ca03 100644 --- a/qutebrowser/widgets/statusbar.py +++ b/qutebrowser/widgets/statusbar.py @@ -6,7 +6,7 @@ class StatusBar(QWidget): def __init__(self, parent): super().__init__(parent) self.setObjectName(self.__class__.__name__) - self.bg_color("black") + self.bg_color("white", "black") self.hbox = QHBoxLayout(self) self.hbox.setObjectName("status_hbox") self.hbox.setContentsMargins(0, 0, 0, 0) @@ -18,14 +18,18 @@ class StatusBar(QWidget): self.lbl = StatusText(self) self.hbox.addWidget(self.lbl) - def bg_color(self, color): + def bg_color(self, fg, bg): self.setStyleSheet(""" * { - background: """ + color + """; - color: white; + background: """ + bg + """; + color: """ + fg + """; font-family: Monospace; }""") + def disp_error(self, text): + self.bg_color('white', 'red') + self.lbl.setText('Error: {}'.format(text)) + class StatusText(QLabel): def __init__(self, parent): super().__init__(parent)