261017.6 · 3faa3505d894f32ad10f816c943a99689d34535d
screen: add GetCursor method (#1199)
reading declarations
@@ -106,6 +106,10 @@ type Screen interface { // and the terminal supports doing so. SetCursorStyle(CursorStyle, ...color.Color) + // GetCursor returns the last cursor's location as x,y coordinates.+ // If the cursor is hidden, -1, -1 are returned+ GetCursor() (x, y int)+ // Size returns the screen size as width, height. This changes in // response to a call to Clear or Flush. Size() (width, height int)@@ -343,6 +347,7 @@ type screenImpl interface { ShowCursor(x int, y int) HideCursor() SetCursor(CursorStyle, color.Color)+ GetCursor() (x, y int) Size() (width, height int) EnableMouse(...MouseFlags) DisableMouse()
@@ -963,8 +963,13 @@ func (t *tScreen) HideCursor() { t.ShowCursor(-1, -1) } -func (t *tScreen) showCursor() {+func (t *tScreen) GetCursor() (x, y int) {+ t.Lock()+ defer t.Unlock()+ return t.cursorx, t.cursory+} +func (t *tScreen) showCursor() { x, y := t.cursorx, t.cursory w, h := t.cells.Size() if x < 0 || y < 0 || x >= w || y >= h {