📄 wperror.c
字号:
/* CXL - Copyright (c) 1987-1989 by Mike Smedley - All Rights Reserved */
/* WPERROR.C - displays an error message window */
/*-----------------08-10-97 11:01am-----------------
Modified to support multi-line error messages. To use multi-line
support, embed "\n" in string.
09/01/977 - Added parameter to indicate whether to display [ Error ]
--------------------------------------------------*/
#include <stdio.h>
#include <string.h>
#include "cxldef.h"
#include "cxlkey.h"
#include "cxlvid.h"
#include "cxlwin.h"
int wperror(char *message, int error)
{
static int wattr=WHITE|_RED,tattr=YELLOW|_RED;
int lmessage,wwidth,row,col,srow,scol;
int i;
int cur_length = 0;
int max_length = 0;
int num_rows = 0;
/* determine longest line & number of rows */
lmessage=strlen(message);
for ( i=0; i<lmessage+1; i++ )
{
if ( message[i] == '\n' || message[i] == '\0' )
{
if ( cur_length > max_length )
{
max_length = cur_length;
}
cur_length = 0;
num_rows++;
}
else {
cur_length++;
}
}
/* calculate error window coordinates */
wwidth=max_length+2;
readcur(&row,&col);
if(row> 21-num_rows ) {
srow=row-(num_rows + 3);
}
else {
srow=row+2;
}
if( (col+wwidth) >= _vinfo.numcols )
scol=_vinfo.numcols-1-wwidth;
else
scol=col;
if(scol<0) {
return(_winfo.errno=W_STRLONG);
}
/* check for monochrome */
if(_vinfo.mono) {
wattr=LGREY;
tattr=WHITE;
}
/* open error window */
if(!wopen(srow,scol,srow+num_rows+1,scol+wwidth,0,WHITE|_RED,WHITE|_RED)) {
return(_winfo.errno);
}
if (error) {
wtitle("[ Error ]",TCENTER,WHITE|_RED);
}
else {
wtitle("[ Warning ]",TCENTER,WHITE|_RED);
}
/* display error message */
wtextattr(YELLOW|_RED);
/* wputc(' '); */
wputs(message);
/* sound beep and wait for a keypress */
beep();
waitkey();
/* close error window, reset cursor, and return normally */
wclose();
gotoxy_(row,col);
return(_winfo.errno=W_NOERROR);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -