use the spoofed uname compiling git.
[AROS-Contrib.git] / rexx / bsub / winio.c
blobb60e4ef1164d9b6e91678b3e938978b0570f821d
1 /*
2 * $Header$
3 * $Log$
4 * Revision 1.1 2001/04/04 05:43:36 wang
5 * First commit: compiles on Linux, Amiga, Windows, Windows CE, generic gcc
7 * Revision 1.1 1999/09/13 15:06:41 bnv
8 * Initial revision
12 #include <stdlib.h>
13 #include <string.h>
14 #include <windows.h>
17 * These are dummy variables that are used because this module is
18 * always linked in.
21 HINSTANCE _hInstance;
22 HINSTANCE _hPrevInstance;
24 POINT _WindowOrg = { CW_USEDEFAULT, CW_USEDEFAULT};
25 POINT _WindowSize = { CW_USEDEFAULT, CW_USEDEFAULT};
27 POINT _ScreenSize = { 80, 25 }; // Screen buffer dimensions
28 POINT _Cursor = { 0, 0 }; // Cursor location
29 POINT _Origin = { 0, 0 }; // Client area origin
30 LPSTR _InactiveTitle = "(Inactive %s)"; // Inactive window title
31 BOOL _AutoTracking = TRUE; // Track cursor on Write?
32 BOOL _CheckEOF = TRUE; // Allow Ctrl-Z for EOF?
33 BOOL _CheckBreak = TRUE; // Allow Ctrl-C for break?
34 HFONT _hFont; // Current working font
36 char _WindowTitle[80]; // Window title
38 void _DoneWinIO(void);
40 BOOL _KeyPressed(void);
41 int _ReadKey(void);
42 WORD _ReadBuf(char *Buffer, WORD Count);
44 void gotoxy(int X, int Y);
45 int wherex(void);
46 int wherey(void);
47 void clrscr(void);
48 void clreol(void);
50 void _CursorTo(int X, int Y);
51 void _ScrollTo(int X, int Y);
52 void _TrackCursor(void);
54 void _InitWinIO(HINSTANCE,HINSTANCE,int);
56 // MinMaxInfo array
58 typedef POINT TMinMaxInfo[5];
60 // Scroll key definition record
62 typedef struct
64 BYTE Key;
65 BOOL Ctrl;
66 BYTE SBar;
67 BYTE Action;
68 } TScrollKey;
70 // Window I/O procedure
72 long PASCAL _WinIOProc(HWND Window, UINT Message,
73 WPARAM WParam, LONG LParam);
75 // CRT window class
77 static WNDCLASS CrtClass =
79 CS_HREDRAW | CS_VREDRAW, _WinIOProc, 0, 0, 0, 0, 0, 0,
80 NULL, TEXT("WinIO")
83 static int FirstLine = 0; // First line in circular buffer
84 static int KeyCount = 0; // Count of keys in KeyBuffer
85 static BOOL Created = FALSE; // Window created?
86 static BOOL Focused = FALSE; // Window focused?
87 static BOOL Reading = FALSE; // Reading from window?
88 static BOOL Painting = FALSE; // Handling wm_Paint?
90 static HWND CrtWindow = 0; // CRT window handle
91 static char *ScreenBuffer; // Screen buffer pointer
92 static POINT ClientSize; // Client area dimensions
93 static POINT Range; // Scroll bar ranges
94 static POINT CharSize; // Character cell size
95 static int CharAscent; // Character ascent
96 static HDC DC; // Global device context
97 static PAINTSTRUCT PS; // Global paint structure
98 static HFONT SaveFont; // Saved device context font
99 static char KeyBuffer[64]; // Keyboard type-ahead buffer
101 // Scroll keys table
102 #define SCROLLKEYCOUNT 12
103 static TScrollKey ScrollKeys[SCROLLKEYCOUNT] =
105 { VK_LEFT, FALSE, SB_HORZ, SB_LINEUP },
106 { VK_RIGHT, FALSE, SB_HORZ, SB_LINEDOWN },
107 { VK_LEFT, TRUE, SB_HORZ, SB_PAGEUP },
108 { VK_RIGHT, TRUE, SB_HORZ, SB_PAGEDOWN },
109 { VK_HOME, FALSE, SB_HORZ, SB_TOP },
110 { VK_END, FALSE, SB_HORZ, SB_BOTTOM },
111 { VK_UP, FALSE, SB_VERT, SB_LINEUP },
112 { VK_DOWN, FALSE, SB_VERT, SB_LINEDOWN },
113 { VK_PRIOR, FALSE, SB_VERT, SB_PAGEUP },
114 { VK_NEXT, FALSE, SB_VERT, SB_PAGEDOWN },
115 { VK_HOME, TRUE, SB_VERT, SB_TOP },
116 { VK_END, TRUE, SB_VERT, SB_BOTTOM }
119 /* ------------ Allocate device context ----------- */
120 static void
121 InitDeviceContext(void)
123 if (Painting)
124 DC = BeginPaint(CrtWindow, &PS);
125 else
126 DC = GetDC(CrtWindow);
127 // SaveFont = (HFONT) SelectObject( DC, GetStockObject(SYSTEM_FIXED_FONT));
128 SaveFont = (HFONT)SelectObject (DC, _hFont);
129 } /* InitDeviceContext */
131 /* ------------ Release device context ------------ */
132 static void
133 DoneDeviceContext(void)
135 SelectObject(DC, SaveFont);
136 if (Painting)
137 EndPaint(CrtWindow, &PS);
138 else
139 ReleaseDC(CrtWindow, DC);
140 } /* DoneDeviceContext */
142 /* ---------- Show caret --------- */
143 static void
144 _ShowCursor(void)
146 CreateCaret(CrtWindow, 0, CharSize.x, 2);
147 SetCaretPos((_Cursor.x - _Origin.x) * CharSize.x,
148 (_Cursor.y - _Origin.y) * CharSize.y + CharAscent);
149 ShowCaret(CrtWindow);
150 } /* _ShowCursor */
152 /* ----------- Hide caret ------------ */
153 static void
154 _HideCursor(void)
156 DestroyCaret();
157 } /* _HideCursor */
159 /* ---------- Update scroll bars --------- */
160 static void
161 SetScrollBars(void)
163 SetScrollRange(CrtWindow, SB_HORZ, 0, max(1, Range.x), FALSE);
164 SetScrollPos(CrtWindow, SB_HORZ, _Origin.x, TRUE);
165 SetScrollRange(CrtWindow, SB_VERT, 0, max(1, Range.y), FALSE);
166 SetScrollPos(CrtWindow, SB_VERT, _Origin.y, TRUE);
167 } /* SetScrollBars */
169 /* --------- Terminate window ----------- */
170 static void
171 Terminate(void)
173 if (Focused && Reading)
174 _HideCursor();
175 //? exit(255);
176 } /* Terminate */
178 /* --------- Set cursor position ---------- */
179 void
180 _CursorTo(int X, int Y)
182 _Cursor.x = max(0, min(X, _ScreenSize.x - 1));
183 _Cursor.y = max(0, min(Y, _ScreenSize.y - 1));
186 /* ------- Scroll window to given origin -------- */
187 void
188 _ScrollTo(int X, int Y)
190 if (Created) {
191 X = max(0, min(X, Range.x));
192 Y = max(0, min(Y, Range.y));
193 if ((X != _Origin.x) || (Y != _Origin.y)) {
194 if (X != _Origin.x)
195 SetScrollPos(CrtWindow, SB_HORZ, X, TRUE);
196 if (Y != _Origin.y)
197 SetScrollPos(CrtWindow, SB_VERT, Y, TRUE);
198 ScrollWindow(CrtWindow,
199 (_Origin.x - X) * CharSize.x,
200 (_Origin.y - Y) * CharSize.y, NULL, NULL);
201 _Origin.x = X;
202 _Origin.y = Y;
203 UpdateWindow(CrtWindow);
206 } /* _ScrollTo */
208 /* ------ Scroll to make cursor visible --------- */
209 void
210 _TrackCursor(void)
212 _ScrollTo(max(_Cursor.x - ClientSize.x + 1,
213 min(_Origin.x, _Cursor.x)),
214 max(_Cursor.y - ClientSize.y + 1,
215 min(_Origin.y, _Cursor.y)));
216 } /* _TrackCursor */
218 /* ------ Return pointer to location in screen buffer ----------- */
219 static LPWSTR
220 ScreenPtr(int X, int Y)
222 Y += FirstLine;
223 if (Y >= _ScreenSize.y)
224 Y -= _ScreenSize.y;
225 return (ScreenBuffer+ (Y * _ScreenSize.x + X));
226 } /* ScreenPtr */
228 /* ------ Update text on cursor line -------- */
229 static void
230 ShowText(int L, int R)
232 if (L < R) {
233 InitDeviceContext();
234 ExtTextOut(DC, (L - _Origin.x) * CharSize.x,
235 (_Cursor.y - _Origin.y) * CharSize.y,
236 ETO_OPAQUE, NULL,
237 ScreenPtr(L, _Cursor.y), R - L);
238 //? TextOut(DC, (L - _Origin.x) * CharSize.x,
239 //? (_Cursor.y - _Origin.y) * CharSize.y,
240 //? ScreenPtr(L, _Cursor.y), R - L);
241 DoneDeviceContext();
243 } /* ShowText */
245 /* ------ Write text buffer to window -------- */
246 static void
247 NewLine(int *L, int *R)
249 ShowText(*L, *R);
250 *L = 0;
251 *R = 0;
252 _Cursor.x = 0;
253 ++_Cursor.y;
254 if (_Cursor.y == _ScreenSize.y) {
255 --_Cursor.y;
256 ++FirstLine;
257 if (FirstLine == _ScreenSize.y)
258 FirstLine = 0;
259 memset(ScreenPtr(0, _Cursor.y), ' ', _ScreenSize.x);
260 ScrollWindow(CrtWindow, 0, -CharSize.y, NULL, NULL);
261 UpdateWindow(CrtWindow);
263 } /* NewLine */
265 /* --------- Write the contents of Buffer ----------- */
266 void
267 _WriteBuf(char *Buffer, WORD Count)
269 int L, R;
271 L = _Cursor.x;
272 R = _Cursor.x;
273 while (Count > 0) {
274 if (Buffer[0] == -1)
275 Buffer[0] = ' ';
276 switch (Buffer[0]) {
277 case 13:
278 NewLine(&L, &R);
279 break;
280 case 10:
281 break;
282 case 9:
283 do {
284 *(ScreenPtr(_Cursor.x,_Cursor.y))=' ';
285 ++_Cursor.x;
286 if (_Cursor.x > R)
287 R = _Cursor.x;
288 if (_Cursor.x == _ScreenSize.x) {
289 NewLine(&L, &R);
290 break;
292 } while (_Cursor.x % 8);
293 break;
294 case 8:
295 if (_Cursor.x > 0) {
296 --_Cursor.x;
297 *(ScreenPtr(_Cursor.x,_Cursor.y))=' ';
298 if (_Cursor.x < L )
299 L = _Cursor.x;
301 break;
302 case 7:
303 MessageBeep(0);
304 break;
305 default:
306 *(ScreenPtr(_Cursor.x, _Cursor.y)) = Buffer[0];
307 ++_Cursor.x;
308 if (_Cursor.x > R)
309 R = _Cursor.x;
310 if (_Cursor.x == _ScreenSize.x)
311 NewLine(&L, &R);
314 ++Buffer;
315 --Count;
317 ShowText(L, R);
318 if (_AutoTracking)
319 _TrackCursor();
320 } /* _WriteBuf */
322 /* ------- Write character to window ---------- */
323 void
324 _WriteChar(char Ch)
326 _WriteBuf(&Ch, 1);
327 } /* _WriteChar */
329 /* ------ Return keyboard status -------- */
330 BOOL
331 _KeyPressed(void)
333 MSG M;
335 while (PeekMessage(&M, 0, 0, 0, PM_REMOVE)) {
336 if (M.message == WM_QUIT)
337 Terminate();
338 TranslateMessage(&M);
339 DispatchMessage(&M);
341 return (BOOL)( KeyCount > 0 );
342 } /* _KeyPressed */
344 /* ------- Read key from window ---------- */
346 _ReadKey(void)
348 int readkey;
350 _TrackCursor();
351 if (!_KeyPressed()) {
352 Reading = TRUE;
353 if (Focused)
354 _ShowCursor();
355 do { } while (!_KeyPressed());
356 if (Focused)
357 _HideCursor();
358 Reading = FALSE;
360 readkey = KeyBuffer[0];
361 --KeyCount;
362 memmove(KeyBuffer, KeyBuffer+1, KeyCount);
363 return readkey;
364 } /* _ReadKey */
366 /* ------ Read text buffer from window --------- */
367 WORD
368 _ReadBuf(char *Buffer, WORD Count)
370 unsigned char Ch;
371 WORD I;
373 I = 0;
374 do {
375 Ch = _ReadKey();
376 if (Ch == 8) {
377 if (I > 0) {
378 --I;
379 _WriteChar(8);
381 } else
382 if (Ch >= 32) {
383 if (I < Count) {
384 Buffer[I++] = Ch;
385 _WriteChar(Ch);
388 } while (!((Ch == 13) || (_CheckEOF && (Ch == 26))));
389 if (I < Count - 2) {
390 Buffer[I++] = Ch;
391 if (Ch == 13) {
392 Buffer[I++] = 10;
393 _WriteChar(13);
396 _TrackCursor();
397 return I;
398 } /* _ReadBuf */
400 /* -------- Set cursor position ------------- */
401 void
402 gotoxy(int X, int Y)
404 _CursorTo(X - 1, Y - 1);
405 } /* gotoxy */
407 /* ------- Return cursor X position --------- */
409 wherex(void)
411 return (_Cursor.x + 1);
412 } /* wherex */
414 /* ------- Return cursor Y position ------- */
416 wherey(void)
418 return(_Cursor.y + 1);
419 } /* wherey */
421 /* ------ Clear screen ------ */
422 void
423 clrscr(void)
425 memset(ScreenBuffer, ' ', _ScreenSize.x * _ScreenSize.y);
426 _Cursor.x = 0;
427 _Cursor.y = 0;
428 _Origin.x = 0;
429 _Origin.y = 0;
430 SetScrollBars();
431 InvalidateRect(CrtWindow, NULL, TRUE);
432 UpdateWindow(CrtWindow);
433 } /* clrscr */
435 /* ------ Clear to end of line --------- */
436 void
437 clreol(void)
439 memset(ScreenPtr(_Cursor.x,_Cursor.y),' ',_ScreenSize.x-_Cursor.x);
440 ShowText(_Cursor.x, _ScreenSize.x);
441 } /* clreol */
443 /* ---- WM_CREATE message handler ---- */
444 static void
445 WindowCreate(void)
447 Created = TRUE;
448 ScreenBuffer = (char *) malloc(_ScreenSize.x * _ScreenSize.y);
449 memset(ScreenBuffer, ' ', _ScreenSize.x * _ScreenSize.y);
450 if (!_CheckBreak)
451 EnableMenuItem(GetSystemMenu(CrtWindow, FALSE), SC_CLOSE,
452 MF_DISABLED | MF_GRAYED);
453 } /* WindowCreate */
455 /* ---- WM_PAINT message handler ----- */
456 static void
457 WindowPaint(void)
459 int X1, X2, Y1, Y2;
461 Painting = TRUE;
462 InitDeviceContext();
463 X1 = max(0, PS.rcPaint.left / CharSize.x + _Origin.x);
464 X2 = min(_ScreenSize.x,
465 (PS.rcPaint.right + CharSize.x - 1) / CharSize.x + _Origin.x);
466 Y1 = max(0, PS.rcPaint.top / CharSize.y + _Origin.y);
467 Y2 = min(_ScreenSize.y,
468 (PS.rcPaint.bottom + CharSize.y - 1) / CharSize.y + _Origin.y);
469 while (Y1 < Y2) {
470 TextOut(DC, (X1 - _Origin.x) * CharSize.x, (Y1 - _Origin.y) * CharSize.y,
471 ScreenPtr(X1, Y1), X2 - X1);
472 ++Y1;
474 DoneDeviceContext();
475 Painting = FALSE;
476 } /* WindowPaint */
478 /* ---- WM_VSCROLL and WM_HSCROLL message handler ----- */
479 static int
480 GetNewPos(int Pos, int Page, int Range, int Action, int Thumb)
482 switch (Action) {
483 case SB_LINEUP:
484 return(Pos - 1);
485 case SB_LINEDOWN:
486 return(Pos + 1);
487 case SB_PAGEUP:
488 return(Pos - Page);
489 case SB_PAGEDOWN:
490 return(Pos + Page);
491 case SB_TOP:
492 return(0);
493 case SB_BOTTOM:
494 return(Range);
495 case SB_THUMBPOSITION:
496 return(Thumb);
497 default:
498 return(Pos);
500 } /* GetNewPos */
502 /* ------ WindowScroll ------- */
503 static void
504 WindowScroll(int Which, int Action, int Thumb)
506 int X, Y;
508 X = _Origin.x;
509 Y = _Origin.y;
510 switch (Which) {
511 case SB_HORZ:
512 X = GetNewPos(X, ClientSize.x / 2, Range.x, Action, Thumb);
513 break;
514 case SB_VERT:
515 Y = GetNewPos(Y, ClientSize.y, Range.y, Action, Thumb);
517 _ScrollTo(X, Y);
518 } /* WindowScroll */
520 /* ------ WM_SIZE message handler -------- */
521 static void
522 WindowResize(int X, int Y)
524 if (Focused && Reading)
525 _HideCursor();
526 ClientSize.x = X / CharSize.x;
527 ClientSize.y = Y / CharSize.y;
528 Range.x = max(0, _ScreenSize.x - ClientSize.x);
529 Range.y = max(0, _ScreenSize.y - ClientSize.y);
530 _Origin.x = min(_Origin.x, Range.x);
531 _Origin.y = min(_Origin.y, Range.y);
532 SetScrollBars();
533 if (Focused && Reading)
534 _ShowCursor();
535 } /* WindowResize */
537 /* ------ WM_GETMINMAXINFO message handler ------ */
538 static void
539 WindowMinMaxInfo(TMinMaxInfo* MinMaxInfo)
541 int X, Y;
542 TEXTMETRIC Metrics;
544 InitDeviceContext();
545 GetTextMetrics(DC, &Metrics);
546 CharSize.x = Metrics.tmMaxCharWidth;
547 CharSize.y = Metrics.tmHeight + Metrics.tmExternalLeading;
548 CharAscent = Metrics.tmAscent;
549 X = min(_ScreenSize.x * CharSize.x + GetSystemMetrics(SM_CXVSCROLL),
550 GetSystemMetrics(SM_CXSCREEN)) + GetSystemMetrics(SM_CXFRAME) * 2;
551 Y = min(_ScreenSize.y * CharSize.y + GetSystemMetrics(SM_CYHSCROLL) +
552 GetSystemMetrics(SM_CYCAPTION), GetSystemMetrics(SM_CYSCREEN)) +
553 GetSystemMetrics(SM_CYFRAME) * 2;
554 (*MinMaxInfo)[1].x = X;
555 (*MinMaxInfo)[1].y = Y;
556 (*MinMaxInfo)[3].x = CharSize.x * 16 + GetSystemMetrics(SM_CXVSCROLL) +
557 GetSystemMetrics(SM_CXFRAME) * 2;
558 (*MinMaxInfo)[3].y = CharSize.y * 4 + GetSystemMetrics(SM_CYHSCROLL) +
559 GetSystemMetrics(SM_CYFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION);
560 (*MinMaxInfo)[4].x = X;
561 (*MinMaxInfo)[4].y = Y;
562 DoneDeviceContext();
563 } /* WindowMinMaxInfo */
565 /* ----- WM_CHAR message handler ----- */
566 static void
567 WindowChar(char Ch)
569 if (_CheckBreak && (Ch == 3))
570 Terminate();
571 if (KeyCount < sizeof(KeyBuffer)) {
572 KeyBuffer[KeyCount] = Ch;
573 ++KeyCount;
575 } /* WindowChar */
577 /* ------ WM_KEYDOWN message handler ------ */
578 static void
579 WindowKeyDown(BYTE KeyDown)
581 BOOL CtrlDown;
582 int I;
584 if (_CheckBreak && (KeyDown == VK_CANCEL))
585 Terminate();
586 CtrlDown = (BOOL) (GetKeyState(VK_CONTROL < 0));
587 for (I = 0; I < SCROLLKEYCOUNT; ++I) {
588 if (ScrollKeys[I].Key == KeyDown && ScrollKeys[I].Ctrl == CtrlDown) {
589 WindowScroll(ScrollKeys[I].SBar, ScrollKeys[I].Action, 0);
590 return;
593 } /* WindowKeyDown */
595 /* ----- WM_SETFOCUS message handler ------ */
596 static void
597 WindowSetFocus(void)
599 Focused = TRUE;
600 if (Reading)
601 _ShowCursor();
602 } /* WindowSetFocus */
604 /* ----- WM_KILLFOCUS message handler ----- */
605 static void
606 WindowKillFocus(void)
608 if (Reading)
609 _HideCursor();
610 Focused = FALSE;
611 } /* WindowKillFocus */
613 /* ----- WM_DESTROY message handler ------ */
614 static void
615 WindowDestroy(void)
617 free(ScreenBuffer);
618 _Cursor.x = 0;
619 _Cursor.y = 0;
620 _Origin.x = 0;
621 _Origin.y = 0;
622 PostQuitMessage(0);
623 Created = FALSE;
624 } /* WindowDestroy */
626 /* --------- LoVal --------- */
628 LoVal(LONG LVal)
630 return (((unsigned *)&LVal)[0]);
631 } /* LoVal */
633 /* -------- HiVal ------- */
635 HiVal(LONG LVal)
637 return (((unsigned *)&LVal)[1]);
638 } /* HiVal */
640 /* ------ WindowIO window procedure ------ */
642 long PASCAL
643 _WinIOProc(HWND Window, UINT Message, WPARAM WParam, LONG LParam)
645 CrtWindow = Window;
646 switch (Message) {
647 case WM_CREATE:
648 WindowCreate();
649 break;
650 case WM_PAINT:
651 WindowPaint();
652 break;
653 case WM_VSCROLL:
654 WindowScroll(SB_VERT, WParam, LoVal(LParam));
655 break;
656 case WM_HSCROLL:
657 WindowScroll(SB_HORZ, WParam, LoVal(LParam));
658 break;
659 case WM_SIZE:
660 WindowResize(LoVal(LParam), HiVal(LParam));
661 break;
662 case WM_GETMINMAXINFO:
663 WindowMinMaxInfo((TMinMaxInfo *) LParam);
664 break;
665 case WM_CHAR:
666 WindowChar((char)WParam);
667 break;
668 case WM_KEYDOWN:
669 WindowKeyDown((BYTE)WParam);
670 break;
671 case WM_SETFOCUS:
672 WindowSetFocus();
673 break;
674 case WM_KILLFOCUS:
675 WindowKillFocus();
676 break;
677 case WM_DESTROY:
678 WindowDestroy();
679 break;
680 default:
681 return DefWindowProc(Window, Message, WParam, LParam);
683 return 0L;
684 } /* _WinIOProc */
686 /* ------- _CreateWinIO ------- */
687 void
688 _CreateWinIO(void)
690 if (_hPrevInstance == 0) {
691 CrtClass.hInstance = _hInstance;
692 CrtClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
693 CrtClass.hCursor = LoadCursor(NULL, IDC_ARROW);
694 CrtClass.hbrBackground = GetStockObject(WHITE_BRUSH);
695 RegisterClass(&CrtClass);
697 GetModuleFileName(_hInstance, _WindowTitle, sizeof(_WindowTitle));
698 OemToAnsi(_WindowTitle, _WindowTitle);
699 } /* _CreateWinIO */
701 /* ----- Create window if required ----- */
702 void
703 _InitWinIO(HINSTANCE hInst, HINSTANCE hPrev, int cmdShow)
705 LOGFONT lf;
707 _hInstance = hInst;
708 _hPrevInstance = hPrev;
710 _CreateWinIO();
711 if (!Created) {
712 CrtWindow = CreateWindow(
713 CrtClass.lpszClassName,
714 _WindowTitle,
715 WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
716 _WindowOrg.x, _WindowOrg.y,
717 _WindowSize.x, _WindowSize.y,
720 _hInstance,
721 NULL);
722 ShowWindow(CrtWindow, cmdShow);
723 UpdateWindow(CrtWindow);
725 // For the first time create the font (WCE)
726 memset ((char *)&lf, 0, sizeof(lf));
727 lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
728 lf.lfHeight = 13;
729 _hFont = CreateFontIndirect (&lf);
731 } /* _InitWinIO */
733 /* ----- Destroy window if required ----- */
734 void
735 _DoneWinIO(void)
737 if (Created)
738 DestroyWindow(CrtWindow);
739 exit(0);
740 } /* _DoneWinIO */
742 /* ------ WinIO unit exit procedure ----- */
743 void
744 _ExitWinIO(void)
746 char *P;
747 MSG Message;
748 char Title[128];
750 if (Created) {
751 P = _WindowTitle;
752 wsprintf(Title, _InactiveTitle, (char *) P);
753 SetWindowText(CrtWindow, Title);
754 GetSystemMenu(CrtWindow, TRUE);
755 _CheckBreak = FALSE;
756 while (GetMessage(&Message, 0, 0, 0)) {
757 TranslateMessage(&Message);
758 DispatchMessage(&Message);
761 } /* _ExitWinIO */