# Path: guake/common.py
# def clamp(value, lower, upper):
#     return max(min(value, upper), lower)
# 
# Path: guake/globals.py
# QUICK_OPEN_MATCHERS = [
#     (
#         "Python traceback",
#         r"^\s*File\s\".*\",\sline\s[0-9]+",
#         r"^\s*File\s\"(.*)\",\sline\s([0-9]+)",
#     ),
#     (
#         "Python pytest report",
#         r"^\s.*\:\:[a-zA-Z0-9\_]+\s",
#         r"^\s*(.*\:\:[a-zA-Z0-9\_]+)\s",
#     ),
#     (
#         "line starts by 'ERROR in Filename:line' pattern (GCC/make). File path should exists.",
#         r"\s.\S[^\s\s].[a-zA-Z0-9\/\_\-\.\ ]+\.?[a-zA-Z0-9]+\:[0-9]+",
#         r"\s.\S[^\s\s].(.*)\:([0-9]+)",
#     ),
#     (
#         "line starts by 'Filename:line' pattern (GCC/make). File path should exists.",
#         r"^\s*[a-zA-Z0-9\/\_\-\.\ ]+\.?[a-zA-Z0-9]+\:[0-9]+",
#         r"^\s*(.*)\:([0-9]+)",
#     ),
# ]
# 
# Path: guake/globals.py
# TERMINAL_MATCH_EXPRS = [
#     r"(news:|telnet:|nntp:|file:\/|https?:|ftps?:|webcal:)\/\/([-[:alnum:]]+"
#     r"(:[-[:alnum:],?;.:\/!%$^\*&~\"#']+)?\@)?[-[:alnum:]]+(\.[-[:alnum:]]+)*"
#     r"(:[0-9]{1,5})?(\/[-[:alnum:]_$.+!*(),;:@&=?\/~#%]*[^]'.>) \t\r\n,\\\"])?",
#     r"(www|ftp)[-[:alnum:]]*\.[-[:alnum:]]+(\.[-[:alnum:]]+)*(:[0-9]{1,5})?"
#     r"(\/[-[:alnum:]_$.+!*(),;:@&=?\/~#%]*[^]'.>) \t\r\n,\\\"])?",
#     r"(mailto:)?[-[:alnum:]][-[:alnum:].]*@[-[:alnum:]]+\.[-[:alnum:]]+(\\.[-[:alnum:]]+)*",
# ]
# 
# Path: guake/globals.py
# TERMINAL_MATCH_TAGS = ("schema", "http", "https", "email", "ftp")


import code
import logging
import os
import re
import shlex
import signal
import subprocess
import sys
import threading
import uuid
import gi
from enum import IntEnum
from pathlib import Path
from typing import Optional
from typing import Tuple
from urllib.parse import unquote
from urllib.parse import urlparse
from gi.repository import GLib
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import Pango
from gi.repository import Vte
from guake.common import clamp
from guake.globals import QUICK_OPEN_MATCHERS
from guake.globals import TERMINAL_MATCH_EXPRS
from guake.globals import TERMINAL_MATCH_TAGS
    from atexit import register as at_exit_call
    from ctypes import cdll
            try:
                self.set_bold_is_bright(self.guake.settings.styleFont.get_boolean("bold-is-bright"))
            except:  # pylint: disable=bare-except
                log.error("set_bold_is_bright not supported by your version of VTE")

        # TODO PORT is this still the case with the newer vte version?
        # -- Ubuntu has a patch to libvte which disables mouse scrolling in apps
        # -- like vim and less by default. If this is the case, enable it back.
        if hasattr(self, "set_alternate_screen_scroll"):
            self.set_alternate_screen_scroll(True)

        self.set_can_default(True)
        self.set_can_focus(True)

    def add_matches(self):
        """Adds all regular expressions declared in
        guake.globals.TERMINAL_MATCH_EXPRS to the terminal to make vte
        highlight text that matches them.
        """
        try:
            # NOTE: PCRE2_UTF | PCRE2_NO_UTF_CHECK | PCRE2_MULTILINE
            # reference from vte/bindings/vala/app.vala, flags = 0x40080400u
            # also ref: https://mail.gnome.org/archives/commits-list/2016-September/msg06218.html
            VTE_REGEX_FLAGS = 0x40080400
            for expr in TERMINAL_MATCH_EXPRS:
                tag = self.match_add_regex(
                    Vte.Regex.new_for_match(expr, len(expr), VTE_REGEX_FLAGS), 0
                )
                self.match_set_cursor_type(tag, Gdk.CursorType.HAND2)


# Path: guake/common.py
# def clamp(value, lower, upper):
#     return max(min(value, upper), lower)
# 
# Path: guake/globals.py
# QUICK_OPEN_MATCHERS = [
#     (
#         "Python traceback",
#         r"^\s*File\s\".*\",\sline\s[0-9]+",
#         r"^\s*File\s\"(.*)\",\sline\s([0-9]+)",
#     ),
#     (
#         "Python pytest report",
#         r"^\s.*\:\:[a-zA-Z0-9\_]+\s",
#         r"^\s*(.*\:\:[a-zA-Z0-9\_]+)\s",
#     ),
#     (
#         "line starts by 'ERROR in Filename:line' pattern (GCC/make). File path should exists.",
#         r"\s.\S[^\s\s].[a-zA-Z0-9\/\_\-\.\ ]+\.?[a-zA-Z0-9]+\:[0-9]+",
#         r"\s.\S[^\s\s].(.*)\:([0-9]+)",
#     ),
#     (
#         "line starts by 'Filename:line' pattern (GCC/make). File path should exists.",
#         r"^\s*[a-zA-Z0-9\/\_\-\.\ ]+\.?[a-zA-Z0-9]+\:[0-9]+",
#         r"^\s*(.*)\:([0-9]+)",
#     ),
# ]
# 
# Path: guake/globals.py
# TERMINAL_MATCH_EXPRS = [
#     r"(news:|telnet:|nntp:|file:\/|https?:|ftps?:|webcal:)\/\/([-[:alnum:]]+"
#     r"(:[-[:alnum:],?;.:\/!%$^\*&~\"#']+)?\@)?[-[:alnum:]]+(\.[-[:alnum:]]+)*"
#     r"(:[0-9]{1,5})?(\/[-[:alnum:]_$.+!*(),;:@&=?\/~#%]*[^]'.>) \t\r\n,\\\"])?",
#     r"(www|ftp)[-[:alnum:]]*\.[-[:alnum:]]+(\.[-[:alnum:]]+)*(:[0-9]{1,5})?"
#     r"(\/[-[:alnum:]_$.+!*(),;:@&=?\/~#%]*[^]'.>) \t\r\n,\\\"])?",
#     r"(mailto:)?[-[:alnum:]][-[:alnum:].]*@[-[:alnum:]]+\.[-[:alnum:]]+(\\.[-[:alnum:]]+)*",
# ]
# 
# Path: guake/globals.py
# TERMINAL_MATCH_TAGS = ("schema", "http", "https", "email", "ftp")


# Path: guake/terminal.py
import code
import logging
import os
import re
import shlex
import signal
import subprocess
import sys
import threading
import uuid
import gi
from enum import IntEnum
from pathlib import Path
from typing import Optional
from typing import Tuple
from urllib.parse import unquote
from urllib.parse import urlparse
from gi.repository import GLib
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import Pango
from gi.repository import Vte
from guake.common import clamp
from guake.globals import QUICK_OPEN_MATCHERS
from guake.globals import TERMINAL_MATCH_EXPRS
from guake.globals import TERMINAL_MATCH_TAGS
    from atexit import register as at_exit_call
    from ctypes import cdll

            try:
                self.set_bold_is_bright(self.guake.settings.styleFont.get_boolean("bold-is-bright"))
            except:  # pylint: disable=bare-except
                log.error("set_bold_is_bright not supported by your version of VTE")

        # TODO PORT is this still the case with the newer vte version?
        # -- Ubuntu has a patch to libvte which disables mouse scrolling in apps
        # -- like vim and less by default. If this is the case, enable it back.
        if hasattr(self, "set_alternate_screen_scroll"):
            self.set_alternate_screen_scroll(True)

        self.set_can_default(True)
        self.set_can_focus(True)

    def add_matches(self):
        """Adds all regular expressions declared in
        guake.globals.TERMINAL_MATCH_EXPRS to the terminal to make vte
        highlight text that matches them.
        """
        try:
            # NOTE: PCRE2_UTF | PCRE2_NO_UTF_CHECK | PCRE2_MULTILINE
            # reference from vte/bindings/vala/app.vala, flags = 0x40080400u
            # also ref: https://mail.gnome.org/archives/commits-list/2016-September/msg06218.html
            VTE_REGEX_FLAGS = 0x40080400
            for expr in TERMINAL_MATCH_EXPRS:
                tag = self.match_add_regex(
                    Vte.Regex.new_for_match(expr, len(expr), VTE_REGEX_FLAGS), 0
                )
                self.match_set_cursor_type(tag, Gdk.CursorType.HAND2)


            for _useless, match, _otheruseless in QUICK_OPEN_MATCHERS: