summaryrefslogtreecommitdiff
path: root/news/husky-msged/files/patch-curses.c
blob: 1908ac66734750efff06c4e25057e431fcdcc1dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
--- curses.c.orig	Wed Jan 29 00:48:13 2003
+++ curses.c	Wed Jan 29 01:37:29 2003
@@ -22,6 +22,7 @@
 #include "winsys.h"
 #include "unused.h"
 #include "keys.h"
+#include "readtc.h"
 #include "specch.h"
 
 int color;
@@ -40,6 +41,7 @@
     0
 };
 
+static int tcflags = 0;         /* what we want to extract from termcap */
 
 #define EBUFSZ 100
 static EVT EVent[EBUFSZ];	/* event circular queue */
@@ -436,6 +438,8 @@
     Key_A_5, Key_A_6, Key_A_7, Key_A_8, Key_A_9
 };
 
+void TTSendMsg(int msg, int x, int y, int msgtype);
+
 unsigned int TTGetKey(void)
 {
     int ch;
@@ -443,6 +447,11 @@
     ch = getch();
     switch (ch)
     {
+    case KEY_RESIZE:
+        term.NRow = getmaxy(stdscr);
+	term.NCol = getmaxx(stdscr);
+        TTSendMsg(1, 0, 0, WND_WM_RESIZE);
+	return -1;
     case KEY_LEFT:
         return Key_Lft;
     case KEY_RIGHT:
@@ -566,6 +575,7 @@
         case '0':
             return Key_F10;
         }
+	break;
     }
 
     if (ch >= 127)    /* Treat special characters */
@@ -611,7 +621,7 @@
     return ch;
 }
 
-void TTSendMsg(unsigned int msg, int x, int y, unsigned int msgtype)
+void TTSendMsg(int msg, int x, int y, int msgtype)
 {
     if (((ebufin + 1) % EBUFSZ) != ebufout)
     {
@@ -633,6 +643,7 @@
     meta(stdscr, TRUE);
     intrflush(stdscr, FALSE);
     raw();
+    query_termcap(tcflags);
     return 0;
 }
 
@@ -660,30 +671,47 @@
     return 0;
 }
 
+static void
+collect_events(void)
+{
+    int ch = TTGetKey();
+    if (ch < 0)
+	return;
+
+    TTSendMsg(ch, 0, 0, WND_WM_CHAR);
+}
+
 int TTGetMsg(EVT * e)
 {
-    e->msg = TTGetKey();
-    e->x = 0;
-    e->y = 0;
-    e->msgtype = WND_WM_CHAR;
+    while (ebufin == ebufout)
+	collect_events();
+
+    e->msg = EVent[ebufout].msg;
+    e->x = EVent[ebufout].x;
+    e->y = EVent[ebufout].y;
+    e->msgtype = EVent[ebufout].msgtype;
     e->id = 0;
+    ebufout = (ebufout + 1) % EBUFSZ;
     return e->msg;
 }
 
 int TTPeekQue(void)
 {
-    return kbhit();
+    if (kbhit())
+	collect_events();
+    return ebufin != ebufout;
 }
 
 void TTClearQue(void)
 {
-    while (TTPeekQue())
-        TTGetKey();
+    ebufin = ebufout;
 }
 
 int TTGetChr(void)
 {
-    return TTGetKey();
+    EVT e;
+    TTGetMsg(&e);
+    return e.msg;
 }
 
 static char ansi2curses[8] = {
@@ -754,6 +782,18 @@
         allowed_special_characters =
             (unsigned char *) malloc(l = (strlen(value) + 1));
         memcpy(allowed_special_characters, value, l);
+    }
+    else if (!strcmp(keyword,"pseudographics"))
+    {
+        if (atoi(value))
+        {
+            tcflags |= QUERY_ALTCHARSET;
+        }
+        else
+        {
+            tcflags &= ~QUERY_ALTCHARSET;
+        }
+        query_termcap(tcflags);
     }
     else
     {