Subversion Repositories svn1

Rev

Rev 92 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 92 Rev 94
Line 111... Line 111...
111
 *
111
 *
112
 *========================================================================*/
112
 *========================================================================*/
113
 
113
 
114
void init_screen( void )
114
void init_screen( void )
115
{
115
{
116
    /*
-
 
117
    **  Save a handle to the console
116
    clearscreen();
118
    */
-
 
119
    h_console = GetStdHandle(STD_OUTPUT_HANDLE);
-
 
120
 
-
 
121
    /*
117
    /*
122
    **  Operate within a virtual console area of 24 * 80
118
    **  Operate within a virtual console area of 24 * 80
123
    **  Ignore the real console area
119
    **  Ignore the real console area
124
    */
120
    */
125
    n_lines = 24;                                /* Fix number of lines for export */
121
    n_lines = 24;                                /* Fix number of lines for export */
Line 142... Line 138...
142
 *
138
 *
143
 *========================================================================*/
139
 *========================================================================*/
144
 
140
 
145
void fix_screen( void )                          /* Restore screen to normal */
141
void fix_screen( void )                          /* Restore screen to normal */
146
{
142
{
147
    flush_out();
143
    //flush_out();
148
}
144
}
149
 
145
 
150
/*========================================================================
-
 
151
 *
-
 
152
 *  Position the cursor on the screen
-
 
153
 *
-
 
154
 *  Purpose:
-
 
155
 *      This function is called to Position the cursor on the screen
-
 
156
 *
-
 
157
 *  Parameters:
-
 
158
 *      x               col number
-
 
159
 *      y               line number
-
 
160
 *
-
 
161
 *  Returns:
-
 
162
 *      Nothing
-
 
163
 *
-
 
164
 *========================================================================*/
-
 
165
 
-
 
166
void cur( int x, int y )
-
 
167
{
-
 
168
    COORD cursor;
-
 
169
 
-
 
170
    cursor.Y = y;
-
 
171
    cursor.X = x;
-
 
172
    SetConsoleCursorPosition ( h_console, cursor );
-
 
173
}
-
 
174
 
146
 
175
/*========================================================================
147
/*========================================================================
176
 *
148
 *
177
 *  Position the cursor on the screen
149
 *  Position the cursor on the screen
178
 *
150
 *
Line 206... Line 178...
206
{
178
{
207
    cur( save_x, save_y);
179
    cur( save_x, save_y);
208
}
180
}
209
 
181
 
210
 
182
 
211
/*========================================================================
-
 
212
 *
-
 
213
 *  Clears the vdu screen 
-
 
214
 *
-
 
215
 *  Purpose:
-
 
216
 *      This function is called to Clears the vdu screen
-
 
217
 *      From the Microsoft Web Site 
-
 
218
 *
-
 
219
 *  Parameters:
-
 
220
 *      None
-
 
221
 *
-
 
222
 *  Returns:
-
 
223
 *      Nothing
-
 
224
 *
-
 
225
 *========================================================================*/
-
 
226
 
-
 
227
void clearscreen( void )
-
 
228
{
-
 
229
    COORD coordScreen = { 0, 0 };        /* home for the cursor  */
-
 
230
    DWORD cCharsWritten;
-
 
231
    CONSOLE_SCREEN_BUFFER_INFO csbi;
-
 
232
    DWORD dwConSize;
-
 
233
 
183
 
234
    /*
-
 
235
    **   Get the number of character cells in the current buffer.
-
 
236
    */
-
 
237
 
-
 
238
    if( !GetConsoleScreenBufferInfo( h_console, &csbi ))
-
 
239
        return;
-
 
240
    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
-
 
241
 
-
 
242
    /*
-
 
243
    **   Fill the entire screen with blanks.
-
 
244
    */
-
 
245
    if( !FillConsoleOutputCharacter( h_console, (TCHAR) ' ',
-
 
246
                                dwConSize, coordScreen, &cCharsWritten ))
-
 
247
        return;
-
 
248
 
-
 
249
    /*
-
 
250
    **    Get the current text attribute.
-
 
251
    */
-
 
252
    if( !GetConsoleScreenBufferInfo( h_console, &csbi ))
-
 
253
        return;
-
 
254
 
-
 
255
    /*
-
 
256
    **  Set the buffer's attributes accordingly.
-
 
257
    */
-
 
258
    if( !FillConsoleOutputAttribute( h_console, csbi.wAttributes,
-
 
259
                                dwConSize, coordScreen, &cCharsWritten ))
-
 
260
        return;
-
 
261
 
-
 
262
    /*
-
 
263
    **   Put the cursor at its home coordinates.
-
 
264
    */
-
 
265
    SetConsoleCursorPosition( h_console, coordScreen );
-
 
266
}
-
 
267
 
184
 
268
/*========================================================================
185
/*========================================================================
269
 *
186
 *
270
 *  Generate a bell character
187
 *  Generate a bell character
271
 *
188
 *
Line 885... Line 802...
885
//
802
//
886
//     // Free the buffer.
803
//     // Free the buffer.
887
//     LocalFree( lpMsgBuf );
804
//     LocalFree( lpMsgBuf );
888
// }
805
// }
889
 
806
 
890
int printf( const char *format, ... )
-
 
891
{
-
 
892
    va_list     ap;
-
 
893
    char        pp[200];
-
 
894
    int         len;
-
 
895
    BOOL        result;
-
 
896
    HANDLE      h_console;
-
 
897
 
-
 
898
    DWORD       llen;
-
 
899
    DWORD       rlen;
-
 
900
 
-
 
901
 
-
 
902
    va_start( ap, format );
-
 
903
    len = vsprintf( pp, format, ap );
-
 
904
    va_end( ap );
-
 
905
    llen = len;
-
 
906
    h_console = GetStdHandle(STD_OUTPUT_HANDLE);
-
 
907
    result = WriteConsole( h_console, pp, llen, &rlen, NULL );
-
 
908
    return ( len );
-
 
909
}
-
 
910
 
807
 
911
/*========================================================================
808
/*========================================================================
912
 *
809
 *
913
 *  Display a prompt character in a highlight
810
 *  Display a prompt character in a highlight
914
 *
811
 *