Skip to content
Snippets Groups Projects
Commit 48012755 authored by deuce's avatar deuce
Browse files

Support palettized scrollback.

parent 8b8912eb
No related branches found
No related tags found
No related merge requests found
......@@ -168,6 +168,7 @@ struct note_params {
#define WHEREX() cterm->ciolib_wherex(cterm)
#define WHEREY() cterm->ciolib_wherey(cterm)
#define GETTEXT(a,b,c,d,e) cterm->ciolib_gettext(cterm, a,b,c,d,e)
#define PGETTEXT(a,b,c,d,e,f,g) cterm->ciolib_pgettext(cterm, a,b,c,d,e,f,g)
#define GETTEXTINFO(a) cterm->ciolib_gettextinfo(cterm,a)
#define TEXTATTR(a) cterm->ciolib_textattr(cterm,a)
#define SETCURSORTYPE(a) cterm->ciolib_setcursortype(cterm,a)
......@@ -187,6 +188,7 @@ struct note_params {
#define GOTOXY(x,y) cterm->ciolib_gotoxy(x, y)
#define WHEREX() cterm->ciolib_wherex()
#define WHEREY() cterm->ciolib_wherey()
#define PGETTEXT(a,b,c,d,e,f,g) cterm->ciolib_pgettext(a,b,c,d,e,f,g)
#define GETTEXT(a,b,c,d,e) cterm->ciolib_gettext(a,b,c,d,e)
#define GETTEXTINFO(a) cterm->ciolib_gettextinfo(a)
#define TEXTATTR(a) cterm->ciolib_textattr(a)
......@@ -909,9 +911,13 @@ static void scrollup(struct cterminal *cterm)
if(cterm->scrollback!=NULL) {
if(cterm->backpos>cterm->backlines) {
memmove(cterm->scrollback,cterm->scrollback+cterm->width*2,cterm->width*2*(cterm->backlines-1));
if (cterm->scrollbackf)
memmove(cterm->scrollbackf,cterm->scrollbackf+cterm->width,cterm->width*(cterm->backlines-1));
if (cterm->scrollbackb)
memmove(cterm->scrollbackb,cterm->scrollbackb+cterm->width,cterm->width*(cterm->backlines-1));
cterm->backpos--;
}
GETTEXT(cterm->x, top, cterm->x+cterm->width-1, top, cterm->scrollback+(cterm->backpos-1)*cterm->width*2);
PGETTEXT(cterm->x, top, cterm->x+cterm->width-1, top, cterm->scrollback+(cterm->backpos-1)*cterm->width*2, cterm->scrollbackf?cterm->scrollbackf+(cterm->backpos-1)*cterm->width:NULL, cterm->scrollbackb?cterm->scrollbackb+(cterm->backpos-1)*cterm->width:NULL);
}
MOVETEXT(cterm->x,top+1,cterm->x+cterm->width-1,top+height-1,cterm->x,top);
x=WHEREX();
......@@ -971,8 +977,13 @@ void CIOLIBCALL cterm_clearscreen(struct cterminal *cterm, char attr)
if(cterm->backpos>cterm->backlines) {
memmove(cterm->scrollback,cterm->scrollback+cterm->width*2*(cterm->backpos-cterm->backlines),cterm->width*2*(cterm->backlines-(cterm->backpos-cterm->backlines)));
cterm->backpos=cterm->backlines;
if (cterm->scrollbackf)
memmove(cterm->scrollbackf,cterm->scrollbackf+cterm->width*(cterm->backpos-cterm->backlines),cterm->width*(cterm->backlines-(cterm->backpos-cterm->backlines)));
if (cterm->scrollbackb)
memmove(cterm->scrollbackb,cterm->scrollbackb+cterm->width*(cterm->backpos-cterm->backlines),cterm->width*(cterm->backlines-(cterm->backpos-cterm->backlines)));
}
GETTEXT(cterm->x,cterm->y,cterm->x+cterm->width-1,cterm->y+cterm->height-1,cterm->scrollback+(cterm->backpos-cterm->height)*cterm->width*2);
PGETTEXT(cterm->x,cterm->y,cterm->x+cterm->width-1,cterm->y+cterm->height-1,cterm->scrollback+(cterm->backpos-cterm->height)*cterm->width*2,cterm->scrollbackf?cterm->scrollbackf+(cterm->backpos-cterm->height)*cterm->width:NULL,cterm->scrollbackb?cterm->scrollbackb+(cterm->backpos-cterm->height)*cterm->width:NULL);
}
CLRSCR();
if(cterm->origin_mode)
......@@ -2367,7 +2378,7 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
cterm->sequence=0;
}
struct cterminal* CIOLIBCALL cterm_init(int height, int width, int xpos, int ypos, int backlines, unsigned char *scrollback, int emulation)
struct cterminal* CIOLIBCALL cterm_init(int height, int width, int xpos, int ypos, int backlines, unsigned char *scrollback, uint32_t *scrollbackf, uint32_t *scrollbackb, int emulation)
{
char *revision="$Revision$";
char *in;
......@@ -2402,6 +2413,8 @@ struct cterminal* CIOLIBCALL cterm_init(int height, int width, int xpos, int ypo
cterm->backpos=0;
cterm->backlines=backlines;
cterm->scrollback=scrollback;
cterm->scrollbackf=scrollbackf;
cterm->scrollbackb=scrollbackb;
cterm->log=CTERM_LOG_NONE;
cterm->logfile=NULL;
cterm->emulation=emulation;
......@@ -2412,6 +2425,10 @@ struct cterminal* CIOLIBCALL cterm_init(int height, int width, int xpos, int ypo
cterm->bg_color = UINT32_MAX;
if(cterm->scrollback!=NULL)
memset(cterm->scrollback,0,cterm->width*2*cterm->backlines);
if(cterm->scrollbackf!=NULL)
memset(cterm->scrollbackf,0,cterm->width*cterm->backlines*sizeof(cterm->scrollbackf[0]));
if(cterm->scrollbackb!=NULL)
memset(cterm->scrollbackb,0,cterm->width*cterm->backlines*sizeof(cterm->scrollbackb[0]));
strcpy(cterm->DA,"\x1b[=67;84;101;114;109;");
out=strchr(cterm->DA, 0);
if(out != NULL) {
......
......@@ -88,7 +88,9 @@ struct cterminal {
int top_margin;
int bottom_margin;
int quiet; // No sounds are made
unsigned char *scrollback;
unsigned char *scrollback;
uint32_t *scrollbackf;
uint32_t *scrollbackb;
int backlines; // Number of lines in scrollback
char DA[1024]; // Device Attributes
bool autowrap;
......@@ -155,6 +157,7 @@ struct cterminal {
int (*ciolib_wherex) (struct cterminal *);
int (*ciolib_wherey) (struct cterminal *);
int (*ciolib_gettext) (struct cterminal *,int,int,int,int,void *);
int (*ciolib_pgettext) (struct cterminal *,int,int,int,int,void *,uint32_t *,uint32_t *);
void (*ciolib_gettextinfo) (struct cterminal *,struct text_info *);
void (*ciolib_textattr) (struct cterminal *,int);
void (*ciolib_setcursortype) (struct cterminal *,int);
......@@ -177,6 +180,7 @@ struct cterminal {
int CIOLIBCALL (*ciolib_wherex) (void);
int CIOLIBCALL (*ciolib_wherey) (void);
int CIOLIBCALL (*ciolib_gettext) (int,int,int,int,void *);
int CIOLIBCALL (*ciolib_pgettext) (int,int,int,int,void *,uint32_t *,uint32_t *);
void CIOLIBCALL (*ciolib_gettextinfo) (struct text_info *);
void CIOLIBCALL (*ciolib_textattr) (int);
void CIOLIBCALL (*ciolib_setcursortype) (int);
......@@ -205,7 +209,7 @@ struct cterminal {
extern "C" {
#endif
CIOLIBEXPORT struct cterminal* CIOLIBCALL cterm_init(int height, int width, int xpos, int ypos, int backlines, unsigned char *scrollback, int emulation);
CIOLIBEXPORT struct cterminal* CIOLIBCALL cterm_init(int height, int width, int xpos, int ypos, int backlines, unsigned char *scrollback, uint32_t *scrollbackf, uint32_t *scrollbackb, int emulation);
CIOLIBEXPORT char* CIOLIBCALL cterm_write(struct cterminal *cterm, const void *buf, int buflen, char *retbuf, size_t retsize, int *speed);
CIOLIBEXPORT int CIOLIBCALL cterm_openlog(struct cterminal *cterm, char *logfile, int logtype);
CIOLIBEXPORT void CIOLIBCALL cterm_closelog(struct cterminal *cterm);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment