No longer directly accessing debuggee memory.
[wine] / windows / ttydrv / monitor.c
1 /*
2  * TTY monitor driver
3  *
4  * Copyright 1998,1999 Patrik Stridvall
5  *
6  */
7
8 #include "config.h"
9
10 #include "debugtools.h"
11 #include "heap.h"
12 #include "monitor.h"
13 #include "windef.h"
14 #include "ttydrv.h"
15
16 DEFAULT_DEBUG_CHANNEL(ttydrv)
17
18 /***********************************************************************
19  *              TTYDRV_MONITOR_GetCursesRootWindow
20  *
21  * Return the Curses root window associated to the MONITOR.
22  */
23 #ifdef HAVE_LIBCURSES
24 WINDOW *TTYDRV_MONITOR_GetCursesRootWindow(MONITOR *pMonitor)
25 {
26   TTYDRV_MONITOR_DATA *pTTYMonitor =
27     (TTYDRV_MONITOR_DATA *) pMonitor->pDriverData;
28
29   return pTTYMonitor->rootWindow;
30 }
31 #endif /* defined(HAVE_LIBCURSES) */
32
33 /***********************************************************************
34  *              TTYDRV_MONITOR_GetCellWidth
35  */
36 INT TTYDRV_MONITOR_GetCellWidth(MONITOR *pMonitor)
37 {
38   TTYDRV_MONITOR_DATA *pTTYMonitor =
39     (TTYDRV_MONITOR_DATA *) pMonitor->pDriverData;
40
41   return pTTYMonitor->cellWidth;
42 }
43
44 /***********************************************************************
45  *              TTYDRV_MONITOR_GetCellHeight
46  */
47 INT TTYDRV_MONITOR_GetCellHeight(MONITOR *pMonitor)
48 {
49   TTYDRV_MONITOR_DATA *pTTYMonitor =
50     (TTYDRV_MONITOR_DATA *) pMonitor->pDriverData;
51
52   return pTTYMonitor->cellHeight;
53 }
54
55 /***********************************************************************
56  *              TTYDRV_MONITOR_Initialize
57  */
58 void TTYDRV_MONITOR_Initialize(MONITOR *pMonitor)
59 {
60   TTYDRV_MONITOR_DATA *pTTYMonitor = (TTYDRV_MONITOR_DATA *) 
61     HeapAlloc(SystemHeap, 0, sizeof(TTYDRV_MONITOR_DATA));
62   int rows, cols;
63
64   pMonitor->pDriverData = pTTYMonitor;
65
66   pTTYMonitor->cellWidth = 8;
67   pTTYMonitor->cellHeight = 8;
68
69 #ifdef HAVE_LIBCURSES
70   pTTYMonitor->rootWindow = initscr();
71   if(pTTYMonitor->rootWindow) {
72     werase(pTTYMonitor->rootWindow);
73     wrefresh(pTTYMonitor->rootWindow);
74   }
75
76   getmaxyx(pTTYMonitor->rootWindow, rows, cols);
77 #else /* defined(HAVE_LIBCURSES) */
78   rows = 60; /* FIXME: Hardcoded */
79   cols = 80; /* FIXME: Hardcoded */
80 #endif /* defined(HAVE_LIBCURSES) */
81
82   pTTYMonitor->width  = pTTYMonitor->cellWidth*cols;
83   pTTYMonitor->height = pTTYMonitor->cellWidth*rows;
84   pTTYMonitor->depth  = 1;
85 }
86
87 /***********************************************************************
88  *              TTYDRV_MONITOR_Finalize
89  */
90 void TTYDRV_MONITOR_Finalize(MONITOR *pMonitor)
91 {
92   TTYDRV_MONITOR_DATA *pTTYMonitor =
93     (TTYDRV_MONITOR_DATA *) pMonitor->pDriverData;
94
95 #ifdef HAVE_LIBCURSES
96   if(pTTYMonitor->rootWindow) {
97      endwin();
98   }
99 #endif /* defined(HAVE_LIBCURSES) */
100
101   HeapFree(SystemHeap, 0, pTTYMonitor);
102 }
103
104 /***********************************************************************
105  *              TTYDRV_MONITOR_IsSingleWindow
106  */
107 BOOL TTYDRV_MONITOR_IsSingleWindow(MONITOR *pMonitor)
108 {
109   return TRUE;
110 }
111
112 /***********************************************************************
113  *              TTYDRV_MONITOR_GetWidth
114  *
115  * Return the width of the monitor
116  */
117 int TTYDRV_MONITOR_GetWidth(MONITOR *pMonitor)
118 {
119   TTYDRV_MONITOR_DATA *pTTYMonitor =
120     (TTYDRV_MONITOR_DATA *) pMonitor->pDriverData;
121
122   return pTTYMonitor->width;
123 }
124
125 /***********************************************************************
126  *              TTYDRV_MONITOR_GetHeight
127  *
128  * Return the height of the monitor
129  */
130 int TTYDRV_MONITOR_GetHeight(MONITOR *pMonitor)
131 {
132   TTYDRV_MONITOR_DATA *pTTYMonitor =
133     (TTYDRV_MONITOR_DATA *) pMonitor->pDriverData;
134
135   return pTTYMonitor->height;
136 }
137
138 /***********************************************************************
139  *              TTYDRV_MONITOR_GetDepth
140  *
141  * Return the depth of the monitor
142  */
143 int TTYDRV_MONITOR_GetDepth(MONITOR *pMonitor)
144 {
145   TTYDRV_MONITOR_DATA *pTTYMonitor =
146     (TTYDRV_MONITOR_DATA *) pMonitor->pDriverData;
147
148   return pTTYMonitor->depth;
149 }
150
151 /***********************************************************************
152  *              TTYDRV_MONITOR_GetScreenSaveActive
153  *
154  * Returns the active status of the screen saver
155  */
156 BOOL TTYDRV_MONITOR_GetScreenSaveActive(MONITOR *pMonitor)
157 {
158   return FALSE;
159 }
160
161 /***********************************************************************
162  *              TTYDRV_MONITOR_SetScreenSaveActive
163  *
164  * Activate/Deactivate the screen saver
165  */
166 void TTYDRV_MONITOR_SetScreenSaveActive(MONITOR *pMonitor, BOOL bActivate)
167 {
168   FIXME("(%p, %d): stub\n", pMonitor, bActivate);
169 }
170
171 /***********************************************************************
172  *              TTYDRV_MONITOR_GetScreenSaveTimeout
173  *
174  * Return the screen saver timeout
175  */
176 int TTYDRV_MONITOR_GetScreenSaveTimeout(MONITOR *pMonitor)
177 {
178   return 0;
179 }
180
181 /***********************************************************************
182  *              TTYDRV_MONITOR_SetScreenSaveTimeout
183  *
184  * Set the screen saver timeout
185  */
186 void TTYDRV_MONITOR_SetScreenSaveTimeout(
187   MONITOR *pMonitor, int nTimeout)
188 {
189   FIXME("(%p, %d): stub\n", pMonitor, nTimeout);
190 }