System.TermInfoReader.Get C# (CSharp) Method

Get() public method

public Get ( TermInfoBooleans boolean ) : bool
boolean TermInfoBooleans
return bool
		public bool Get (TermInfoBooleans boolean)
		{
			int x = (int) boolean;
			if (x < 0 || boolean >= TermInfoBooleans.Last || x >= boolSize)
				return false;

			int offset = booleansOffset;
			offset += (int) boolean;
			return (buffer [offset] != 0);
		}

Same methods

TermInfoReader::Get ( TermInfoNumbers number ) : int
TermInfoReader::Get ( TermInfoStrings tstr ) : string

Usage Example

示例#1
0
        public void Init()
        {
            if (inited)
            {
                return;
            }

            /* This should not happen any more, since it is checked for in Console */
            if (!ConsoleDriver.IsConsole)
            {
                throw new IOException("Not a tty.");
            }

            inited = true;

            ConsoleDriver.SetEcho(false);

            string endString = null;

            keypadXmit  = reader.Get(TermInfoStrings.KeypadXmit);
            keypadLocal = reader.Get(TermInfoStrings.KeypadLocal);
            if (keypadXmit != null)
            {
                WriteConsole(keypadXmit);                  // Needed to get the arrows working
                if (keypadLocal != null)
                {
                    endString += keypadLocal;
                }
            }

            origPair   = reader.Get(TermInfoStrings.OrigPair);
            origColors = reader.Get(TermInfoStrings.OrigColors);
            setfgcolor = MangleParameters(reader.Get(TermInfoStrings.SetAForeground));
            setbgcolor = MangleParameters(reader.Get(TermInfoStrings.SetABackground));
            // lighter fg colours are 90 -> 97 rather than 30 -> 37
            setlfgcolor = color16 ? setfgcolor.Replace("[3", "[9") : setfgcolor;
            // lighter bg colours are 100 -> 107 rather than 40 -> 47
            setlbgcolor = color16 ? setbgcolor.Replace("[4", "[10") : setbgcolor;
            string resetColors = (origColors == null) ? origPair : origColors;

            if (resetColors != null)
            {
                endString += resetColors;
            }

            if (!ConsoleDriver.TtySetup(endString, out verase, out vsusp, out intr))
            {
                throw new IOException("Error initializing terminal.");
            }

            stdin = new StreamReader(Console.OpenStandardInput(0), Console.InputEncoding);
            clear = reader.Get(TermInfoStrings.ClearScreen);
            bell  = reader.Get(TermInfoStrings.Bell);
            if (clear == null)
            {
                clear  = reader.Get(TermInfoStrings.CursorHome);
                clear += reader.Get(TermInfoStrings.ClrEos);
            }

            csrVisible = reader.Get(TermInfoStrings.CursorNormal);
            if (csrVisible == null)
            {
                csrVisible = reader.Get(TermInfoStrings.CursorVisible);
            }

            csrInvisible = reader.Get(TermInfoStrings.CursorInvisible);
            if (term == "cygwin" || term == "linux" || (term != null && term.StartsWith("xterm")) ||
                term == "rxvt" || term == "dtterm")
            {
                titleFormat = "\x1b]0;{0}\x7";                 // icon + window title
            }
            else if (term == "iris-ansi")
            {
                titleFormat = "\x1bP1.y{0}\x1b\\";                 // not tested
            }
            else if (term == "sun-cmd")
            {
                titleFormat = "\x1b]l{0}\x1b\\";                 // not tested
            }

            cursorAddress = reader.Get(TermInfoStrings.CursorAddress);
            if (cursorAddress != null)
            {
                string result = cursorAddress.Replace("%i", String.Empty);
                home_1_1      = (cursorAddress != result);
                cursorAddress = MangleParameters(result);
            }

            GetCursorPosition();
#if DEBUG
            logger.WriteLine("noGetPosition: {0} left: {1} top: {2}", noGetPosition, cursorLeft, cursorTop);
            logger.Flush();
#endif
            if (noGetPosition)
            {
                WriteConsole(clear);
                cursorLeft = 0;
                cursorTop  = 0;
            }
        }