projects
/
apps
/
madtty.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add a way to associate custom data with a madtty term.
[apps/madtty.git]
/
madtty
/
madtty.c
diff --git
a/madtty/madtty.c
b/madtty/madtty.c
index
4bb95f7
..
c35959a
100644
(file)
--- a/
madtty/madtty.c
+++ b/
madtty/madtty.c
@@
-37,7
+37,7
@@
# include <pty.h>
#elif defined(__FreeBSD__)
# include <libutil.h>
# include <pty.h>
#elif defined(__FreeBSD__)
# include <libutil.h>
-#elif defined(__OpenBSD__)
+#elif defined(__OpenBSD__)
|| defined(__NetBSD__)
# include <util.h>
#endif
#include "madtty.h"
# include <util.h>
#endif
#include "madtty.h"
@@
-106,6
+106,8
@@
struct madtty_t {
char rbuf[BUFSIZ];
char ebuf[BUFSIZ];
int rlen, elen;
char rbuf[BUFSIZ];
char ebuf[BUFSIZ];
int rlen, elen;
+ madtty_handler_t handler;
+ void *data;
};
typedef struct t_row_t {
};
typedef struct t_row_t {
@@
-597,11
+599,17
@@
static void es_interpret_csi(madtty_t *t)
static void try_interpret_escape_seq(madtty_t *t)
{
char lastchar = t->ebuf[t->elen-1];
static void try_interpret_escape_seq(madtty_t *t)
{
char lastchar = t->ebuf[t->elen-1];
-
+ if(!*t->ebuf)
+ return;
+ if(t->handler){
+ switch((*(t->handler))(t, t->ebuf)){
+ case MADTTY_HANDLER_OK:
+ goto cancel;
+ case MADTTY_HANDLER_NOTYET:
+ return;
+ }
+ }
switch (*t->ebuf) {
switch (*t->ebuf) {
- case '\0':
- return;
-
case 'M':
interpret_csi_SR(t);
cancel_escape_sequence(t);
case 'M':
interpret_csi_SR(t);
cancel_escape_sequence(t);
@@
-1083,3
+1091,18
@@
int madtty_color_pair(int fg, int bg)
bg = COLOR_BLACK;
return COLOR_PAIR((7 - fg) * 8 + bg);
}
bg = COLOR_BLACK;
return COLOR_PAIR((7 - fg) * 8 + bg);
}
+
+void madtty_set_handler(madtty_t *t, madtty_handler_t handler)
+{
+ t->handler = handler;
+}
+
+void madtty_set_data(madtty_t *t, void *data)
+{
+ t->data = data;
+}
+
+void *madtty_get_data(madtty_t *t)
+{
+ return t->data;
+}