xio.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef VTXIO_H
  2. #define VTXIO_H
  3. #include <X11/Xlib.h>
  4. #include "vt.h"
  5. #include "dllist.h"
  6. typedef u32 lbits;
  7. #define ALL_LINES ((1ul << H) - 1)
  8. /* one xio per display */
  9. struct xio
  10. {
  11. struct dl_node node[1];
  12. int argc;
  13. char **argv;
  14. Display *dpy; /* display connection */
  15. int fd; /* the displays file descriptor */
  16. Atom xa_del_win; /* WM_DELETE_WINDOW atom */
  17. Atom xa_targets; /* TARGETS atom (selection) */
  18. Atom xa_timestamp; /* TIMESTAMP atom (selection) */
  19. Atom xa_text; /* TEXT atom (selection) */
  20. Atom xa_multiple; /* MULTIPLE atom (selection) */
  21. Window group_leader; /* unmapped window */
  22. int screen; /* DefaultScreen */
  23. int width, height; /* DisplayWidth/Height */
  24. int depth; /* DefaultDepth */
  25. Window root; /* DefaultRoot */
  26. Colormap cmap;
  27. int color[16]; /* 8 normal, 8 dim intensity */
  28. Pixmap font[2]; /* normal, dbl-height */
  29. Pixmap icon; /* icon pixmap */
  30. struct dl_head windows[1]; /* all windows on this display */
  31. };
  32. /* one vt_win per window */
  33. struct xio_win
  34. {
  35. struct dl_node node[1];
  36. struct xio *xio; /* display */
  37. Window win; /* the drawing window */
  38. Time tstamp; /* timestamp of last user event */
  39. GC gc; /* it's graphics context */
  40. u8 ch[H*W]; /* the page contents */
  41. lbits modified, hidden, lhidden; /* states for each line */
  42. lbits dheight, blink, concealed; /* attributes for each line */
  43. int fg, bg; /* current foreground/background */
  44. int blink_on; /* blinking on */
  45. int reveal; /* reveal concealed text */
  46. void (*handler)(void *data, struct vt_event *ev); /* event-handler */
  47. void *data; /* data for the event-handler */
  48. int curs_x, curs_y; /* cursor position */
  49. u8 title[32]; /* the user title */
  50. // selection support
  51. int sel_start_x, sel_start_y;
  52. Time sel_start_t;
  53. Time sel_set_t; /* time we got selection owner */
  54. int sel_x1, sel_y1, sel_x2, sel_y2; /* selected area */
  55. Pixmap sel_pixmap; /* for pixmap-selection requests */
  56. };
  57. struct xio *xio_open_dpy(char *dpy, int argc, char **argv);
  58. struct xio_win *xio_open_win(struct xio *xio, char *geom);
  59. void xio_close_win(struct xio_win *xw, int dpy_too);
  60. void xio_close_dpy(struct xio *xio);
  61. void xio_set_handler(struct xio_win *xw, void *handler, void *data);
  62. void xio_clear_win(struct xio_win *xw);
  63. void xio_put_line(struct xio_win *xw, int line, u8 *data);
  64. void xio_put_str(struct xio_win *xw, int line, u8 *c_str);
  65. int xio_get_line(struct xio_win *xw, int line, u8 *data);
  66. int xio_set_concealed(struct xio_win *xw, int on);
  67. void xio_update_win(struct xio_win *xw);
  68. void xio_fd_handler(int fd, void *handler, void *data);
  69. void xio_cancel_selection(struct xio_win *xw);
  70. void xio_query_selection(struct xio_win *xw);
  71. void xio_set_selection(struct xio_win *xw, int x1, int y1, int x2, int y2);
  72. void xio_set_cursor(struct xio_win *xw, int x, int y);
  73. void xio_event_loop(void);
  74. void xio_title(struct xio_win *xw, char *title);
  75. #endif