Debian Codegraph @

terps/tads/glk/osglkban.c

raw symbols SCIP
1 /******************************************************************************
2 * *
3 * Copyright (C) 2006-2009 by Tor Andersson. *
4 * Copyright (C) 2010 by Ben Cressey. *
5 * *
6 * This file is part of Gargoyle. *
7 * *
8 * Gargoyle is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * Gargoyle is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with Gargoyle; if not, write to the Free Software *
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
21 * *
22 *****************************************************************************/
23
24 /* osglkban.c -- glk banner interface */
25
26 #include <stdbool.h>
27
28 #include "os.h"
29 #include "glk.h"
30
31 typedef struct os_banner_s *osbanid_t;
32 typedef struct banner_contents_s *contentid_t;
33
34 /* for tracking banner windows */
35 typedef struct os_banner_s
36 {
37 glui32 id; /* unique identifier */
38 glui32 valid; /* banner status */
39
40 osbanid_t prev; /* previous sibling */
41 osbanid_t next; /* next sibling */
42 osbanid_t children; /* child's descendents */
43 osbanid_t parent; /* child's parent */
44
45 glui32 method; /* glk window method */
46 glui32 size; /* glk window size */
47 glui32 type; /* glk window type */
48 bool tab_aligned; /* for OS_BANNER_STYLE_TAB_ALIGN banners that need to be scrolled */
49
50 glui32 cheight; /* glk char height */
51 glui32 cwidth; /* glk char width */
52
53 glui32 fgcolor; /* foreground color */
54 glui32 bgcolor; /* background color */
55 glui32 fgcustom; /* custom colors */
56 glui32 bgcustom;
57 glui32 bgtrans;
58 bool invisible;
59
60 contentid_t contents; /* window contents */
61 glui32 style; /* active Glk style value */
62 glui32 newline; /* active newline */
63 glui32 move, x, y; /* active cursor position */
64
65 winid_t win; /* glk window object */
66 }
67 os_banner_t;
68
69 /* for reprinting banner contents */
70 typedef struct banner_contents_s
71 {
72 osbanid_t banner; /* content owner */
73 contentid_t next; /* next set of contents */
74
75 glui32 style; /* stored contents style */
76 glui32 newline; /* stored newline */
77 glui32 move, x, y; /* stored cursor position */
78
79 char *chars;
80 glui32 len;
81 }
82 banner_contents_t;
83
84 static osbanid_t os_banners = NULL;
85 static glui32 os_banner_count = 999;
86
87 extern winid_t mainwin;
88 extern winid_t statuswin;
89
90 extern glui32 mainfg;
91 extern glui32 mainbg;
92
93 extern glui32 statusfg;
94 extern glui32 statusbg;
95
96 void banner_contents_display(contentid_t contents);
97
98 /* Implementation-specific functions for managing banner windows */
99 /*
100 os_banner_init();
101 os_banner_insert();
102 os_banner_styles_apply();
103 os_banner_styles_reset();
104 os_banners_close();
105 os_banners_open();
106 os_banners_redraw();
107 */
108
109 osbanid_t os_banner_init(void)
110 {
111 osbanid_t instance;
112 instance = malloc(sizeof(os_banner_t));
113 if (!instance)
114 return 0;
115
116 instance->id = ++ os_banner_count;
117 instance->valid = 1;
118
119 instance->prev = 0;
120 instance->next = 0;
121 instance->children = 0;
122 instance->parent = 0;
123
124 instance->method = 0;
125 instance->size = 0;
126 instance->type = 0;
127 instance->tab_aligned = FALSE;
128
129 instance->cheight = 0;
130 instance->cwidth = 0;
131
132 instance->invisible = FALSE;
133
134 instance->contents = 0;
135 instance->style = style_Normal;
136 instance->newline = 0;
137 instance->move = 0;
138 instance->x = 0;
139 instance->y = 0;
140
141 instance->win = 0;
142
143 return instance;
144 }
145
146 osbanid_t os_banner_insert(osbanid_t parent, glui32 operation, osbanid_t other,
147 glui32 method, glui32 size, glui32 type, bool tab_aligned)
148 {
149 if (!parent || !(parent->valid))
150 return 0;
151
152 if (operation == OS_BANNER_BEFORE || operation == OS_BANNER_AFTER)
153 if (!other || !(other->valid) || !(other->parent == parent))
154 operation = OS_BANNER_LAST;
155
156 osbanid_t baby = os_banner_init();
157 if (!baby)
158 return 0;
159 baby->parent = parent;
160
161 if (!(parent->children))
162 {
163 parent->children = baby;
164 }
165 else
166 {
167 osbanid_t child = parent->children;
168
169 switch (operation)
170 {
171 case OS_BANNER_FIRST:
172 parent->children = baby;
173 baby->next = child;
174 child->prev = baby;
175 break;
176
177 case OS_BANNER_BEFORE:
178 while (child != other && child->next)
179 child = child->next;
180
181 if (child->prev)
182 {
183 child->prev->next = baby;
184 baby->prev = child->prev;
185 }
186 else
187 {
188 parent->children = baby;
189 }
190
191 baby->next = child;
192 child->prev = baby;
193 break;
194
195 case OS_BANNER_LAST:
196 while(child->next)
197 child = child->next;
198
199 baby->prev = child;
200 child->next = baby;
201 break;
202
203 case OS_BANNER_AFTER:
204 while (child != other && child->next)
205 child = child->next;
206
207 if (child->next)
208 {
209 child->next->prev = baby;
210 baby->next = child->next;
211 }
212
213 baby->prev = child;
214 child->next = baby;
215 break;
216
217 default: break;
218 }
219 }
220
221 baby->method = method;
222 baby->size = size;
223 baby->type = type;
224 baby->tab_aligned = tab_aligned;
225
226 return baby;
227 }
228
229 void os_banner_styles_apply (osbanid_t banner)
230 {
231 if (!banner || !(banner->valid))
232 return;
233
234 glui32 bgcustom = banner->bgtrans ? banner->bgcolor : banner->bgcustom;
235
236 /* font style: monospace for tab aligned buffers */
237 if (banner->tab_aligned) {
238 for (int i = 0; i < style_NUMSTYLES; i++) {
239 glk_stylehint_set(banner->type, i, stylehint_Proportional, 0);
240 }
241 }
242
243 /* foreground color: user1 reverse, user2 custom */
244 glk_stylehint_set(banner->type, style_Alert, stylehint_TextColor, banner->fgcolor);
245 glk_stylehint_set(banner->type, style_Subheader, stylehint_TextColor, banner->fgcolor);
246 glk_stylehint_set(banner->type, style_Emphasized, stylehint_TextColor, banner->fgcolor);
247 glk_stylehint_set(banner->type, style_Normal, stylehint_TextColor, banner->fgcolor);
248 glk_stylehint_set(banner->type, style_User1, stylehint_TextColor, banner->bgcolor);
249 glk_stylehint_set(banner->type, style_User2, stylehint_TextColor, banner->fgcustom);
250
251 /* background color: user1 reverse, user2 custom */
252 glk_stylehint_set(banner->type, style_Alert, stylehint_BackColor, banner->bgcolor);
253 glk_stylehint_set(banner->type, style_Subheader, stylehint_BackColor, banner->bgcolor);
254 glk_stylehint_set(banner->type, style_Emphasized, stylehint_BackColor, banner->bgcolor);
255 glk_stylehint_set(banner->type, style_Normal, stylehint_BackColor, banner->bgcolor);
256 glk_stylehint_set(banner->type, style_User1, stylehint_BackColor, banner->fgcolor);
257 glk_stylehint_set(banner->type, style_User2, stylehint_BackColor, bgcustom);
258
259 // Use blockquote for invisible text - set both to the banner background
260 if (mainbg != 0xFFFFFFFF) {
261 glk_stylehint_set(banner->type, style_BlockQuote, stylehint_TextColor, banner->bgcolor);
262 glk_stylehint_set(banner->type, style_BlockQuote, stylehint_BackColor, banner->bgcolor);
263 }
264 }
265
266 void os_banner_styles_reset(osbanid_t banner)
267 {
268 if (banner->tab_aligned) {
269 for (int i = 0; i < style_NUMSTYLES; i++) {
270 glk_stylehint_clear(banner->type, i, stylehint_Proportional);
271 }
272 }
273
274 glk_stylehint_clear(wintype_AllTypes, style_Alert, stylehint_TextColor);
275 glk_stylehint_clear(wintype_AllTypes, style_Subheader, stylehint_TextColor);
276 glk_stylehint_clear(wintype_AllTypes, style_Emphasized, stylehint_TextColor);
277 glk_stylehint_clear(wintype_AllTypes, style_Normal, stylehint_TextColor);
278 glk_stylehint_clear(wintype_AllTypes, style_User1, stylehint_TextColor);
279 glk_stylehint_clear(wintype_AllTypes, style_User2, stylehint_TextColor);
280
281 glk_stylehint_clear(wintype_AllTypes, style_Alert, stylehint_BackColor);
282 glk_stylehint_clear(wintype_AllTypes, style_Subheader, stylehint_BackColor);
283 glk_stylehint_clear(wintype_AllTypes, style_Emphasized, stylehint_BackColor);
284 glk_stylehint_clear(wintype_AllTypes, style_Normal, stylehint_BackColor);
285 glk_stylehint_clear(wintype_AllTypes, style_User1, stylehint_BackColor);
286 glk_stylehint_clear(wintype_AllTypes, style_User2, stylehint_BackColor);
287
288 if (mainbg != 0xFFFFFFFF) {
289 glk_stylehint_clear(wintype_AllTypes, style_BlockQuote, stylehint_TextColor);
290 glk_stylehint_clear(wintype_AllTypes, style_BlockQuote, stylehint_BackColor);
291 }
292
293 /* reset our default colors with a superfluous hint */
294 glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_TextColor, mainfg);
295 glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_BackColor, mainbg);
296 }
297
298 void os_banners_close(osbanid_t banner)
299 {
300 if (!banner)
301 return;
302
303 os_banners_close(banner->children);
304 os_banners_close(banner->next);
305
306 if (banner->win && (banner->win != mainwin))
307 {
308 glk_window_close(banner->win, 0);
309 banner->win = 0;
310 }
311 }
312
313 void os_banners_open(osbanid_t banner)
314 {
315 if (!banner)
316 return;
317
318 if (banner->valid)
319 {
320 if (banner->size && banner->parent && banner->parent->win)
321 {
322 os_banner_styles_apply(banner);
323 banner->win = glk_window_open(banner->parent->win, banner->method,
324 banner->size, banner->type, banner->id);
325 banner_contents_display(banner->contents);
326 }
327 os_banners_open(banner->children);
328 }
329
330 os_banners_open(banner->next);
331 }
332
333 void os_banners_redraw()
334 {
335 if (!os_banners)
336 return;
337
338 os_banners_close(os_banners);
339 os_banners_open(os_banners);
340 os_banner_styles_reset(os_banners);
341 }
342
343 /* Implementation-specific functions for managing banner contents */
344 /*
345 banner_contents_init();
346 banner_contents_insert();
347 banner_contents_display();
348 banner_contents_clear();
349 */
350
351 contentid_t banner_contents_init(void)
352 {
353 contentid_t instance;
354 instance = malloc(sizeof(banner_contents_t));
355 if (!instance)
356 return 0;
357
358 instance->banner = 0;
359 instance->next = 0;
360
361 instance->style = style_Normal;
362 instance->newline = 0;
363 instance->move = 0;
364 instance->x = 0;
365 instance->y = 0;
366
367 instance->chars = 0;
368 instance->len = 0;
369
370 return instance;
371 }
372
373 void banner_contents_insert(contentid_t contents, const char *txt, size_t len)
374 {
375 if (!contents)
376 return;
377
378 contents->chars = malloc(sizeof(char) * (len + 1));
379 if (!(contents->chars))
380 return;
381
382 memcpy(contents->chars, txt, len);
383
384 contents->chars[len] = '\0';
385 contents->len = len;
386 }
387
388 void banner_contents_display(contentid_t contents)
389 {
390 if (!contents || !(contents->banner))
391 return;
392
393 winid_t win = contents->banner->win;
394 glui32 len = contents->len;
395
396 glk_set_window(win);
397
398 if (contents->newline)
399 {
400 unsigned char ch = '\n';
401 os_put_buffer(&ch, 1);
402 }
403
404 if (len && (contents->chars[len-1] == '\n'))
405 {
406 len --;
407 contents->banner->newline = 1;
408 }
409 else
410 {
411 contents->banner->newline = 0;
412 }
413
414 if (contents->move)
415 {
416 glk_window_move_cursor(win, contents->x, contents->y);
417 contents->banner->move = 0;
418 contents->banner->x = 0;
419 contents->banner->y = 0;
420 }
421
422 glk_set_style(contents->style);
423 os_put_buffer((unsigned char *)contents->chars, len);
424 glk_set_window(mainwin);
425 banner_contents_display(contents->next);
426 }
427
428 void banner_contents_clear(contentid_t contents)
429 {
430 if (!contents)
431 return;
432
433 banner_contents_clear(contents->next);
434
435 if (contents->chars)
436 free(contents->chars);
437
438 free(contents);
439 }
440
441 /* Banner API functions */
442
443 void *os_banner_create(void *parent, int where, void *other, int wintype,
444 int align, int siz, int siz_units,
445 unsigned long style)
446 {
447 osbanid_t gparent = parent;
448 osbanid_t gbanner;
449 glui32 gwinmeth = 0;
450 glui32 gwinsize = siz;
451 glui32 gwintype = 0;
452 bool tab_aligned = (style & OS_BANNER_STYLE_TAB_ALIGN) > 0;
453 // If any of these modes are set then the banner needs to be scrollable
454 bool scrollable = (style & (OS_BANNER_STYLE_VSCROLL | OS_BANNER_STYLE_AUTO_VSCROLL | OS_BANNER_STYLE_MOREMODE)) > 0;
455
456 if (gparent && !(gparent->valid))
457 return 0;
458
459 if (!os_banners)
460 {
461 os_banners = os_banner_init();
462 if (!os_banners)
463 return 0;
464 os_banners->win = mainwin;
465 }
466
467 if (!gparent)
468 gparent = os_banners;
469
470 switch (wintype)
471 {
472 // Use a Glk grid window if the banner is explicit a textgrid, or if OS_BANNER_STYLE_TAB_ALIGN is set, but not any of the scrolling modes
473 case OS_BANNER_TYPE_TEXT: gwintype = (tab_aligned && !scrollable ? wintype_TextGrid : wintype_TextBuffer); break;
474 case OS_BANNER_TYPE_TEXTGRID: gwintype = wintype_TextGrid; break;
475 default: gwintype = wintype_TextGrid; break;
476 }
477
478 switch (align)
479 {
480 case OS_BANNER_ALIGN_TOP: gwinmeth = winmethod_Above; break;
481 case OS_BANNER_ALIGN_BOTTOM: gwinmeth = winmethod_Below; break;
482 case OS_BANNER_ALIGN_LEFT: gwinmeth = winmethod_Left; break;
483 case OS_BANNER_ALIGN_RIGHT: gwinmeth = winmethod_Right; break;
484 default: gwinmeth = winmethod_Above; break;
485 }
486
487 switch (siz_units)
488 {
489 case OS_BANNER_SIZE_PCT: gwinmeth |= winmethod_Proportional; break;
490 case OS_BANNER_SIZE_ABS: gwinmeth |= winmethod_Fixed; break;
491 default: gwinmeth |= winmethod_Fixed; break;
492 }
493
494 gbanner = os_banner_insert(gparent, where, other, gwinmeth, gwinsize, gwintype, tab_aligned && scrollable);
495
496 if (gbanner)
497 {
498 gbanner->fgcolor = tab_aligned ? statusbg : mainfg;
499 gbanner->bgcolor = tab_aligned ? statusfg : mainbg;
500 gbanner->fgcustom = gbanner->fgcolor;
501 gbanner->bgcustom = gbanner->bgcolor;
502 gbanner->bgtrans = 1;
503 }
504
505 os_banners_redraw();
506
507 return gbanner;
508 }
509
510 void os_banner_set_size(void *banner_handle, int siz, int siz_units, int is_advisory)
511 {
512 osbanid_t banner = banner_handle;
513
514 if (!banner || !banner->valid)
515 return;
516
517 glui32 gwinsize = siz;
518 glui32 gwinmeth = 0;
519
520 gwinmeth = banner->method &
521 (winmethod_Above | winmethod_Below |
522 winmethod_Left | winmethod_Right);
523
524 switch (siz_units)
525 {
526 case OS_BANNER_SIZE_PCT: gwinmeth |= winmethod_Proportional; break;
527 case OS_BANNER_SIZE_ABS: gwinmeth |= winmethod_Fixed; break;
528 default: gwinmeth |= winmethod_Fixed; break;
529 }
530
531 banner->method = gwinmeth;
532 banner->size = gwinsize;
533
534 os_banners_redraw();
535 }
536
537 void os_banner_size_to_contents(void *banner_handle)
538 {
539 osbanid_t banner = banner_handle;
540
541 if (!banner || !banner->valid || !banner->win)
542 return;
543
544 #ifdef GARGLK
545 if (banner->type == wintype_TextBuffer)
546 {
547 int size = garglk_tads_os_banner_size(banner->win);
548 os_banner_set_size(banner, size, OS_BANNER_SIZE_ABS, 0);
549 }
550 #endif /* GARGLK */
551 }
552
553 void os_banner_delete(void *banner_handle)
554 {
555 osbanid_t banner = banner_handle;
556 if (!banner || !(banner->valid))
557 return;
558
559 banner->valid = 0;
560 os_banners_redraw();
561
562 if (banner->parent && banner->parent->children == banner)
563 banner->parent->children = banner->next;
564
565 if (banner->next)
566 banner->next->prev = banner->prev;
567
568 if (banner->prev)
569 banner->prev->next = banner->next;
570
571 banner_contents_clear(banner->contents);
572
573 free(banner);
574 }
575
576 void os_banner_orphan(void *banner_handle)
577 {
578 os_banner_delete(banner_handle);
579 }
580
581 int os_banner_getinfo(void *banner_handle, os_banner_info_t *info)
582 {
583 osbanid_t banner = banner_handle;
584 if (!banner || !banner->valid || !banner->win)
585 return 1;
586
587 winid_t win = banner->win;
588 glui32 gwintype = banner->type;
589 glui32 gwinmeth = banner->method;
590 bool tab_aligned = banner->tab_aligned;
591
592 if (gwinmeth & winmethod_Above)
593 info->align = OS_BANNER_ALIGN_TOP;
594 if (gwinmeth & winmethod_Below)
595 info->align = OS_BANNER_ALIGN_BOTTOM;
596 if (gwinmeth & winmethod_Left)
597 info->align = OS_BANNER_ALIGN_LEFT;
598 if (gwinmeth & winmethod_Right)
599 info->align = OS_BANNER_ALIGN_RIGHT;
600
601 info->style = 0;
602 if (banner->tab_aligned) {
603 info->style |= OS_BANNER_STYLE_TAB_ALIGN | OS_BANNER_STYLE_AUTO_VSCROLL;
604 }
605 else if (gwintype == wintype_TextGrid) {
606 info->style |= OS_BANNER_STYLE_TAB_ALIGN;
607 }
608
609 glk_window_get_size(banner->win, &(banner->cwidth), &(banner->cheight));
610
611 info->rows = banner->cheight;
612 info->columns = banner->cwidth;
613
614 info->pix_width = 0;
615 info->pix_height = 0;
616
617 info->os_line_wrap = gwintype == wintype_TextBuffer;
618
619 return 1;
620 }
621
622 int os_banner_get_charwidth(void *banner_handle)
623 {
624 osbanid_t banner = banner_handle;
625 if (!banner || !banner->valid || !banner->win)
626 return 0;
627
628 glk_window_get_size(banner->win, &(banner->cwidth), &(banner->cheight));
629
630 return banner->cwidth;
631 }
632
633 int os_banner_get_charheight(void *banner_handle)
634 {
635 osbanid_t banner = banner_handle;
636 if (!banner || !banner->valid || !banner->win)
637 return 0;
638
639 glk_window_get_size(banner->win, &(banner->cwidth), &(banner->cheight));
640
641 return banner->cheight;
642 }
643
644 void os_banner_clear(void *banner_handle)
645 {
646 osbanid_t banner = banner_handle;
647 if (!banner || !banner->valid)
648 return;
649
650 if (banner->win)
651 {
652 winid_t win = banner->win;
653 glk_window_clear(win);
654 }
655
656 banner_contents_clear(banner->contents);
657 banner->contents = 0;
658 banner->newline = 0;
659 banner->move = 0;
660 banner->x = 0;
661 banner->y = 0;
662 }
663
664 void os_banner_disp(void *banner_handle, const char *txt, size_t len)
665 {
666 osbanid_t banner = banner_handle;
667 if (!banner || !banner->valid || !banner->win)
668 return;
669
670 contentid_t update = banner_contents_init();
671 if (!update)
672 return;
673 update->banner = banner;
674
675 if (!(banner->contents))
676 {
677 banner->contents = update;
678 }
679 else
680 {
681 contentid_t contents = banner->contents;
682 while (contents->next)
683 contents = contents->next;
684 contents->next = update;
685 }
686
687 update->style = banner->style;
688 update->newline = banner->newline;
689 update->move = banner->move;
690 update->x = banner->x;
691 update->y = banner->y;
692
693 // If invisible, overwrite with spaces
694 if (banner->invisible) {
695 char *spaces = malloc(sizeof(char) * (len));
696 if (!spaces) {
697 return;
698 }
699 memset(spaces, ' ', len);
700 banner_contents_insert(update, spaces, len);
701 free(spaces);
702 }
703 else {
704 banner_contents_insert(update, txt, len);
705 }
706
707 banner_contents_display(update);
708 }
709
710 void os_banner_goto(void *banner_handle, int row, int col)
711 {
712 osbanid_t banner = banner_handle;
713 if (!banner || !banner->valid || !banner->win)
714 return;
715
716 if (banner->type == wintype_TextGrid)
717 {
718 banner->move = 1;
719 banner->x = col;
720 banner->y = row;
721 }
722 }
723
724 void os_banner_set_attr(void *banner_handle, int attr)
725 {
726 osbanid_t banner = banner_handle;
727 if (!banner || !banner->valid)
728 return;
729
730 if (attr & OS_ATTR_BOLD && attr & OS_ATTR_ITALIC)
731 banner->style = style_Alert;
732 else if (attr & OS_ATTR_BOLD)
733 banner->style = style_Subheader;
734 else if (attr & OS_ATTR_ITALIC)
735 banner->style = style_Emphasized;
736 else
737 banner->style = style_Normal;
738 }
739
740 void os_banner_set_color(void *banner_handle, os_color_t fg, os_color_t bg)
741 {
742 osbanid_t banner = banner_handle;
743 if (!banner || !banner->valid)
744 return;
745
746 glui32 reversed = 0;
747 glui32 normal = 0;
748 glui32 transparent = 0;
749 bool invisible = FALSE;
750 banner->invisible = FALSE;
751
752 /* evaluate parameters */
753
754 if (os_color_is_param(fg))
755 {
756 switch(fg)
757 {
758 case OS_COLOR_P_TEXTBG:
759 if (bg == OS_COLOR_P_TRANSPARENT) {
760 invisible = TRUE;
761 break;
762 }
763 case OS_COLOR_P_STATUSBG:
764 reversed = 1;
765 break;
766
767 case OS_COLOR_P_TEXT:
768 case OS_COLOR_P_STATUSLINE:
769 case OS_COLOR_P_INPUT:
770 normal = 1;
771 break;
772
773 default:
774 break;
775 }
776 }
777
778 if (os_color_is_param(bg))
779 {
780 switch (bg)
781 {
782 case OS_COLOR_P_TRANSPARENT:
783 transparent = 1;
784 break;
785
786 default:
787 break;
788 }
789 }
790
791 /* choose a style */
792
793 if (invisible) {
794 // If we can't measure the background colour, then use the replace-with-spaces method
795 if (mainbg == 0xFFFFFFFF) {
796 banner->style = style_Preformatted;
797 banner->invisible = TRUE;
798 }
799 else {
800 banner->style = style_BlockQuote;
801 }
802 }
803 else if (normal && transparent)
804 banner->style = style_Normal;
805 else if (reversed)
806 banner->style = style_User1;
807 else
808 banner->style = style_User2;
809
810 /* process our custom color */
811
812 if (banner->style == style_User2)
813 {
814 /* store current settings */
815 glui32 oldfg = banner->fgcustom;
816 glui32 oldbg = banner->bgcustom;
817 glui32 oldtr = banner->bgtrans;
818
819 /* reset custom color parameters */
820 banner->fgcustom = banner->fgcolor;
821 banner->bgcustom = banner->bgcolor;
822 banner->bgtrans = 1;
823
824 if (!normal)
825 banner->fgcustom = fg;
826
827 if (!transparent)
828 {
829 banner->bgcustom = bg;
830 banner->bgtrans = 0;
831 }
832
833 if (!(banner->fgcustom == oldfg
834 && banner->bgcustom == oldbg
835 && banner->bgtrans == oldtr))
836 os_banners_redraw();
837 }
838 }
839
840 void os_banner_set_screen_color(void *banner_handle, os_color_t color)
841 {
842 osbanid_t banner = banner_handle;
843 if (!banner || !banner->valid)
844 return;
845
846 if (!(os_color_is_param(color)))
847 banner->bgcolor = color;
848
849 os_banners_redraw();
850 }
851
852 void os_banner_flush(void *banner_handle) {}
853 void os_banner_start_html(void *banner_handle) {}
854 void os_banner_end_html(void *banner_handle) {}