about summary refs log tree commit diff stats
path: root/input_win.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-02-26 20:09:39 +0000
committerJames Booth <boothj5@gmail.com>2012-02-26 20:09:39 +0000
commit76c6e49dc78d8f55b68c26ef577e25af514d1005 (patch)
tree317383d824e15dac77ce282733e09bba162e199d /input_win.c
parent61b2a0803b6e8d7d901b63b8c9e22d117ea776d1 (diff)
downloadprofani-tty-76c6e49dc78d8f55b68c26ef577e25af514d1005.tar.gz
Allow left/right movement in input window
Diffstat (limited to 'input_win.c')
-rw-r--r--input_win.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/input_win.c b/input_win.c
index 564c76ca..80db4d74 100644
--- a/input_win.c
+++ b/input_win.c
@@ -59,7 +59,7 @@ void inp_block(void)
     wtimeout(inp_win, -1);
 }
 
-void inp_poll_char(int *ch, char command[], int *size)
+void inp_poll_char(int *ch, char *command, int *size)
 {
     int inp_y = 0;
     int inp_x = 0;
@@ -80,11 +80,29 @@ void inp_poll_char(int *ch, char command[], int *size)
             wdelch(inp_win);
             (*size)--;
         }
-    }
 
-    // else if not error or newline, show it and store it
-    else if (*ch != ERR &&
+    // left arrow
+    } else if (*ch == KEY_LEFT) {
+        getyx(inp_win, inp_y, inp_x);
+        if (inp_x > 1) {
+            wmove(inp_win, inp_y, inp_x-1);
+        }
+
+    // right arrow
+    } else if (*ch == KEY_RIGHT) {
+        getyx(inp_win, inp_y, inp_x);
+        if (inp_x < *size + 1) {
+            wmove(inp_win, inp_y, inp_x+1);
+        }
+
+    // else if not error, newline or special key, 
+    // show it and store it
+    } else if (*ch != ERR &&
              *ch != '\n' &&
+             *ch != KEY_LEFT &&
+             *ch != KEY_RIGHT &&
+             *ch != KEY_UP &&
+             *ch != KEY_DOWN &&
              *ch != KEY_F(1) &&
              *ch != KEY_F(2) &&
              *ch != KEY_F(3) &&
'>^
386641c0 ^
3b81d748 ^


9a524793 ^





3b81d748 ^


a77643c6 ^
3b81d748 ^
5f8d065d ^
a7088a2f ^
30b2fcf8 ^


784e17d4 ^
e2e0f5cc ^

05c2f62a ^
e2e0f5cc ^

784e17d4 ^
e2e0f5cc ^



784e17d4 ^

e2e0f5cc ^

784e17d4 ^
a77643c6 ^







30b2fcf8 ^

e2e0f5cc ^

e2a0b440 ^
e2e0f5cc ^
e2a0b440 ^

e2e0f5cc ^
784e17d4 ^
e2e0f5cc ^
ffa80ee2 ^

784e17d4 ^
9a524793 ^
32241605 ^
9a524793 ^
3b81d748 ^
9a524793 ^

32241605 ^
ac8b37f9 ^
5f8d065d ^



2c64c52e ^
3b1686b6 ^
31a5c8f6 ^
3b81d748 ^
47287fbf ^

f7746778 ^
47287fbf ^

31a5c8f6 ^
32241605 ^
3b81d748 ^
49a99383 ^





517a01c9 ^
57c3617e ^
49a99383 ^


b663b579 ^

517a01c9 ^
3b81d748 ^


49a99383 ^
517a01c9 ^
9a524793 ^
9f589350 ^
9a524793 ^


5268b0e1 ^




6e1eeeeb ^
9a524793 ^
6e1eeeeb ^
e3349a16 ^
2c9aa92f ^
9586db16 ^





797a46d5 ^
9a524793 ^
797a46d5 ^
7817fdb2 ^









e420279a ^
9586db16 ^









2c64c52e ^
e9e06638 ^
9a524793 ^
b338e82e ^

396a7ef6 ^
7ce83f9b ^
b338e82e ^
e2e0f5cc ^
07a1a299 ^
3b12aab3 ^
9a83eac4 ^



3b12aab3 ^


e786968a ^

b338e82e ^
9a524793 ^
6e1eeeeb ^
9a524793 ^
4f33ff22 ^
9586db16 ^
4f33ff22 ^
b8f5ef8d ^
71e4f381 ^







b8f5ef8d ^
3b81d748 ^


bb1a1ac2 ^
9a524793 ^
bb1a1ac2 ^
9a524793 ^
a7088a2f ^
784e17d4 ^






97f4d3ed ^
784e17d4 ^

784e17d4 ^


2136ad26 ^
784e17d4 ^


6cd12b18 ^



9a524793 ^
6cd12b18 ^

9a524793 ^
6cd12b18 ^
2c64c52e ^
6cd12b18 ^
0167d5c5 ^


6cd12b18 ^


a94ac8f0 ^


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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248