1 #include "allincludes.h"
2 
3 /* Add a string to the string list of the scrolling window.
4  */
5  void
AddToScrolling(win,color,str,len)6 AddToScrolling(win, color, str, len)
7     struct window *win;
8     W_Color color;
9     char   *str;
10     int     len;
11 {
12     char   *newstring;
13     char  **p = & (win->data);
14     struct stringList **strings = (struct stringList **)p ;
15     int count = 0;
16 
17     while ((*strings) != NULL) {
18 	count++;
19 	strings = &((*strings)->next);
20     }
21     (*strings) = (struct stringList *) malloc(sizeof(struct stringList));
22     (*strings)->next = NULL;
23     (*strings)->color = color;
24     newstring = (char *) malloc((unsigned)(len + 1));
25     strncpy(newstring, str, (unsigned)len);
26     newstring[len] = 0;
27     (*strings)->string = newstring;
28     if (count >= 100) {		/* Arbitrary large size. */
29 	struct stringList *temp;
30 
31 	temp = (struct stringList *) win->data;
32 	free(temp->string);
33 	temp = temp->next;
34 	free((char *) win->data);
35 	win->data = (char *) temp;
36     }
37 }
38 
39  void
redrawScrolling(win)40 redrawScrolling(win)
41     struct window *win;
42 {
43     int     count;
44     struct stringList *list;
45     int     y;
46 
47 #ifdef BUFFERING
48     if(win->isbuffered) {
49       W_DisplayBuffer(W_Window2Void(win));
50       return;
51     }
52 #endif /*BUFFERING [BDyess]*/
53 
54     XClearWindow(W_Display, win->window);
55     count = 0;
56     list = (struct stringList *) win->data;
57     while (list != NULL) {
58 	list = list->next;
59 	count++;
60     }
61     list = (struct stringList *) win->data;
62     while (count > win->height) {
63 	list = list->next;
64 	count--;
65     }
66     y = (win->height - count) * W_Textheight + fonts[1].baseline;
67     if (count == 0)
68 	return;
69     while (list != NULL) {
70 	XDrawImageString(W_Display, win->drawable,
71 			 colortable[list->color].contexts[1],
72 		WIN_EDGE, MENU_PAD + y, list->string,(int)strlen(list->string));
73 	list = list->next;
74 	y = y + W_Textheight;
75     }
76 }
77 
78 void
W_SetSensitive(window,v)79 W_SetSensitive(window, v)
80     W_Window window;
81     int     v;
82 {
83     struct window *win = W_Void2Window(window);
84 
85     win->insensitive = !v;
86 
87     if (win->type == WIN_SCROLL)
88 	redrawScrolling(win);
89 }
90 
91  void
resizeScrolling(win,width,height)92 resizeScrolling(win, width, height)
93     struct window *win;
94     int     width, height;
95 {
96     win->height = (height - MENU_PAD * 2) / W_Textheight;
97     win->width = (width - WIN_EDGE * 2) / W_Textwidth;
98     XResizeWindow(W_Display, win->window, win->width * W_Textwidth + WIN_EDGE * 2,
99 		  win->height * W_Textheight + MENU_PAD * 2);
100 }
101 
102