windisp.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 619 行 · 第 1/2 页
C
619 行
if( EditFlags.Quiet ) {
return;
}
w = Windows[ wn ];
/*
* find dimensions of line
*/
if( !w->has_border ) {
return;
}
if( line < 1 || line > w->height-2 ) {
return;
}
line--;
/*
* initialize
*/
w = AccessWindow( wn );
addr = 1 + (1+line) * w->width;
txt = (char_info *) &(w->text[ sizeof(char_info)*addr ]);
scr = (char_info _FAR *) &Scrn[ (w->x1 + (1+line+w->y1)*WindMaxWidth) *
sizeof(char_info) ];
#ifdef __VIO__
oscr = (unsigned) ((char _FAR *) (scr) - Scrn);
#endif
what.attr = MAKE_ATTR( w, w->border_color1, w->border_color2 );
what.ch = WindowBordersNG[ WB_LEFTT ];
over = &(w->overlap[ addr ]);
if( *over++ == NO_CHAR ) {
WRITE_SCREEN( *scr, what );
}
WRITE_SCREEN_DATA( *txt, what );
txt++;
scr++;
what.ch = WindowBordersNG[ WB_TOPBOTTOM ];
for( i=w->x1+1;i<w->x2;i++ ) {
if( *over++ == NO_CHAR ) {
WRITE_SCREEN( *scr, what );
}
WRITE_SCREEN_DATA( *txt, what );
txt++;
scr++;
}
if( line != w->height-3 && line != 0 ) {
what.ch = WindowBordersNG[ WB_RIGHTT ];
WRITE_SCREEN_DATA( *txt, what );
if( *over == NO_CHAR ) {
WRITE_SCREEN( *scr, what );
}
scr++;
txt++;
}
#ifdef __VIO__
MyVioShowBuf( oscr, w->width );
#endif
ReleaseWindow( w );
} /* DisplayCrossLineInWindow */
/*
* changeColorOfDisplayLine - do just that, using given colors and column range
*/
static void changeColorOfDisplayLine( int line, int scol, int ecol, type_style *s )
{
wind *w;
char *over;
char_info _FAR *scr;
char_info what;
#ifdef __VIO__
unsigned oscr;
unsigned onscr;
#endif
int attr,t,end,spend,cnt1,cnt2,sscol,spl;
if( EditFlags.Quiet ) {
return;
}
w = AccessWindow( CurrentWindow );
/*
* find dimensions of line
*/
if( w->has_border ) {
if( line < 1 || line > w->height-2 ) {
ReleaseWindow( w );
return;
}
spl = line;
sscol = 1+scol;
spend = end = ecol+2;
if( spend > w->width-1 ) {
spend = end = w->width-1;
}
if( sscol < 1 ) {
sscol = 1;
}
} else {
if( line < 1 || line > w->height ) {
ReleaseWindow( w );
return;
}
spl = line-1;
sscol = scol;
spend = end = ecol+1;
if( spend > w->width ) {
spend = end = w->width;
}
if( sscol < 0 ) {
sscol = 0;
}
}
cnt1 = end-sscol;
cnt2 = spend-end;
line--;
/*
* initialize
*/
t = sscol + spl * w->width;
scr = (char_info _FAR *) &Scrn[ (w->x1+sscol + (spl+w->y1)*WindMaxWidth)
*sizeof(char_info) ];
#ifdef __VIO__
oscr = (unsigned) ((char _FAR *) scr - Scrn);
onscr = 0;
#endif
attr = MAKE_ATTR( w, s->foreground, s->background );
what.attr = attr;
/*
* display line
*/
if( w->overcnt[ spl ] ) {
over = w->overlap + t;
while( cnt1-- != 0 ) {
if( *over++ == NO_CHAR ) {
what.ch = (*scr).ch;
WRITE_SCREEN( *scr, what );
#ifdef __VIO__
onscr++;
#endif
}
scr++;
}
while( cnt2-- != 0 ) {
if( *over++ == NO_CHAR ) {
what.ch = (*scr).ch;
WRITE_SCREEN( *scr, what );
#ifdef __VIO__
onscr++;
#endif
}
scr++;
}
} else {
while( cnt1-- != 0 ) {
what.ch = (*scr).ch;
WRITE_SCREEN( *scr, what );
#ifdef __VIO__
onscr++;
#endif
scr++;
}
while( cnt2-- != 0 ) {
what.ch = (*scr).ch;
WRITE_SCREEN( *scr, what );
#ifdef __VIO__
onscr++;
#endif
scr++;
}
}
#ifdef __VIO__
MyVioShowBuf( oscr, onscr );
#endif
ReleaseWindow( w );
} /* changeColorOfDisplayLine */
/*
* HiliteAColumnRange - color a specified word on a line
*/
void HiliteAColumnRange( linenum line, int scol, int ecol )
{
int s,e;
s = VirtualCursorPosition2( scol );
e = VirtualCursorPosition2( ecol + 1 ) - 1;
if( scol == 0 ) {
s = 0;
}
changeColorOfDisplayLine( (int) (line-TopOfPage+1),
s - LeftColumn, e - LeftColumn, &editw_info.hilight );
} /* HiliteAColumnRange */
/*
* ColorAColumnRange - color a specified word on a line
*/
void ColorAColumnRange( int row, int scol, int ecol, type_style *style )
{
int s,e,t;
s = VirtualCursorPosition2( scol );
e = VirtualCursorPosition2( ecol );
if( s > e ) {
t = s;
s = e;
e = t;
}
s--;
e--;
changeColorOfDisplayLine( row, s - LeftColumn, e - LeftColumn, style );
} /* ColorAColumnRange */
/*
* SetCharInWindowWithColor - do just that, using given colors
*/
int SetCharInWindowWithColor( window_id wn, int line, int col, char text, type_style *style )
{
wind *w;
char *over;
int attr,addr,start,spl;
char_info tmp;
char_info *txt;
char_info _FAR *scr;
bool has_mouse;
if( EditFlags.Quiet ) {
return( ERR_NO_ERR );
}
w = Windows[ wn ];
/*
* find dimensions of line
*/
if( w->has_border ) {
if( line < 1 || line > w->height-2 ) {
return( ERR_WIND_NO_SUCH_LINE );
}
start = 1;
spl = line;
} else {
if( line < 1 || line > w->height ) {
return( ERR_WIND_NO_SUCH_LINE );
}
start = 0;
spl = line-1;
}
if( col < 1 || col > w->width ) {
return( ERR_WIND_NO_SUCH_COLUMN );
}
line--;
col--;
/*
* initialize
*/
w = AccessWindow( wn );
addr = col + start + spl * w->width;
txt = (char_info *) &(w->text[ sizeof(char_info)*addr ]);
scr = (char_info _FAR *) &Scrn[ (w->x1+start + col + (spl+w->y1)*
WindMaxWidth) *sizeof(char_info) ];
attr = MAKE_ATTR( w, style->foreground, style->background );
/*
* display char
*/
has_mouse = DisplayMouse( FALSE );
over = &(w->overlap[ addr ]);
tmp.attr = attr;
tmp.ch = text;
WRITE_SCREEN_DATA( *txt, tmp );
if( *over == NO_CHAR ) {
WRITE_SCREEN( *scr, tmp );
}
#ifdef __VIO__
MyVioShowBuf( (unsigned)((char *) scr-Scrn), 1 );
#endif
ReleaseWindow( w );
DisplayMouse( has_mouse );
return( ERR_NO_ERR );
} /* SetCharInWindowWithColor */
/*
* DisplayLineInWindow - do as it sounds, use default colors
*/
int DisplayLineInWindow( window_id wn, int c_line_no, char *text )
{
ss_block ss;
SEType[ SE_UNUSED ].foreground = Windows[ wn ]->text_color;
SEType[ SE_UNUSED ].background = Windows[ wn ]->background_color;
SEType[ SE_UNUSED ].font = 0;
ss.type = SE_UNUSED;
ss.end = BEYOND_TEXT;
return( displayLineInWindowGeneric( wn, c_line_no, text, 0, &ss ) );
} /* DisplayLineInWindow */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?