aboutsummaryrefslogtreecommitdiff
path: root/vietnamese/vnterm/files/patch-input.c
blob: ad6a731c662d826a8fe787095a339112734f3117 (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
--- input.c.orig	Mon Aug 21 08:47:47 2000
+++ input.c	Sat Feb 10 05:32:41 2001
@@ -155,7 +155,40 @@
 		      unparseputc (033, pty);  /* escape */
 		}
 		while (nbytes-- > 0)
+#ifndef NO_VIETNAMESE
+		{
+#include <vnkeys.h>
+			unsigned char       outchars[5];
+			register int        i;
+			int                 nchars;
+			extern Vk_Fsm       vn_keyboard_id;
+			extern Boolean      vn_filter_keyboard;
+
+			if (!vn_filter_keyboard) { /* don't filter */
+				unparseputc(*string++, pty);
+			} else {
+
+				Vk_State        state;
+				static Vk_State lastState;
+
+				/* feed in the keypresses */
+				state = vk_step(vn_keyboard_id, *string++, outchars, &nchars);
+				if (lastState != state) {
+					lastState = state;
+					_Set_Vn_Title(state);
+				}
+
+				/* send out the Vietnamese translation */
+				for (i = 0; i < nchars; i++) {
+					unparseputc(outchars[i], pty);
+				}
+			}
+		}
+#else /* NO_VIETNAMESE */
+		{
 			unparseputc(*string++, pty);
+		}
+#endif /* NO_VIETNAMESE */
 		key = TRUE;
 	}
 	if(key && !screen->TekEmu)
@@ -165,6 +198,47 @@
 #endif
 	return;
 }
+
+#ifndef NO_VIETNAMESE
+_Set_Vn_Title(state)
+    int               state;
+{
+    int               nochange = 0;
+    char      title[80], icon[80];
+    extern Boolean    vn_filter_keyboard;
+
+    strcpy(title, "vnterm-");
+    strcpy(icon, title);
+    if (!vn_filter_keyboard){
+      strcat(title, "No Filtering");
+      strcat(icon, "off");
+    } else {
+      switch(state) {
+      case VK_ST_VIETNAMESE:
+          strcat(title, "Vietnamese");
+          strcat(icon, "V");
+          break;
+      case VK_ST_ENGLISH:
+          strcat(title, "English");
+          strcat(icon, "E");
+          break;
+      case VK_ST_LITERAL:
+          strcat(title, "Literal");
+          strcat(icon, "L");
+          break;
+      default:
+          nochange = 1;
+          break;
+      }
+    }
+
+    if (!nochange) {
+      Changetitle(title);
+      Changename(icon);
+    }
+}
+#endif /* NO_VIETNAMESE */
+
 
 StringInput (screen, string, nbytes)
     register TScreen	*screen;