got a lot of crypt32 stuff working
[reactos.git] / rosapps / mc / src / dialog.c
1 /* Dialog managing.
2 Copyright (C) 1994 Miguel de Icaza.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #include <config.h>
19 #include "tty.h"
20 #include <stdio.h>
21 #include <stdlib.h> /* For free() */
22 #include <stdarg.h>
23 #include <sys/types.h>
24 #include <string.h>
25 #include "x.h"
26 #include "mad.h"
27 #include "global.h"
28 #include "util.h"
29 #include "dialog.h"
30 #include "color.h"
31 #include "win.h"
32 #include "mouse.h"
33 #include "main.h"
34 #include "key.h" /* For mi_getch() */
35 #include "dlg.h" /* draw_box, yes I know, it's silly */
36 #include "background.h" /* we_are_background definition */
37
38 /* "$Id$" */
39
40 Refresh *refresh_list = 0;
41
42 void push_refresh (void (*new_refresh)(void *), void *parameter, int flags)
43 {
44 Refresh *new;
45
46 new = xmalloc (sizeof (Refresh), "push_refresh");
47 new->next = (struct Refresh *) refresh_list;
48 new->refresh_fn = new_refresh;
49 new->parameter = parameter;
50 new->flags = flags;
51 refresh_list = new;
52 }
53
54 void pop_refresh (void)
55 {
56 Refresh *old;
57
58 if (!refresh_list)
59 fprintf (stderr, _("\n\n\nrefresh stack underflow!\n\n\n"));
60 else {
61 old = refresh_list;
62 refresh_list = refresh_list->next;
63 free (old);
64 }
65 }
66
67 static void do_complete_refresh (Refresh *refresh_list)
68 {
69 if (!refresh_list)
70 return;
71
72 if (refresh_list->flags != REFRESH_COVERS_ALL)
73 do_complete_refresh (refresh_list->next);
74
75 (*(refresh_list->refresh_fn))(refresh_list->parameter);
76 }
77
78 void do_refresh (void)
79 {
80 if (we_are_background)
81 return;
82 if (!refresh_list)
83 return;
84 else {
85 if (fast_refresh)
86 (*(refresh_list->refresh_fn))(refresh_list->parameter);
87 else {
88 do_complete_refresh (refresh_list);
89 }
90 }
91 }
92
93 /* Poor man's window puts, it doesn't handle auto-wrap */
94 void my_wputs (int y, int x, char *text)
95 {
96 char p;
97
98 move (y, x);
99 while ((p = *text++) != 0){
100 if (p == '\n')
101 move (++y, x);
102 else
103 addch ((unsigned char)p);
104 }
105 }
106