cursor.go 361 B

1234567891011121314151617181920212223242526272829303132
  1. package terminalparser
  2. type Cursor struct {
  3. X, Y int
  4. }
  5. func (c *Cursor) MoveHome() {
  6. c.X = 0
  7. c.Y = 0
  8. }
  9. func (c *Cursor) MoveUp(ps int) {
  10. c.Y -= ps
  11. if c.Y < 0 {
  12. c.Y = 0
  13. }
  14. }
  15. func (c *Cursor) MoveDown(ps int) {
  16. c.Y += ps
  17. }
  18. func (c *Cursor) MoveRight(ps int) {
  19. c.X += ps
  20. }
  21. func (c *Cursor) MoveLeft(ps int) {
  22. c.X -= ps
  23. if c.X < 0 {
  24. c.X = 0
  25. }
  26. }