~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Introduced wrapper macros snew(), snewn() and sresize() for the
[sgt/putty]
/
terminal.c
diff --git
a/terminal.c
b/terminal.c
index
2a9470b
..
362d8b5
100644
(file)
--- a/
terminal.c
+++ b/
terminal.c
@@
-99,7
+99,7
@@
static unsigned long *resizeline(unsigned long *line, int cols)
*/
oldlen = line[0];
lineattrs = line[oldlen + 1];
*/
oldlen = line[0];
lineattrs = line[oldlen + 1];
- line = sre
alloc(line, TSIZE * (2 + cols)
);
+ line = sre
size(line, 2 + cols, TTYPE
);
line[0] = cols;
for (i = oldlen; i < cols; i++)
line[i + 1] = ERASE_CHAR;
line[0] = cols;
for (i = oldlen; i < cols; i++)
line[i + 1] = ERASE_CHAR;
@@
-372,7
+372,7
@@
Terminal *term_init(Config *mycfg, struct unicode_data *ucsdata,
* Allocate a new Terminal structure and initialise the fields
* that need it.
*/
* Allocate a new Terminal structure and initialise the fields
* that need it.
*/
- term = s
malloc(sizeof(Terminal)
);
+ term = s
new(Terminal
);
term->frontend = frontend;
term->ucsdata = ucsdata;
term->cfg = *mycfg; /* STRUCTURE COPY */
term->frontend = frontend;
term->ucsdata = ucsdata;
term->cfg = *mycfg; /* STRUCTURE COPY */
@@
-511,7
+511,7
@@
void term_size(Terminal *term, int newrows, int newcols, int newsavelines)
term->savecurs.y += 1;
} else {
/* Add a new blank line at the bottom of the screen. */
term->savecurs.y += 1;
} else {
/* Add a new blank line at the bottom of the screen. */
- line = s
malloc(TSIZE * (newcols + 2)
);
+ line = s
newn(newcols + 2, TTYPE
);
line[0] = newcols;
for (j = 0; j < newcols; j++)
line[j + 1] = ERASE_CHAR;
line[0] = newcols;
for (j = 0; j < newcols; j++)
line[j + 1] = ERASE_CHAR;
@@
-551,7
+551,7
@@
void term_size(Terminal *term, int newrows, int newcols, int newsavelines)
term->disptop = 0;
/* Make a new displayed text buffer. */
term->disptop = 0;
/* Make a new displayed text buffer. */
- newdisp = s
malloc(newrows * (newcols + 1) * TSIZ
E);
+ newdisp = s
newn(newrows * (newcols + 1), TTYP
E);
for (i = 0; i < newrows * (newcols + 1); i++)
newdisp[i] = ATTR_INVALID;
sfree(term->disptext);
for (i = 0; i < newrows * (newcols + 1); i++)
newdisp[i] = ATTR_INVALID;
sfree(term->disptext);
@@
-561,7
+561,7
@@
void term_size(Terminal *term, int newrows, int newcols, int newsavelines)
/* Make a new alternate screen. */
newalt = newtree234(NULL);
for (i = 0; i < newrows; i++) {
/* Make a new alternate screen. */
newalt = newtree234(NULL);
for (i = 0; i < newrows; i++) {
- line = s
malloc(TSIZE * (newcols + 2)
);
+ line = s
newn(newcols + 2, TTYPE
);
line[0] = newcols;
for (j = 0; j < newcols; j++)
line[j + 1] = term->erase_char;
line[0] = newcols;
for (j = 0; j < newcols; j++)
line[j + 1] = term->erase_char;
@@
-576,7
+576,7
@@
void term_size(Terminal *term, int newrows, int newcols, int newsavelines)
term->alt_screen = newalt;
term->alt_sblines = 0;
term->alt_screen = newalt;
term->alt_sblines = 0;
- term->tabs = sre
alloc(term->tabs, newcols * sizeof(*term->tabs)
);
+ term->tabs = sre
size(term->tabs, newcols, unsigned char
);
{
int i;
for (i = (term->cols > 0 ? term->cols : 0); i < newcols; i++)
{
int i;
for (i = (term->cols > 0 ? term->cols : 0); i < newcols; i++)
@@
-769,14
+769,14
@@
static void scroll(Terminal *term, int topline, int botline, int lines, int sb)
if (term->selstart.y >= topline && term->selstart.y <= botline) {
term->selstart.y++;
if (term->selstart.y > botline) {
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->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;
}
}
term->selend.x = 0;
}
}
@@
-797,7
+797,7
@@
static void scroll(Terminal *term, int topline, int botline, int lines, int sb)
if (sblen == term->savelines) {
sblen--, line2 = delpos234(term->scrollback, 0);
} else {
if (sblen == term->savelines) {
sblen--, line2 = delpos234(term->scrollback, 0);
} else {
- line2 = s
malloc(TSIZE * (term->cols + 2)
);
+ line2 = s
newn(term->cols + 2, TTYPE
);
line2[0] = term->cols;
term->tempsblines += 1;
}
line2[0] = term->cols;
term->tempsblines += 1;
}
@@
-889,7
+889,7
@@
static void save_scroll(Terminal *term, int topline, int botline, int lines)
term->scrolltail->botline == botline) {
term->scrolltail->lines += lines;
} else {
term->scrolltail->botline == botline) {
term->scrolltail->lines += lines;
} else {
- newscroll = s
malloc(sizeof(struct scrollregion)
);
+ newscroll = s
new(struct scrollregion
);
newscroll->topline = topline;
newscroll->botline = botline;
newscroll->lines = lines;
newscroll->topline = topline;
newscroll->botline = botline;
newscroll->lines = lines;
@@
-1181,6
+1181,10
@@
static void toggle_mode(Terminal *term, int mode, int query, int state)
if (!term->cfg.no_remote_resize)
request_resize(term->frontend, state ? 132 : 80, term->rows);
term->reset_132 = state;
if (!term->cfg.no_remote_resize)
request_resize(term->frontend, state ? 132 : 80, term->rows);
term->reset_132 = state;
+ term->alt_t = term->marg_t = 0;
+ term->alt_b = term->marg_b = term->rows - 1;
+ move(term, 0, 0, 0);
+ erase_lots(term, FALSE, TRUE, TRUE);
break;
case 5: /* reverse video */
/*
break;
case 5: /* reverse video */
/*
@@
-1627,7
+1631,7
@@
void term_out(Terminal *term)
ticks = GETTICKCOUNT();
if (!term->beep_overloaded) {
ticks = GETTICKCOUNT();
if (!term->beep_overloaded) {
- newbeep = s
malloc(sizeof(struct beeptime)
);
+ newbeep = s
new(struct beeptime
);
newbeep->ticks = ticks;
newbeep->next = NULL;
if (!term->beephead)
newbeep->ticks = ticks;
newbeep->next = NULL;
if (!term->beephead)
@@
-3559,7
+3563,7
@@
static void clipme(Terminal *term, pos top, pos bottom, int rect)
int buflen; /* amount of memory allocated to workbuf */
buflen = 5120; /* Default size */
int buflen; /* amount of memory allocated to workbuf */
buflen = 5120; /* Default size */
- workbuf = s
malloc(buflen * sizeof(wchar_t)
);
+ workbuf = s
newn(buflen, wchar_t
);
wbptr = workbuf; /* start filling here */
old_top_x = top.x; /* needed for rect==1 */
wbptr = workbuf; /* start filling here */
old_top_x = top.x; /* needed for rect==1 */
@@
-3675,9
+3679,8
@@
static void clipme(Terminal *term, pos top, pos bottom, int rect)
for (p = cbuf; *p; p++) {
/* Enough overhead for trailing NL and nul */
if (wblen >= buflen - 16) {
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++;
wbptr = workbuf + wblen;
}
wblen++;
@@
-3946,7
+3949,7
@@
void term_do_paste(Terminal *term)
if (term->paste_buffer)
sfree(term->paste_buffer);
term->paste_pos = term->paste_hold = term->paste_len = 0;
if (term->paste_buffer)
sfree(term->paste_buffer);
term->paste_pos = term->paste_hold = term->paste_len = 0;
- term->paste_buffer = s
malloc(len * sizeof(wchar_t)
);
+ term->paste_buffer = s
newn(len, wchar_t
);
p = q = data;
while (p < data + len) {
p = q = data;
while (p < data + len) {