private void Submit(object sender, SubmitEventArgs e) { var h = waitHandle; if (h != null) { line = e.Text; h.Set(); } }
private void OnKeyDown(object sender, KeyEventArgs e) { var n = NoMod(e); if (n && e.KeyCode == Keys.Left && InPos()) sci.Keyboard.ExecuteCommand(SciCommand.CharLeft); else if (n && e.KeyCode == Keys.Right) sci.Keyboard.ExecuteCommand(SciCommand.CharRight); else if (n && e.KeyCode == Keys.Up && InPosLine()) ReplaceIf(history.Previous()); else if (n && e.KeyCode == Keys.Down && InPosLine()) ReplaceIf(history.Next()); else if (n && e.KeyCode == Keys.Insert) sci.Overtype = !sci.Overtype; else if (n && e.KeyCode == Keys.Return) { var s = sci.GetSelection(); if (s.Start != s.End) { sci.Copy(); sci.ClearSelections(); sci.CaretPosition = sci.GetTextLength(); } else { var line = GetLine(sci.CurrentLine); history.Add(line.Trim('\0')); var ev = new SubmitEventArgs(line); PrintLine(); OnSubmit(ev); } } else if (n && e.KeyCode == Keys.Back && InPos()) sci.Keyboard.ExecuteCommand(SciCommand.DeleteBack); else if (n && e.KeyCode == Keys.Delete && InPosRelax()) sci.ReplaceText(sci.CurrentPosition, sci.CurrentPosition + 1, String.Empty); else if (n && e.KeyCode == Keys.Home && InPos()) sci.CaretPosition = sci.GetPositionFromLine(sci.LineCount - 1) + lastLen; else if (n && (sci.CurrentLine != sci.LineCount - 1 || sci.GetColumnFromPosition(sci.CurrentPosition) < lastLen)) e.SuppressKeyPress = true; else if (n && e.KeyCode == Keys.Escape) Replace(String.Empty); else if (e.Shift && !e.Alt && !e.Control && e.KeyCode == Keys.Left && InPos()) sci.Keyboard.ExecuteCommand(SciCommand.CharLeftExtend); else if (e.Shift && !e.Alt && !e.Control && e.KeyCode == Keys.Right) sci.Keyboard.ExecuteCommand(SciCommand.CharRightExtend); else if (e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.Right) sci.WordRight(); else if (e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.Left && sci.GetColumnFromPosition(sci.CurrentPosition) > lastLen) sci.WordLeft(); }
protected virtual void OnSubmit(SubmitEventArgs e) { var h = Submit; if (h != null) h(this, e); }