*/
oldlen = line[0];
lineattrs = line[oldlen + 1];
- line = srealloc(line, TSIZE * (2 + cols));
+ line = sresize(line, 2 + cols, TTYPE);
line[0] = cols;
for (i = oldlen; i < cols; i++)
line[i + 1] = ERASE_CHAR;
term->alt_wrap = term->wrap = term->cfg.wrap_mode;
if (reset_decom)
term->alt_om = term->dec_om = term->cfg.dec_om;
- if (reset_bce)
+ if (reset_bce) {
term->use_bce = term->cfg.bce;
+ if (term->use_bce)
+ term->erase_char = (' ' | ATTR_ASCII |
+ (term->curr_attr &
+ (ATTR_FGMASK | ATTR_BGMASK)));
+ else
+ term->erase_char = ERASE_CHAR;
+ }
if (reset_blink)
term->blink_is_real = term->cfg.blinktext;
if (reset_charclass)
* Allocate a new Terminal structure and initialise the fields
* that need it.
*/
- term = smalloc(sizeof(Terminal));
+ term = snew(Terminal);
term->frontend = frontend;
term->ucsdata = ucsdata;
term->cfg = *mycfg; /* STRUCTURE COPY */
term->attr_mask = 0xffffffff;
term->resize_fn = NULL;
term->resize_ctx = NULL;
+ term->in_term_out = FALSE;
return term;
}
term->savecurs.y += 1;
} else {
/* Add a new blank line at the bottom of the screen. */
- line = smalloc(TSIZE * (newcols + 2));
+ line = snewn(newcols + 2, TTYPE);
line[0] = newcols;
for (j = 0; j < newcols; j++)
line[j + 1] = ERASE_CHAR;
term->disptop = 0;
/* Make a new displayed text buffer. */
- newdisp = smalloc(newrows * (newcols + 1) * TSIZE);
+ newdisp = snewn(newrows * (newcols + 1), TTYPE);
for (i = 0; i < newrows * (newcols + 1); i++)
newdisp[i] = ATTR_INVALID;
sfree(term->disptext);
/* Make a new alternate screen. */
newalt = newtree234(NULL);
for (i = 0; i < newrows; i++) {
- line = smalloc(TSIZE * (newcols + 2));
+ line = snewn(newcols + 2, TTYPE);
line[0] = newcols;
for (j = 0; j < newcols; j++)
line[j + 1] = term->erase_char;
term->alt_screen = newalt;
term->alt_sblines = 0;
- term->tabs = srealloc(term->tabs, newcols * sizeof(*term->tabs));
+ term->tabs = sresize(term->tabs, newcols, unsigned char);
{
int i;
for (i = (term->cols > 0 ? term->cols : 0); i < newcols; i++)
if (term->selstart.y >= topline && term->selstart.y <= botline) {
term->selstart.y++;
if (term->selstart.y > botline) {
- term->selstart.y = botline;
+ term->selstart.y = botline + 1;
term->selstart.x = 0;
}
}
if (term->selend.y >= topline && term->selend.y <= botline) {
term->selend.y++;
if (term->selend.y > botline) {
- term->selend.y = botline;
+ term->selend.y = botline + 1;
term->selend.x = 0;
}
}
if (sblen == term->savelines) {
sblen--, line2 = delpos234(term->scrollback, 0);
} else {
- line2 = smalloc(TSIZE * (term->cols + 2));
+ line2 = snewn(term->cols + 2, TTYPE);
line2[0] = term->cols;
term->tempsblines += 1;
}
term->scrolltail->botline == botline) {
term->scrolltail->lines += lines;
} else {
- newscroll = smalloc(sizeof(struct scrollregion));
+ newscroll = snew(struct scrollregion);
newscroll->topline = topline;
newscroll->botline = botline;
newscroll->lines = lines;
ticks = GETTICKCOUNT();
if (!term->beep_overloaded) {
- newbeep = smalloc(sizeof(struct beeptime));
+ newbeep = snew(struct beeptime);
newbeep->ticks = ticks;
newbeep->next = NULL;
if (!term->beephead)
*/
break;
case 20:
- if (term->ldisc) {
+ if (term->ldisc &&
+ !term->cfg.no_remote_qtitle) {
p = get_window_title(term->frontend, TRUE);
len = strlen(p);
ldisc_send(term->ldisc, "\033]L", 3, 0);
}
break;
case 21:
- if (term->ldisc) {
+ if (term->ldisc &&
+ !term->cfg.no_remote_qtitle) {
p = get_window_title(term->frontend,FALSE);
len = strlen(p);
ldisc_send(term->ldisc, "\033]l", 3, 0);
term_update(term);
}
-static void clipme(Terminal *term, pos top, pos bottom, int rect)
+static void clipme(Terminal *term, pos top, pos bottom, int rect, int desel)
{
wchar_t *workbuf;
wchar_t *wbptr; /* where next char goes within workbuf */
int buflen; /* amount of memory allocated to workbuf */
buflen = 5120; /* Default size */
- workbuf = smalloc(buflen * sizeof(wchar_t));
+ workbuf = snewn(buflen, wchar_t);
wbptr = workbuf; /* start filling here */
old_top_x = top.x; /* needed for rect==1 */
for (p = cbuf; *p; p++) {
/* Enough overhead for trailing NL and nul */
if (wblen >= buflen - 16) {
- workbuf =
- srealloc(workbuf,
- sizeof(wchar_t) * (buflen += 100));
+ buflen += 100;
+ workbuf = sresize(workbuf, buflen, wchar_t);
wbptr = workbuf + wblen;
}
wblen++;
wblen++;
*wbptr++ = 0;
#endif
- write_clip(term->frontend, workbuf, wblen, FALSE); /* transfer to clipbd */
+ write_clip(term->frontend, workbuf, wblen, desel); /* transfer to clipbd */
if (buflen > 0) /* indicates we allocated this buffer */
sfree(workbuf);
}
pos top;
top.y = -sblines(term);
top.x = 0;
- clipme(term, top, term->curs, 0);
+ clipme(term, top, term->curs, 0, TRUE);
}
/*
if (term->paste_buffer)
sfree(term->paste_buffer);
term->paste_pos = term->paste_hold = term->paste_len = 0;
- term->paste_buffer = smalloc(len * sizeof(wchar_t));
+ term->paste_buffer = snewn(len, wchar_t);
p = q = data;
while (p < data + len) {
* data to the clipboard.
*/
clipme(term, term->selstart, term->selend,
- (term->seltype == RECTANGULAR));
+ (term->seltype == RECTANGULAR), FALSE);
term->selstate = SELECTED;
} else
term->selstate = NO_SELECTION;
return FALSE;
}
-/*
- * from_backend(), to get data from the backend for the terminal.
- */
-int from_backend(void *vterm, int is_stderr, const char *data, int len)
+int term_data(Terminal *term, int is_stderr, const char *data, int len)
{
- Terminal *term = (Terminal *)vterm;
-
assert(len > 0);
bufchain_add(&term->inbuf, data, len);
+ if (!term->in_term_out) {
+ term->in_term_out = TRUE;
+ term_blink(term, 1);
+ term_out(term);
+ term->in_term_out = FALSE;
+ }
+
/*
* term_out() always completely empties inbuf. Therefore,
* there's no reason at all to return anything other than zero