# 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
                return True
        return False

    def _execute_quick_open(self, filepath, line_number):
        if not filepath:
            return
        cmdline = self.guake.settings.general.get_string("quick-open-command-line")
        if not line_number:
            line_number = ""
        else:
            line_number = str(line_number)
        logging.debug("Opening file %s at line %s", filepath, line_number)
        resolved_cmdline = cmdline % {"file_path": filepath, "line_number": line_number}
        logging.debug("Command line: %s", resolved_cmdline)
        quick_open_in_current_terminal = self.guake.settings.general.get_boolean(
            "quick-open-in-current-terminal"
        )
        if quick_open_in_current_terminal:
            logging.debug("Executing it in current tab")
            if resolved_cmdline[-1] != "\n":
                resolved_cmdline += "\n"
            self.feed_child(resolved_cmdline)
        else:
            resolved_cmdline += " &"
            logging.debug("Executing it independently")
            subprocess.call(resolved_cmdline, shell=True)

    def handleTerminalMatch(self, matched_string):
        value, tag = matched_string
        log.debug("found tag: %r, item: %r", tag, value)

# 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

                return True
        return False

    def _execute_quick_open(self, filepath, line_number):
        if not filepath:
            return
        cmdline = self.guake.settings.general.get_string("quick-open-command-line")
        if not line_number:
            line_number = ""
        else:
            line_number = str(line_number)
        logging.debug("Opening file %s at line %s", filepath, line_number)
        resolved_cmdline = cmdline % {"file_path": filepath, "line_number": line_number}
        logging.debug("Command line: %s", resolved_cmdline)
        quick_open_in_current_terminal = self.guake.settings.general.get_boolean(
            "quick-open-in-current-terminal"
        )
        if quick_open_in_current_terminal:
            logging.debug("Executing it in current tab")
            if resolved_cmdline[-1] != "\n":
                resolved_cmdline += "\n"
            self.feed_child(resolved_cmdline)
        else:
            resolved_cmdline += " &"
            logging.debug("Executing it independently")
            subprocess.call(resolved_cmdline, shell=True)

    def handleTerminalMatch(self, matched_string):
        value, tag = matched_string
        log.debug("found tag: %r, item: %r", tag, value)

        if tag in TERMINAL_MATCH_TAGS: