예제 #1
0
        public static bool Is_Valid_FloatingPoint(ReadOnlyMemory <char> input)
        {
            DataConsumer <char> Stream = new DataConsumer <char>(input, EOF);

            return(Is_Valid_FloatingPoint(Stream));
        }
예제 #2
0
        public static bool Try_Parse_FloatingPoint(DataConsumer <char> Stream, out double outValue)
        {/* Docs: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values */
            if (Stream is null)
            {
                throw new ArgumentNullException(nameof(Stream));
            }
            Contract.EndContractBlock();

            double value    = 1;
            double divisor  = 1;
            double exponent = 1;

            /* Skip ASCII whitespace */
            Stream.Consume_While(Is_Ascii_Whitespace);

            if (Stream.atEnd)
            {
                outValue = double.NaN;
                return(false);
            }

            switch (Stream.Next)
            {
            case CHAR_HYPHEN_MINUS:
            {
                value = divisor = -1;
                Stream.Consume();
            }
            break;

            case CHAR_PLUS_SIGN:
            {
                Stream.Consume();
            }
            break;
            }

            if (Stream.atEnd)
            {
                outValue = double.NaN;
                return(false);
            }

            /* 9) If the character indicated by position is a U+002E FULL STOP (.),
             * and that is not the last character in input,
             * and the character after the character indicated by position is an ASCII digit,
             * then set value to zero and jump to the step labeled fraction. */
            if (Stream.Remaining > 1 && Stream.Next == CHAR_FULL_STOP && Is_Ascii_Digit(Stream.NextNext))
            {
                value = 0;
            }
            else if (!Is_Ascii_Digit(Stream.Next))
            {
                outValue = double.NaN;
                return(false);
            }
            else
            {
                /* 11) Collect a sequence of code points that are ASCII digits from input given position, and interpret the resulting sequence as a base-ten integer. Multiply value by that integer. */
                Stream.Consume_While(Is_Ascii_Digit, out ReadOnlySpan <char> outDigits);
                value *= ParsingCommon.Digits_To_Base10(outDigits);
            }

            /* 12) If position is past the end of input, jump to the step labeled conversion. */
            if (!Stream.atEnd)
            {
                /* 13) Fraction: If the character indicated by position is a U+002E FULL STOP (.), run these substeps: */
                if (Stream.Next == CHAR_FULL_STOP)
                {
                    Stream.Consume();
                    /* 2) If position is past the end of input, or if the character indicated by position is not an ASCII digit, U+0065 LATIN SMALL LETTER E (e), or U+0045 LATIN CAPITAL LETTER E (E), then jump to the step labeled conversion. */
                    if (!Stream.atEnd && (Is_Ascii_Digit(Stream.Next) || Stream.Next == CHAR_E_LOWER || Stream.Next == CHAR_E_UPPER))
                    {
                        /* 3) If the character indicated by position is a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN CAPITAL LETTER E character (E), skip the remainder of these substeps. */
                        if (Is_Ascii_Digit(Stream.Next))
                        {
                            while (Is_Ascii_Digit(Stream.Next))
                            {
                                /* 4) Fraction loop: Multiply divisor by ten. */
                                divisor *= 10;
                                /* 5) Add the value of the character indicated by position, interpreted as a base-ten digit (0..9) and divided by divisor, to value. */
                                double n = Ascii_Digit_To_Value(Stream.Next) / divisor;
                                value += n;
                                /* 6) Advance position to the next character. */
                                Stream.Consume();
                                /* 7) If position is past the end of input, then jump to the step labeled conversion. */

                                if (Stream.atEnd)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }

                /* 14) If the character indicated by position is U+0065 (e) or a U+0045 (E), then: */
                if (Stream.Next == CHAR_E_LOWER || Stream.Next == CHAR_E_UPPER)
                {
                    Stream.Consume();
                    /* 2) If position is past the end of input, then jump to the step labeled conversion. */
                    /* 3) If the character indicated by position is a U+002D HYPHEN-MINUS character (-): */
                    if (Stream.Next == CHAR_HYPHEN_MINUS)
                    {
                        exponent = -1;
                        Stream.Consume();
                    }
                    else if (Stream.Next == CHAR_PLUS_SIGN)
                    {
                        Stream.Consume();
                    }

                    /* 4) If the character indicated by position is not an ASCII digit, then jump to the step labeled conversion. */
                    if (Is_Ascii_Digit(Stream.Next))
                    {
                        /* 5) Collect a sequence of code points that are ASCII digits from input given position, and interpret the resulting sequence as a base-ten integer. Multiply exponent by that integer. */
                        Stream.Consume_While(Is_Ascii_Digit, out ReadOnlySpan <char> outDigits);
                        exponent *= ParsingCommon.Digits_To_Base10(outDigits);
                        /* 6) Multiply value by ten raised to the exponentth power. */
                        value *= Math.Pow(10, exponent);
                    }
                }
            }

            /* 15) Conversion: Let S be the set of finite IEEE 754 double-precision floating-point values except −0, but with two special values added: 21024 and −21024. */

            /* 16) Let rounded-value be the number in S that is closest to value,
             * selecting the number with an even significand if there are two equally close values.
             * (The two special values 21024 and −21024 are considered to have even significands for this purpose.) */
            var roundedValue = Math.Round(value, MidpointRounding.ToEven);

            /* 17) If rounded-value is 21024 or −21024, return an error. */
            if ((roundedValue == double.MinValue) || (roundedValue == double.MaxValue))
            {
                outValue = double.NaN;
                return(false);
            }

            outValue = roundedValue;
            return(true);
        }
        public VirtualTerminalControl()
        {
            blinkDispatcher          = new DispatcherTimer();
            blinkDispatcher.Tick    += (sender, e) => InvalidateVisual();
            blinkDispatcher.Interval = TimeSpan.FromMilliseconds(GCD(BlinkShowMs, BlinkHideMs));
            //blinkDispatcher.Start();



            this.GetObservable(TerminalProperty)
            .ObserveOn(AvaloniaScheduler.Instance)
            .Subscribe(terminal =>
            {
                if (_terminalDisposables != null)
                {
                    _terminalDisposables.Dispose();
                    _terminalDisposables = null;
                    Consumer             = null;
                }

                Columns           = -1;
                Rows              = -1;
                InputBuffer       = "";
                TerminalIdleSince = DateTime.Now;
                _rawTextChanged   = false;
                _rawTextString    = "";
                _rawTextLength    = 0;
                _rawText          = new char[0];
                ViewTop           = 0;
                CharacterHeight   = -1;
                CharacterWidth    = -1;

                if (terminal != null)
                {
                    _terminalDisposables = new CompositeDisposable();
                    Consumer             = new DataConsumer(terminal);

                    _terminalDisposables.Add(
                        Observable.FromEventPattern <SendDataEventArgs>(terminal, nameof(terminal.SendData)).Subscribe(e => OnSendData(e.EventArgs)));

                    _terminalDisposables.Add(
                        Observable.FromEventPattern <TextEventArgs>(terminal, nameof(terminal.WindowTitleChanged))
                        .ObserveOn(AvaloniaScheduler.Instance)
                        .Subscribe(e => WindowTitle = e.EventArgs.Text));

                    terminal.StoreRawText = true;
                }
            });

            this.GetObservable(ConnectionProperty)
            .ObserveOn(AvaloniaScheduler.Instance)
            .Subscribe(connection =>
            {
                if (_disposables != null)
                {
                    _disposables.Dispose();
                    _disposables = null;
                }

                _disposables = new CompositeDisposable();

                if (connection != null)
                {
                    _disposables.Add(Observable.FromEventPattern <DataReceivedEventArgs>(connection, nameof(connection.DataReceived))
                                     .ObserveOn(AvaloniaScheduler.Instance)
                                     .Subscribe(args => OnDataReceived(args.EventArgs)));

                    connection.SetTerminalWindowSize(Columns, Rows, 800, 600);
                }
            });
        }
예제 #4
0
        public static bool Is_Valid_Integer(ReadOnlyMemory <char> input)
        {
            DataConsumer <char> Stream = new DataConsumer <char>(input, EOF);

            return(Is_Valid_Integer(Stream));
        }
예제 #5
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="label"></param>
        public FormDiffEquation(IObjectLabel label)
            : this()
        {
            PanelFormula.SetResize(panelFormula);
            this.label = label;
            solver     = label.Object as DifferentialEquationSolver;
            consumer   = solver;
            // ArrayList comments = solver.Comments;
            this.SetComments(solver.Comments);
            numericUpDownDerivationOrder.Value = solver.DerivationOrder;
            first = false;
            string        var = "";
            List <string> vv  = new List <string>();

            foreach (char c in solver.Keys)
            {
                var += c;
                vv.Add(c + "");
            }
            for (int i = 0; i < Variables.Length; i++)
            {
                char v = Variables[i];
                if (var.IndexOf(v) > -1)
                {
                    checkedListBoxV.Items.Add("" + v, CheckState.Checked);
                }
                else
                {
                    checkedListBoxV.Items.Add("" + v, CheckState.Unchecked);
                }
            }
            userControlCharIntDictionary.Minimum = 1;
            userControlCharIntDictionary.Keys    = vv;
            Dictionary <string, int> dder = new Dictionary <string, int>();
            Dictionary <string, int> dor  = solver.DerivationOrders;

            foreach (string key in dor.Keys)
            {
                dder[key] = dor[key] + 1;
            }
            userControlCharIntDictionary.Dictionary = dder;
            string         str = solver.AllParameters;
            IList <string> l   = solver.AliasNames;

            foreach (char c in str)
            {
                string s = c + "";
                if (l.Contains(s))
                {
                    checkedListBoxP.Items.Add(s, CheckState.Checked);
                }
                else
                {
                    checkedListBoxP.Items.Add(s, CheckState.Unchecked);
                }
            }
            int top = 0;

            foreach (char c in solver.Keys)
            {
                PanelFormula p = new PanelFormula("" + c, this, panelFormula.Width, 200, Variables, true, null, null);
                p.Left    = 0;
                p.Top     = top;
                top      += p.Height;
                p.Formula = solver[c];
                panelFormula.Controls.Add(p);
            }
            UpdateFormUI();
            setFormulas();
            fillTable();
            createAndFillAliasComboBox();
        }
예제 #6
0
 private void Push(DataConsumer d, string s)
 {
     d.Push(Encoding.UTF8.GetBytes(s));
 }
예제 #7
0
 private void PushToTerminal(DataConsumer t, string s)
 {
     t.Push(s.Select(x => (byte)x).ToArray());
 }
예제 #8
0
 private void DarkBackgroundPage(VirtualTerminalController t, DataConsumer d)
 {
     Push(d, "\u001b[1;24r");
     Push(d, "\u001b[2J");
     Push(d, "\u001b[1;20H");
     Push(d, "Graphic rendition test pattern:");
     Push(d, "\u001b[4;1H");
     Push(d, "\u001b[0m");
     Push(d, "vanilla");
     Push(d, "\u001b[4;40H");
     Push(d, "\u001b[0;1m");
     Push(d, "bold");
     Push(d, "\u001b[6;6H");
     Push(d, "\u001b[;4m");
     Push(d, "underline");
     Push(d, "\u001b[6;45H");
     Push(d, "\u001b[;1m");
     Push(d, "\u001b[4m");
     Push(d, "bold underline");
     Push(d, "\u001b[8;1H");
     Push(d, "\u001b[0;5m");
     Push(d, "blink");
     Push(d, "\u001b[8;40H");
     Push(d, "\u001b[0;5;1m");
     Push(d, "bold blink");
     Push(d, "\u001b[10;6H");
     Push(d, "\u001b[0;4;5m");
     Push(d, "underline blink");
     Push(d, "\u001b[10;45H");
     Push(d, "\u001b[0;1;4;5m");
     Push(d, "bold underline blink");
     Push(d, "\u001b[12;1H");
     Push(d, "\u001b[1;4;5;0;7m");
     Push(d, "negative");
     Push(d, "\u001b[12;40H");
     Push(d, "\u001b[0;1;7m");
     Push(d, "bold negative");
     Push(d, "\u001b[14;6H");
     Push(d, "\u001b[0;4;7m");
     Push(d, "underline negative");
     Push(d, "\u001b[14;45H");
     Push(d, "\u001b[0;1;4;7m");
     Push(d, "bold underline negative");
     Push(d, "\u001b[16;1H");
     Push(d, "\u001b[1;4;;5;7m");
     Push(d, "blink negative");
     Push(d, "\u001b[16;40H");
     Push(d, "\u001b[0;1;5;7m");
     Push(d, "bold blink negative");
     Push(d, "\u001b[18;6H");
     Push(d, "\u001b[0;4;5;7m");
     Push(d, "underline blink negative");
     Push(d, "\u001b[18;45H");
     Push(d, "\u001b[0;1;4;5;7m");
     Push(d, "bold underline blink negative");
     Push(d, "\u001b[m");
     Push(d, "\u001b[?5l");
     Push(d, "\u001b[23;1H");
     Push(d, "\u001b[0K");
     Push(d, "Dark background.Push<RETURN>");
 }
예제 #9
0
        /// <summary>
        /// Resolves an elements IDL-exposed autofill value
        /// </summary>
        /// <param name="element"></param>
        /// <param name="outFieldName">The autofill field name specifies the specific kind of data expected in the field, e.g. "street-address" or "cc-exp".</param>
        /// <param name="outHint">The autofill hint set identifies what address or contact information type the user agent is to look at, e.g. "shipping fax" or "billing".</param>
        /// <param name="outScope">The autofill scope identifies the group of fields whose information concerns the same subject, and consists of the autofill hint set with, if applicable, the "section-*" prefix, e.g. "billing", "section-parent shipping", or "section-child shipping home".</param>
        public static void Resolve_Autofill(FormAssociatedElement element, out EAutofill outFieldName, out IReadOnlyList <string> outHint, out IReadOnlyList <string> outScope, out string outidlValue)
        {/* Docs: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-processing-model */
            AttributeValue  autocomplete = element.getAttribute(EAttributeName.Autocomplete);
            EAutofillMantle afMantle     = Get_Autofill_Mantle(element);

            if (autocomplete != null)
            {
                /* 2) Let tokens be the result of splitting the attribute's value on ASCII whitespace. */
                //var tokens = DOMCommon.Parse_Ordered_Set(autocomplete.Get_String().AsMemory());
                string acString  = StringCommon.Transform(autocomplete.AsString().AsMemory(), To_ASCII_Lower_Alpha);
                var    tokenList = new List <string>(DOMCommon.Parse_Ordered_Set(acString.AsMemory()).Select(o => o.ToString()));
                tokenList.Reverse();
                DataConsumer <string> Stream = new DataConsumer <string>(tokenList.ToArray(), null);

                /* 3) If tokens is empty, then jump to the step labeled default. */
                if (Stream.Length > 0)
                {
                    /* 4) Let index be the index of the last token in tokens. */
                    //int index = tokens.Count - 1;

                    /* 5) If the indexth token in tokens is not an ASCII case-insensitive match for one of the tokens given in the first column of the following table,
                     * or if the number of tokens in tokens is greater than the maximum number given in the cell in the second column of that token's row, then jump to the step labeled default.
                     * Otherwise, let field be the string given in the cell of the first column of the matching row, and let category be the value of the cell in the third column of that same row. */

                    //var key = tokens[index];
                    string            key        = Stream.Next;
                    EAutofill         afValue    = Lookup.Enum <EAutofill>(key);
                    EnumData          afData     = Lookup.Data(afValue);
                    int               maxTokens  = (int)afData[0];
                    EAutofillCategory afCategory = (EAutofillCategory)afData[1];

                    /* ...if the number of tokens in tokens is greater than the maximum number given in the cell in the second column of that token's row, then jump to the step labeled default. */
                    if (Stream.Length <= maxTokens)
                    {
                        var field    = afValue;
                        var category = afCategory;

                        /* 6) If category is Off or Automatic but the element's autocomplete attribute is wearing the autofill anchor mantle, then jump to the step labeled default. */
                        if ((category == EAutofillCategory.Off || category == EAutofillCategory.Automatic) && afMantle == EAutofillMantle.Anchor)
                        {/* "Jump" to default */
                        }
                        else
                        {
                            /* 7) If category is Off, let the element's autofill field name be the string "off", let its autofill hint set be empty, and let its IDL-exposed autofill value be the string "off". Then, return. */
                            if (category == EAutofillCategory.Off)
                            {
                                outFieldName = EAutofill.Off;
                                outHint      = Array.Empty <string>();
                                outScope     = Array.Empty <string>();
                                outidlValue  = "off";
                                return;
                            }

                            /* 8) If category is Automatic, let the element's autofill field name be the string "on", let its autofill hint set be empty, and let its IDL-exposed autofill value be the string "on". Then, return. */
                            if (category == EAutofillCategory.Automatic)
                            {
                                outFieldName = EAutofill.On;
                                outHint      = Array.Empty <string>();
                                outScope     = Array.Empty <string>();
                                outidlValue  = "on";
                                return;
                            }

                            /* 9) Let scope tokens be an empty list. */
                            LinkedList <string> scopeTokens = new LinkedList <string>();
                            /* 10) Let hint tokens be an empty set. */
                            LinkedList <string> hintTokens = new LinkedList <string>();
                            /* 11) Let IDL value have the same value as field. */
                            string idlValue = Lookup.Keyword(field);

                            /* 12) If the indexth token in tokens is the first entry, then skip to the step labeled done. */
                            //if (index == 0)
                            if (Stream.Remaining > 1)
                            {
                                /* 13) Decrement index by one. */
                                //index--;
                                Stream.Consume();
                                /* 14) If category is Contact and the indexth token in tokens is an ASCII case-insensitive match for one of the strings in the following list, then run the substeps that follow: */
                                if (category == EAutofillCategory.Contact)
                                {
                                    if (Lookup.TryEnum(Stream.Next, out EAutofillContact hint))
                                    {
                                        /* 1) Let contact be the matching string from the list above. */
                                        string contact = Stream.Next;
                                        /* 2) Insert contact at the start of scope tokens. */
                                        scopeTokens.AddFirst(contact);
                                        /* 3) Add contact to hint tokens. */
                                        hintTokens.AddLast(contact);
                                        /* 4) Let IDL value be the concatenation of contact, a U+0020 SPACE character, and the previous value of IDL value (which at this point will always be field). */
                                        idlValue = string.Concat(Stream.Next, CHAR_SPACE, idlValue);
                                        /* 5) If the indexth entry in tokens is the first entry, then skip to the step labeled done. */
                                        if (Stream.Remaining > 1)
                                        {
                                            /* 6) Decrement index by one. */
                                            //index--;
                                            Stream.Consume();
                                        }
                                    }
                                }
                                /* 15) If the indexth token in tokens is an ASCII case-insensitive match for one of the strings in the following list, then run the substeps that follow: */
                                if (Lookup.Is_Declared <EAutofillMode>(Stream.Next))
                                {
                                    /* 1) Let mode be the matching string from the list above. */
                                    var mode = Stream.Next;
                                    /* 2) Insert mode at the start of scope tokens. */
                                    scopeTokens.AddFirst(mode);
                                    /* 3) Add mode to hint tokens. */
                                    hintTokens.AddLast(mode);
                                    /* 4) Let IDL value be the concatenation of mode, a U+0020 SPACE character, and the previous value of IDL value (which at this point will either be field or the concatenation of contact, a space, and field). */
                                    idlValue = string.Concat(Stream.Next, CHAR_SPACE, idlValue);
                                    /* 5) If the indexth entry in tokens is the first entry, then skip to the step labeled done. */
                                    if (Stream.Remaining > 1)
                                    {
                                        /* 6) Decrement index by one. */
                                        //index--;
                                        Stream.Consume();
                                    }
                                }
                            }

                            /* 16) If the indexth entry in tokens is not the first entry, then jump to the step labeled default. */
                            if (Stream.Remaining == 1)
                            {
                                /* 17) If the first eight characters of the indexth token in tokens are not an ASCII case-insensitive match for the string "section-", then jump to the step labeled default. */
                                if (Stream.Next.StartsWith("section-"))
                                {
                                    /* 18) Let section be the indexth token in tokens, converted to ASCII lowercase. */
                                    string section = Stream.Next;/* Already in ascii lowercase */
                                    /* 19) Insert section at the start of scope tokens. */
                                    scopeTokens.AddFirst(section);
                                    /* 20) Let IDL value be the concatenation of section, a U+0020 SPACE character, and the previous value of IDL value. */
                                    idlValue = string.Concat(Stream.Next, CHAR_SPACE, idlValue);
                                }


                                /* 21) Done: Let the element's autofill hint set be hint tokens. */
                                outHint = hintTokens.ToArray();

                                /* 22) Let the element's autofill scope be scope tokens. */
                                outScope = scopeTokens.ToArray();

                                /* 23) Let the element's autofill field name be field. */
                                outFieldName = field;

                                /* 24) Let the element's IDL-exposed autofill value be IDL value. */
                                outidlValue = idlValue;

                                /* 25) Return. */
                                return;
                            }
                        }
                    }
                }
            }

            /* 26) Default: Let the element's IDL-exposed autofill value be the empty string, and its autofill hint set and autofill scope be empty. */
            outidlValue = string.Empty;
            outHint     = Array.Empty <string>();
            outScope    = Array.Empty <string>();

            /* 27) If the element's autocomplete attribute is wearing the autofill anchor mantle, then let the element's autofill field name be the empty string and return. */
            if (afMantle == EAutofillMantle.Anchor)
            {
                outFieldName = EAutofill.EMPTY;
                return;
            }

            /* 28) Let form be the element's form owner, if any, or null otherwise. */
            var form = element.form;

            /* 29) If form is not null and form's autocomplete attribute is in the off state, then let the element's autofill field name be "off".
             * Otherwise, let the element's autofill field name be "on". */

            outFieldName = (form != null && autocomplete != null && autocomplete.AsEnum <EAutoComplete>() == EAutoComplete.Off) ? EAutofill.Off : EAutofill.On;
        }
예제 #10
0
        public void TextVt52Identify()
        {
            var t = new VirtualTerminalController();

            t.Debugging = true;
            var d = new DataConsumer(t);

            t.ResizeView(80, 25);

            string toSend = "";

            t.SendData += (sender, args) =>
            {
                toSend = Encoding.ASCII.GetString(args.Data);
            };

            // vt52home();   /* Cursor home     */
            // vt52ed();     /* Erase to end of screen  */
            // println("Test of terminal response to IDENTIFY command");
            Push(d, "".SetVt52Mode().Vt52Home().Vt52ed().T("Test of terminal response to IDENTIFY command\r\n"));

            /*
             * According to J.Altman, DECID isn't recognized by VT5xx terminals.  Real
             * DEC terminals through VT420 do, though it isn't recommended.  VT420's
             * emulation of VT52 does not recognize DA -- so we use DECID in this case.
             */
            // set_tty_raw(TRUE);
            // decid();      /* Identify     */
            // response = get_reply();
            // println("");
            Push(d, "".DECID().T("\r\n"));
            var response = toSend;

            // restore_level(&save);
            // restore_ttymodes();
            // padding(10);  /* some terminals miss part of the 'chrprint()' otherwise */
            Push(d, "".DECSCL(64, 0));

            // printf("Response was");
            // chrprint(response);
            Push(d, "Response was ".ChrPrint(response));


            // for (i = 0; resptable[i].rcode[0] != '\0'; i++)
            // {
            //     if (!strcmp(response, resptable[i].rcode))
            //     {
            //         show_result("%s", resptable[i].rmsg);
            //         break;
            //     }
            // }
            var found = ResponseTable.TryGetValue(response, out string responseText);

            Assert.True(found);

            Push(d, responseText);

            // println("");
            // println("");
            Push(d, "\r\n\r\n");

            // /*
            //  * Verify whether returning to ANSI mode restores the previous operating
            //  * level.  If it was a VT220, we can check this by seeing if 8-bit controls
            //  * work; if a VT420 we can check the value of DECSCL.  A real VT420 goes to
            //  * VT100 mode.
            //  */
            // if (terminal_id() >= 200)
            // {
            //     int row = 8;
            //     set_level(0);   /* Reset ANSI (VT100) mode, Set VT52 mode  */
            var row = 8;

            Push(d, "".SetVt52Mode());

            //     println("Verify operating level after restoring ANSI mode");
            //     esc("<");   /* Enter ANSI mode (VT100 mode) */
            Push(d, "".EnterANSIMode());

            //     set_tty_raw(TRUE);
            //     if (save.cur_level >= 3)
            //     {  /* VT340 implements DECRQSS */
            //         vt_move(row, 1);
            Push(d, "".CUP(row, 1));

            //         row = testing("DECSCL", row);
            //         println("You should have to press return to continue:");
            //         println("");
            //         decrqss("\"p");
            //         response = get_reply();
            toSend = "";
            Push(d, "Testing DECSL. A real VT420 will not recognize DECSL at this point\n".DECRQSS("\"p"));
            row++;

            Thread.Sleep(5);
            Assert.Empty(toSend);

            //         vt_move(++row, 10);
            //         printf("Response was");
            //         chrprint(response);
            //         if (isreturn(response))
            //         {
            //             show_result(SHOW_SUCCESS);
            //         }
            //         else
            //         {
            //             if (parse_decrqss(response, "\"p") > 0)
            //                 printf("DECSCL recognized --");
            //             show_result(SHOW_FAILURE);
            //         }
            //         println("");
            //         row++;
            //     }
            //
            //     if (save.cur_level >= 2)
            //     {
            //         vt_move(++row, 1);
            //         row = testing("S8C1T", row);
            //         s8c1t(1);
            //         cup(1, 1);
            //         dsr(6);
            //         response = instr();
            //         vt_move(row, 10);
            //         printf("Response to CUP(1,1)/DSR(6)");
            //         chrprint(response);
            //         if ((temp = skip_prefix(csi_input(), response)) != 0)
            //         {
            //             if (!strcmp("1;1R", temp))
            //             {
            //                 printf("S8C1T recognized --");
            //                 show_result(SHOW_FAILURE);
            //             }
            //             else
            //             {
            //                 printf("unknown response --");
            //                 show_result(SHOW_FAILURE);
            //             }
            //         }
            //         else
            //         {
            //             input_8bits = FALSE;  /* we expect this anyway */
            //             if ((temp = skip_prefix(csi_input(), response)) != 0
            //                 && !strcmp("1;1R", temp))
            //             {
            //                 show_result(SHOW_SUCCESS);
            //             }
            //             else
            //             {
            //                 printf("unknown response --");
            //                 show_result(SHOW_FAILURE);
            //             }
            //         }
            //     }
            //     restore_level(&save);
            //     restore_ttymodes();
            //     println("");
            //     println("");
            // }
        }
예제 #11
0
        public void TestVt52()
        {
            string s;
            var    t = new VirtualTerminalController();

            t.Debugging = true;
            var d = new DataConsumer(t);

            t.ResizeView(80, 25);

            // set_level(0);        /* Reset ANSI (VT100) mode, Set VT52 mode  */
            Push(d, "".SetVt52Mode());

            // t52home();   /* Cursor home     */
            // vt52ed();     /* Erase to end of screen  */
            // vt52home();   /* Cursor home     */
            Push(d, "".Vt52Home().Vt52ed().Vt52Home());

            // for (i = 0; i <= max_lines - 1; i++)
            // {
            //     for (j = 0; j <= 9; j++)
            //         printf("%s", "FooBar ");
            //     println("Bletch");
            // }
            for (var i = 0; i <= MaxLines - 1; i++)
            {
                for (var j = 0; j <= 9; j++)
                {
                    Push(d, "FooBar ");
                }

                Push(d, "Bletch\r\n");
            }

            s = t.GetScreenText();
            Assert.Equal(ExpectTestVt52Fill, s);

            // vt52home();   /* Cursor home     */
            // vt52ed();     /* Erase to end of screen  */
            Push(d, "".Vt52Home().Vt52ed());

            // vt52cup(7, 47);
            // printf("nothing more.");
            Push(d, "".Vt52cup(7, 47).T("nothing more."));

            s = t.GetScreenText();
            Assert.Equal(ExpectTestVt52ClearCup, s);

            // for (i = 1; i <= 10; i++)
            //     printf("THIS SHOULD GO AWAY! ");
            for (var i = 1; i <= 10; i++)
            {
                Push(d, "THIS SHOULD GO AWAY! ");
            }

            // for (i = 1; i <= 5; i++)
            // {
            //     vt52cup(1, 1);
            //     printf("%s", "Back scroll (this should go away)");
            //     vt52ri();   /* Reverse LineFeed (with backscroll!)  */
            // }
            for (var i = 1; i <= 5; i++)
            {
                Push(d, "".Vt52cup(1, 1).T("Back scroll (this should go away)").Vt52ri());
            }

            s = t.GetScreenText();
            Assert.Equal(ExpectTestVt52Backscroll, s);

            // vt52cup(12, 60);
            // vt52ed();     /* Erase to end of screen  */
            Push(d, "".Vt52cup(12, 60).Vt52ed());

            // for (i = 2; i <= 6; i++)
            // {
            //     vt52cup(i, 1);
            //     vt52el();   /* Erase to end of line */
            // }
            for (var i = 2; i <= 6; i++)
            {
                Push(d, "".Vt52cup(i, 1).Vt52el());
            }

            s = t.GetScreenText();
            Assert.Equal(ExpectTestVt52EraseToEnd, s);

            // for (i = 2; i <= max_lines - 1; i++)
            // {
            //     vt52cup(i, 70);
            //     printf("%s", "**Foobar");
            // }
            for (var i = 2; i <= MaxLines - 1; i++)
            {
                Push(d, "".Vt52cup(i, 70).T("**Foobar"));
            }

            // vt52cup(max_lines - 1, 10);
            Push(d, "".Vt52cup(MaxLines - 1, 10));

            // for (i = max_lines - 1; i >= 2; i--)
            // {
            //     printf("%s", "*");
            //     printf("%c", 8);  /* BS */
            //     vt52ri();   /* Reverse LineFeed (LineStarve)        */
            // }
            for (var i = MaxLines - 1; i >= 2; i--)
            {
                Push(d, "*\b".Vt52ri());
            }

            // vt52cup(1, 70);
            Push(d, "".Vt52cup(1, 70));

            // for (i = 70; i >= 10; i--)
            // {
            //     printf("%s", "*");
            //     vt52cub1();
            //     vt52cub1(); /* Cursor Left */
            // }
            for (var i = 70; i >= 10; i--)
            {
                Push(d, "*".Vt52cub1().Vt52cub1());
            }

            // vt52cup(max_lines, 10);
            Push(d, "".Vt52cup(MaxLines, 10));

            // for (i = 10; i <= 70; i++)
            // {
            //     printf("%s", "*");
            //     printf("%c", 8);  /* BS */
            //     vt52cuf1(); /* Cursor Right */
            // }
            for (var i = 10; i <= 70; i++)
            {
                Push(d, "*\b".Vt52cuf1());
            }

            // vt52cup(2, 11);
            Push(d, "".Vt52cup(2, 11));

            // for (i = 2; i <= max_lines - 1; i++)
            // {
            //     printf("%s", "!");
            //     printf("%c", 8);  /* BS */
            //     vt52cud1(); /* Cursor Down  */
            // }
            for (var i = 2; i <= MaxLines - 1; i++)
            {
                Push(d, "!\b".Vt52cud1());
            }

            // vt52cup(max_lines - 1, 69);
            Push(d, "".Vt52cup(MaxLines - 1, 69));

            // for (i = max_lines - 1; i >= 2; i--)
            // {
            //     printf("%s", "!");
            //     printf("%c", 8);  /* BS */
            //     vt52cuu1(); /* Cursor Up    */
            // }
            for (var i = MaxLines - 1; i >= 2; i--)
            {
                Push(d, "!\b".Vt52cuu1());
            }

            // for (i = 2; i <= max_lines - 1; i++)
            // {
            //     vt52cup(i, 71);
            //     vt52el();   /* Erase to end of line */
            // }
            for (var i = 2; i <= MaxLines - 1; i++)
            {
                Push(d, "".Vt52cup(i, 71).Vt52el());
            }

            // vt52cup(10, 16);
            // printf("%s", "The screen should be cleared, and have a centered");
            Push(d, "".Vt52cup(10, 16).T("The screen should be cleared, and have a centered"));

            // vt52cup(11, 16);
            // printf("%s", "rectangle of \"*\"s with \"!\"s on the inside to the");
            Push(d, "".Vt52cup(11, 16).T("rectangle of \"*\"s with \"!\"s on the inside to the"));

            // vt52cup(12, 16);
            // printf("%s", "left and right. Only this, and");
            Push(d, "".Vt52cup(12, 16).T("left and right. Only this, and"));

            // vt52cup(13, 16);
            Push(d, "".Vt52cup(13, 16));

            s = t.GetScreenText();
            Assert.Equal(ExpectTestVt52Final, s);
        }
예제 #12
0
 public PseudoClassSelectorNegationFunction(string Name, DataConsumer <CssToken> Stream) : base(Name)
 {
     Selector = SelectorParser.Consume_Single_Selector(Stream);
 }
예제 #13
0
 /// <summary>
 /// Consumes a list of complex selectors
 /// </summary>
 public static ComplexSelector Consume_Single_Selector(DataConsumer <CssToken> Stream)
 {
     return(Consume_Complex_Selector(Stream));
 }