many many updates
[apps/madtty.git] / madtty / madtty.h
index e8123db..7424429 100644 (file)
 #ifndef MADTTY_MADTTY_H
 #define MADTTY_MADTTY_H
 
-#ifdef USE_NCURSES
-#include <ncurses.h>
-#else
+#include <ncursesw/curses.h>
 #include <stdbool.h>
-#endif
+#include <stdint.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <stdlib.h>
 
 /* Color codes: 0 = black, 1 = red, 2 = green, 3 = yellow, 4 = blue,
  *              5 = magenta, 6 = cyan, 7 = white. 
 
 /* Represents each of the text cells in the terminal screen */
 typedef struct RoteCell_ {
-    unsigned int ch;     /* >= 32, that is, control characters are not
-                          * allowed to be on the virtual screen */
-
-    unsigned char attr;  /* a color attribute, as described previously */
+    char s[4];
+    char len;
+    uint8_t attr;  /* a color attribute, as described previously */
 } RoteCell;
 
 /* Declaration of opaque rote_Term_Private structure */
@@ -114,7 +111,7 @@ typedef struct RoteTerm_ {
 
     int crow, ccol;              /* cursor coordinates. READ-ONLY. */
 
-    unsigned char curattr;       /* current attribute, that is the attribute
+    uint8_t curattr;             /* current attribute, that is the attribute
                                   * that will be used for newly inserted
                                   * characters */
 
@@ -124,12 +121,12 @@ typedef struct RoteTerm_ {
 
     RoteTermPrivate *pd;         /* private state data */
 
-    bool insert;                 /* insert or replace mode */
+    unsigned insert : 1;         /* insert or replace mode */
 
     /* --- dirtiness flags: the following flags will be raised when the
      * corresponding items are modified. They can only be unset by YOU
      * (when, for example, you redraw the term or something) --- */
-    bool curpos_dirty;           /* whether cursor location has changed */
+    unsigned curpos_dirty : 1;   /* whether cursor location has changed */
     bool *line_dirty;            /* whether each row is dirty  */
     /* --- end dirtiness flags */
 } RoteTerm;
@@ -170,12 +167,6 @@ void rote_vt_destroy(RoteTerm *rt);
  */
 pid_t rote_vt_forkpty(RoteTerm *rt, const char *path, const char *argv[]);
 
-/* Disconnects the RoteTerm from its forked child process. This function
- * should be called when the child process dies or something of the sort.
- * It is not strictly necessary to call this function, but it is
- * certainly tidy. */
-void rote_vt_forsake_child(RoteTerm *rt);
-
 int rote_vt_read(RoteTerm *rt, char *buf, int buflen);
 int rote_vt_write(RoteTerm *rt, const char *data, int length);
 
@@ -187,28 +178,8 @@ int rote_vt_write(RoteTerm *rt, const char *data, int length);
  * to use rote_vt_write.
  */
 int rote_vt_inject(RoteTerm *rt, const char *data, int length);
+void rote_vt_draw(RoteTerm *rt, WINDOW *win, int startrow, int startcol);
 
-#ifdef USE_NCURSES
-/* Paints the virtual terminal screen on the given window, putting
- * the top-left corner at the given position. The cur_set_attr
- * function must set the curses attributes given a Rote attribute
- * byte. It should, for example, do wattrset(win, COLOR_PAIR(n)) where
- * n is the colorpair appropriate for the attribute and such.
- *
- * If you pass NULL for cur_set_attr, the default implementation will
- * set the color pair given by (bg * 8 + 7 - fg), which seems to be
- * a common mapping, and the bold and blink attributes will be mapped 
- * to A_BOLD and A_BLINK.
- *
- * At the end of the function, the cursor will be left where the virtual 
- * cursor of the terminal is supposed to be.
- *
- * This function does not call wrefresh(win); you have to do that yourself.
- */
-void rote_vt_draw(RoteTerm *rt, WINDOW *win, int startrow, int startcol,
-                  void (*cur_set_attr)(WINDOW *win, unsigned char attr));
-
-#endif
 /* Indicates to the terminal that the given key has been pressed.
  * This will cause the terminal to rote_vt_write() the appropriate
  * escape sequence for that key (that is, the escape sequence
@@ -217,15 +188,4 @@ void rote_vt_draw(RoteTerm *rt, WINDOW *win, int startrow, int startcol,
  * when you use keypad(somewin, TRUE) (see man page). */
 void rote_vt_keypress(RoteTerm *rt, int keycode);
 
-/* Takes a snapshot of the current contents of the terminal and
- * saves them to a dynamically allocated buffer. Returns a pointer
- * to the newly created buffer, which you can pass to
- * rote_vt_restore_snapshot. Caller is responsible for free()'ing when
- * the snapshot is no longer needed. */
-void *rote_vt_take_snapshot(RoteTerm *rt);
-
-/* Restores a snapshot previously taken with rote_vt_take_snapshot.
- * This function does NOT free() the passed buffer */
-void rote_vt_restore_snapshot(RoteTerm *rt, void *snapbuf);
-
 #endif /* MADTTY_MADTTY_H */