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
|
$NetBSD: patch-ah,v 1.3 2000/07/28 20:30:11 jlam Exp $
--- textbox.c.orig Thu Aug 17 19:07:40 1995
+++ textbox.c Fri Jul 28 15:30:22 2000
@@ -45,6 +45,11 @@
char search_term[MAX_LEN + 1], *tempptr, *found;
WINDOW *dialog, *text;
+ if (height < 0 || width < 0) {
+ fprintf(stderr, "\nAutosizing is impossible in dialog_textbox().\n");
+ return(-1);
+ }
+
search_term[0] = '\0'; /* no search term entered yet */
/* Open input file for reading */
@@ -634,7 +639,7 @@
static int
get_search_term (WINDOW * win, char *search_term, int height, int width)
{
- int i, x, y, input_x = 0, scroll = 0, key = 0;
+ int i, x, y, input_x = 0, d_scroll = 0, key = 0;
int box_height = 3, box_width = 30;
x = (width - box_width) / 2;
@@ -663,18 +668,18 @@
break;
case KEY_BACKSPACE:
case 127:
- if (input_x || scroll) {
+ if (input_x || d_scroll) {
if (!input_x) {
- scroll = scroll < box_width - 1 ?
- 0 : scroll - (box_width - 1);
+ d_scroll = d_scroll < box_width - 1 ?
+ 0 : d_scroll - (box_width - 1);
wmove (win, y + 1, x + 1);
for (i = 0; i < box_width; i++)
- waddch (win, search_term[scroll + input_x + i] ?
- search_term[scroll + input_x + i] : ' ');
- input_x = strlen (search_term) - scroll;
+ waddch (win, search_term[d_scroll + input_x + i] ?
+ search_term[d_scroll + input_x + i] : ' ');
+ input_x = strlen (search_term) - d_scroll;
} else
input_x--;
- search_term[scroll + input_x] = '\0';
+ search_term[d_scroll + input_x] = '\0';
wmove (win, y + 1, input_x + x + 1);
waddch (win, ' ');
wmove (win, y + 1, input_x + x + 1);
@@ -685,14 +690,14 @@
break;
default:
if (isprint (key))
- if (scroll + input_x < MAX_LEN) {
- search_term[scroll + input_x] = key;
- search_term[scroll + input_x + 1] = '\0';
+ if (d_scroll + input_x < MAX_LEN) {
+ search_term[d_scroll + input_x] = key;
+ search_term[d_scroll + input_x + 1] = '\0';
if (input_x == box_width - 1) {
- scroll++;
+ d_scroll++;
wmove (win, y + 1, x + 1);
for (i = 0; i < box_width - 1; i++)
- waddch (win, search_term[scroll + i]);
+ waddch (win, search_term[d_scroll + i]);
} else {
wmove (win, y + 1, input_x++ + x + 1);
waddch (win, key);
|