screen.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Text screen: a grid of character cells (char + VGA attribute) plus a cursor.
  2. Pure cell-buffer logic — no framebuffer access. The window manager renders
  3. these screens into windows. */
  4. #ifndef SCREEN_H
  5. #define SCREEN_H
  6. #define SCREEN_COLS 64
  7. #define SCREEN_ROWS 32
  8. struct text_screen {
  9. unsigned short cells[SCREEN_COLS * SCREEN_ROWS];
  10. unsigned int cols;
  11. unsigned int rows;
  12. unsigned int cursor; /* linear index 0..cols*rows-1 */
  13. unsigned int cursor_attr;
  14. unsigned int cursor_visible;
  15. /* Pending damage: the inclusive cell block [dmg_col0..dmg_col1] x
  16. [dmg_row0..dmg_row1] that changed since the last render, so the WM
  17. repaints a keystroke's cell instead of the whole window content.
  18. Only the helpers below update it -- screen_damage_block() reports it
  19. and screen_clear_damage() drops it after rendering. */
  20. int dirty; /* content changed since last WM render */
  21. unsigned int dmg_col0, dmg_col1;
  22. unsigned int dmg_row0, dmg_row1;
  23. unsigned int damage_seq; /* bumped on every damage mark (WM ACK) */
  24. int scrolled; /* one-shot, replaces io_did_scroll */
  25. };
  26. void screen_init(struct text_screen *s);
  27. void screen_clear(struct text_screen *s);
  28. void screen_putchar(struct text_screen *s, char c);
  29. void screen_putstr(struct text_screen *s, const char *str);
  30. void screen_puthex(struct text_screen *s, unsigned int n);
  31. unsigned int screen_get_cursor(const struct text_screen *s);
  32. void screen_set_cursor(struct text_screen *s, unsigned int pos);
  33. void screen_put_at(struct text_screen *s, unsigned int pos, unsigned short value);
  34. int screen_did_scroll(struct text_screen *s);
  35. /* Pending damage as a cell block: returns 1 and fills col0, row0, cols and
  36. rows when something changed, 0 when the screen is clean. */
  37. int screen_damage_block(const struct text_screen *s, unsigned int *col0,
  38. unsigned int *row0, unsigned int *cols, unsigned int *rows);
  39. void screen_clear_damage(struct text_screen *s);
  40. /* Mark the cell the cursor sits in (a blink or a cursor move only changes
  41. that cell, but both the old and the new position must be repainted). */
  42. void screen_damage_cursor(struct text_screen *s);
  43. #endif