private static string GetTitle(TermInfo.Database db)
    {
        // Try to get the format string from tsl/fsl and use it if they're available
        string?tsl = db.GetString(TermInfo.WellKnownStrings.ToStatusLine);
        string?fsl = db.GetString(TermInfo.WellKnownStrings.FromStatusLine);

        if (tsl != null && fsl != null)
        {
            return(tsl + "%p1%s" + fsl);
        }

        string term = db.Term;

        if (term == null)
        {
            return(string.Empty);
        }

        if (term.StartsWith("xterm", StringComparison.Ordinal)) // normalize all xterms to enable easier matching
        {
            term = "xterm";
        }
        else if (term.StartsWith("screen", StringComparison.Ordinal)) // normalize all tmux configs
        {
            term = "screen";
        }

        switch (term)
        {
        case "aixterm":
        case "dtterm":
        case "linux":
        case "rxvt":
        case "xterm":
            return("\x1B]0;%p1%s\x07");

        case "cygwin":
            return("\x1B];%p1%s\x07");

        case "konsole":
            return("\x1B]30;%p1%s\x07");

        case "screen":
            return("\x1Bk%p1%s\x1B");

        default:
            return(string.Empty);
        }
    }
    private void AddKey(TermInfo.Database db, TermInfo.WellKnownStrings keyId, ConsoleKey key, bool shift, bool alt, bool control)
    {
        ReadOnlyMemory <char> keyFormat = db.GetString(keyId).AsMemory();

        if (!keyFormat.IsEmpty)
        {
            KeyFormatToConsoleKey[keyFormat] = new ConsoleKeyInfo(key == ConsoleKey.Enter ? '\r' : '\0', key, shift, alt, control);
        }
    }