private void AddKey(TermInfo.Database db, string extendedName, ConsoleKey key, bool shift, bool alt, bool control) { ReadOnlyMemory <char> keyFormat = db.GetExtendedString(extendedName).AsMemory(); if (!keyFormat.IsEmpty) { KeyFormatToConsoleKey[keyFormat] = new ConsoleKeyInfo('\0', key, shift, alt, control); } }
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); } }
public void TermInfoVerification(string termToTest, string expectedForeground, string expectedBackground, int colorValue) { TermInfo.Database db = TermInfo.DatabaseFactory.ReadDatabase(termToTest); if (db != null) { TerminalFormatStrings info = new(db); Assert.Equal(expectedForeground, TermInfo.ParameterizedStrings.Evaluate(info.Foreground, colorValue)); Assert.Equal(expectedBackground, TermInfo.ParameterizedStrings.Evaluate(info.Background, colorValue)); Assert.InRange(info.MaxColors, 1, int.MaxValue); } }
private void AddPrefixKey(TermInfo.Database db, string extendedNamePrefix, ConsoleKey key) { if (db.HasExtendedStrings) // avoid string concatenation in case when there are no Extended Strings (typical scenario) { AddKey(db, extendedNamePrefix + "3", key, shift: false, alt: true, control: false); AddKey(db, extendedNamePrefix + "4", key, shift: true, alt: true, control: false); AddKey(db, extendedNamePrefix + "5", key, shift: false, alt: false, control: true); AddKey(db, extendedNamePrefix + "6", key, shift: true, alt: false, control: true); AddKey(db, extendedNamePrefix + "7", key, shift: false, alt: false, control: true); } }
[PlatformSpecific(TestPlatforms.AnyUnix)] // Tests TermInfo public void TryingToLoadTermThatDoesNotExistDoesNotThrow() { const string NonexistentTerm = "foobar____"; TermInfo.Database db = TermInfo.DatabaseFactory.ReadDatabase(NonexistentTerm); TerminalFormatStrings info = new(db); Assert.Null(db); Assert.Null(info.Background); Assert.Null(info.Foreground); Assert.Equal(0, info.MaxColors); Assert.Null(info.Reset); }
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) { AddKey(db, keyId, key, shift: false, alt: false, control: false); }