コード例 #1
0
 public irq(int i1, int i2, LineState s1, Atime t1)
 {
     cpunum = i1;
     line   = i2;
     state  = s1;
     time   = t1;
 }
コード例 #2
0
ファイル: HttpConnection.cs プロジェクト: mikem8361/runtime
        private string?ReadLine(byte[] buffer, int offset, int len, ref int used)
        {
            _currentLine ??= new StringBuilder(128);
            int last = offset + len;

            used = 0;
            for (int i = offset; i < last && _lineState != LineState.LF; i++)
            {
                used++;
                byte b = buffer[i];
                if (b == 13)
                {
                    _lineState = LineState.CR;
                }
                else if (b == 10)
                {
                    _lineState = LineState.LF;
                }
                else
                {
                    _currentLine.Append((char)b);
                }
            }

            string?result = null;

            if (_lineState == LineState.LF)
            {
                _lineState          = LineState.None;
                result              = _currentLine.ToString();
                _currentLine.Length = 0;
            }

            return(result);
        }
コード例 #3
0
    //public int CompareTo(object obj)
    //{
    //    Line line = (Line)obj;
    //    if (line.rotation > rotation)
    //        return -1;
    //    else
    //        return 1;
    //}

    public void ChangeState(LineState state)
    {
        if (state == LineState.isChoose && bStatic)
        {
            state = LineState.show;
        }
        linestate = state;
        switch (state)
        {
        case LineState.isChoose:
            //transform.Find("Line").GetComponent<SpriteRenderer>().color = Color.red;
            break;

        case LineState.ready:
            //transform.Find("Line").GetComponent<SpriteRenderer>().color = Color.white;
            break;

        case LineState.show:
            //if (!bStatic)
            //    transform.Find("Line").GetComponent<SpriteRenderer>().color = Color.black;
            //else
            //    transform.Find("Line").GetComponent<SpriteRenderer>().color = Color.green;
            gameObject.tag = "Line";
            break;
        }
    }
コード例 #4
0
        private string readLineFrom(byte[] buffer, int offset, int length, out int read)
        {
            read = 0;

            for (var i = offset; i < length && _lineState != LineState.Lf; i++)
            {
                read++;

                var b = buffer[i];
                if (b == 13)
                {
                    _lineState = LineState.Cr;
                }
                else if (b == 10)
                {
                    _lineState = LineState.Lf;
                }
                else
                {
                    _currentLine.Append((char)b);
                }
            }

            if (_lineState != LineState.Lf)
            {
                return(null);
            }

            var line = _currentLine.ToString();

            _currentLine.Length = 0;
            _lineState          = LineState.None;

            return(line);
        }
コード例 #5
0
        public override void set_input_line_and_vector(int line, LineState state, int vector)
        {
            Atime time1;

            time1 = Timer.get_current_time();
            bool b1 = false;

            foreach (irq irq1 in Cpuint.lirq)
            {
                if (irq1.cpunum == 1 && irq1.line == line)
                {
                    if (Attotime.attotime_compare(irq1.time, time1) > 0)
                    {
                        b1 = true;
                        break;
                    }
                    else
                    {
                        int i1 = 1;
                    }
                }
            }
            if (b1)
            {
                int i1 = 1;
            }
            else
            {
                Timer.timer_set_internal(Cpuint.cpunum_empty_event_queue, "cpunum_empty_event_queue");
            }
        }
コード例 #6
0
ファイル: StageLine.cs プロジェクト: 741645596/batgame
    private void CalcRoadState()
    {
        int PrevStageID = StageM.GetStageID(m_Type, m_Chapter, m_PrevStage);
        int NextStageID = StageM.GetStageID(m_Type, m_Chapter, m_NextStage);

        bool IsPrevOpen  = StageDC.CheckOpenStage(m_Type, PrevStageID);
        int  PrevstarNum = StageDC.GetPassStageStar(m_Type, PrevStageID);

        bool IsNextOpen  = StageDC.CheckOpenStage(m_Type, NextStageID);
        int  NextstarNum = StageDC.GetPassStageStar(m_Type, NextStageID);

        //
        if (IsPrevOpen == false || PrevstarNum <= 0)
        {
            m_state = LineState.UnOPEN;
        }
        else if (IsPrevOpen == true && PrevstarNum > 0)
        {
            if (IsNextOpen == true)
            {
                if (NextstarNum > 0)
                {
                    m_state = LineState.Finish;
                }
                else
                {
                    m_state = LineState.Roading;
                }
            }
        }
        else
        {
            m_state = LineState.UnOPEN;
        }
    }
コード例 #7
0
    public static List <string> GetAllKeywordsInclude(string path)
    {
        List <string> keywords = new List <string> ();

        var lines = File.ReadAllLines(path);

        for (int i = 0; i < lines.Length; i++)
        {
            LineState skipLineState = GetLineState(lines [i], "skip_variants");
            if (skipLineState == LineState.word)
            {
                char[] ch    = new char[] { ' ', '\t' };
                var    words = lines [i].Split(ch, StringSplitOptions.RemoveEmptyEntries);
                foreach (var word in words)
                {
                    if (excludeList.Contains(word))
                    {
                        continue;
                    }
                    if (keywords.Contains(word))
                    {
                        continue;
                    }
                    keywords.Add(word);
                }
            }
        }
        return(keywords);
    }
コード例 #8
0
ファイル: LogicRectangle.cs プロジェクト: litovets/CrossZero
 public LogicRectangle(LineState top, LineState bot, LineState left, LineState right)
 {
     LineTop    = top;
     LineBottom = bot;
     LineLeft   = left;
     LineRight  = right;
 }
コード例 #9
0
 private void m6800_reset()
 {
     SEI();                              /* IRQ disabled */
     PC.LowWord       = RM16(0xfffe);
     wai_state        = 0;
     nmi_state        = 0;
     irq_state[0]     = 0;
     irq_state[1]     = 0;
     ic_eddge         = 0;
     port1_ddr        = 0x00;
     port2_ddr        = 0x00;
     tcsr             = 0x00;
     pending_tcsr     = 0x00;
     irq2             = 0;
     counter.d        = 0x0000;
     output_compare.d = 0xffff;
     timer_over.d     = 0xffff;
     ram_ctrl        |= 0x40;
     trcsr            = M6800_TRCSR_TDRE;
     rmcr             = 0;
     Timer.timer_enable(m6800_rx_timer, false);
     Timer.timer_enable(m6800_tx_timer, false);
     txstate    = M6800_TX_STATE.INIT;
     txbits     = rxbits = 0;
     trcsr_read = 0;
 }
コード例 #10
0
 public LineAction(string key, LineState leftSensor, LineState rightSensor, LogicOp operation)
 {
     this.key         = key;
     this.leftSensor  = leftSensor;
     this.rightSensor = rightSensor;
     this.operation   = operation;
 }
コード例 #11
0
        public LineAction(string key, XmlElement properties)
        {
            this.key = key;
            if (properties.Name != "properties")
            {
                throw new ActionException("Can't create the action");
            }
            foreach (XmlElement property in properties.ChildNodes)
            {
                switch (property.Name)
                {
                case "version":
                    break;

                case "leftSensor":
                    this.leftSensor = (LineState)Enum.Parse(typeof(LineState), property.InnerText);
                    break;

                case "rightSensor":
                    this.rightSensor = (LineState)Enum.Parse(typeof(LineState), property.InnerText);
                    break;

                case "operation":
                    this.operation = (LogicOp)Enum.Parse(typeof(LogicOp), property.InnerText);
                    break;

                default:
                    throw new ProjectException("Error el crear la acción");
                }
            }
        }
コード例 #12
0
ファイル: Nec.cs プロジェクト: JavierCanon/MAME.NET
 public override void set_irq_line(int irqline, LineState state)
 {
     if (irqline == (int)LineState.INPUT_LINE_NMI)
     {
         if (I.nmi_state == (uint)state)
         {
             return;
         }
         I.nmi_state = (uint)state;
         if (state != LineState.CLEAR_LINE)
         {
             I.pending_irq |= 0x02;
         }
     }
     else
     {
         I.irq_state = (uint)state;
         if (state == LineState.CLEAR_LINE)
         {
             I.pending_irq &= 0xfffffffe;
         }
         else
         {
             I.pending_irq |= 0x01;
         }
     }
 }
コード例 #13
0
    public static ConsoleColor GetColour(this LineState state)
    {
        switch (state)
        {
        case LineState.COMPLETE:
            return(ConsoleColor.Green);

        case LineState.MISSING_TERM_ENDS:
            return(ConsoleColor.DarkGreen);

        case LineState.MISSING_CERTAIN_EMAILS:
            return(ConsoleColor.Yellow);

        case LineState.MISSING_ANY_CONTACT:
            return(ConsoleColor.Red);

        case LineState.ONLY_GENERAL_CONTACT:
            return(ConsoleColor.DarkYellow);

        case LineState.INCOMPLETE:
            return(ConsoleColor.DarkGray);

        default:
            return(ConsoleColor.Gray);
        }
    }
コード例 #14
0
 public void SetColors(LineState state)
 {
     MainGrid.Background = new SolidColorBrush(mainBackground[state]);
     Index.Background    = new SolidColorBrush(numberBackground[state]);
     Index.Foreground    = new SolidColorBrush(numberForeground[state]);
     Duration.Foreground = new SolidColorBrush(durationForeground[state]);
 }
コード例 #15
0
        public static void cpunum_set_input_line(int cpunum, int line, LineState state)
        {
            int vector = (line >= 0 && line < 35) ? interrupt_vector[cpunum, line] : 0xff;

            lirq.Add(new irq(cpunum, line, state, vector, Timer.get_current_time()));
            Cpuexec.cpu[cpunum].cpunum_set_input_line_and_vector(cpunum, line, state, vector);
        }
コード例 #16
0
ファイル: Eeprom.cs プロジェクト: SimonJGillespie/VRuClinux
 public static void eeprom_set_cs_line(LineState state)
 {
     reset_line = state;
     if (reset_line != LineState.CLEAR_LINE)
     {
         eeprom_reset();
     }
 }
コード例 #17
0
        public void Test_LineState_IsInclusive()
        {
            //This is how LineState looks after the user has pressed a then b then the back arrow (to move cursor back 1 position)
            var line = new LineState("ab", 1);

            Assert.AreEqual("a", line.LineBeforeCursor);
            Assert.AreEqual("b", line.LineAfterCursor);
        }
コード例 #18
0
ファイル: Packets.cs プロジェクト: sean-callahan/Sift
 public void ReadFrom(BinaryReader reader)
 {
     Index  = reader.ReadByte();
     Id     = reader.ReadString();
     Number = reader.ReadString();
     //Created = reader.ReadInt64();
     State = (LineState)reader.ReadByte();
 }
コード例 #19
0
 public irq(int _cpunum, int _line, LineState _state, int _vector, Atime _time)
 {
     cpunum = _cpunum;
     line   = _line;
     state  = _state;
     vector = _vector;
     time   = _time;
 }
コード例 #20
0
ファイル: Eeprom.cs プロジェクト: SimonJGillespie/VRuClinux
        public static void eeprom_init()
        {
            switch (Machine.sBoard)
            {
            case "CPS-1":
                break;

            case "CPS-1(QSound)":
                for (int i = 0; i < 0x80; i++)
                {
                    eeprom_data[i] = 0xff;
                }
                serial_count = 0;
                latch        = 0;
                reset_line   = LineState.ASSERT_LINE;
                clock_line   = LineState.ASSERT_LINE;
                sending      = 0;
                locked       = 0;
                address_bits = 7;
                data_bits    = 8;
                break;

            case "CPS2":
                for (int i = 0; i < 0x80; i++)
                {
                    eeprom_data[i] = 0xff;
                }
                serial_count = 0;
                latch        = 0;
                reset_line   = LineState.ASSERT_LINE;
                clock_line   = LineState.ASSERT_LINE;
                sending      = 0;
                locked       = 0;
                address_bits = 6;
                data_bits    = 16;
                break;
            }
            switch (Machine.sName)
            {
            case "pang3":
            case "pang3r1":
            case "pang3j":
            case "pang3b":
                for (int i = 0; i < 0x80; i++)
                {
                    eeprom_data[i] = 0xff;
                }
                serial_count = 0;
                latch        = 0;
                reset_line   = LineState.ASSERT_LINE;
                clock_line   = LineState.ASSERT_LINE;
                sending      = 0;
                locked       = 0;
                address_bits = 6;
                data_bits    = 16;
                break;
            }
        }
コード例 #21
0
        //private object _columnName;

        public DaxLineState(LineState lineState, int caretOffset, int startOffset, int endOffset, int startOfLineOffset)
        {
            _state             = lineState;
            _caretOffset       = caretOffset;
            _startOffset       = startOffset;
            _endOffset         = endOffset;
            _endState          = LineState.NotSet;
            _startOfLineOffset = startOfLineOffset;
        }
コード例 #22
0
        public int ChangeObjectFile(ObjectInfo info,
                                    string strObjectFilePath,
                                    string strUsage,
                                    string strRights,
                                    out string strError)
        {
            strError = "";

            if (this.IndexOf(info) == -1)
            {
                strError = "info 不是当前集合的元素之一";
                return(-1);
            }

            if (info.LineState == LineState.Deleted)
            {
                strError = "对已经标记删除的对象不能进行修改...";
                return(-1);
            }

            LineState old_state    = info.LineState;
            string    strOldUsage  = info.Usage;
            string    strOldRights = info.Rights;

            info.Mime = PathUtil.MimeTypeFrom(strObjectFilePath);
            FileInfo fileInfo = new FileInfo(strObjectFilePath);

            info.FileName = fileInfo.FullName;
            info.Size     = Convert.ToString(fileInfo.Length);
            if (strUsage != null)
            {
                info.Usage = strUsage;
            }
            if (strRights != null)
            {
                info.Rights = strRights;
            }
            // info.Timestamp = null;   // 以前的时间戳不要修改

            if (old_state != LineState.New)
            {
                info.LineState  = LineState.Changed;
                info.ResChanged = true;
            }
            else
            {
                info.ResChanged = true;
            }

            if (strOldRights != info.Rights ||
                strOldUsage != info.Usage)
            {
                info.XmlChanged = true;
            }
            this.Changed = true;
            return(0);
        }
コード例 #23
0
ファイル: Line.cs プロジェクト: fguiet/kQuatreWPF
        public void SetImminentLaunch()
        {
            _state = LineState.ImminentLaunch;

            foreach (Firework firework in _fireworks)
            {
                firework.SetImminentLaunch();
            }
        }
コード例 #24
0
 void CleanUp()
 {
     //resets all changed variables to what they were at the start.
     lineRend.positionCount = 0;
     curPosIndex            = 0;
     startAllowed           = true;
     dotLineAngle           = 0f;
     myState = LineState.Start;
 }
コード例 #25
0
        public void Test_LineState_AfterSingleKeypress()
        {
            //This is how LineState looks after the user has pressed a single keystroke in the console (note that the cursor position
            //is off the end of the line string - as you would expect)
            var line = new LineState("t", 1);

            Assert.AreEqual("t", line.LineBeforeCursor);
            Assert.AreEqual("", line.LineAfterCursor);
        }
コード例 #26
0
 private void init()
 {
     _context       = new HttpListenerContext(this);
     _inputState    = InputState.RequestLine;
     _inputStream   = null;
     _lineState     = LineState.None;
     _outputStream  = null;
     _position      = 0;
     _requestBuffer = new MemoryStream();
 }
コード例 #27
0
ファイル: Line.cs プロジェクト: fguiet/kQuatreWPF
        public void Reset()
        {
            _state = LineState.Standby;
            _launchedTimeCounter = 0;

            foreach (Firework firework in _fireworks)
            {
                firework.Reset();
            }
        }
コード例 #28
0
        private Color ConvertLineStateToColor(LineState state)
        {
            switch (state)
            {
            case LineState.Progress: return(Color.DeepSkyBlue);

            case LineState.Done: return(Color.LightGreen);
            }
            return(Color.White);
        }
コード例 #29
0
 private void init()
 {
     this._context       = new WebSocketSharp.Net.HttpListenerContext(this);
     this._inputState    = InputState.RequestLine;
     this._inputStream   = null;
     this._lineState     = LineState.None;
     this._outputStream  = null;
     this._position      = 0;
     this._requestBuffer = new MemoryStream();
 }
コード例 #30
0
        public override void set_irq_line(int irqline, LineState state)
        {
            if (irqline == INPUT_LINE_NMI)
            {
                if (nmi_state == state)
                {
                    return;
                }
                nmi_state = state;
                if (state == LineState.CLEAR_LINE)
                {
                    return;
                }
                ENTER_INTERRUPT(0xfffc);
            }
            else
            {
                int eddge;
                if (irq_state[irqline] == state)
                {
                    return;
                }
                irq_state[irqline] = state;
                switch (irqline)
                {
                case M6800_IRQ_LINE:
                    if (state == LineState.CLEAR_LINE)
                    {
                        return;
                    }
                    break;

                case M6800_TIN_LINE:
                    eddge = (state == LineState.CLEAR_LINE) ? 2 : 0;
                    if (((tcsr & TCSR_IEDG) ^ (state == LineState.CLEAR_LINE ? TCSR_IEDG : 0)) == 0)
                    {
                        return;
                    }
                    /* active edge in */
                    tcsr         |= TCSR_ICF;
                    pending_tcsr |= TCSR_ICF;
                    input_capture = counter.LowWord;
                    MODIFIED_tcsr();
                    if ((cc & 0x10) == 0)
                    {
                        m6800_check_irq2();
                    }
                    break;

                default:
                    return;
                }
                CHECK_IRQ_LINES(); /* HJB 990417 */
            }
        }
コード例 #31
0
ファイル: GrappleLine.cs プロジェクト: jfoxx/swingx
    void OnSerializeNetworkView(BitStream stream,NetworkMessageInfo info)
    {
        Vector3 playerPos;
        Vector3 grapplePos;

        if (stream.isWriting)
        {
            playerPos = player.transform.position;
            grapplePos = grapple.transform.position;

            stream.Serialize(ref playerPos);
            stream.Serialize(ref grapplePos);
        }
        else
        {
            playerPos = Vector3.zero;
            grapplePos = Vector3.zero;
            stream.Serialize(ref playerPos);
            stream.Serialize(ref grapplePos);

            for (var i = m_BufferedState.Length - 1; i >= 1; i --)
            {
                m_BufferedState[i] = m_BufferedState[i-1];
            }

            LineState state = new LineState();
            state.timeStamp = (float)info.timestamp;
            state.plPos = playerPos;
            state.grPos = grapplePos;
            m_BufferedState[0] = state;

            m_TimestampCount = Mathf.Min(m_TimestampCount + 1, m_BufferedState.Length);

            for (int i = 0; i < m_TimestampCount-1; i++)
            {
                if (m_BufferedState[i].timeStamp < m_BufferedState[i+1].timeStamp)
                {
                    Debug.Log("State inconsistent");
                }
            }
        }
    }
コード例 #32
0
ファイル: GenerateLine.cs プロジェクト: famerij/kattelypeli
    void ChangeState(LineState _newState)
    {
        currentState = _newState;

        switch (currentState)
        {
            case LineState.MovingIn:
                MoveTheLine();
                break;
            case LineState.ShakingHands:
                delayTimer = 0f;
                break;
            case LineState.MovingOut:
                foreach (var guest in guests)
                {
                    guest.GetComponent<AnimateGuest>().moving = true;
                }
                MoveOut();
                break;
            default:
                break;
        }
    }
コード例 #33
0
ファイル: CTDControler.cs プロジェクト: nikson/ArtechCTI-SDK
        public Boolean SetLineStatus(int channelNo, LineState status)
        {
            int retVal;

            retVal = AD101NativeMethods.AD101_SetBusy(channelNo, (int)status);

            return (retVal == OK);
        }
コード例 #34
0
    private string readLineFrom (byte[] buffer, int offset, int length, out int read)
    {
      read = 0;
      for (var i = offset; i < length && _lineState != LineState.Lf; i++) {
        read++;
        var b = buffer[i];
        if (b == 13)
          _lineState = LineState.Cr;
        else if (b == 10)
          _lineState = LineState.Lf;
        else
          _currentLine.Append ((char) b);
      }

      if (_lineState == LineState.Lf) {
        _lineState = LineState.None;
        var line = _currentLine.ToString ();
        _currentLine.Length = 0;

        return line;
      }

      return null;
    }
コード例 #35
0
    private string readLine (byte [] buffer, int offset, int length, ref int used)
    {
      if (_currentLine == null)
        _currentLine = new StringBuilder ();

      var last = offset + length;
      used = 0;
      for (int i = offset; i < last && _lineState != LineState.LF; i++) {
        used++;
        var b = buffer [i];
        if (b == 13)
          _lineState = LineState.CR;
        else if (b == 10)
          _lineState = LineState.LF;
        else
          _currentLine.Append ((char) b);
      }

      string res = null;
      if (_lineState == LineState.LF) {
        _lineState = LineState.None;
        res = _currentLine.ToString ();
        _currentLine.Length = 0;
      }

      return res;
    }
コード例 #36
0
ファイル: Phone.cs プロジェクト: imfarrukhkhan/sipdotnet
        public Phone(Account account)
        {
            Debug.Assert (null != account, "Phone requires an Account to make calls.");
            this.account = account;
            linphone = new Linphone ();
            linphone.RegistrationStateChangedEvent += (Linphone.LinphoneRegistrationState state) => {
                switch (state) {
                    case Linphone.LinphoneRegistrationState.LinphoneRegistrationProgress:
                        connectState = ConnectState.Progress;
                        break;

                    case Linphone.LinphoneRegistrationState.LinphoneRegistrationFailed:
                        linphone.DestroyPhone();
                        if (ErrorEvent != null) ErrorEvent (null, Error.RegisterFailed);
                        break;

                    case Linphone.LinphoneRegistrationState.LinphoneRegistrationCleared:
                        connectState = ConnectState.Disconnected;
                        if (PhoneDisconnectedEvent != null) PhoneDisconnectedEvent();
                        break;

                    case Linphone.LinphoneRegistrationState.LinphoneRegistrationOk:
                        connectState = ConnectState.Connected;
                        if (PhoneConnectedEvent != null) PhoneConnectedEvent();
                        break;

                    case Linphone.LinphoneRegistrationState.LinphoneRegistrationNone:
                    default:
                        break;
                }
            };

            linphone.ErrorEvent += (call, message) => {
                Console.WriteLine ("Error: {0}", message);
                if (ErrorEvent != null) ErrorEvent (call, Error.UnknownError);
            };

            linphone.CallStateChangedEvent += (Call call) => {
                Call.CallState state = call.GetState();

                switch (state) {
                case Call.CallState.Active:
                    lineState = LineState.Busy;
                    if (CallActiveEvent != null)
                        CallActiveEvent (call);
                    break;

                case Call.CallState.Loading:
                    lineState = LineState.Busy;
                    if (call.GetCallType () == Call.CallType.Incoming)
                        if (IncomingCallEvent != null)
                            IncomingCallEvent (call);
                    break;

                case Call.CallState.Error:
                    this.lineState = LineState.Free;
                    if (ErrorEvent != null) ErrorEvent(null, Error.CallError);
                    if (CallCompletedEvent != null)
                        CallCompletedEvent(call);
                    break;

                case Call.CallState.Completed:
                default:
                    this.lineState = LineState.Free;
                    if (CallCompletedEvent != null)
                        CallCompletedEvent (call);
                    break;
                }

            };
        }
コード例 #37
0
ファイル: Lexer.cs プロジェクト: ndmitchell/VSHaskell
        public static Lexeme[] Forward(string Text, ref LineState state)
        {
            var res = new List<Lexeme>();

            var i = 0;
            var isImport = false; // True if import keywords are allowed
            if (state >= LineState.MultilineComment1)
            {
            int Depth = (int) state - (int) LineState.MultilineComment1 + 1;
            MultilineComment(Text, ref i, ref Depth);
            int j = 0;
            foreach (var s in SplitText(Text.Substring(0, i)))
            {
                var r = new Lexeme();
                r.Start = j;
                r.Length = s.Length;
                j += s.Length;
                r.Token = Token.Comment;
                if (!char.IsWhiteSpace(s[0]))
                    res.Add(r);
            }
            if (Depth != 0)
            {
                state = (LineState) ((int) LineState.MultilineComment1 + Depth - 1);
                return res.ToArray();
            }
            state = LineState.Normal;
            }

            for (; i < Text.Length; )
            {
            var c = Text[i];
            if (char.IsWhiteSpace(c))
            {
                i++;
                continue;
            }
            var r = new Lexeme();
            r.Start = i;
            r.Length = 1;
            r.Token = Token.Unknown;

            isImport = isImport && (c != '(') && (c != ';');
            if (IsSymbol(c))
            {
                int n = 1;
                while (i + n < Text.Length && IsSymbol(Text[i + n]))
                    n++;
                string sym = Text.Substring(i, n);
                if (!(sym.Length >= 2 && sym.Replace("-","").Length == 0))
                {
                    r.Token = KeywordSyms.Contains(sym) ? Token.Keyword : Token.Unknown;
                    r.Length = n;
                }
                else
                {
                    foreach (var part in SplitText(Text.Substring(i)))
                    {
                        r = new Lexeme();
                        r.Start = i;
                        r.Length = part.Length;
                        r.Token = Token.Comment;
                        i += part.Length;
                        if (!char.IsWhiteSpace(part[0]))
                            res.Add(r);
                    }
                    break;
                }
            }
            else if (IsIdentStart(c))
            {
                int n = 1;
                while (i + n < Text.Length && IsIdentCont(Text[i + n]))
                    n++;
                string ident = Text.Substring(i, n);
                r.Token = KeywordIds.Contains(ident) ? Token.Keyword : Token.Unknown;
                if (isImport && KeywordImport.Contains(ident)) r.Token = Token.Keyword;
                if (ident == "import") isImport = true;
                r.Length = n;
            }
            else if (c == '\"' || c == '\'')
            {
                int n = 1;
                while (i + n < Text.Length)
                {
                    if (Text[i+n] == c) {n++; break;}
                    if (Text[i+n] == '\\') n++;
                    n++;
                }
                n = Math.Min(Text.Length - i, n); // in case a trailing \ character
                foreach (var part in SplitText(Text.Substring(i, n)))
                {
                    r = new Lexeme();
                    r.Start = i;
                    r.Length = part.Length;
                    r.Token = c == '\"' ? Token.String : Token.Char;
                    i += part.Length;
                    if (!char.IsWhiteSpace(part[0]))
                        res.Add(r);
                }
                continue;
            }
            else if (c == '[') r.Token = Token.OpenSquare;
            else if (c == ']') r.Token = Token.CloseSquare;
            else if (c == '(') r.Token = Token.OpenParen;
            else if (c == ')') r.Token = Token.CloseParen;
            else if (c == '}') r.Token = Token.CloseCurly;
            else if (c == '{' && Text.Length > i+1 && Text[i+1] == '-')
            {
                int Depth = 0;
                int j = i;
                MultilineComment(Text, ref i, ref Depth);
                foreach (var s in SplitText(Text.Substring(j, i-j)))
                {
                    var rr = new Lexeme();
                    rr.Start = j;
                    rr.Length = s.Length;
                    j += s.Length;
                    rr.Token = Token.Comment;
                    if (!char.IsWhiteSpace(s[0]))
                        res.Add(rr);
                }
                if (Depth != 0)
                {
                    state = (LineState) ((int) LineState.MultilineComment1 + Depth - 1);
                    return res.ToArray();
                }
                continue;
            }
            else if (c == '{') r.Token = Token.OpenCurly;

            res.Add(r);
            i += Math.Max(1, r.Length);
            }
            return res.ToArray();
        }
コード例 #38
0
ファイル: BinaryResControl.cs プロジェクト: renyh1013/dp2
        /*
        void SetLineState(ListViewItem item,
            LineState state)
        {
            if (state == LineState.Normal)
            {
                ListViewUtil.ChangeItemText(item, 1, CaptionNormal);
                item.ForeColor = Color.Black;
                item.BackColor = Color.White;
            }
            else if (state == LineState.New)
            {
                ListViewUtil.ChangeItemText(item, 1, CaptionNew);
                item.ForeColor = Color.Black;
                item.BackColor = Color.LightGreen;
            }
            else if (state == LineState.Changed)
            {
                ListViewUtil.ChangeItemText(item, 1, CaptionChanged);
                item.ForeColor = Color.Black;
                item.BackColor = Color.Yellow;
            }
            else if (state == LineState.Deleted)
            {
                ListViewUtil.ChangeItemText(item, 1, CaptionDeleted);
                item.ForeColor = Color.DarkGray;
                item.BackColor = Color.White;
            }
            else if (state == LineState.Error)
            {
                ListViewUtil.ChangeItemText(item, 1, CaptionError);
                item.ForeColor = Color.Red;
                item.BackColor = Color.White;
            }

            LineInfo info = (LineInfo)item.Tag;
            if (info == null)
            {
                info = new LineInfo();
                item.Tag = info;
            }

            info.LineState = state;
        }
         * */

        // 设置 item 的 Tag,并设置 item 的前景背景颜色
        // parameters:
        //      strInitialUsage 如果为null,则不设置此项
        void SetLineInfo(ListViewItem item,
            // string strInitialUsage,
            LineState state)
        {
            if (state == LineState.Normal)
            {
                ListViewUtil.ChangeItemText(item, 1, CaptionNormal);
                item.ForeColor = Color.Black;
                item.BackColor = Color.White;
            }
            else if (state == LineState.New)
            {
                ListViewUtil.ChangeItemText(item, 1, CaptionNew);
                item.ForeColor = Color.Black;
                item.BackColor = Color.LightGreen;
            }
            else if (state == LineState.Changed)
            {
                ListViewUtil.ChangeItemText(item, 1, CaptionChanged);
                item.ForeColor = Color.Black;
                item.BackColor = Color.Yellow;
            }
            else if (state == LineState.Deleted)
            {
                ListViewUtil.ChangeItemText(item, 1, CaptionDeleted);
                item.ForeColor = Color.DarkGray;
                item.BackColor = Color.White;
            }
            else if (state == LineState.Error)
            {
                ListViewUtil.ChangeItemText(item, 1, CaptionError);
                item.ForeColor = Color.Red;
                item.BackColor = Color.White;
            }

            LineInfo info = (LineInfo)item.Tag;
            if (info == null)
            {
                info = new LineInfo();
                item.Tag = info;
            }

#if NO
            if (strInitialUsage != null)
                info.InitialUsage = strInitialUsage;
#endif
            info.LineState = state;
        }
コード例 #39
0
ファイル: HttpConnection.cs プロジェクト: unosquare/embedio
        private string ReadLine(byte[] buffer, int offset, int len, ref int used)
        {
            if (_currentLine == null)
                _currentLine = new StringBuilder(128);
            var last = offset + len;
            used = 0;
            for (var i = offset; i < last && _lineState != LineState.Lf; i++)
            {
                used++;
                var b = buffer[i];
                if (b == 13)
                {
                    _lineState = LineState.Cr;
                }
                else if (b == 10)
                {
                    _lineState = LineState.Lf;
                }
                else
                {
                    _currentLine.Append((char) b);
                }
            }

            string result = null;
            if (_lineState == LineState.Lf)
            {
                _lineState = LineState.None;
                result = _currentLine.ToString();
                _currentLine.Length = 0;
            }

            return result;
        }
コード例 #40
0
ファイル: HttpConnection.cs プロジェクト: unosquare/embedio
 private void Init()
 {
     #if SSL
     if (ssl_stream != null)
     {
         ssl_stream.AuthenticateAsServer(cert, true, (SslProtocols)ServicePointManager.SecurityProtocol, false);
     }
     #endif
     _contextBound = false;
     _iStream = null;
     _oStream = null;
     Prefix = null;
     _chunked = false;
     _ms = new MemoryStream();
     _position = 0;
     _inputState = InputState.RequestLine;
     _lineState = LineState.None;
     _context = new HttpListenerContext(this);
 }
コード例 #41
0
        // --------------------------------------------------------------------
        // 接続成功 (IInterruptableConnectorClient.SuccessfullyExit)
        // --------------------------------------------------------------------
        /// <summary>
        /// IInterruptableConnectorClient.SuccessfullyExitのコールバック関数です。
        /// </summary>
        /// <remarks>
        /// SSH接続もしくはTelnet接続が確立したときに呼ばれます。ターミナル画面を表示するために
        /// 以下の手順で処理を行います。<br/>
        /// (1) 新規にPoderosa.Forms.MainWindowを作成します。<br/>
        /// (2) MainWindow上にビューを作成します。<br/>
        /// (3) 作成したビュー上でターミナルセッションを開始します。<br/>
        /// (4) MainWindow上にあるメニューチップとツールチップを非表示にします。<br/>
        /// (5) ターミナル画面のみが表示されたMainWindowを本コントロール上に載せます。<br/>
        /// (6) TerminalConnectedイベントを発行します。
        /// </remarks>
        /// <param name="result">Newly-created SSH connection.</param>
        public void SuccessfullyExit(ITerminalConnection result)
        {
            #if DEBUG
            WriteLog("SuccessfullyExit()が呼び出されました。");
            #endif
            //
            // 返されたターミナルコネクションがICloseableTerminalConnectionであれば、
            // コネクションが切断されたことを通知するイベントが利用できますので、ハンドラを
            // 設定します。
            // ※ SSH接続時はICloseableTerminalConnectionが返されますが、Telnet接続時は返されません。
            //
            ICloseableTerminalConnection closableConnection = result as ICloseableTerminalConnection;
            if (closableConnection != null)
            {
                _isCloseableConnection = true;
                closableConnection.ConnectionClosed += terminal_ConnectionClosed;
                closableConnection.ConnectionLost += terminal_ConnectionLost;
            }
            else
            {
                _isCloseableConnection = false;
            }

            //
            // ウィンドウマネージャを取得します。
            //
            ICoreServices coreServices =
                (ICoreServices)PoderosaAccessPoint.World.GetAdapter(typeof(ICoreServices));
            IWindowManager windowManager = coreServices.WindowManager;

            //
            // Invokeメソッドを用いてGUIスレッド上で処理実行させます。
            //
            windowManager.MainWindows.First().AsForm().Invoke(new Action(() =>
            {
                //
                // 返されたターミナルコネクションとターミナル設定から、ターミナルセッションを
                // 作成します。
                //
                _session = new Sessions.TerminalSession(result, _settings);

                //
                // Poderosa.Forms.MainWindowを新規に生成し、ビューを作成します。
                //
                IPoderosaMainWindow window = windowManager.CreateNewWindow(
                    new MainWindowArgument(ClientRectangle, FormWindowState.Normal, "", "", 1));
                IViewManager viewManager = window.ViewManager;
                IContentReplaceableView view =
                    (IContentReplaceableView)viewManager.GetCandidateViewForNewDocument().GetAdapter(
                    typeof(IContentReplaceableView));

                //
                // セッションマネージャに新しいターミナルセッションを作成したビュー上で
                // 開始するように要求します。
                //
                coreServices.SessionManager.StartNewSession(_session, view);

                //
                // ターミナルセッションの設定を調整します。
                // - サイズチップは表示しません。
                //
                _session.TerminalControl.HideSizeTip = true;

                //
                // ビューの親フォームはPoderosa.Forms.MainWindowです。
                // MainWindow上にはメニューストリップやツールストリップが載せられていますので、
                // ターミナル画面以外の全てを非表示にします。
                //
                Form containerForm = view.ParentForm.AsForm();
                foreach (Control control in containerForm.Controls)
                {
                    if (control is MenuStrip || control.GetType().Name == "PoderosaStatusBar")
                    {
                        control.Visible = false;
                    }
                    else if (control.GetType().Name == "PoderosaToolStripContainer")
                    {
                        foreach (ToolStripPanel child in control.Controls.OfType<ToolStripPanel>())
                        {
                            child.Visible = false;
                        }
                        foreach (ToolStripContentPanel child
                            in control.Controls.OfType<ToolStripContentPanel>())
                        {
                            foreach (Control grandChild in child.Controls)
                            {
                                if (grandChild.GetType().Name != "TerminalControl")
                                {
                                    grandChild.Visible = false;
                                }
                            }
                        }
                    }
                }

                //
                // ターミナル画面のみが表示されるMainWindowを本コントロール上に載せます。
                //
                containerForm.TopLevel = false;
                containerForm.FormBorderStyle = FormBorderStyle.None;
                containerForm.Width = Width;
                containerForm.Height = Height;
                containerForm.Dock = DockStyle.Fill;
                containerForm.Parent = this;

                //
                // ビューコントロールのBackColorChangedイベントを捕捉することで、
                // Telnet接続時のCtrl-D入力やlogoutコマンドによる切断を検査する契機とします。
                // ※ Ctrl-Dを送信した後、ビューコントロールのBackColorChangedイベントは
                //    2回発生します。1回目はBlackに変わっており、2回目はControlDarkです。
                //    これにより、表示プロファイルの背景色とかぶっても問題がないと言えます。
                //
                view.AsControl().BackColorChanged += new EventHandler(view_BackColorChanged);

                view.AsControl().Focus();
            }));

            //
            // TerminalConnectイベントを発行します。
            //
            State = LineState.Connected;
            if (TerminalConnected != null)
            {
                TerminalConnected(this, new EventArgs());
            }
        }
コード例 #42
0
 /// <summary>
 /// ICloseableTerminalConnection.ConnectionClosedイベントに対するイベントハンドラです。
 /// </summary>
 /// <remarks>
 /// 確立されたターミナルコネクションが正常切断された場合に呼び出されるイベントハンドラです。
 /// </remarks>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void terminal_ConnectionClosed(object sender, EventArgs e)
 {
     #if DEBUG
     WriteLog("ConnectionClosedイベントハンドラが呼び出されました。");
     #endif
     State = LineState.NotConnected;
     if (TerminalClosed != null)
     {
         TerminalClosed(this, new EventArgs());
     }
 }
コード例 #43
0
 /// <summary>
 /// ICloseableTerminalConnection.ConnectionLostイベントに対するイベントハンドラです。
 /// </summary>
 /// <remarks>
 /// 確立されたターミナルコネクションが異常切断された場合に呼び出されるイベントハンドラです。
 /// </remarks>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void terminal_ConnectionLost(object sender, ErrorEventArgs e)
 {
     #if DEBUG
     WriteLog("ConnectionLostイベントハンドラが呼び出されました。");
     #endif
     State = LineState.NotConnected;
     ConnectionFailed(e.GetException().Message);
 }
コード例 #44
0
 /// <summary>
 /// ビューコントロールのBackColorChangedイベントに対するイベントハンドラです。
 /// </summary>
 /// <remarks>
 /// このハンドラはTelnet接続などのIClosableTerminalConnectionではない接続において、
 /// Ctrl-D入力時にサーバから切断されたことを本コントロールで判断するために利用しています。
 /// </remarks>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void view_BackColorChanged(object sender, EventArgs e)
 {
     #if DEBUG
     WriteLog("BackColorChangedイベントハンドラが呼び出されました。");
     #endif
     //
     // ターミナルコネクションの状態を調べ、クローズ状態であればTerminalClosedイベントを
     // 発行します。
     //
     if (_session != null && _session.TerminalConnection.IsClosed)
     {
         State = LineState.NotConnected;
         if (TerminalClosed != null)
         {
     #if DEBUG
             WriteLog("コネクション切断を検知したのでTerminalClosedイベントを通知します。");
     #endif
             TerminalClosed(this, new EventArgs());
         }
     }
 }
コード例 #45
0
ファイル: ORDA_transfer.cs プロジェクト: rjohnson72/ORDA
        public override void OnUpdate()
        {
            float dt = Time.deltaTime;
            Vessel activeVessel = FlightGlobals.ActiveVessel;
            bool keyDown = Input.GetKeyDown (grappleKey);

            // check for illegal states (eg. when a kerbal dies)
            if (
                (lineState == LineState.GRAPPLED && grappledKerbal == null) ||
                (lineState == LineState.CONNECTED && (connectedShip == null || connectedPart == null))
               ) {
                lineState = LineState.IDLE;
                grappledKerbal = null;
                connectedShip = null;
                connectedPart = null;
            }

            // cut fuel line if too long
            if (lineState == LineState.GRAPPLED) {
                if ((this.transform.position - grappledKerbal.transform.position).magnitude > Mathf.Abs (maxLineLength)) {
                    lineState = LineState.IDLE;
                    grappledKerbal = null;
                    grappledKerbalsList.Remove (grappledKerbal);
                    print ("Snap!");
                }
            } else if (lineState == LineState.CONNECTED) {
                if ((this.transform.position - connectedPart.transform.position).magnitude > Mathf.Abs (maxLineLength)) {
                    lineState = LineState.IDLE;
                    connectedShip = null;
                    connectedPart = null;
                    print ("Snap!");
                }
            }

            // state logic
            if (lineState == LineState.IDLE) {

                // key pressed?
                if (keyDown) {

                    // player controlling a kerbal?
                    if (activeVessel.isEVA) {

                        // in range?
                        float distance = (this.transform.position - activeVessel.transform.position).magnitude;
                        if (distance < Mathf.Abs (maxGrappleDistance)) {

                            // kerbal not yet grappled?
                            if (grappledKerbalsList.Contains (activeVessel) == false) {

                                // grapple fuel line to kerbal
                                lineState = LineState.GRAPPLED;
                                grappledKerbal = activeVessel;
                                connectedShip = null;
                                connectedPart = null;
                                print ("GRAPPLED at " + distance.ToString () + "m");

                                // add to list of grappled kerbals
                                grappledKerbalsList.Add (grappledKerbal);
                            } else {
                                print ("Kerbal already grappled");
                            }
                        }
                    }
                }

            } else if (lineState == LineState.GRAPPLED) {

                // player controlling our kerbal?
                if (activeVessel.isEVA && activeVessel == grappledKerbal) {

                    // key pressed?
                    if (keyDown) {

                        // find closest ship (no kerbals)
                        Vessel closestVessel = null;
                        float closestVesselDistance = 0;
                        foreach (Vessel v in FlightGlobals.Vessels) {
                            if (v.isEVA)
                                continue;

                            Vector3 relPos = v.orbit.pos - activeVessel.orbit.pos;
                            float distance = relPos.magnitude;

                            if (closestVessel == null || distance < closestVesselDistance) {
                                closestVessel = v;
                                closestVesselDistance = distance;
                            }
                        }

                        if (closestVessel) {

                            // at own vessel?
                            if (closestVessel == this.vessel) {

                                Vector3 relPos = activeVessel.transform.position - this.transform.position;
                                float distance = relPos.magnitude;

                                // in range?
                                if (distance < Mathf.Abs (maxGrappleDistance)) {
                                    // remove kerbal from list
                                    grappledKerbalsList.Remove (grappledKerbal);

                                    // return the fuel line
                                    lineState = LineState.IDLE;
                                    grappledKerbal = null;
                                    connectedShip = null;
                                    connectedPart = null;
                                    print ("IDLE at " + distance.ToString () + "m");
                                }
                            } else {
                                // find closest fuel or rcs tank
                                Part closestTank = null;
                                float closestTankDistance = 0;

                                foreach (Part p in closestVessel.parts) {
                                    if(p.Resources.Count > 0) {
                                        Vector3 relPos = activeVessel.transform.position - p.transform.position;
                                        float distance = relPos.magnitude;

                                        if (closestTank == null || distance < closestTankDistance) {
                                            closestTank = p;
                                            closestTankDistance = distance;
                                        }
                                    }
                                }

                                // in range?
                                if (closestTankDistance < Mathf.Abs (maxGrappleDistance) && closestTank != null) {

                                    // remove kerbal from list
                                    grappledKerbalsList.Remove (grappledKerbal);

                                    // connect fuel line to ship
                                    lineState = LineState.CONNECTED;
                                    grappledKerbal = null;
                                    connectedShip = closestVessel;
                                    connectedPart = closestTank;

                                    print ("CONNECTED at " + closestTankDistance.ToString ());
                                }
                            }
                        }
                    }
                }

            } else if (lineState == LineState.CONNECTED) {

                // key pressed?
                if (keyDown) {

                    // player controlling a kerbal?
                    if (activeVessel.isEVA) {

                        // in range?
                        float distance = (connectedPart.transform.position - activeVessel.transform.position).magnitude;
                        if (distance < Mathf.Abs (maxGrappleDistance)) {

                            // kerbal not yet grappled?
                            if (grappledKerbalsList.Contains (activeVessel) == false) {

                                // grapple fuel line to kerbal
                                lineState = LineState.GRAPPLED;
                                grappledKerbal = activeVessel;
                                connectedShip = null;
                                connectedPart = null;
                                print ("GRAPPLED at " + distance.ToString () + "m");

                                // add to list of grappled kerbals
                                grappledKerbalsList.Add (grappledKerbal);
                            } else {
                                print ("Kerbal already grappled");
                            }
                        }
                    }
                }
            }

            // render logic
            if (lineState == LineState.GRAPPLED) {
                // render fuel line
                Vector3 relPos = grappledKerbal.transform.position - this.transform.position;
                Vector3 ps = transform.InverseTransformDirection (relPos);
                lineRenderer.SetPosition (1, ps);

            } else if (lineState == LineState.CONNECTED) {
                // render fuel line
                Vector3 relPos = connectedPart.transform.position - this.transform.position;
                Vector3 ps = transform.InverseTransformDirection (relPos);
                lineRenderer.SetPosition (1, ps);

            } else {
                // nothing
                lineRenderer.SetPosition (1, Vector3.zero);
            }
        }
コード例 #46
0
ファイル: DaxLineParser.cs プロジェクト: votrongdao/DaxStudio
 public void SetState(LineState newState, int pos)
 {
     if (newState != _state)
     {
         if (pos <= _caretOffset && _endOffset == 0)
         {
             _state = newState;
             _startOffset = pos;
         }
         else
         {
             if ( _endState == Utils.LineState.NotSet)
             {
                 _endState = newState;
                 _endOffset = pos;
             }
         }
     }
 }
コード例 #47
0
        private string readLineFrom(byte[] buffer, int offset, int count, ref int read)
        {
            if (_currentLine == null)
            _currentLine = new StringBuilder ();

              var last = offset + count;
              read = 0;
              for (var i = offset; i < last && _lineState != LineState.Lf; i++) {
            read++;
            var b = buffer[i];
            if (b == 13)
              _lineState = LineState.Cr;
            else if (b == 10)
              _lineState = LineState.Lf;
            else
              _currentLine.Append ((char) b);
              }

              string ret = null;
              if (_lineState == LineState.Lf) {
            _lineState = LineState.None;
            ret = _currentLine.ToString ();
            _currentLine.Length = 0;
              }

              return ret;
        }
コード例 #48
0
 // --------------------------------------------------------------------
 // 接続失敗 (IInterruptableConnectorClient.ConnectionFailed)
 // --------------------------------------------------------------------
 /// <summary>
 /// IInterruptableConnectorClient.ConnectionFailedのコールバック関数です。
 /// </summary>
 /// <remarks>
 /// SSH接続もしくはTelnet接続に失敗したときに呼ばれます。
 /// </remarks>
 /// <param name="message">接続失敗の理由を示すテキスト</param>
 public void ConnectionFailed(string message)
 {
     #if DEBUG
     WriteLog("ConnectionFailed()が呼び出されました。");
     #endif
     State = LineState.NotConnected;
     if (TerminalDisconnected != null)
     {
         TerminalDisconnected(this, new ErrorEventArgs(new Exception(message)));
     }
 }
コード例 #49
0
ファイル: BinaryResControl.cs プロジェクト: renyh1013/dp2
        void SetOldLineState(ListViewItem item,
            LineState old_state)
        {
            LineInfo info = (LineInfo)item.Tag;
            if (info == null)
            {
                info = new LineInfo();
                item.Tag = info;
            }

            info.OldLineState = old_state;
        }
コード例 #50
0
ファイル: HttpConnection.cs プロジェクト: jamesaxl/reactor
        void Init()
        {
            context_bound = false;

            i_stream      = null;

            o_stream      = null;

            prefix        = null;

            chunked       = false;

            ms            = new MemoryStream();

            position      = 0;

            input_state   = InputState.RequestLine;

            line_state    = LineState.None;

            context       = new HttpListenerContext(this);
        }
コード例 #51
0
 private void Init()
 {
     _chunked = false;
     _context = new HttpListenerContext (this);
     _contextWasBound = false;
     _inputState = InputState.RequestLine;
     _inputStream = null;
     _lineState = LineState.None;
     _outputStream = null;
     _position = 0;
     _prefix = null;
     _requestBuffer = new MemoryStream ();
     _timeout = 90000; // 90k ms for first request, 15k ms from then on.
 }
コード例 #52
0
        // --------------------------------------------------------------------
        // 接続解除
        // --------------------------------------------------------------------
        /// <summary>
        /// 接続を解除します。
        /// </summary>
        public void Close()
        {
            #if DEBUG
            WriteLog("Close()が呼び出されました。");
            #endif
            if (State == LineState.Connecting)
            {
                if (_connector != null)
                {
                    //
                    // 待機中の接続をキャンセルします。
                    //
            #if DEBUG
                    WriteLog("待機中の接続をキャンセルします。");
            #endif
                    _connector.Interrupt();
                }
            }
            else if (State == LineState.Connected)
            {
                if (_session != null)
                {
                    //
                    // セッションマネージャにセッション終了を要求します。
                    //
            #if DEBUG
                    WriteLog("セッションマネージャにセッション終了を要求します。");
            #endif
                    ICoreServices coreServices =
                        (ICoreServices)PoderosaAccessPoint.World.GetAdapter(typeof(ICoreServices));
                    coreServices.SessionManager.TerminateSession(_session);

                    //
                    // ターミナルコネクションがICloseableTerminalConnectionでなかった場合、
                    // ConnectionClosedイベントによる通知は得られませんので、ここでTerminalClosed
                    // イベントを発行します。
                    //
                    if (!_isCloseableConnection)
                    {
                        State = LineState.NotConnected;
                        if (TerminalClosed != null)
                        {
                            TerminalClosed(this, new EventArgs());
                        }
                    }
                }
            }
        }
コード例 #53
0
ファイル: Lexer.cs プロジェクト: ndmitchell/VSHaskell
 private static void Test(string command, LineState start, LineState end)
 {
     // first step, parse command
     var cmds = command.Replace('|','\0').Replace("\0\0","|").Split('\0');
     var enms = Enum.GetNames(typeof(TestResult));
     var str = string.Join("", cmds.Where(s => !enms.Contains(s)).ToArray());
     var st = start;
     var res = Forward(str, ref st);
     Assert(st == end);
     var i = 0;
     var expect = TestResult.Norm;
     foreach (var c in cmds)
     {
     if (enms.Contains(c))
         expect = (TestResult) Enum.Parse(typeof(TestResult), c);
     else
     {
         var r = res[i++];
         var y1 = str.Substring(r.Start, r.Length);
         var y2 = c.Trim();
         Assert(str.Substring(r.Start, r.Length) == c.Trim());
         Assert((expect == TestResult.Key) == IsKeyword(r.Token));
         Assert((expect == TestResult.Str) == IsString(r.Token));
         Assert((expect == TestResult.Com) == IsComment(r.Token));
     }
     }
     Assert(i == res.Length);
 }
コード例 #54
0
        // --------------------------------------------------------------------
        // 接続開始
        // --------------------------------------------------------------------
        /// <summary>
        /// 非同期接続を開始します。
        /// </summary>
        /// <remarks>
        /// 接続パラメータとターミナル設定を作成して、非同期接続を開始します。
        /// 接続が成功するとSuccessfullyExit()が呼ばれ、失敗するとConnectionFailed()が呼ばれます。
        /// </remarks>
        public void AsyncConnect()
        {
            State = LineState.Connecting;
            _settings = null;
            _session = null;
            _connector = null;

            //
            // ターミナルエミュレータサービスとプロトコルサービスを取得します。
            //
            ITerminalEmulatorService terminalEmulatorService =
                (ITerminalEmulatorService)PoderosaAccessPoint.World.PluginManager.FindPlugin(
                "org.poderosa.terminalemulator", typeof(ITerminalEmulatorService));
            IProtocolService protocolService =
                (IProtocolService)PoderosaAccessPoint.World.PluginManager.FindPlugin(
                "org.poderosa.protocols", typeof(IProtocolService));

            //
            // 接続パラメータを作成します。
            //
            ITCPParameter tcpParameter = null;
            ISSHLoginParameter sshLoginParameter =  null;
            if (LoginProfile.ConnectionMethod == ConnectionParam.ConnectionMethod.Telnet)
            {
                //
                // Telnet接続パラメータの作成
                // ※ tcpParameterの実体はTCPParameterクラスのインスタンスです。
                //
                tcpParameter = protocolService.CreateDefaultTelnetParameter();
                tcpParameter.Destination = LoginProfile.Host;
                tcpParameter.Port = LoginProfile.Port;
            }
            else
            {
                //
                // SSH接続パラメータの作成
                // ※ sshLoginParameterの実体はSSHLoginParameterクラスのインスタンスであり、
                //    SSHLoginParameterクラスはTCPParameterクラスを継承しています。
                //
                sshLoginParameter = protocolService.CreateDefaultSSHParameter();
                sshLoginParameter.Account = LoginProfile.UserName;
                if (LoginProfile.Password != null && LoginProfile.Password.Length > 0)
                {
                    IntPtr pswdBytes = Marshal.SecureStringToGlobalAllocAnsi(LoginProfile.Password);
                    sshLoginParameter.PasswordOrPassphrase = Marshal.PtrToStringAnsi(pswdBytes);
                }
                if (!String.IsNullOrEmpty(LoginProfile.IdentityFile))
                {
                    sshLoginParameter.AuthenticationType = AuthenticationType.PublicKey;
                    sshLoginParameter.IdentityFileName = LoginProfile.IdentityFile;
                }
                else
                {
                    sshLoginParameter.AuthenticationType = AuthenticationType.Password;
                }
                sshLoginParameter.Method = (SSHProtocol)Enum.Parse(
                    typeof(SSHProtocol), LoginProfile.ConnectionMethod.ToString("G"));

                tcpParameter = (ITCPParameter)sshLoginParameter.GetAdapter(typeof(ITCPParameter));
                tcpParameter.Destination = LoginProfile.Host;
                tcpParameter.Port = LoginProfile.Port;
            }

            //
            // ターミナル設定のパラメータをセットします。
            //
            terminalEmulatorService.TerminalEmulatorOptions.RightButtonAction =
                MouseButtonAction.Paste;
            _settings = terminalEmulatorService.CreateDefaultTerminalSettings(
                tcpParameter.Destination, null);
            _settings.BeginUpdate();
            _settings.TerminalType = (ConnectionParam.TerminalType)Enum.Parse(
                typeof(ConnectionParam.TerminalType), LoginProfile.TerminalType.ToString("G"));
            _settings.Encoding = LoginProfile.EncodingType;
            _settings.LocalEcho = LoginProfile.LocalEcho;
            _settings.TransmitNL = LoginProfile.TransmitNL;
            _settings.RenderProfile = LoginProfile.ExportRenderProfile();
            _settings.EndUpdate();
            ITerminalParameter param =
                (ITerminalParameter)tcpParameter.GetAdapter(typeof(ITerminalParameter));
            param.SetTerminalName(_settings.TerminalType.ToString("G").ToLower());

            //
            // 非同期接続開始処理を行います。
            //
            if (LoginProfile.ConnectionMethod == ConnectionParam.ConnectionMethod.Telnet)
            {
            #if DEBUG
                WriteLog("Telnet非同期接続を開始します。");
            #endif
                _connector = protocolService.AsyncTelnetConnect(this, tcpParameter);
            }
            else
            {
            #if DEBUG
                WriteLog("SSH非同期接続を開始します。");
            #endif
                _connector = protocolService.AsyncSSHConnect(this, sshLoginParameter);
            }
        }
コード例 #55
0
ファイル: SourceBox.cs プロジェクト: imarshall/Interpretator
 private void ColorLine(int index, LineState state)
 {
     int curbeg = m_tb.SelectionStart;
     int curlen = m_tb.SelectionLength;
     SelectLine(index);
     switch (state) {
         case LineState.ErrorLine:
             {
                 m_tb.SelectionColor = Color.Red;
                 break;
             }
         case LineState.CurrentLine:
             {
                 m_tb.SelectionFont = s_cfont;
                 break;
             }
         case LineState.NormalLine:
             {
                 m_tb.SelectionFont = s_nfont;
                 HighlightLine(index);
                 break;
             }
     }
     m_tb.SelectionStart = curbeg;
     m_tb.SelectionLength = curlen;
 }
コード例 #56
0
 void Init()
 {
     context_bound = false;
     i_stream      = null;
     o_stream      = null;
     prefix        = null;
     chunked       = false;
     ms            = new MemoryStream ();
     position      = 0;
     input_state   = InputState.RequestLine;
     line_state    = LineState.None;
     context       = new HttpListenerContext (this);
     s_timeout     = 90000; // 90k ms for first request, 15k ms from then on
 }
コード例 #57
0
 private void init ()
 {
   _context = new HttpListenerContext (this);
   _inputState = InputState.RequestLine;
   _inputStream = null;
   _lineState = LineState.None;
   _outputStream = null;
   _position = 0;
   _prefix = null;
   _requestBuffer = new MemoryStream ();
 }
コード例 #58
0
ファイル: DaxLineParser.cs プロジェクト: votrongdao/DaxStudio
 public DaxLineState(LineState lineState,int caretOffset, int startOffset, int endOffset, int startOfLineOffset)
 {
     _state = lineState;
     _caretOffset = caretOffset;
     _startOffset = startOffset;
     _endOffset = endOffset;
     _endState = Utils.LineState.NotSet;
     _startOfLineOffset = startOfLineOffset;
 }
コード例 #59
0
ファイル: HttpConnection.cs プロジェクト: rcruzs00/mono
		string ReadLine (byte [] buffer, int offset, int len, ref int used)
		{
			if (current_line == null)
				current_line = new StringBuilder (128);
			int last = offset + len;
			used = 0;
			for (int i = offset; i < last && line_state != LineState.LF; i++) {
				used++;
				byte b = buffer [i];
				if (b == 13) {
					line_state = LineState.CR;
				} else if (b == 10) {
					line_state = LineState.LF;
				} else {
					current_line.Append ((char) b);
				}
			}

			string result = null;
			if (line_state == LineState.LF) {
				line_state = LineState.None;
				result = current_line.ToString ();
				current_line.Length = 0;
			}

			return result;
		}
コード例 #60
0
        void Init()
        {
            if (ssl_stream != null)
            {
                //ssl_stream.AuthenticateAsServer(client_cert, true, (SslProtocols)ServicePointManager.SecurityProtocol, false);
            }

            context_bound = false;
            i_stream = null;
            o_stream = null;
            prefix = null;
            chunked = false;
            ms = new MemoryStream();
            position = 0;
            input_state = InputState.RequestLine;
            line_state = LineState.None;
            context = new HttpListenerContext(this, _logger);
        }