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
51 changes: 51 additions & 0 deletions kermit/k95/ckoco2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3181,6 +3181,9 @@ VscrnGetCurPos( BYTE vmode ) {
static viocell * cellmem[VNUM] = { NULL, NULL, NULL, NULL } ;
static unsigned short * attrmem[VNUM] = { NULL, NULL, NULL, NULL } ;
static unsigned short * hyperlinkmem[VNUM] = { NULL, NULL, NULL, NULL } ;
#ifdef KUI
static char * cellattrmem[VNUM] = { NULL, NULL, NULL, NULL } ;
#endif /* KUI */

/*---------------------------------------------------------------------------*/
/* VscrnSetBufferSize | Page: All */
Expand Down Expand Up @@ -3284,6 +3287,10 @@ VscrnSetBufferSize( BYTE vmode, ULONG newsize, int new_page_count )
cellmem[vmode]=NULL ;
free(attrmem[vmode]) ;
attrmem[vmode]=NULL ;
#ifdef KUI
free(cellattrmem[vmode]);
cellattrmem[vmode]=NULL ;
#endif /* KUI */
}

if (vscrn[vmode].pages == NULL) {
Expand Down Expand Up @@ -3359,6 +3366,10 @@ VscrnSetBufferSize( BYTE vmode, ULONG newsize, int new_page_count )
(total_lines + 1) * MAXTERMCOL * sizeof(short)) ;
debug( F101,"VscrnSetBufferSize hyperlinkmem size","",
(total_lines + 1) * MAXTERMCOL * sizeof(short)) ;
#ifdef KUI
debug( F101,"VscrnSetBufferSize cellattrmem size","",
(total_lines + 1) * MAXTERMROW * sizeof(char)) ;
#endif /* KUI */

cellmem[vmode] = malloc( (total_lines + 1) * MAXTERMCOL * sizeof(viocell) ) ;
if ( !cellmem[vmode] )
Expand All @@ -3369,6 +3380,11 @@ VscrnSetBufferSize( BYTE vmode, ULONG newsize, int new_page_count )
hyperlinkmem[vmode] = malloc( (total_lines + 1) * MAXTERMCOL * sizeof(short) ) ;
if ( !hyperlinkmem[vmode] )
fatal("VscrnSetBufferSize: unable to allocate memory for hyperlinkmem[]!");
#ifdef KUI
cellattrmem[vmode] = malloc( (total_lines + 1) * MAXTERMCOL * sizeof(char) ) ;
if ( !cellattrmem[vmode] )
fatal("VscrnSetBufferSize: unable to allocate memory for cellattrmem[]!");
#endif /* KUI */

/* Loop over all lines in all pages assigning memory to them. As the
* various per-cell members are allocated in big blocks of memory, we
Expand All @@ -3386,6 +3402,9 @@ VscrnSetBufferSize( BYTE vmode, ULONG newsize, int new_page_count )
vscrn[vmode].pages[pagenum].lines[j].width = 0 ;
vscrn[vmode].pages[pagenum].lines[j].cells = cellmem[vmode] + mem_offset ;
vscrn[vmode].pages[pagenum].lines[j].vt_char_attrs = attrmem[vmode] + mem_offset ;
#ifdef KUI
vscrn[vmode].pages[pagenum].lines[j].cell_attrs = cellattrmem[vmode] + mem_offset ;
#endif /* KUI */
vscrn[vmode].pages[pagenum].lines[j].vt_line_attr = VT_LINE_ATTR_NORMAL ;
vscrn[vmode].pages[pagenum].lines[j].hyperlinks = hyperlinkmem[vmode] + mem_offset ;
vscrn[vmode].pages[pagenum].lines[j].markbeg = -1 ;
Expand All @@ -3402,6 +3421,9 @@ VscrnSetBufferSize( BYTE vmode, ULONG newsize, int new_page_count )
vscrn_t TmpScrn ;
viocell * oldcellmem = cellmem[vmode] ;
unsigned short * oldattrmem = attrmem[vmode] ;
#ifdef KUI
char * oldcellattrmem = cellattrmem[vmode] ;
#endif /* KUI */
unsigned short * oldhyperlinkmem = hyperlinkmem[vmode] ;
int old_lines;

Expand Down Expand Up @@ -3475,6 +3497,14 @@ VscrnSetBufferSize( BYTE vmode, ULONG newsize, int new_page_count )
memcpy( attrmem[vmode], oldattrmem, (old_lines + 1)
* MAXTERMCOL * sizeof(short) ) ;

#ifdef KUI
cellattrmem[vmode] = malloc( (total_lines + 1) * MAXTERMCOL * sizeof(char) ) ;
if ( !cellattrmem[vmode] )
fatal("VscrnSetBufferSize: unable to allocate memory for cellattrmem[]!");
memcpy( cellattrmem[vmode], oldcellattrmem, (old_lines + 1)
* MAXTERMCOL * sizeof(short) ) ;
#endif /* KUI */

hyperlinkmem[vmode] = malloc( (total_lines + 1) * MAXTERMCOL * sizeof(short) ) ;
if ( !hyperlinkmem[vmode] )
fatal("VscrnSetBufferSize: unable to allocate memory for hyperlinkmem[]!");
Expand Down Expand Up @@ -3503,6 +3533,12 @@ VscrnSetBufferSize( BYTE vmode, ULONG newsize, int new_page_count )
+ (attrmem[vmode] - oldattrmem);
line->vt_char_attrs = 0 ;

#ifdef KUI
TmpScrn.pages[pagenum].lines[i].cell_attrs = line->cell_attrs
+ (cellattrmem[vmode] - oldcellattrmem);
line->vt_char_attrs = 0 ;
#endif /* KUI */

TmpScrn.pages[pagenum].lines[i].hyperlinks = line->hyperlinks
+ (hyperlinkmem[vmode] - oldhyperlinkmem);
line->hyperlinks = 0 ;
Expand All @@ -3519,6 +3555,9 @@ VscrnSetBufferSize( BYTE vmode, ULONG newsize, int new_page_count )
TmpScrn.pages[pagenum].lines[i].width = 0 ;
TmpScrn.pages[pagenum].lines[i].cells = cellmem[vmode] + (i+total_lines+1) * MAXTERMCOL ;
TmpScrn.pages[pagenum].lines[i].vt_char_attrs = attrmem[vmode] + (i+total_lines+1) * MAXTERMCOL ;
#ifdef KUI
TmpScrn.pages[pagenum].lines[i].cell_attrs = cellattrmem[vmode] + (i+total_lines+1) * MAXTERMCOL ;
#endif /* KUI */
TmpScrn.pages[pagenum].lines[i].hyperlinks = hyperlinkmem[vmode] + (i+total_lines+1) * MAXTERMCOL ;
TmpScrn.pages[pagenum].lines[i].vt_line_attr = VT_LINE_ATTR_NORMAL ;
TmpScrn.pages[pagenum].lines[i].markbeg = -1 ;
Expand All @@ -3532,6 +3571,9 @@ VscrnSetBufferSize( BYTE vmode, ULONG newsize, int new_page_count )

free(oldcellmem) ;
free(oldattrmem) ;
#ifdef KUI
free(oldcellattrmem) ;
#endif /* KUI */
free(oldhyperlinkmem) ;
vscrn[vmode] = TmpScrn ;
}
Expand Down Expand Up @@ -3706,6 +3748,9 @@ VscrnScrollPage(BYTE vmode, int updown, int topmargin, int bottommargin,

line->cells = linetodelete.cells ;
line->vt_char_attrs = linetodelete.vt_char_attrs ;
#ifdef KUI
line->cell_attrs = linetodelete.cell_attrs ;
#endif /* KUI */
}

for ( i = 0 ; i < nlines ; i++ ) {
Expand All @@ -3721,6 +3766,9 @@ VscrnScrollPage(BYTE vmode, int updown, int topmargin, int bottommargin,
for ( x = 0 ; x < MAXTERMCOL ; x++ ) {
line->cells[x] = blankcell ;
line->vt_char_attrs[x] = VT_CHAR_ATTR_NORMAL ;
#ifdef KUI
line->cell_attrs[x] = CA_ATTR_NONE;
#endif /* KUI */
}
}
break;
Expand Down Expand Up @@ -5315,6 +5363,9 @@ vscrn_size_bytes(BYTE vnum) {
size_t result;
size_t cellsize = sizeof(viocell) /* viocell */
+ sizeof(short) /* attributes */
#ifdef KUI
+ sizeof(char) /* Cell attributes */
#endif /* KUI */
+ sizeof(short); /* hyperlink IDs */
size_t vlinesize = sizeof(videoline) + MAXTERMCOL * cellsize;

Expand Down
191 changes: 189 additions & 2 deletions kermit/k95/ckoco3.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,11 @@ struct tt_info_rec tt_info[] = { /* Indexed by terminal type */
"VT420", {"DEC-VT420","DEC-VT400","VT400",NULL}, "[?64;1;2;6;8;9;15;22;23;42;44;45;46c", /* DEC VT420 */
"VT525", {"DEC-VT525","DEC-VT500","VT500",NULL}, "[?65;1;2;6;8;9;15;22;23;42;44;45;46c", /* DEC VT520 */
#endif /* COMMENT */
"K95", {"K95",NULL}, "[?63;1;2;6;8;9;15;28;32;44c", /* Kermit 95 self-personality */
"K95", {"K95",NULL}, "[?63;1;2;6;8;9;15;28;32;43;44c", /* Kermit 95 self-personality */
/* K95 Device Attributes:
VT320;132-columns;printer;selective-erase;user-defined-keys;
national-replacement-character-sets;technical-characters;
rectangular-editing;text-macros;PCTerm */
rectangular-editing;text-macros;ruled-lines;PCTerm */
"TVI910", {"TELEVIDEO-910","TVI910+""910",NULL}, "TVS 910 REV.I\r", /* TVI 910+ */
"TVI925", {"TELEVIDEO-925","925",NULL}, "TVS 925 REV.I\r", /* TVI 925 */
"TVI950", {"TELEVIDEO-950","950",NULL}, "1.0,0\r", /* TVI 950 */
Expand Down Expand Up @@ -6747,6 +6747,117 @@ boxrect_escape( BYTE vmode, int row, int col )
}
}

#ifdef KUI
#define DECDRLBR_BOTTOM 0x01
#define DECDRLBR_RIGHT 0x02
#define DECDRLBR_TOP 0x04
#define DECDRLBR_LEFT 0x08
void
ruledlines_escape(int pattern, int left, int top, int width, int height, BOOL set) {
int right, bot, x, y;

/* TODO:
* - Cursor Coupling: should this be happening on the cursor page only?
* Currently assuming yes.
*/

if (pattern & 0x0F == 0) return; /* Nothing to do */

/* Columns and lines are numbered from 0 */
left -= 1;
right = left + width-1;
bot = top + height-1;

/* Top or Bottom boundary */
if (pattern & DECDRLBR_BOTTOM || pattern & DECDRLBR_TOP) {
videoline *topLine = NULL;
videoline *botLine = NULL;

/* Top line */
if (pattern & DECDRLBR_TOP) {
debug(F111, "Ruled Lines top at", "y", top - 1);
topLine = VscrnGetLineFromTop(vmode, top - 1, FALSE);
}

if (pattern & DECDRLBR_BOTTOM) {
debug(F111, "Ruled Lines bot at", "y", bot - 1);
botLine = VscrnGetLineFromTop(vmode, bot - 1, FALSE);
}

/* Cells are numbered from 0 */
for (x = left; x <= right; x++) {
if (topLine) {
debug(F111, "Ruled Lines top at", "x", x);
topLine->cell_attrs[x] =
set ? topLine->cell_attrs[x] | CA_ATTR_TOP_BORDER
: topLine->cell_attrs[x] & ~CA_ATTR_TOP_BORDER;
}

if (botLine) {
debug(F111, "Ruled Lines bot at", "x", x);
botLine->cell_attrs[x] =
set ? botLine->cell_attrs[x] | CA_ATTR_BOTTOM_BORDER
: botLine->cell_attrs[x] & ~CA_ATTR_BOTTOM_BORDER;
}
}
}

/* Left or Right boundary */
if (pattern & DECDRLBR_RIGHT || pattern & DECDRLBR_LEFT) {
debug(F111, "Ruled Lines left at", "x", left);
debug(F111, "Ruled Lines left at", "x", right);
for (y = top-1; y < bot; y++) {
videoline *line = VscrnGetLineFromTop(vmode, y, FALSE);

if (pattern & DECDRLBR_LEFT) {
debug(F111, "Ruled Lines left at", "y", y);
line->cell_attrs[left] =
set ? line->cell_attrs[left] | CA_ATTR_LEFT_BORDER
: line->cell_attrs[left] & ~CA_ATTR_LEFT_BORDER;
}

if (pattern & DECDRLBR_RIGHT) {
debug(F111, "Ruled Lines right at", "y", y);
line->cell_attrs[right] =
set ? line->cell_attrs[right] | CA_ATTR_RIGHT_BORDER
: line->cell_attrs[right] & ~CA_ATTR_RIGHT_BORDER;
}
}
}

if (cursor_on_visible_page(VTERM)) {
VscrnIsDirty(vmode);
}
}

/* Erase all ruled lines in an area */
void
decerlbra_escape(int left, int top, int width, int height) {
int right, bot, x, y, mask;

/* Columns and lines are numbered from 0 */
left -= 1;
right = left + width-1;
bot = top + height-1;

mask = ~(CA_ATTR_TOP_BORDER | CA_ATTR_BOTTOM_BORDER |
CA_ATTR_LEFT_BORDER | CA_ATTR_RIGHT_BORDER);

for (y = top-1; y < bot; y++) {
videoline *line = VscrnGetLineFromTop(vmode, y, FALSE);

for (x = left; x <= right; x++) {
line->cell_attrs[x] = line->cell_attrs[x] & mask;
}
}

if (cursor_on_visible_page(VTERM)) {
VscrnIsDirty(vmode);
}
}

#endif /* KUI */

void
decdwl_escape(bool dwlflag) {
videoline * line = NULL ;
Expand Down Expand Up @@ -24125,6 +24236,82 @@ vtcsi(void)
pn[1] = 8 ;
loadtod( pn[1], pn[2] ) ;
break;
#ifdef KUI
case 'r':
case 's':
/* r - DECDRLBR - Draw Ruled Lines in a pattern
* s - DECERLBRP - Erase Ruled Lines in a pattern */
if (ISDECTERM(tt_type_mode) || ISK95(tt_type_mode)) {
int pattern, left, top, width, height;

if (k < 1) break; /* First parameter (pattern) required */
pattern = pn[1];

/* Starting column */
if (k < 2) left = 1;
else left = pn[2];

/* width in columns */
if (k < 3) width = 1;
else width = pn[3];

/* Starting line */
if (k < 4) top = 1;
else top = pn[4];

/* height in lines */
if (k < 5) height = 1;
else height = pn[5];

ruledlines_escape(pattern, left, top, width, height,
achar == 'r'); /* 'r' is set, 's' is clear */
}
break;
case 't':
/* DECERLBRA - Erase All Ruled Lines in an Area */
if (ISDECTERM(tt_type_mode) || ISK95(tt_type_mode)) {
int scope;

if (k < 1) scope = 1;
else scope = pn[1];

if (scope == 0 || scope == 1) {
/* Erase all ruled lines on screen */

/* For scope 0/1 DECterm would still require an area
to be specified, otherwise it would ignore the
whole thing. We won't enforce that though.
if (k < 5) break; */

decerlbra_escape(1, 1,
tt_cols[VTERM], tt_rows[VTERM]);

} else if (scope == 2) {
/* Erase all ruled lines in an area */

int left, top, width, height;

/* Starting column */
if (k < 2) left = 1;
else left = pn[2];

/* width in columns */
if (k < 3) width = 1;
else width = pn[3];

/* Starting line */
if (k < 4) top = 1;
else top = pn[4];

/* height in lines */
if (k < 5) height = 1;
else height = pn[5];

decerlbra_escape(left, top, width, height);
}
}
break;
#endif /* KUI */
case 'x': /* DECSPMA - Session Page Memory Allocation */
if (ISVT520(tt_type_mode)) {
/* We don't support multiple sessions, so this just
Expand Down
3 changes: 3 additions & 0 deletions kermit/k95/ckocon.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,9 @@ cleartermpage( BYTE vmode, int page ) {
line->cells[x].c = ' ' ;
line->cells[x].video_attr = vmode == VTERM ? attribute : colorcmd ;
line->vt_char_attrs[x] = VT_CHAR_ATTR_NORMAL ;
#ifdef KUI
line->cell_attrs[x] = CA_ATTR_NONE;
#endif /* KUI */
}
}
lgotoxy(vmode,1, 1);
Expand Down
16 changes: 16 additions & 0 deletions kermit/k95/ckocon.h
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,19 @@ typedef struct _vtattrib { /* Character (SGR) attributes, 1 bit each */

#define WY_LINE_ATTR_PROTECTED ((USHORT) 0x08)

#ifdef KUI
/* These currently only used by K95G */
#define CA_ATTR_NONE ((CHAR) 0x00)
#define CA_ATTR_LEFT_BORDER ((CHAR) 0x01)
#define CA_ATTR_TOP_BORDER ((CHAR) 0x02)
#define CA_ATTR_RIGHT_BORDER ((CHAR) 0x04)
#define CA_ATTR_BOTTOM_BORDER ((CHAR) 0x08)
#define CA_ATTR_RESERVED_4 ((CHAR) 0x10)
#define CA_ATTR_RESERVED_3 ((CHAR) 0x20)
#define CA_ATTR_RESERVED_2 ((CHAR) 0x40)
#define CA_ATTR_RESERVED_1 ((CHAR) 0x80)
#endif /* KUI */

/* On OS/2, this struct must be a pair of unsigned chars - the first a
* character, the second its attributes. */
typedef struct cell_struct { /* to be used with VioWrtNCell() */
Expand All @@ -1306,6 +1319,9 @@ typedef struct videoline_struct {
unsigned short width ; /* number of valid chars */
viocell * cells ; /* valid to length width */
unsigned short * vt_char_attrs ; /* bitwise & of VT_CHAR_ATTR Values */
#ifdef KUI
unsigned char * cell_attrs; /* bitwise & of CA_ATTR Values */
#endif /* KUI */
unsigned short * hyperlinks; /* hyperlink index values */
unsigned short vt_line_attr ;
short markbeg ;
Expand Down
Loading