public CConsoleFilteredDelegate(CConsoleView consoleView) { m_consoleView = consoleView; m_oldConsoleEntriesHeadIndex = Entries.HeadIndex; m_filteredIndices = new CCycleArray <int>(consoleView.Entries.Capacity); }
private void CreateUI() { this.AutoresizeMask = CViewAutoresizing.FlexibleWidth | CViewAutoresizing.FlexibleHeight; CToolBar toolbar = new CToolBar(this.Width); toolbar.Width = this.Width; toolbar.AddButton("Clear", delegate(CButton button) { Terminal.Clear(); }); // copy to clipboard toolbar.AddButton("Copy", delegate(CButton button) { string text = GetText(); CEditor.CopyToClipboard(text); }); // save to file toolbar.AddButton("Save", delegate(CButton button) { string title = "Console log"; string directory = CFileUtils.DataPath; string defaultName = string.Format("console"); string filename = CEditor.SaveFilePanel(title, directory, defaultName, "log"); if (!string.IsNullOrEmpty(filename)) { string text = GetText(); CFileUtils.Write(filename, text); } }); m_infoLabel = toolbar.AddLabel(""); toolbar.AddFlexibleSpace(); AddSubview(toolbar); m_commandField = new CTextField(); m_commandField.Width = Width; AddSubview(m_commandField); m_commandField.AlignX(CView.AlignCenter); m_commandField.AlignBottom(0); m_commandField.AutoresizeMask = CViewAutoresizing.FlexibleTopMargin | CViewAutoresizing.FlexibleWidth; m_commandField.TextKeyDelegate = delegate(CTextField tf, KeyCode code, bool pressed) { if (pressed) { switch (code) { case KeyCode.Return: case KeyCode.KeypadEnter: { string commandLine = tf.Text.Trim(); if (commandLine.Length > 0) { HistoryPush(commandLine); ExecCommand(commandLine); } tf.Text = ""; HistoryReset(); return(true); } case KeyCode.Tab: { string line = Terminal.DoAutoComplete(tf.Text, tf.CaretPos, IsDoubleTab()); if (line != null) { tf.Text = line; } m_lastTabTimestamp = Time.realtimeSinceStartup; return(true); } case KeyCode.Escape: { tf.Text = ""; HistoryReset(); return(true); } case KeyCode.C: { if (tf.IsCtrlPressed) { tf.Text = ""; HistoryReset(); return(true); } break; } case KeyCode.K: { if (tf.IsCtrlPressed) { Terminal.Clear(); return(true); } break; } case KeyCode.DownArrow: { if (HistoryNext(tf)) { return(true); } if (m_lastUserInput != null) { tf.Text = m_lastUserInput; HistoryReset(); return(true); } return(true); } case KeyCode.UpArrow: { // keep user input to restore it if (m_lastUserInput == null) { m_lastUserInput = tf.Text; } if (HistoryPrev(tf)) { return(true); } return(true); } } } return(false); }; m_commandField.TextChangedDelegate = delegate(CTextField field) { HistoryReset(); }; m_consoleView = new CConsoleView(Terminal, m_commandField.Width, this.Height - (toolbar.Height + m_commandField.Height)); m_consoleView.Y = toolbar.Bottom; m_consoleView.IsScrollLocked = true; m_consoleView.AutoresizeMask = CViewAutoresizing.FlexibleWidth | CViewAutoresizing.FlexibleHeight; AddSubview(m_consoleView); m_lastUserInput = null; }