# Path: vise/cmd.py
# class Close(Command):
# class PasswordManager(Command):
# class ClearSearchHighlighting(Command):
# class Restart(Command):
# class Clear(Command):
# class Quit(Command):
# class Save(Command):
# class Export(Command):
# class Print(Command):
# class Inspect(Command):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
# def init_commands():
#     def process_dict(d):
# def read_command_names():
# def run_command(window, text):
# 
# Path: vise/config.py
# def color(key, default):
#     ans = colors().get(key)
#     if not ans or ans == 'default':
#         ans = default
#     return ans
# 
# Path: vise/utils.py
# def make_highlighted_text(text, positions, emph='color:magenta', wrapper=None):
#     positions = sorted(set(positions) - {-1})
#     if positions:
#         parts = []
#         pos = 0
#         for p in positions:
#             ch = text[p]
#             parts.append(escape(text[pos:p]))
#             parts.append('<span style="%s">%s</span>' % (emph, escape(ch)))
#             pos = p + len(ch)
#         parts.append(escape(text[pos:]))
#         text = ''.join(parts)
#     if wrapper:
#         text = '<span style="%s">%s</span>' % (wrapper, text)
#     ans = QStaticText(text)
#     to = ans.textOption()
#     to.setWrapMode(QTextOption.WrapMode.NoWrap)
#     ans.setTextOption(to)
#     ans.setTextFormat(Qt.TextFormat.RichText)
#     return ans


import sys
from gettext import gettext as _
from queue import Queue
from threading import Thread
from PyQt6 import sip
from PyQt6.QtCore import (QAbstractListModel, QModelIndex, QPoint, QSize,
                          QStringListModel, Qt, pyqtSignal)
from PyQt6.QtGui import QColor, QKeySequence, QPainter, QClipboard
from PyQt6.QtWidgets import (QApplication, QFrame, QLineEdit, QListView, QStyle,
                             QStyledItemDelegate, QVBoxLayout, QWidget)
from .cmd import all_command_names, command_map
from .config import color
from .utils import make_highlighted_text
            from .commands.open import Open
    from .main import Application
    from vise.utils import parse_url
    from .main import Application
    from .places import places, QWebEnginePage

class Candidate:

    def __init__(self, text, positions):
        self.value = text + ' '
        self.text = make_highlighted_text(text, positions)

    def __repr__(self):
        return self.value

    def draw_item(self, painter, style, option):
        text_rect = style.subElementRect(QStyle.SubElement.SE_ItemViewItemText, option, None)
        y = text_rect.y()
        y += int(text_rect.height() - self.text.size().height()) // 2
        painter.drawStaticText(QPoint(int(text_rect.x()), y), self.text)

    def adjust_size_hint(self, option, sz):
        pass


class ListView(QListView):

    def __init__(self, parent=None):
        QListView.__init__(self, parent)
        self.setStyleSheet('''
        QListView { color: FG; background: BG }
        QListView::item:selected { border-radius: 8px; background: HB; color: HF }
        '''.replace(
            'HB', color('tab tree current background', 'palette(highlight)')).replace(
            'HF', color('tab tree current foreground', 'palette(highlight-text')).replace(

# Path: vise/cmd.py
# class Close(Command):
# class PasswordManager(Command):
# class ClearSearchHighlighting(Command):
# class Restart(Command):
# class Clear(Command):
# class Quit(Command):
# class Save(Command):
# class Export(Command):
# class Print(Command):
# class Inspect(Command):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
#     def __call__(self, cmd, rest, window):
# def init_commands():
#     def process_dict(d):
# def read_command_names():
# def run_command(window, text):
# 
# Path: vise/config.py
# def color(key, default):
#     ans = colors().get(key)
#     if not ans or ans == 'default':
#         ans = default
#     return ans
# 
# Path: vise/utils.py
# def make_highlighted_text(text, positions, emph='color:magenta', wrapper=None):
#     positions = sorted(set(positions) - {-1})
#     if positions:
#         parts = []
#         pos = 0
#         for p in positions:
#             ch = text[p]
#             parts.append(escape(text[pos:p]))
#             parts.append('<span style="%s">%s</span>' % (emph, escape(ch)))
#             pos = p + len(ch)
#         parts.append(escape(text[pos:]))
#         text = ''.join(parts)
#     if wrapper:
#         text = '<span style="%s">%s</span>' % (wrapper, text)
#     ans = QStaticText(text)
#     to = ans.textOption()
#     to.setWrapMode(QTextOption.WrapMode.NoWrap)
#     ans.setTextOption(to)
#     ans.setTextFormat(Qt.TextFormat.RichText)
#     return ans


# Path: vise/ask.py
import sys
from gettext import gettext as _
from queue import Queue
from threading import Thread
from PyQt6 import sip
from PyQt6.QtCore import (QAbstractListModel, QModelIndex, QPoint, QSize,
                          QStringListModel, Qt, pyqtSignal)
from PyQt6.QtGui import QColor, QKeySequence, QPainter, QClipboard
from PyQt6.QtWidgets import (QApplication, QFrame, QLineEdit, QListView, QStyle,
                             QStyledItemDelegate, QVBoxLayout, QWidget)
from .cmd import all_command_names, command_map
from .config import color
from .utils import make_highlighted_text
            from .commands.open import Open
    from .main import Application
    from vise.utils import parse_url
    from .main import Application
    from .places import places, QWebEnginePage


class Candidate:

    def __init__(self, text, positions):
        self.value = text + ' '
        self.text = make_highlighted_text(text, positions)

    def __repr__(self):
        return self.value

    def draw_item(self, painter, style, option):
        text_rect = style.subElementRect(QStyle.SubElement.SE_ItemViewItemText, option, None)
        y = text_rect.y()
        y += int(text_rect.height() - self.text.size().height()) // 2
        painter.drawStaticText(QPoint(int(text_rect.x()), y), self.text)

    def adjust_size_hint(self, option, sz):
        pass


class ListView(QListView):

    def __init__(self, parent=None):
        QListView.__init__(self, parent)
        self.setStyleSheet('''
        QListView { color: FG; background: BG }
        QListView::item:selected { border-radius: 8px; background: HB; color: HF }
        '''.replace(
            'HB', color('tab tree current background', 'palette(highlight)')).replace(
            'HF', color('tab tree current foreground', 'palette(highlight-text')).replace(

            'FG', color('tab tree foreground', 'palette(window-text)')).replace(