1 /* $Id: tty.c,v 1.2 2000/10/23 16:52:51 amura Exp $ */
2 /* OS dependent code used by Ng for WinCE.
3 * Copyright (C) 1998 Eiichiro Ito
4 * Modified for Ng for Win32
5 * Copyright (C) 1999,2000 Toru Imai
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * ree Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22 /*
23 * $Log: tty.c,v $
24 * Revision 1.2 2000/10/23 16:52:51 amura
25 * add GPL copyright to header
26 *
27 * Revision 1.1.1.1 2000/06/27 01:48:00 amura
28 * import to CVS
29 *
30 */
31
32 #include <windows.h>
33 #include "config.h"
34 #include "def.h"
35 #include "winmain.h"
36 #include "tools.h"
37
38 extern int ttrow ;
39 extern int ttcol ;
40 extern int tttop ;
41 extern int ttbot ;
42 extern int tthue ;
43
44 int SG = 0 ;
45 int tceeol ; /* Costs are set later */
46 int tcinsl ;
47 int tcdell ;
48
49 int
ttinit()50 ttinit()
51 {
52 tceeol = ttcol ;
53 tcdell = NROW * NCOL ;
54 tcinsl = NROW * NCOL ;
55 return 0 ;
56 }
57
58 int
tttidy()59 tttidy()
60 {
61 return 0 ;
62 }
63
64 int
ttmove(int row,int col)65 ttmove( int row, int col )
66 {
67 if ( ttrow != row || ttcol != col ) {
68 GotoXY( col, row ) ;
69 ttrow = row ;
70 ttcol = col ;
71 }
72 return 0 ;
73 }
74
75 /*
76 * Erase to end of line.
77 */
78 int
tteeol()79 tteeol()
80 {
81 GotoXY( ttcol, ttrow ) ;
82 EraseEOL() ;
83 return 0 ;
84 }
85
86 int
ttnowindow()87 ttnowindow()
88 {
89 ttrow = HUGE ;
90 ttcol = HUGE ;
91 tttop = HUGE ;
92 ttbot = HUGE ;
93 return 0 ;
94 }
95
96 /*
97 * Set the current writing color to the
98 * specified color. Watch for color changes that are
99 * not going to do anything (the color is already right)
100 * and don't send anything to the display.
101 * The rainbow version does this in putline.s on a
102 * line by line basis, so don't bother sending
103 * out the color shift.
104 */
105 int
ttcolor(int color)106 ttcolor( int color )
107 {
108 if ( color != tthue ) {
109 tthue = color ; /* Save the color. */
110 }
111 return 0 ;
112 }
113
114 /*
115 * Erase to end of page.
116 */
117 int
tteeop()118 tteeop()
119 {
120 GotoXY( ttcol, ttrow ) ;
121 EraseEOP() ;
122 return 0 ;
123 }
124
125 /*
126 * Delete nchunk line(s) from "row", replacing the
127 * bottom line on the screen with a blank line.
128 * Unless we're using the scrolling region, this is
129 * done with a crafty sequences of insert and delete
130 * lines. The presence of the echo area makes a
131 * boundry condition go away.
132 */
133 int
ttdell(int row,int bot,int nchunk)134 ttdell( int row, int bot, int nchunk )
135 {
136 ttrow = HUGE ;
137 ttcol = HUGE ;
138 return 0 ;
139 }
140
141 /*
142 * Insert nchunk blank line(s) onto the
143 * screen, scrolling the last line on the
144 * screen off the bottom. Use the scrolling
145 * region if possible for a smoother display.
146 * If no scrolling region, use a set
147 * of insert and delete line sequences
148 */
149 int
ttinsl(int row,int bot,int nchunk)150 ttinsl( int row, int bot, int nchunk )
151 {
152 ttrow = HUGE ;
153 ttcol = HUGE ;
154 return 0 ;
155 }
156
157 /*
158 * Make a noise.
159 */
160 int
ttbeep()161 ttbeep()
162 {
163 extern DWORD g_beepsound;
164 extern TCHAR g_beepfile[];
165
166 switch (g_beepsound) {
167 case 0:
168 /* no sounds */
169 break;
170
171 #ifndef TARGET_WCEVER_IS_100
172 case 1: /* play specified sound file */
173 if (g_beepfile[0]) {
174 sndPlaySound(g_beepfile, SND_ASYNC | SND_NODEFAULT);
175 break;
176 }
177 #endif
178
179 default:
180 MessageBeep(0xFFFFFFFF); /* Default wave sound */
181 break;
182
183 case MB_OK + NG_WAVE_OFFSET:
184 case MB_ICONASTERISK + NG_WAVE_OFFSET:
185 case MB_ICONEXCLAMATION + NG_WAVE_OFFSET:
186 case MB_ICONHAND + NG_WAVE_OFFSET:
187 case MB_ICONQUESTION + NG_WAVE_OFFSET:
188 MessageBeep(g_beepsound - NG_WAVE_OFFSET);
189 break;
190 }
191 return 0;
192 }
193
194 /*
195 * This routine is called by the
196 * "refresh the screen" command to try and resize
197 * the display. The new size, which must be deadstopped
198 * to not exceed the NROW and NCOL limits, it stored
199 * back into "nrow" and "ncol". Display can always deal
200 * with a screen NROW by NCOL. Look in "window.c" to
201 * see how the caller deals with a change.
202 */
203 int
ttresize()204 ttresize()
205 {
206 extern void setttysize pro((void));
207 setttysize();
208 return 0;
209 }
210