Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 85 additions & 39 deletions kermit/k95/ckoco2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 ;
}
}
Expand Down Expand Up @@ -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 ;
}
}
Expand Down Expand Up @@ -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;
Expand All @@ -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 ) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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--;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 = ' ' ;
}
}
Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -5206,6 +5232,10 @@ TermScrnUpd( void * threadinfo)
}
(pDcell+1)->c = ' ' ;
}

if (vt_char_attrs & VT_CHAR_ATTR_INVISIBLE) {
pDcell->c = ' ';
}
}
}
else
Expand All @@ -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 &&
Expand Down Expand Up @@ -5263,6 +5292,10 @@ TermScrnUpd( void * threadinfo)
vt_char_attrs );
}
}

if (vt_char_attrs & VT_CHAR_ATTR_INVISIBLE) {
pDcell->c = ' ';
}
}
}
}
Expand All @@ -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)
Expand All @@ -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 = ' ';
}
}
}
}
Expand All @@ -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)
Expand All @@ -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 = ' ';
}
}
}
}
Expand Down Expand Up @@ -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 ;
}
Expand Down
35 changes: 19 additions & 16 deletions kermit/k95/ckoco3.c
Original file line number Diff line number Diff line change
Expand Up @@ -8696,13 +8696,27 @@ 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
* characters unsurprisingly differ from Unicode. For the
* 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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) )
Expand Down
15 changes: 12 additions & 3 deletions kermit/k95/ckoco4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion kermit/k95/ckocon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading
Loading