diff --git a/kermit/k95/ckoco2.c b/kermit/k95/ckoco2.c index 676bdd43..42093fd2 100644 --- a/kermit/k95/ckoco2.c +++ b/kermit/k95/ckoco2.c @@ -2114,7 +2114,7 @@ VscrnWrtCell( BYTE vmode, viocell Cell, vtattrib att, USHORT Row, USHORT Col ) /* TX_DECSPEC has a null character in position 5/15 which we need to handle. * I'm not confident that everything will handle a null appearing in the * terminal buffer, so... */ - if (Cell.c == NULL) { + if (Cell.c == 0) { Cell.c = ' '; att.erased = TRUE; } @@ -4214,9 +4214,10 @@ VscrnMark( BYTE vmode, LONG y, SHORT xbeg, SHORT xend ) if ( page->lines[y].markend >= 0 && page->lines[y].markbeg >= 0 ) { for ( x = page->lines[y].markend ; x >= page->lines[y].markbeg ; x-- ) { - if (page->lines[y].cells[x].c == ' ') + if (page->lines[y].cells[x].c == ' ' + || page->lines[y].vt_char_attrs[x] & VT_CHAR_ATTR_INVISIBLE) { page->lines[y].markshowend-- ; - else + } else break ; } } @@ -4291,9 +4292,10 @@ VscrnUnmark( BYTE vmode, LONG y, SHORT xbeg, SHORT xend ) if ( page->lines[y].markend >= 0 && page->lines[y].markbeg >= 0 ) { for ( x = page->lines[y].markend ; x >= page->lines[y].markbeg ; x-- ) { - if (page->lines[y].cells[x].c == ' ') + if (page->lines[y].cells[x].c == ' ' + || page->lines[y].vt_char_attrs[x] & VT_CHAR_ATTR_INVISIBLE) { page->lines[y].markshowend-- ; - else + } else break ; } } @@ -4501,9 +4503,20 @@ IsURLChar( USHORT ch ) /*---------------------------------------------------------------------------*/ /* IsCellPartOfURL | Page: View */ /*---------------------------------------------------------------------------*/ -/* This ONLY called from the renderer, so it must be view-page only */ +/* This ONLY called from the renderer, so it must be view-page only + * + * Checks if a particular cell at coordinates row,col is part of a URL (and so + * suitable for highlighting as a URL). + * + * Parameters: + * mode vscrn containing the cell to check + * row Row of the vscrn containing the cell to check + * col Column of the vscrn containing the cell to check + * row_line row as a videoline* - as all callers are likely to already have + * this handy it saves this function having to look it up again. + */ int -IsCellPartOfURL( BYTE mode, USHORT row, USHORT col ) +IsCellPartOfURL( BYTE mode, USHORT row, USHORT col, videoline* row_line ) { videoline * line=NULL; viocell * cells = NULL; @@ -4516,6 +4529,26 @@ IsCellPartOfURL( BYTE mode, USHORT row, USHORT col ) static int retval = 0; static int brow=-1, bcol=-1, erow=-1, ecol=-1, _mode=-1; + /* Formerly every caller of IsCellPartOfURL only did so after first checking + * IsURLChar() for the current character. With the change to store invisible + * characters, we also now need to check for the invisible attribute too. As + * every caller of IsCellPartOfURL has the videoline handy, its easier to + * just pass that in and perform all checks here rather than have every + * caller of IsCellPartOfURL handle first calling IsURLChar then checking + * attributes. + * + * As for *why* every caller of IsCellPartOfURL was also calling ISURLChar + * directly I'm not really sure. Perhaps an optimisation - skip this + * function if the current character isn't valid in a URL anyway. Or maybe + * to deal with the fact this function caches its result which might become + * invalid if the host modifies a character. */ + if (!row_line || row_line->width == 0 || + !IsURLChar(row_line->cells[col].c) || + row_line->vt_char_attrs[col] & VT_CHAR_ATTR_INVISIBLE) { + + return(0); + } + if ( mode == _mode ) { if ( row == brow && col >= bcol ) { if ( row == erow && col <= ecol || row < erow ) { @@ -4545,19 +4578,13 @@ IsCellPartOfURL( BYTE mode, USHORT row, USHORT col ) brow = erow = row; bcol = ecol = col; - rc = RequestVscrnMutex( mode, SEM_INDEFINITE_WAIT ) ; - if ( scrollflag[mode] ) - line = VscrnGetLine( mode, VscrnGetScrollTop(mode, TRUE) + brow ); - else - line = VscrnGetLineFromTop( mode, brow, TRUE ); - rc = ReleaseVscrnMutex( mode ) ; - if ( !line || line->width == 0 ) - return(retval = 0); + line = row_line; cells = line->cells; while(1) { while ( bcol >= 0 ) { - if ( IsURLChar(cells[bcol].c) ) { + if ( IsURLChar(cells[bcol].c) && + !(line->vt_char_attrs[bcol] & VT_CHAR_ATTR_INVISIBLE) ) { bcol--; } else { if (first) @@ -4594,19 +4621,13 @@ IsCellPartOfURL( BYTE mode, USHORT row, USHORT col ) bfound: /* Find the end of the URL */ - rc = RequestVscrnMutex( mode, SEM_INDEFINITE_WAIT ) ; - if ( scrollflag[mode] ) - line = VscrnGetLine( mode, VscrnGetScrollTop(mode, TRUE) + erow ); - else - line = VscrnGetLineFromTop( mode, erow, TRUE ); - rc = ReleaseVscrnMutex( mode ) ; - if ( !line || line->width == 0 ) - return(retval = 0); + line = row_line; cells = line->cells; while(1) { while ( ecol < line->width ) { - if (IsURLChar(cells[ecol].c)) { + if (IsURLChar(cells[ecol].c) && + !(line->vt_char_attrs[ecol] & VT_CHAR_ATTR_INVISIBLE)) { ecol++; } else { ecol--; @@ -5014,8 +5035,7 @@ TermScrnUpd( void * threadinfo) if ( vt_char_attrs & VT_CHAR_ATTR_HYPERLINK ) vt_char_attrs |= tt_url_hilite_attr; else if ( tt_url_hilite && incnt < URLMINCNT) { - if ( IsURLChar(pScell->c) && - IsCellPartOfURL(avm, y, x+xho ) ) + if ( IsCellPartOfURL(avm, y, x+xho, line ) ) vt_char_attrs |= tt_url_hilite_attr; } if (vt_char_attrs & VT_CHAR_ATTR_BLINK) @@ -5043,6 +5063,10 @@ TermScrnUpd( void * threadinfo) ComputeColorFromAttr( avm, pScell->video_attr, vt_char_attrs ); } + + if (vt_char_attrs & VT_CHAR_ATTR_INVISIBLE) { + pDcell->c = ' '; + } (pDcell+1)->c = ' ' ; } } @@ -5056,8 +5080,7 @@ TermScrnUpd( void * threadinfo) if ( vt_char_attrs & VT_CHAR_ATTR_HYPERLINK ) vt_char_attrs |= tt_url_hilite_attr; else if ( tt_url_hilite && incnt < URLMINCNT) { - if ( IsURLChar(pScell->c) && - IsCellPartOfURL(avm, y, x+xho ) ) + if ( IsCellPartOfURL(avm, y, x+xho, line ) ) vt_char_attrs |= tt_url_hilite_attr; } if (vt_char_attrs & VT_CHAR_ATTR_BLINK) @@ -5085,6 +5108,10 @@ TermScrnUpd( void * threadinfo) ComputeColorFromAttr( avm, pScell->video_attr, vt_char_attrs ); } + + if (vt_char_attrs & VT_CHAR_ATTR_INVISIBLE) { + pDcell->c = ' '; + } } } } else { @@ -5141,8 +5168,7 @@ TermScrnUpd( void * threadinfo) if ( vt_char_attrs & VT_CHAR_ATTR_HYPERLINK ) vt_char_attrs |= tt_url_hilite_attr; else if ( tt_url_hilite && incnt < URLMINCNT ) { - if ( IsURLChar(pScell->c) && - IsCellPartOfURL(avm, y, x+xho ) ) + if ( IsCellPartOfURL(avm, y, x+xho, line ) ) vt_char_attrs |= tt_url_hilite_attr; } if ( line->markshowend != -1 && @@ -5206,6 +5232,10 @@ TermScrnUpd( void * threadinfo) } (pDcell+1)->c = ' ' ; } + + if (vt_char_attrs & VT_CHAR_ATTR_INVISIBLE) { + pDcell->c = ' '; + } } } else @@ -5218,8 +5248,7 @@ TermScrnUpd( void * threadinfo) if ( vt_char_attrs & VT_CHAR_ATTR_HYPERLINK ) vt_char_attrs |= tt_url_hilite_attr; else if ( tt_url_hilite && incnt < URLMINCNT ) { - if ( IsURLChar(pScell->c) && - IsCellPartOfURL(avm, y, x+xho ) ) + if ( IsCellPartOfURL(avm, y, x+xho, line ) ) vt_char_attrs |= tt_url_hilite_attr; } if ( line->markshowend != -1 && @@ -5263,6 +5292,10 @@ TermScrnUpd( void * threadinfo) vt_char_attrs ); } } + + if (vt_char_attrs & VT_CHAR_ATTR_INVISIBLE) { + pDcell->c = ' '; + } } } } @@ -5278,8 +5311,7 @@ TermScrnUpd( void * threadinfo) if ( vt_char_attrs & VT_CHAR_ATTR_HYPERLINK ) vt_char_attrs |= tt_url_hilite_attr; else if ( tt_url_hilite && incnt < URLMINCNT ) { - if ( IsURLChar(pScell->c) && - IsCellPartOfURL(avm, y, x+xho ) ) + if ( IsCellPartOfURL(avm, y, x+xho, line ) ) vt_char_attrs |= tt_url_hilite_attr; } if (vt_char_attrs & VT_CHAR_ATTR_BLINK) @@ -5306,7 +5338,12 @@ TermScrnUpd( void * threadinfo) (pDcell+1)->c = ' ' ; pDcell->video_attr = (pDcell+1)->video_attr = ComputeColorFromAttr( avm, pScell->video_attr, - vt_char_attrs ); } + vt_char_attrs ); + } + + if (vt_char_attrs & VT_CHAR_ATTR_INVISIBLE) { + pDcell->c = ' '; + } } } } @@ -5321,8 +5358,7 @@ TermScrnUpd( void * threadinfo) if ( vt_char_attrs & VT_CHAR_ATTR_HYPERLINK ) vt_char_attrs |= tt_url_hilite_attr; else if ( tt_url_hilite && incnt < URLMINCNT ) { - if ( IsURLChar(pScell->c) && - IsCellPartOfURL(avm, y, x+xho ) ) + if ( IsCellPartOfURL(avm, y, x+xho, line ) ) vt_char_attrs |= tt_url_hilite_attr; } if (vt_char_attrs & VT_CHAR_ATTR_BLINK) @@ -5331,11 +5367,17 @@ TermScrnUpd( void * threadinfo) pDcell->c = blinkon ? pScell->c : ' ' ; } - else + else { pDcell->c = pScell->c ; + } + pDcell->video_attr = ComputeColorFromAttr( avm, pScell->video_attr, vt_char_attrs ); + + if (vt_char_attrs & VT_CHAR_ATTR_INVISIBLE) { + pDcell->c = ' '; + } } } } @@ -5415,6 +5457,10 @@ TermScrnUpd( void * threadinfo) ComputeColorFromAttr( avm, pScell->video_attr, vt_char_attrs ); } + + if (vt_char_attrs & VT_CHAR_ATTR_INVISIBLE) { + pDcell->c = ' '; + } } c += xs ; } diff --git a/kermit/k95/ckoco3.c b/kermit/k95/ckoco3.c index d1ec1707..84dc7ad0 100644 --- a/kermit/k95/ckoco3.c +++ b/kermit/k95/ckoco3.c @@ -8696,6 +8696,10 @@ calculate_decrqcra_checksum(int top, int left, int bot, int right, int page, c = line->cells[x].c; a = line->vt_char_attrs[x]; + if (a & VT_CHAR_ATTR_ERASED) { + c = 0; + } + /* TODO: If c is outside the range of values for the latin1 * character set, the calculation here will be incorrect * as the values the VT420/VT520 assigns to those @@ -8703,6 +8707,16 @@ calculate_decrqcra_checksum(int top, int left, int bot, int right, int page, * calculation to match the real terminal we'll need to do * Unicode->VT conversion here. */ + checksum -= c; + + /* The VT420, VT520 and VT525 only support these attributes */ + if (a & VT_CHAR_ATTR_PROTECTED) checksum -= 0x04; + if (a & VT_CHAR_ATTR_INVISIBLE) checksum -= 0x08; + if (a & VT_CHAR_ATTR_UNDERLINE) checksum -= 0x10; + if (a & VT_CHAR_ATTR_REVERSE) checksum -= 0x20; + if (a & VT_CHAR_ATTR_BLINK) checksum -= 0x40; + if (a & VT_CHAR_ATTR_BOLD) checksum -= 0x80; + if (include_color) { /* These will be 0 for RGB colours */ fgcoloridx = cell_video_attr_foreground(line->cells[x].video_attr); @@ -8755,23 +8769,7 @@ calculate_decrqcra_checksum(int top, int left, int bot, int right, int page, * will fix that up */ fgcoloridx = color_index_from_vio(fgcoloridx); bgcoloridx = color_index_from_vio(bgcoloridx); - } - /* Unoccupied character cells are excluded from the checksum */ - if (a != VT_CHAR_ATTR_ERASED) { - checksum -= c; - - /* The VT420, VT520 and VT525 only support these attributes */ - if (a & VT_CHAR_ATTR_PROTECTED) checksum -= 0x04; - if (a & VT_CHAR_ATTR_INVISIBLE) checksum -= 0x08; - if (a & VT_CHAR_ATTR_UNDERLINE) checksum -= 0x10; - if (a & VT_CHAR_ATTR_REVERSE) checksum -= 0x20; - if (a & VT_CHAR_ATTR_BLINK) checksum -= 0x40; - if (a & VT_CHAR_ATTR_BOLD) checksum -= 0x80; - } - - /* But erased cells can still have colour... */ - if (include_color) { checksum -= (unsigned short)fgcoloridx << 4; checksum -= bgcoloridx; } @@ -19443,8 +19441,13 @@ wrtch(unsigned short ch) { ((ISWYSE(tt_type_mode) || ISTVI(tt_type_mode)) && (ch == STX || ch == ETX))) { /* Treat as a Normal character */ + /* Since C-Kermit 5A(190), we used to just write invisible characters as + * a SPACE. But a real VT doesn't work that way - it deals with it at + * render time, and you can see the character is still there in the + * buffer via DECRQCRA. So for compatibility we must do the same. if (attrib.invisible) ch = SP; + */ if ( ck_isunicode() && crm && ch < SP ) { if ( ISANSI(tt_type_mode) ) diff --git a/kermit/k95/ckoco4.c b/kermit/k95/ckoco4.c index 7e9cf75d..3c232a3a 100644 --- a/kermit/k95/ckoco4.c +++ b/kermit/k95/ckoco4.c @@ -455,12 +455,21 @@ VscrnSelect( BYTE vmode, int mode ) #ifdef NT if ( ck_isunicode() ) { extern int tcsl; - *p = xl_tx[tcsl](line->cells[line->markbeg].c); - *pU = line->cells[line->markbeg].c; + if (line->vt_char_attrs[line->markbeg] & VT_CHAR_ATTR_INVISIBLE) { + *p = ' '; + *pU = ' '; + } else { + *p = xl_tx[tcsl](line->cells[line->markbeg].c); + *pU = line->cells[line->markbeg].c; + } } else #endif /* NT */ { - *pU = *p = line->cells[line->markbeg].c; + if (line->vt_char_attrs[line->markbeg] & VT_CHAR_ATTR_INVISIBLE) { + *pU = ' '; + } else { + *pU = *p = line->cells[line->markbeg].c; + } } p++ ; pU++; diff --git a/kermit/k95/ckocon.h b/kermit/k95/ckocon.h index 9f59cfdd..bd545db9 100644 --- a/kermit/k95/ckocon.h +++ b/kermit/k95/ckocon.h @@ -1909,7 +1909,7 @@ _PROTOTYP( VOID SNI_chcode, (int)); _PROTOTYP( const char * GetSelection,(void)); _PROTOTYP( const char * GetURL,(void)); _PROTOTYP( int GetURLType, (void)); -_PROTOTYP( int IsCellPartOfURL,( BYTE mode, USHORT row, USHORT col )); +_PROTOTYP( int IsCellPartOfURL,( BYTE mode, USHORT row, USHORT col, videoline* )); _PROTOTYP( int IsURLChar, (USHORT)); _PROTOTYP( int os2_settermheight,(int)); diff --git a/kermit/k95/kui/ikterm.cxx b/kermit/k95/kui/ikterm.cxx index f591e6af..059537f4 100644 --- a/kermit/k95/kui/ikterm.cxx +++ b/kermit/k95/kui/ikterm.cxx @@ -292,8 +292,7 @@ BOOL IKTerm::getDrawInfo(BYTE vscrn_number, bool smoothScroll) if ( vt_char_attrs & VT_CHAR_ATTR_HYPERLINK ) vt_char_attrs |= tt_url_hilite_attr; else if ( tt_url_hilite && incnt < URLMINCNT) { - if ( IsURLChar(cell.c) && - IsCellPartOfURL(vnum, y, x+xho ) ) + if ( IsCellPartOfURL(vnum, y, x+xho, line ) ) vt_char_attrs |= tt_url_hilite_attr; } @@ -378,9 +377,13 @@ BOOL IKTerm::getDrawInfo(BYTE vscrn_number, bool smoothScroll) x+xho >= line->markbeg && x+xho <= line->markshowend ) { + /* Throw away the erased flag - the renderer doesn't care + * about it, and it messes with its attribute batching */ + vt_char_attrs = line->vt_char_attrs[x+xho] & ~VT_CHAR_ATTR_ERASED; + textBuffer[c+x] = line->cells[x+xho].c ; attrBuffer[c+x] = colorselect ; - effectBuffer[c+x] = line->vt_char_attrs[x+xho]; + effectBuffer[c+x] = vt_char_attrs; cellAttrBuffer[c+x] = CELL_ATTR_GET(line,x+xho); } else @@ -402,8 +405,7 @@ BOOL IKTerm::getDrawInfo(BYTE vscrn_number, bool smoothScroll) if ( vt_char_attrs & VT_CHAR_ATTR_HYPERLINK ) vt_char_attrs |= tt_url_hilite_attr; else if ( tt_url_hilite && incnt < URLMINCNT) { - if ( IsURLChar(line->cells[x+xho].c) && - IsCellPartOfURL(vnum, y, x+xho ) ) + if ( IsCellPartOfURL(vnum, y, x+xho, line ) ) vt_char_attrs |= tt_url_hilite_attr; } @@ -437,8 +439,7 @@ BOOL IKTerm::getDrawInfo(BYTE vscrn_number, bool smoothScroll) if ( vt_char_attrs & VT_CHAR_ATTR_HYPERLINK ) vt_char_attrs |= tt_url_hilite_attr; else if ( tt_url_hilite && incnt < URLMINCNT) { - if ( IsURLChar(line->cells[x+xho].c) && - IsCellPartOfURL(vnum, y, x+xho ) ) + if ( IsCellPartOfURL(vnum, y, x+xho, line ) ) vt_char_attrs |= tt_url_hilite_attr; } diff --git a/kermit/k95/kui/kclient.cxx b/kermit/k95/kui/kclient.cxx index feb1ee56..e63f4adc 100644 --- a/kermit/k95/kui/kclient.cxx +++ b/kermit/k95/kui/kclient.cxx @@ -1737,6 +1737,11 @@ int KClient::PrepareWorkStore( COLORREF thisBgAttr = cell_video_attr_background_rgb(attrBuffer[i]); vt_char_attr_t thisEffect = effectBuffer[i]; + // Apply invisible attribute. + if (thisEffect & VT_CHAR_ATTR_INVISIBLE) { + textBuffer[i] = ' '; + } + // Apply dim attribute. Ideally, this would have been done by // ComputeColorFromAttr. But it can only return RGB values in 24bit // colour builds, so that would prevent us from applying the dim