public bool CheckOutput(OutputCollectingReader r) { bool outputComplete = false; if (r.state == OutputState.Executing) { int startIndex = r.textReceived.IndexOf(Networking.StartToken + "\r"); if (startIndex != -1) { // skip past the start token and the "\r" that should be after it r.textReceived = r.textReceived.Substring(startIndex + Networking.StartToken.Length + 2); r.state = OutputState.Busy; } } if (r.state == OutputState.Busy) { int endIndex = r.textReceived.IndexOf(Networking.EndToken); if (endIndex != -1) { // remove the end token and everything after it r.textReceived = r.textReceived.Substring(0, endIndex); r.state = OutputState.Finished; } } // if we're ready to finish, send the received text back to whoever // supplied the callback function if (r.state == OutputState.Finished && !r.finished) { if (r.textReceived != "") { lock (_locker) { sb.Clear(); byte[] bytes = Encoding.UTF8.GetBytes(r.textReceived); vt.Input(bytes); r.finalOutput = sb.ToString(); } if (r.callback != null) { FireAndForgetMethods.FireAndForget <string>(r.callback, r.finalOutput); //r.callback(r.finalOutput); } } r.finished = true; m_readers.Remove(r); outputComplete = true; } return(outputComplete); }
private void Input(String _input) { byte[] data = new byte[_input.Length]; int i = 0; foreach (char c in _input) { data[i] = (byte)c; i++; } m_vt100.Input(data); }
private void Load() { _screen = new DynamicScreen((ClientSize.Width - _lineNumberWidth - (_border * 2)) / _charSize.Width); _screen.TabSpaces = 4; _vt100.Encoding = Encoding.UTF8; _vt100.Subscribe(_screen); _vt100.Input(System.IO.File.ReadAllBytes(File)); _screen.CursorPosition = new Point(0, 0); Text = $" - {File} ({_screen.Width}x{_screen.Height})"; Invalidate(); }