/*
* Initialise the terminal.
*/
-Terminal *term_init(Config *mycfg, void *frontend)
+Terminal *term_init(Config *mycfg, struct unicode_data *ucsdata,
+ void *frontend)
{
Terminal *term;
*/
term = smalloc(sizeof(Terminal));
term->frontend = frontend;
+ term->ucsdata = ucsdata;
term->cfg = *mycfg; /* STRUCTURE COPY */
term->logctx = NULL;
term->compatibility_level = TM_PUTTY;
return term;
}
+void term_free(Terminal *term)
+{
+ unsigned long *line;
+ struct beeptime *beep;
+
+ while ((line = delpos234(term->scrollback, 0)) != NULL)
+ sfree(line);
+ freetree234(term->scrollback);
+ while ((line = delpos234(term->screen, 0)) != NULL)
+ sfree(line);
+ freetree234(term->screen);
+ while ((line = delpos234(term->alt_screen, 0)) != NULL)
+ sfree(line);
+ freetree234(term->alt_screen);
+ sfree(term->disptext);
+ while (term->beephead) {
+ beep = term->beephead;
+ term->beephead = beep->next;
+ sfree(beep);
+ }
+ bufchain_clear(&term->inbuf);
+ if(term->print_job)
+ printer_finish_job(term->print_job);
+ bufchain_clear(&term->printer_buf);
+ sfree(term->paste_buffer);
+ sfree(term);
+}
+
/*
* Set up the terminal for a given size.
*/
case 0:
if (c < 0x80) {
/* UTF-8 must be stateless so we ignore iso2022. */
- if (unitab_ctrl[c] != 0xFF)
- c = unitab_ctrl[c];
+ if (term->ucsdata->unitab_ctrl[c] != 0xFF)
+ c = term->ucsdata->unitab_ctrl[c];
else c = ((unsigned char)c) | ATTR_ASCII;
break;
} else if ((c & 0xe0) == 0xc0) {
* the same encoding.
*/
case ATTR_LINEDRW:
- if (unitab_ctrl[c] != 0xFF)
- c = unitab_ctrl[c];
+ if (term->ucsdata->unitab_ctrl[c] != 0xFF)
+ c = term->ucsdata->unitab_ctrl[c];
else
c = ((unsigned char) c) | ATTR_LINEDRW;
break;
break;
}
/*FALLTHROUGH*/ case ATTR_ASCII:
- if (unitab_ctrl[c] != 0xFF)
- c = unitab_ctrl[c];
+ if (term->ucsdata->unitab_ctrl[c] != 0xFF)
+ c = term->ucsdata->unitab_ctrl[c];
else
c = ((unsigned char) c) | ATTR_ASCII;
break;
tattr = (*d & (ATTR_MASK ^ CSET_MASK));
switch (tchar & CSET_MASK) {
case ATTR_ASCII:
- tchar = unitab_line[tchar & 0xFF];
+ tchar = term->ucsdata->unitab_line[tchar & 0xFF];
break;
case ATTR_LINEDRW:
- tchar = unitab_xterm[tchar & 0xFF];
+ tchar = term->ucsdata->unitab_xterm[tchar & 0xFF];
break;
case ATTR_SCOACS:
- tchar = unitab_scoacs[tchar&0xFF];
+ tchar = term->ucsdata->unitab_scoacs[tchar&0xFF];
break;
}
tattr |= (tchar & CSET_MASK);
if ((attr & CSET_MASK) == 0x2300 && tchar >= 0xBA
&& tchar <= 0xBD) break_run = TRUE;
- if (!dbcs_screenfont && !dirty_line) {
+ if (!term->ucsdata->dbcs_screenfont && !dirty_line) {
if ((tchar | tattr) == term->disptext[idx])
break_run = TRUE;
else if (!dirty_run && ccount == 1)
start = j;
ccount = 0;
attr = tattr;
- if (dbcs_screenfont)
+ if (term->ucsdata->dbcs_screenfont)
last_run_dirty = dirty_run;
dirty_run = dirty_line;
}
switch (uc & CSET_MASK) {
case ATTR_LINEDRW:
if (!term->cfg.rawcnp) {
- uc = unitab_xterm[uc & 0xFF];
+ uc = term->ucsdata->unitab_xterm[uc & 0xFF];
break;
}
case ATTR_ASCII:
- uc = unitab_line[uc & 0xFF];
+ uc = term->ucsdata->unitab_line[uc & 0xFF];
break;
case ATTR_SCOACS:
- uc = unitab_scoacs[uc&0xFF];
+ uc = term->ucsdata->unitab_scoacs[uc&0xFF];
break;
}
switch (uc & CSET_MASK) {
case ATTR_ACP:
- uc = unitab_font[uc & 0xFF];
+ uc = term->ucsdata->unitab_font[uc & 0xFF];
break;
case ATTR_OEMCP:
- uc = unitab_oemcp[uc & 0xFF];
+ uc = term->ucsdata->unitab_oemcp[uc & 0xFF];
break;
}
char buf[4];
WCHAR wbuf[4];
int rv;
- if (is_dbcs_leadbyte(font_codepage, (BYTE) c)) {
+ if (is_dbcs_leadbyte(term->ucsdata->font_codepage, (BYTE) c)) {
buf[0] = c;
buf[1] = (char) (0xFF & ldata[top.x + 1]);
- rv = mb_to_wc(font_codepage, 0, buf, 2, wbuf, 4);
+ rv = mb_to_wc(term->ucsdata->font_codepage, 0, buf, 2, wbuf, 4);
top.x++;
} else {
buf[0] = c;
- rv = mb_to_wc(font_codepage, 0, buf, 1, wbuf, 4);
+ rv = mb_to_wc(term->ucsdata->font_codepage, 0, buf, 1, wbuf, 4);
}
if (rv > 0) {
switch (uc & CSET_MASK) {
case ATTR_LINEDRW:
- uc = unitab_xterm[uc & 0xFF];
+ uc = term->ucsdata->unitab_xterm[uc & 0xFF];
break;
case ATTR_ASCII:
- uc = unitab_line[uc & 0xFF];
+ uc = term->ucsdata->unitab_line[uc & 0xFF];
break;
case ATTR_SCOACS:
- uc = unitab_scoacs[uc&0xFF];
+ uc = term->ucsdata->unitab_scoacs[uc&0xFF];
break;
}
switch (uc & CSET_MASK) {
case ATTR_ACP:
- uc = unitab_font[uc & 0xFF];
+ uc = term->ucsdata->unitab_font[uc & 0xFF];
break;
case ATTR_OEMCP:
- uc = unitab_oemcp[uc & 0xFF];
+ uc = term->ucsdata->unitab_oemcp[uc & 0xFF];
break;
}
/* For DBCS font's I can't do anything usefull. Even this will sometimes
* fail as there's such a thing as a double width space. :-(
*/
- if (dbcs_screenfont && font_codepage == line_codepage)
+ if (term->ucsdata->dbcs_screenfont &&
+ term->ucsdata->font_codepage == term->ucsdata->line_codepage)
return (uc != ' ');
if (uc < 0x80)
get_clip(term->frontend, NULL, NULL);
}
-void term_mouse(Terminal *term, Mouse_Button b, Mouse_Action a, int x, int y,
- int shift, int ctrl, int alt)
+void term_mouse(Terminal *term, Mouse_Button braw, Mouse_Button bcooked,
+ Mouse_Action a, int x, int y, int shift, int ctrl, int alt)
{
pos selpoint;
unsigned long *ldata;
if (term->ldisc) {
- switch (b) {
+ switch (braw) {
case MBT_LEFT:
encstate = 0x20; /* left button down */
break;
term->mouse_is_down = 0;
break;
case MA_CLICK:
- if (term->mouse_is_down == b)
+ if (term->mouse_is_down == braw)
return;
- term->mouse_is_down = b;
+ term->mouse_is_down = braw;
break;
default: break; /* placate gcc warning about enum use */
}
return;
}
- b = translate_button(term->frontend, b);
-
/*
* Set the selection type (rectangular or normal) at the start
* of a selection attempt, from the state of Alt.
term->seltype = default_seltype;
}
- if (b == MBT_SELECT && a == MA_CLICK) {
+ if (bcooked == MBT_SELECT && a == MA_CLICK) {
deselect(term);
term->selstate = ABOUT_TO;
term->seltype = default_seltype;
term->selanchor = selpoint;
term->selmode = SM_CHAR;
- } else if (b == MBT_SELECT && (a == MA_2CLK || a == MA_3CLK)) {
+ } else if (bcooked == MBT_SELECT && (a == MA_2CLK || a == MA_3CLK)) {
deselect(term);
term->selmode = (a == MA_2CLK ? SM_WORD : SM_LINE);
term->selstate = DRAGGING;
term->selend = term->selstart;
incpos(term->selend);
sel_spread(term);
- } else if ((b == MBT_SELECT && a == MA_DRAG) ||
- (b == MBT_EXTEND && a != MA_RELEASE)) {
+ } else if ((bcooked == MBT_SELECT && a == MA_DRAG) ||
+ (bcooked == MBT_EXTEND && a != MA_RELEASE)) {
if (term->selstate == ABOUT_TO && poseq(term->selanchor, selpoint))
return;
- if (b == MBT_EXTEND && a != MA_DRAG && term->selstate == SELECTED) {
+ if (bcooked == MBT_EXTEND && a != MA_DRAG &&
+ term->selstate == SELECTED) {
if (term->seltype == LEXICOGRAPHIC) {
/*
* For normal selection, we extend by moving
term->selend.y = max(term->selanchor.y, selpoint.y);
}
sel_spread(term);
- } else if ((b == MBT_SELECT || b == MBT_EXTEND) && a == MA_RELEASE) {
+ } else if ((bcooked == MBT_SELECT || bcooked == MBT_EXTEND) &&
+ a == MA_RELEASE) {
if (term->selstate == DRAGGING) {
/*
* We've completed a selection. We now transfer the
term->selstate = SELECTED;
} else
term->selstate = NO_SELECTION;
- } else if (b == MBT_PASTE
+ } else if (bcooked == MBT_PASTE
&& (a == MA_CLICK
#if MULTICLICK_ONLY_EVENT
|| a == MA_2CLK || a == MA_3CLK