System.TermInfo.Database.GetString C# (CSharp) Méthode

GetString() public méthode

Gets a string from the strings section by the string's well-known index.
public GetString ( WellKnownStrings stringTableIndex ) : string
stringTableIndex WellKnownStrings The index of the string to find.
Résultat string
            public string GetString(WellKnownStrings stringTableIndex)
            {
                int index = (int)stringTableIndex;
                Debug.Assert(index >= 0);

                if (index >= _stringSectionNumOffsets)
                {
                    // Some terminfo files may not contain enough entries to actually 
                    // have the requested one.
                    return null;
                }

                int tableIndex = ReadInt16(_data, StringOffsetsOffset + (index * 2));
                if (tableIndex == -1)
                {
                    // Some terminfo files may have enough entries, but may not actually
                    // have it filled in for this particular string.
                    return null;
                }

                return ReadString(_data, StringsTableOffset + tableIndex);
            }

Usage Example

Exemple #1
0
            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";
                }

                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);
                }
            }
All Usage Examples Of System.TermInfo.Database::GetString