public void SetCursorPosition(int x, int y) { Log.DebugFormat("SetCursorScreenPosition: [{0},{1}]", x, y); if (_lastScreenCursorPoint != null && y != _lastScreenCursorPoint.Y) { _currentBuffer.AppendLine(); } _lastScreenCursorPoint = new ZPoint(x, y); }
/* * os_read_key * * Read a single character from the keyboard (or a mouse click) and * return it. Input aborts after timeout/10 seconds. * */ public static zword read_key(int timeout, bool cursor) { _screen.RefreshScreen(); _screen.SetInputMode(true, true); if (_setCursorPositionCalled == false) { set_cursor(_newCursorPosition.Y, _newCursorPosition.X); } ZPoint p = _screen.GetCursorPosition(); try { //#if SILVERLIGHT // var sw = new WiredPrairie.Silverlight.Stopwatch(); //#else // System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); //#endif // sw.Start(); while (true) { do { if (main.abort_game_loop == true) { return CharCodes.ZC_RETURN; } lock (entries) { if (entries.Count > 0) break; //if (sw.Elapsed.TotalSeconds > timeout / 10 && timeout > 0) // return CharCodes.ZC_TIME_OUT; } //System.Threading.Thread.Sleep(10); } while (true); lock (entries) { _setCursorPositionCalled = false; zword c = entries.Dequeue(); int width = _screen.GetStringWidth(((char)c).ToString(), new CharDisplayInfo(ZFont.FIXED_WIDTH_FONT, ZStyles.NORMAL_STYLE, 1, 1)); // _screen.SetCursorPosition(p.X + width, p.Y); _newCursorPosition = new ZPoint(p.X + width, p.Y); return c; } } } finally { _screen.SetInputMode(false, false); } }
public ZPoint GetCursorPosition() { ZPoint p = null; Dispatcher.Invoke(new Action(delegate { p = new ZPoint(_cursorX, _cursorY); })); return p; }