# 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
                pass
            elif TERMINAL_MATCH_TAGS[tag] == "http":
                value = f"http://{value}"
            elif TERMINAL_MATCH_TAGS[tag] == "https":
                value = f"https://{value}"
            elif TERMINAL_MATCH_TAGS[tag] == "ftp":
                value = f"ftp://{value}"
            elif TERMINAL_MATCH_TAGS[tag] == "email":
                value = f"mailto:{value}"

        if value:
            return value

    def get_link_under_cursor(self):
        return self.found_link

    def browse_link_under_cursor(self):
        # TODO move the call to xdg-open to guake.utils
        if not self.found_link:
            return
        log.debug("Opening link: %s", self.found_link)
        cmd = ["xdg-open", self.found_link]
        with subprocess.Popen(cmd, shell=False):
            pass

    def set_font(self, font):
        self.font = font
        self.set_font_scale_index(0)

    def set_font_scale_index(self, scale_index):

# 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

                pass
            elif TERMINAL_MATCH_TAGS[tag] == "http":
                value = f"http://{value}"
            elif TERMINAL_MATCH_TAGS[tag] == "https":
                value = f"https://{value}"
            elif TERMINAL_MATCH_TAGS[tag] == "ftp":
                value = f"ftp://{value}"
            elif TERMINAL_MATCH_TAGS[tag] == "email":
                value = f"mailto:{value}"

        if value:
            return value

    def get_link_under_cursor(self):
        return self.found_link

    def browse_link_under_cursor(self):
        # TODO move the call to xdg-open to guake.utils
        if not self.found_link:
            return
        log.debug("Opening link: %s", self.found_link)
        cmd = ["xdg-open", self.found_link]
        with subprocess.Popen(cmd, shell=False):
            pass

    def set_font(self, font):
        self.font = font
        self.set_font_scale_index(0)

    def set_font_scale_index(self, scale_index):

        self.font_scale_index = clamp(scale_index, -6, 12)