--- rxvt-unicode/src/screen.C 2003/12/16 23:04:13 1.7 +++ rxvt-unicode/src/screen.C 2003/12/26 07:42:23 1.14 @@ -1,7 +1,7 @@ /*--------------------------------*-C-*--------------------------------------* * File: screen.c *---------------------------------------------------------------------------* - * $Id: screen.C,v 1.7 2003/12/16 23:04:13 pcg Exp $ + * $Id: screen.C,v 1.14 2003/12/26 07:42:23 pcg Exp $ * * Copyright (c) 1997-2001 Geoff Wing * @@ -33,6 +33,8 @@ #include #include +#include "salloc.C" // HACK!! + inline void fill_text (text_t *start, text_t value, int len) { while (len--) @@ -89,350 +91,386 @@ * CLEAR_CHARS: clear chars starting from pixel position * ERASE_ROWS : set rows starting from row to the foreground colour */ -#define drawBuffer (R->TermWin.vt) +#define drawBuffer TermWin.vt #define CLEAR_ROWS(row, num) \ - if (R->TermWin.mapped) \ - XClearArea(R->Xdisplay, drawBuffer, R->TermWin.int_bwidth, \ - Row2Pixel(row), (unsigned int)R->TermWin.width, \ - (unsigned int)Height2Pixel(num), False) + if (TermWin.mapped) \ + XClearArea (Xdisplay, drawBuffer, TermWin.int_bwidth, \ + Row2Pixel(row), (unsigned int)TermWin.width, \ + (unsigned int)Height2Pixel(num), False) #define CLEAR_CHARS(x, y, num) \ - if (R->TermWin.mapped) \ - XClearArea(R->Xdisplay, drawBuffer, x, y, \ - (unsigned int)Width2Pixel(num), \ - (unsigned int)Height2Pixel(1), False) + if (TermWin.mapped) \ + XClearArea (Xdisplay, drawBuffer, x, y, \ + (unsigned int)Width2Pixel(num), \ + (unsigned int)Height2Pixel(1), False) #define ERASE_ROWS(row, num) \ - XFillRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, \ - R->TermWin.int_bwidth, Row2Pixel(row), \ - (unsigned int)R->TermWin.width, \ - (unsigned int)Height2Pixel(num)) + XFillRectangle (Xdisplay, drawBuffer, TermWin.gc, \ + TermWin.int_bwidth, Row2Pixel(row), \ + (unsigned int)TermWin.width, \ + (unsigned int)Height2Pixel(num)) /* ------------------------------------------------------------------------- * * SCREEN `COMMON' ROUTINES * * ------------------------------------------------------------------------- */ /* Fill part/all of a line with blanks. */ -/* INTPROTO */ void -rxvt_blank_line(pR_ text_t *et, rend_t *er, unsigned int width, rend_t efs) +rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) { - efs &= ~RS_baseattrMask; - efs = SET_FONT (efs, R->TermWin.fontset->find_font (' ')); + efs &= ~RS_baseattrMask; + efs = SET_FONT (efs, TermWin.fontset->find_font (' ')); - while (width--) - { - *et++ = ' '; - *er++ = efs; - } + while (width--) + { + *et++ = ' '; + *er++ = efs; + } } /* ------------------------------------------------------------------------- */ /* Fill a full line with blanks - make sure it is allocated first */ -/* INTPROTO */ void -rxvt_blank_screen_mem(pR_ text_t **tp, rend_t **rp, unsigned int row, rend_t efs) +rxvt_term::scr_blank_screen_mem (text_t **tp, rend_t **rp, unsigned int row, rend_t efs) { - int width = R->TermWin.ncol; - rend_t *er; - #ifdef DEBUG_STRICT - assert((tp[row] && rp[row]) || (tp[row] == NULL && rp[row] == NULL)); + assert((tp[row] && rp[row]) || (tp[row] == NULL && rp[row] == NULL)); #endif - if (tp[row] == NULL) { - tp[row] = (text_t *)rxvt_malloc(sizeof(text_t) * width); - rp[row] = (rend_t *)rxvt_malloc(sizeof(rend_t) * width); + if (tp[row] == NULL) + { + tp[row] = (text_t *)talloc->alloc (); + rp[row] = (rend_t *)ralloc->alloc (); } - rxvt_blank_line (aR_ tp[row], rp[row], width, efs); + + scr_blank_line (tp[row], rp[row], TermWin.ncol, efs); } /* ------------------------------------------------------------------------- * * SCREEN INITIALISATION * * ------------------------------------------------------------------------- */ -/* EXTPROTO */ void -rxvt_scr_reset(pR) +rxvt_term::scr_reset () { - unsigned int ncol, nrow, prev_ncol, prev_nrow, - total_rows, prev_total_rows; - unsigned int p, q; - int k; - rend_t setrstyle; + unsigned int ncol, nrow, total_rows, prev_total_rows; + unsigned int p, q; + int k; + rend_t setrstyle; - D_SCREEN((stderr, "rxvt_scr_reset()")); + D_SCREEN((stderr, "rxvt_scr_reset()")); - R->TermWin.view_start = 0; - R->num_scr = 0; + TermWin.view_start = 0; + num_scr = 0; - prev_ncol = R->prev_ncol; - prev_nrow = R->prev_nrow; - if (R->TermWin.ncol == 0) - R->TermWin.ncol = 80; - if (R->TermWin.nrow == 0) - R->TermWin.nrow = 24; - ncol = R->TermWin.ncol; - nrow = R->TermWin.nrow; - if (ncol == prev_ncol && nrow == prev_nrow) - return; + if (TermWin.ncol == 0) + TermWin.ncol = 80; - R->want_refresh = 1; + if (TermWin.nrow == 0) + TermWin.nrow = 24; - total_rows = nrow + R->TermWin.saveLines; - prev_total_rows = prev_nrow + R->TermWin.saveLines; + ncol = TermWin.ncol; + nrow = TermWin.nrow; - R->screen.tscroll = 0; - R->screen.bscroll = nrow - 1; + if (ncol == prev_ncol && nrow == prev_nrow) + return; - if (prev_nrow == 0) { -/* - * A: first time called so just malloc everything : don't rely on realloc - * Note: this is still needed so that all the scrollback lines are NULL - */ - R->screen.text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); - R->buf_text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); - R->drawn_text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); - R->swap.text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); - - R->screen.tlen = (int16_t *)rxvt_calloc(total_rows, sizeof(int16_t)); - R->swap.tlen = (int16_t *)rxvt_calloc(nrow, sizeof(int16_t)); - - R->screen.rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); - R->buf_rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); - R->drawn_rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); - R->swap.rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); - - for (p = 0; p < nrow; p++) { - q = p + R->TermWin.saveLines; - rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, - q, DEFAULT_RSTYLE); - rxvt_blank_screen_mem(aR_ R->swap.text, R->swap.rend, - p, DEFAULT_RSTYLE); - R->screen.tlen[q] = R->swap.tlen[p] = 0; - rxvt_blank_screen_mem(aR_ R->drawn_text, R->drawn_rend, - p, DEFAULT_RSTYLE); + want_refresh = 1; + + total_rows = nrow + TermWin.saveLines; + prev_total_rows = prev_nrow + TermWin.saveLines; + + screen.tscroll = 0; + screen.bscroll = nrow - 1; + + if (!talloc) + { + talloc = new rxvt_salloc (ncol * sizeof (text_t)); + ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); + } + + if (prev_nrow == 0) + { + /* + * first time called so just malloc everything : don't rely on realloc + * Note: this is still needed so that all the scrollback lines are NULL + */ + screen.text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); + buf_text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); + drawn_text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); + swap.text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); + + screen.tlen = (int16_t *)rxvt_calloc(total_rows, sizeof(int16_t)); + swap.tlen = (int16_t *)rxvt_calloc(nrow, sizeof(int16_t)); + + screen.rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); + buf_rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); + drawn_rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); + swap.rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); + + for (p = 0; p < nrow; p++) + { + q = p + TermWin.saveLines; + scr_blank_screen_mem (screen.text, screen.rend, q, DEFAULT_RSTYLE); + scr_blank_screen_mem (swap.text, swap.rend, p, DEFAULT_RSTYLE); + screen.tlen[q] = swap.tlen[p] = 0; + scr_blank_screen_mem (drawn_text, drawn_rend, p, DEFAULT_RSTYLE); } - MEMSET(R->charsets, 'B', sizeof(R->charsets)); - R->TermWin.nscrolled = 0; /* no saved lines */ - R->rstyle = DEFAULT_RSTYLE; - R->screen.flags = Screen_DefaultFlags; - R->screen.cur.row = R->screen.cur.col = 0; - R->screen.charset = 0; - R->current_screen = PRIMARY; - rxvt_scr_cursor(aR_ SAVE); + + MEMSET(charsets, 'B', sizeof(charsets)); + TermWin.nscrolled = 0; /* no saved lines */ + rstyle = DEFAULT_RSTYLE; + screen.flags = Screen_DefaultFlags; + screen.cur.row = screen.cur.col = 0; + screen.charset = 0; + current_screen = PRIMARY; + rxvt_scr_cursor (this, SAVE); + #if NSCREENS - R->swap.flags = Screen_DefaultFlags; - R->swap.cur.row = R->swap.cur.col = 0; - R->swap.charset = 0; - R->current_screen = SECONDARY; - rxvt_scr_cursor(aR_ SAVE); - R->current_screen = PRIMARY; -#endif - R->selection.text = NULL; - R->selection.len = 0; - R->selection.op = SELECTION_CLEAR; - R->selection.screen = PRIMARY; - R->selection.clicks = 0; - CLEAR_ALL_SELECTION(R); - R->rvideo = 0; + swap.flags = Screen_DefaultFlags; + swap.cur.row = swap.cur.col = 0; + swap.charset = 0; + current_screen = SECONDARY; + rxvt_scr_cursor (this, SAVE); + current_screen = PRIMARY; +#endif + + selection.text = NULL; + selection.len = 0; + selection.op = SELECTION_CLEAR; + selection.screen = PRIMARY; + selection.clicks = 0; + CLEAR_ALL_SELECTION (this); + rvideo = 0; + } + else + { + /* + * add or delete rows as appropriate + */ + setrstyle = DEFAULT_RSTYLE; - } else { -/* - * B1: add or delete rows as appropriate - */ - setrstyle = DEFAULT_RSTYLE; + if (nrow < prev_nrow) + { + /* delete rows */ + k = min (TermWin.nscrolled, prev_nrow - nrow); + scr_scroll_text (0, (int)prev_nrow - 1, k, 1); - if (nrow < prev_nrow) { - /* delete rows */ - k = min(R->TermWin.nscrolled, prev_nrow - nrow); - rxvt_scroll_text(aR_ 0, (int)prev_nrow - 1, k, 1); - for (p = nrow; p < prev_nrow; p++) { - q = p + R->TermWin.saveLines; - if (R->screen.text[q]) { + for (p = nrow; p < prev_nrow; p++) + { + q = p + TermWin.saveLines; + if (screen.text[q]) + { #ifdef DEBUG_STRICT - assert(R->screen.rend[q]); + assert (screen.rend[q]); #endif - free(R->screen.text[q]); - free(R->screen.rend[q]); + talloc->free (screen.text[q]); + ralloc->free (screen.rend[q]); } - if (R->swap.text[p]) { + if (swap.text[p]) + { #ifdef DEBUG_STRICT - assert(R->swap.rend[p]); + assert (swap.rend[p]); #endif - free(R->swap.text[p]); - free(R->swap.rend[p]); + talloc->free (swap.text[p]); + ralloc->free (swap.rend[p]); } #ifdef DEBUG_STRICT - assert(R->drawn_text[p] && R->drawn_rend[p]); + assert (drawn_text[p] && drawn_rend[p]); #endif - free(R->drawn_text[p]); - free(R->drawn_rend[p]); + talloc->free (drawn_text[p]); + ralloc->free (drawn_rend[p]); } - /* we have fewer rows so fix up cursor position */ - MIN_IT(R->screen.cur.row, (int32_t)nrow - 1); - MIN_IT(R->swap.cur.row, (int32_t)nrow - 1); - - rxvt_scr_reset_realloc(aR); /* realloc _last_ */ - - } else if (nrow > prev_nrow) { - /* add rows */ - rxvt_scr_reset_realloc(aR); /* realloc _first_ */ - - k = min(R->TermWin.nscrolled, nrow - prev_nrow); - for (p = prev_total_rows; p < total_rows; p++) { - R->screen.tlen[p] = 0; - R->screen.text[p] = NULL; - R->screen.rend[p] = NULL; + + /* we have fewer rows so fix up cursor position */ + MIN_IT (screen.cur.row, (int32_t)nrow - 1); + MIN_IT (swap.cur.row, (int32_t)nrow - 1); + + scr_reset_realloc (); /* realloc _last_ */ + } + else if (nrow > prev_nrow) + { + /* add rows */ + scr_reset_realloc (); /* realloc _first_ */ + + TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this + + k = min (TermWin.nscrolled, nrow - prev_nrow); + + for (p = prev_total_rows; p < total_rows; p++) + { + screen.tlen[p] = 0; + screen.text[p] = NULL; + screen.rend[p] = NULL; } - for (p = prev_total_rows; p < total_rows - k; p++) - rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, - p, setrstyle); - for (p = prev_nrow; p < nrow; p++) { - R->swap.tlen[p] = 0; - R->swap.text[p] = NULL; - R->swap.rend[p] = NULL; - R->drawn_text[p] = NULL; - R->drawn_rend[p] = NULL; - rxvt_blank_screen_mem(aR_ R->swap.text, R->swap.rend, - p, setrstyle); - rxvt_blank_screen_mem(aR_ R->drawn_text, R->drawn_rend, - p, setrstyle); + + for (p = prev_total_rows; p < total_rows - k; p++) + scr_blank_screen_mem (screen.text, screen.rend, p, setrstyle); + + for (p = prev_nrow; p < nrow; p++) + { + swap.tlen[p] = 0; + swap.text[p] = NULL; + swap.rend[p] = NULL; + drawn_text[p] = NULL; + drawn_rend[p] = NULL; + scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle); + scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle); } - if (k > 0) { - rxvt_scroll_text(aR_ 0, (int)nrow - 1, -k, 1); - R->screen.cur.row += k; - R->screen.s_cur.row += k; - R->TermWin.nscrolled -= k; + + if (k > 0) + { + scr_scroll_text (0, (int)nrow - 1, -k, 1); + screen.cur.row += k; + screen.s_cur.row += k; + TermWin.nscrolled -= k; } #ifdef DEBUG_STRICT - assert(R->screen.cur.row < R->TermWin.nrow); - assert(R->swap.cur.row < R->TermWin.nrow); + assert(screen.cur.row < TermWin.nrow); + assert(swap.cur.row < TermWin.nrow); #else /* drive with your eyes closed */ - MIN_IT(R->screen.cur.row, nrow - 1); - MIN_IT(R->swap.cur.row, nrow - 1); + + MIN_IT(screen.cur.row, nrow - 1); + MIN_IT(swap.cur.row, nrow - 1); #endif + TermWin.ncol = ncol; // save b/c scr_blank_screen_mem uses this } -/* B2: resize columns */ - if (ncol != prev_ncol) { - for (p = 0; p < total_rows; p++) { - if (R->screen.text[p]) { - R->screen.text[p] = (text_t *)rxvt_realloc(R->screen.text[p], ncol * sizeof(text_t)); - R->screen.rend[p] = (rend_t *)rxvt_realloc(R->screen.rend[p], ncol * sizeof(rend_t)); - MIN_IT(R->screen.tlen[p], (int16_t)ncol); - if (ncol > prev_ncol) - rxvt_blank_line(aR_ - &(R->screen.text[p][prev_ncol]), - &(R->screen.rend[p][prev_ncol]), - ncol - prev_ncol, - setrstyle); + + /* resize columns */ + if (ncol != prev_ncol) + { + int common = min (prev_ncol, ncol); + rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); + rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); + + for (p = 0; p < total_rows; p++) + { + if (screen.text[p]) + { + text_t *t = (text_t *)ta->alloc (); memcpy (t, screen.text[p], common * sizeof (text_t)); screen.text[p] = t; + rend_t *r = (rend_t *)ra->alloc (); memcpy (r, screen.rend[p], common * sizeof (rend_t)); screen.rend[p] = r; + + MIN_IT(screen.tlen[p], (int16_t)ncol); + + if (ncol > prev_ncol) + scr_blank_line (&(screen.text[p][prev_ncol]), + &(screen.rend[p][prev_ncol]), + ncol - prev_ncol, + setrstyle); } } - for (p = 0; p < nrow; p++) { - R->drawn_text[p] = (text_t *)rxvt_realloc(R->drawn_text[p], ncol * sizeof(text_t)); - R->drawn_rend[p] = (rend_t *)rxvt_realloc(R->drawn_rend[p], ncol * sizeof(rend_t)); - if (R->swap.text[p]) { - R->swap.text[p] = (text_t *)rxvt_realloc(R->swap.text[p], ncol * sizeof(text_t)); - R->swap.rend[p] = (rend_t *)rxvt_realloc(R->swap.rend[p], ncol * sizeof(rend_t)); - MIN_IT(R->swap.tlen[p], (int16_t)ncol); - if (ncol > prev_ncol) - rxvt_blank_line(aR_ - &(R->swap.text[p][prev_ncol]), - &(R->swap.rend[p][prev_ncol]), - ncol - prev_ncol, setrstyle); - } - if (ncol > prev_ncol) - rxvt_blank_line(aR_ - &(R->drawn_text[p][prev_ncol]), - &(R->drawn_rend[p][prev_ncol]), + + for (p = 0; p < nrow; p++) + { + text_t *t = (text_t *)ta->alloc (); memcpy (t, drawn_text[p], common * sizeof (text_t)); drawn_text[p] = t; + rend_t *r = (rend_t *)ra->alloc (); memcpy (r, drawn_rend[p], common * sizeof (rend_t)); drawn_rend[p] = r; + + if (ncol > prev_ncol) + scr_blank_line (&(drawn_text[p][prev_ncol]), + &(drawn_rend[p][prev_ncol]), + ncol - prev_ncol, setrstyle); + + if (swap.text[p]) + { + text_t *t = (text_t *)ta->alloc (); memcpy (t, swap.text[p], common * sizeof (text_t)); swap.text[p] = t; + rend_t *r = (rend_t *)ra->alloc (); memcpy (r, swap.rend[p], common * sizeof (rend_t)); swap.rend[p] = r; + + MIN_IT(swap.tlen[p], (int16_t)ncol); + + if (ncol > prev_ncol) + scr_blank_line (&(swap.text[p][prev_ncol]), + &(swap.rend[p][prev_ncol]), ncol - prev_ncol, setrstyle); + } + } - MIN_IT(R->screen.cur.col, (int16_t)ncol - 1); - MIN_IT(R->swap.cur.col, (int16_t)ncol - 1); + + MIN_IT (screen.cur.col, (int16_t)ncol - 1); + MIN_IT (swap.cur.col, (int16_t)ncol - 1); + + delete talloc; talloc = ta; + delete ralloc; ralloc = ra; } - if (R->tabs) - free(R->tabs); + + if (tabs) + free(tabs); } - R->tabs = (char *)rxvt_malloc(ncol * sizeof(char)); + prev_nrow = nrow; + prev_ncol = ncol; - for (p = 0; p < ncol; p++) - R->tabs[p] = (p % TABSIZE == 0) ? 1 : 0; + tabs = (char *)rxvt_malloc (ncol * sizeof(char)); - R->prev_nrow = nrow; - R->prev_ncol = ncol; + for (p = 0; p < ncol; p++) + tabs[p] = (p % TABSIZE == 0) ? 1 : 0; - R->tt_winch (); + tt_winch (); } -/* INTPROTO */ void -rxvt_scr_reset_realloc(pR) +rxvt_term::scr_reset_realloc() { - uint16_t total_rows, nrow; + uint16_t total_rows, nrow; + + nrow = TermWin.nrow; + total_rows = nrow + TermWin.saveLines; + /* *INDENT-OFF* */ + screen.text = (text_t **)rxvt_realloc(screen.text, total_rows * sizeof(text_t *)); + buf_text = (text_t **)rxvt_realloc(buf_text , total_rows * sizeof(text_t *)); + drawn_text = (text_t **)rxvt_realloc(drawn_text , nrow * sizeof(text_t *)); + swap.text = (text_t **)rxvt_realloc(swap.text , nrow * sizeof(text_t *)); - nrow = R->TermWin.nrow; - total_rows = nrow + R->TermWin.saveLines; -/* *INDENT-OFF* */ - R->screen.text = (text_t **)rxvt_realloc(R->screen.text, total_rows * sizeof(text_t *)); - R->buf_text = (text_t **)rxvt_realloc(R->buf_text , total_rows * sizeof(text_t *)); - R->drawn_text = (text_t **)rxvt_realloc(R->drawn_text , nrow * sizeof(text_t *)); - R->swap.text = (text_t **)rxvt_realloc(R->swap.text , nrow * sizeof(text_t *)); - - R->screen.tlen = (int16_t *)rxvt_realloc(R->screen.tlen, total_rows * sizeof(int16_t)); - R->swap.tlen = (int16_t *)rxvt_realloc(R->swap.tlen , total_rows * sizeof(int16_t)); - - R->screen.rend = (rend_t **)rxvt_realloc(R->screen.rend, total_rows * sizeof(rend_t *)); - R->buf_rend = (rend_t **)rxvt_realloc(R->buf_rend , total_rows * sizeof(rend_t *)); - R->drawn_rend = (rend_t **)rxvt_realloc(R->drawn_rend , nrow * sizeof(rend_t *)); - R->swap.rend = (rend_t **)rxvt_realloc(R->swap.rend , nrow * sizeof(rend_t *)); -/* *INDENT-ON* */ + screen.tlen = (int16_t *)rxvt_realloc(screen.tlen, total_rows * sizeof(int16_t)); + swap.tlen = (int16_t *)rxvt_realloc(swap.tlen , total_rows * sizeof(int16_t)); + + screen.rend = (rend_t **)rxvt_realloc(screen.rend, total_rows * sizeof(rend_t *)); + buf_rend = (rend_t **)rxvt_realloc(buf_rend , total_rows * sizeof(rend_t *)); + drawn_rend = (rend_t **)rxvt_realloc(drawn_rend , nrow * sizeof(rend_t *)); + swap.rend = (rend_t **)rxvt_realloc(swap.rend , nrow * sizeof(rend_t *)); + /* *INDENT-ON* */ } /* ------------------------------------------------------------------------- */ /* * Free everything. That way malloc debugging can find leakage. */ -/* EXTPROTO */ void -rxvt_scr_release(pR) +rxvt_term::scr_release() { - uint16_t total_rows; - int i; + uint16_t total_rows; + int i; + + total_rows = TermWin.nrow + TermWin.saveLines; - total_rows = R->TermWin.nrow + R->TermWin.saveLines; - for (i = 0; i < total_rows; i++) { - if (R->screen.text[i]) { /* then so is R->screen.rend[i] */ - free(R->screen.text[i]); #ifdef DEBUG_STRICT - assert(R->screen.rend[i]); -#endif - free(R->screen.rend[i]); - } + for (i = 0; i < total_rows; i++) + { + if (screen.text[i]) + /* then so is screen.rend[i] */ + assert(screen.rend[i]); } - for (i = 0; i < R->TermWin.nrow; i++) { - free(R->drawn_text[i]); - free(R->drawn_rend[i]); - free(R->swap.text[i]); - free(R->swap.rend[i]); - } - free(R->screen.text); - free(R->screen.tlen); - free(R->screen.rend); - free(R->drawn_text); - free(R->drawn_rend); - free(R->swap.text); - free(R->swap.tlen); - free(R->swap.rend); - free(R->buf_text); - free(R->buf_rend); - free(R->tabs); - -/* NULL these so if anything tries to use them, we'll know about it */ - R->screen.text = R->drawn_text = R->swap.text = NULL; - R->screen.rend = R->drawn_rend = R->swap.rend = NULL; - R->screen.tlen = R->swap.tlen = NULL; - R->buf_text = NULL; - R->buf_rend = NULL; - R->tabs = NULL; +#endif + + delete talloc; + delete ralloc; + + free (screen.text); + free (screen.tlen); + free (screen.rend); + free (drawn_text); + free (drawn_rend); + free (swap.text); + free (swap.tlen); + free (swap.rend); + free (buf_text); + free (buf_rend); + free (tabs); + + /* NULL these so if anything tries to use them, we'll know about it */ + screen.text = drawn_text = swap.text = NULL; + screen.rend = drawn_rend = swap.rend = NULL; + screen.tlen = swap.tlen = NULL; + buf_text = NULL; + buf_rend = NULL; + tabs = NULL; } /* ------------------------------------------------------------------------- */ @@ -443,16 +481,16 @@ void rxvt_scr_poweron(pR) { - D_SCREEN((stderr, "rxvt_scr_poweron()")); + D_SCREEN((stderr, "rxvt_scr_poweron()")); - rxvt_scr_release(aR); - R->prev_nrow = R->prev_ncol = 0; - rxvt_scr_reset(aR); + R->scr_release (); + R->prev_nrow = R->prev_ncol = 0; + R->scr_reset (); - rxvt_scr_clear(aR); - rxvt_scr_refresh(aR_ SLOW_REFRESH); + R->scr_clear (); + R->scr_refresh (SLOW_REFRESH); #ifdef RXVT_GRAPHICS - rxvt_Gr_reset(aR); + rxvt_Gr_reset (aR); #endif } @@ -578,7 +616,7 @@ && !rxvt_Gr_Displayed(aR) # endif ) - rxvt_scroll_text(aR_ 0, (R->prev_nrow - 1), R->prev_nrow, 0); + R->scr_scroll_text(0, (R->prev_nrow - 1), R->prev_nrow, 0); # endif #endif return scrn; @@ -622,108 +660,129 @@ * count negative ==> scroll down * spec == 0 for normal routines */ -/* EXTPROTO */ int -rxvt_scroll_text(pR_ int row1, int row2, int count, int spec) +rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) { - int i, j; - long nscrolled; + int i, j; + long nscrolled; - if (count == 0 || (row1 > row2)) - return 0; + if (count == 0 || (row1 > row2)) + return 0; - R->want_refresh = 1; - D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (R->current_screen == PRIMARY) ? "Primary" : "Secondary")); + want_refresh = 1; + D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (current_screen == PRIMARY) ? "Primary" : "Secondary")); - if ((count > 0) && (row1 == 0) && (R->current_screen == PRIMARY)) { - nscrolled = (long)R->TermWin.nscrolled + (long)count;; - if (nscrolled > (long)R->TermWin.saveLines) - R->TermWin.nscrolled = R->TermWin.saveLines; - else - R->TermWin.nscrolled = (uint16_t)nscrolled; - if ((R->Options & Opt_scrollWithBuffer) - && R->TermWin.view_start != 0 - && R->TermWin.view_start != R->TermWin.saveLines) - rxvt_scr_page(aR_ UP, count); - } else if (!spec) - row1 += R->TermWin.saveLines; - row2 += R->TermWin.saveLines; + if ((count > 0) && (row1 == 0) && (current_screen == PRIMARY)) + { + nscrolled = (long)TermWin.nscrolled + (long)count; - if (R->selection.op && R->current_screen == R->selection.screen) { - i = R->selection.beg.row + R->TermWin.saveLines; - j = R->selection.end.row + R->TermWin.saveLines; - if ((i < row1 && j > row1) - || (i < row2 && j > row2) - || (i - count < row1 && i >= row1) - || (i - count > row2 && i <= row2) - || (j - count < row1 && j >= row1) - || (j - count > row2 && j <= row2)) { - CLEAR_ALL_SELECTION(R); - R->selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ - } else if (j >= row1 && j <= row2) { - /* move selected region too */ - R->selection.beg.row -= count; - R->selection.end.row -= count; - R->selection.mark.row -= count; - } - } - rxvt_selection_check(aR_ 0); /* _after_ R->TermWin.nscrolled update */ - - R->num_scr += count; - j = count; - if (count < 0) - count = -count; - i = row2 - row1 + 1; - MIN_IT(count, i); - - if (j > 0) { -/* A: scroll up */ - -/* A1: Copy lines that will get clobbered by the rotation */ - for (i = 0, j = row1; i < count; i++, j++) { - R->buf_text[i] = R->screen.text[j]; - R->buf_rend[i] = R->screen.rend[j]; - } -/* A2: Rotate lines */ - for (j = row1, i = j + count; i <= row2; i++, j++) { - R->screen.tlen[j] = R->screen.tlen[i]; - R->screen.text[j] = R->screen.text[i]; - R->screen.rend[j] = R->screen.rend[i]; - } - j = row2 - count + 1, i = count; - } else /* if (j < 0) */ { -/* B: scroll down */ - -/* B1: Copy lines that will get clobbered by the rotation */ - for (i = 0, j = row2; i < count; i++, j--) { - R->buf_text[i] = R->screen.text[j]; - R->buf_rend[i] = R->screen.rend[j]; - } -/* B2: Rotate lines */ - for (j = row2, i = j - count; i >= row1; i--, j--) { - R->screen.tlen[j] = R->screen.tlen[i]; - R->screen.text[j] = R->screen.text[i]; - R->screen.rend[j] = R->screen.rend[i]; - } - j = row1, i = count; - count = -count; - } - -/* C: Resurrect lines */ - for (; i--; j++) { - R->screen.tlen[j] = 0; - R->screen.text[j] = R->buf_text[i]; - R->screen.rend[j] = R->buf_rend[i]; - if (!spec) /* line length may not equal TermWin.ncol */ - rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, - (unsigned int)j, R->rstyle); + if (nscrolled > (long)TermWin.saveLines) + TermWin.nscrolled = TermWin.saveLines; + else + TermWin.nscrolled = (uint16_t)nscrolled; + + if ((Options & Opt_scrollWithBuffer) + && TermWin.view_start != 0 + && TermWin.view_start != TermWin.saveLines) + rxvt_scr_page (this, UP, count); + } + else if (!spec) + row1 += TermWin.saveLines; + + row2 += TermWin.saveLines; + + if (selection.op && current_screen == selection.screen) + { + i = selection.beg.row + TermWin.saveLines; + j = selection.end.row + TermWin.saveLines; + if ((i < row1 && j > row1) + || (i < row2 && j > row2) + || (i - count < row1 && i >= row1) + || (i - count > row2 && i <= row2) + || (j - count < row1 && j >= row1) + || (j - count > row2 && j <= row2)) + { + CLEAR_ALL_SELECTION (this); + selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ + } + else if (j >= row1 && j <= row2) + { + /* move selected region too */ + selection.beg.row -= count; + selection.end.row -= count; + selection.mark.row -= count; + } + } + + rxvt_selection_check (this, 0); /* _after_ TermWin.nscrolled update */ + + num_scr += count; + j = count; + + if (count < 0) + count = -count; + + i = row2 - row1 + 1; + MIN_IT(count, i); + + if (j > 0) + { + /* A: scroll up */ + + /* A1: Copy lines that will get clobbered by the rotation */ + for (i = 0, j = row1; i < count; i++, j++) + { + buf_text[i] = screen.text[j]; + buf_rend[i] = screen.rend[j]; + } + /* A2: Rotate lines */ + for (j = row1, i = j + count; i <= row2; i++, j++) + { + screen.tlen[j] = screen.tlen[i]; + screen.text[j] = screen.text[i]; + screen.rend[j] = screen.rend[i]; + } + j = row2 - count + 1, i = count; + } + else /* if (j < 0) */ + { + /* B: scroll down */ + + /* B1: Copy lines that will get clobbered by the rotation */ + for (i = 0, j = row2; i < count; i++, j--) + { + buf_text[i] = screen.text[j]; + buf_rend[i] = screen.rend[j]; + } + /* B2: Rotate lines */ + for (j = row2, i = j - count; i >= row1; i--, j--) + { + screen.tlen[j] = screen.tlen[i]; + screen.text[j] = screen.text[i]; + screen.rend[j] = screen.rend[i]; + } + j = row1, i = count; + count = -count; + } + + /* C: Resurrect lines */ + for (; i--; j++) + { + screen.tlen[j] = 0; + screen.text[j] = buf_text[i]; + screen.rend[j] = buf_rend[i]; + + if (!spec) /* line length may not equal TermWin.ncol */ + scr_blank_screen_mem (screen.text, screen.rend, + (unsigned int)j, rstyle); } #ifdef RXVT_GRAPHICS - if (rxvt_Gr_Displayed(aR)) - rxvt_Gr_scroll(aR_ count); + if (rxvt_Gr_Displayed (this)) + rxvt_Gr_scroll(this, count); #endif - return count; + + return count; } /* ------------------------------------------------------------------------- */ @@ -754,8 +813,7 @@ && (R->screen.tscroll == 0) && (R->screen.bscroll == (R->TermWin.nrow - 1))) { /* _at least_ this many lines need to be scrolled */ - rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, nlines, - 0); + R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, nlines, 0); R->screen.cur.row -= nlines; } } @@ -781,14 +839,14 @@ c = str[i++]; switch (c) { case '\t': - rxvt_scr_tab(aR_ 1); + rxvt_scr_tab (aR_ 1); continue; case '\n': if (R->screen.tlen[row] != -1) /* XXX: think about this */ MAX_IT(R->screen.tlen[row], R->screen.cur.col); R->screen.flags &= ~Screen_WrapNext; if (R->screen.cur.row == R->screen.bscroll) - rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); + R->scr_scroll_text (R->screen.tscroll, R->screen.bscroll, 1, 0); else if (R->screen.cur.row < (R->TermWin.nrow - 1)) row = (++R->screen.cur.row) + R->TermWin.saveLines; stp = R->screen.text[row]; /* _must_ refresh */ @@ -815,7 +873,7 @@ if (R->screen.flags & Screen_WrapNext) { R->screen.tlen[row] = -1; if (R->screen.cur.row == R->screen.bscroll) - rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); + R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, 1, 0); else if (R->screen.cur.row < (R->TermWin.nrow - 1)) row = (++R->screen.cur.row) + R->TermWin.saveLines; stp = R->screen.text[row]; /* _must_ refresh */ @@ -843,36 +901,27 @@ } rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); + // rely on wcwidth to tell us the character width, at least for non-ascii + int width = c <= 128 ? 1 : wcwidth (c); - stp[R->screen.cur.col] = c; - srp[R->screen.cur.col] = rend; - - if (c > 255) + // width 0 characters (e.g. combining chars) are ignored. your problem, really + while (width-- > 0) { - // rely on wcwidth to tell us the character width, at least for non iso-8859-1 - int width = wcwidth (c); - - if (width > 1) - { - while (--width > 0 && R->screen.cur.col < last_col - 1) - { - - srp[R->screen.cur.col] |= RS_wide; + stp[R->screen.cur.col] = c; + srp[R->screen.cur.col] = rend; - R->screen.cur.col++; - stp[R->screen.cur.col] = NOCHAR; - srp[R->screen.cur.col] = rend; - } + if (R->screen.cur.col < last_col - 1) + R->screen.cur.col++; + else + { + R->screen.tlen[row] = last_col; + if (R->screen.flags & Screen_Autowrap) + R->screen.flags |= Screen_WrapNext; + break; } - } - if (R->screen.cur.col < last_col - 1) - R->screen.cur.col++; - else { - R->screen.tlen[row] = last_col; - if (R->screen.flags & Screen_Autowrap) - R->screen.flags |= Screen_WrapNext; - } + c = NOCHAR; + } } if (R->screen.tlen[row] != -1) /* XXX: think about this */ MAX_IT(R->screen.tlen[row], R->screen.cur.col); @@ -1077,7 +1126,7 @@ R->screen.flags &= ~Screen_WrapNext; if ((R->screen.cur.row == R->screen.bscroll && direction == UP) || (R->screen.cur.row == R->screen.tscroll && direction == DN)) - rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, dirn, 0); + R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, dirn, 0); else R->screen.cur.row += dirn; MAX_IT(R->screen.cur.row, 0); @@ -1096,56 +1145,56 @@ void rxvt_scr_erase_line(pR_ int mode) { - unsigned int row, col, num; + unsigned int row, col, num; - R->want_refresh = 1; - D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); - ZERO_SCROLLBACK(R); + R->want_refresh = 1; + D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); + ZERO_SCROLLBACK (R); #ifdef RXVT_GRAPHICS - if (rxvt_Gr_Displayed(aR)) - rxvt_Gr_scroll(aR_ 0); + if (rxvt_Gr_Displayed (aR)) + rxvt_Gr_scroll (aR_ 0); #endif - rxvt_selection_check(aR_ 1); + rxvt_selection_check (aR_ 1); - R->screen.flags &= ~Screen_WrapNext; + R->screen.flags &= ~Screen_WrapNext; - row = R->TermWin.saveLines + R->screen.cur.row; - switch (mode) { - case 0: /* erase to end of line */ + row = R->TermWin.saveLines + R->screen.cur.row; + switch (mode) + { + case 0: /* erase to end of line */ col = R->screen.cur.col; num = R->TermWin.ncol - col; MIN_IT(R->screen.tlen[row], (int16_t)col); if (ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur) || ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.end, R->screen.cur)) - CLEAR_SELECTION(R); + CLEAR_SELECTION(R); break; - case 1: /* erase to beginning of line */ + case 1: /* erase to beginning of line */ col = 0; num = R->screen.cur.col + 1; if (ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.beg, R->screen.cur) || ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.end, R->screen.cur)) - CLEAR_SELECTION(R); + CLEAR_SELECTION(R); break; - case 2: /* erase whole line */ + case 2: /* erase whole line */ col = 0; num = R->TermWin.ncol; R->screen.tlen[row] = 0; if (R->selection.beg.row <= R->screen.cur.row && R->selection.end.row >= R->screen.cur.row) - CLEAR_SELECTION(R); + CLEAR_SELECTION(R); break; - default: + default: return; } - if (R->screen.text[row]) - rxvt_blank_line(aR_ - &(R->screen.text[row][col]), - &(R->screen.rend[row][col]), num, R->rstyle); - else - rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, row, - R->rstyle); + + if (R->screen.text[row]) + R->scr_blank_line (&(R->screen.text[row][col]), + &(R->screen.rend[row][col]), num, R->rstyle); + else + R->scr_blank_screen_mem (R->screen.text, R->screen.rend, row, R->rstyle); } /* ------------------------------------------------------------------------- */ @@ -1155,73 +1204,71 @@ * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J * XTERM_SEQ: Clear whole screen : ESC [ 2 J */ -/* EXTPROTO */ void -rxvt_scr_erase_screen(pR_ int mode) +rxvt_term::scr_erase_screen (int mode) { int num; int32_t row, row_offset; rend_t ren; XGCValues gcvalue; - R->want_refresh = 1; - D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, R->screen.cur.row)); - ZERO_SCROLLBACK(R); - row_offset = (int32_t)R->TermWin.saveLines; + want_refresh = 1; + D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, screen.cur.row)); + ZERO_SCROLLBACK(this); + row_offset = (int32_t)TermWin.saveLines; switch (mode) { case 0: /* erase to end of screen */ - rxvt_selection_check(aR_ 1); - rxvt_scr_erase_line(aR_ 0); - row = R->screen.cur.row + 1; /* possible OOB */ - num = R->TermWin.nrow - row; + rxvt_selection_check(this,1); + rxvt_scr_erase_line(this,0); + row = screen.cur.row + 1; /* possible OOB */ + num = TermWin.nrow - row; break; case 1: /* erase to beginning of screen */ - rxvt_selection_check(aR_ 3); - rxvt_scr_erase_line(aR_ 1); + rxvt_selection_check(this,3); + rxvt_scr_erase_line(this,1); row = 0; - num = R->screen.cur.row; + num = screen.cur.row; break; case 2: /* erase whole screen */ - rxvt_selection_check(aR_ 3); + rxvt_selection_check (this, 3); #ifdef RXVT_GRAPHICS - rxvt_Gr_ClearScreen(aR); + rxvt_Gr_ClearScreen (this); #endif row = 0; - num = R->TermWin.nrow; + num = TermWin.nrow; break; default: return; } - R->refresh_type |= REFRESH_BOUNDS; - if (R->selection.op && R->current_screen == R->selection.screen - && ((R->selection.beg.row >= row && R->selection.beg.row <= row + num) - || (R->selection.end.row >= row - && R->selection.end.row <= row + num))) - CLEAR_SELECTION(R); - if (row >= R->TermWin.nrow) /* Out Of Bounds */ + refresh_type |= REFRESH_BOUNDS; + if (selection.op && current_screen == selection.screen + && ((selection.beg.row >= row && selection.beg.row <= row + num) + || (selection.end.row >= row + && selection.end.row <= row + num))) + CLEAR_SELECTION (this); + if (row >= TermWin.nrow) /* Out Of Bounds */ return; - MIN_IT(num, (R->TermWin.nrow - row)); - if (R->rstyle & (RS_RVid | RS_Uline)) + MIN_IT(num, (TermWin.nrow - row)); + if (rstyle & (RS_RVid | RS_Uline)) ren = (rend_t) ~RS_None; - else if (GET_BASEBG(R->rstyle) == Color_bg) { + else if (GET_BASEBG(rstyle) == Color_bg) { ren = DEFAULT_RSTYLE; CLEAR_ROWS(row, num); } else { - ren = (R->rstyle & (RS_fgMask | RS_bgMask)); - gcvalue.foreground = R->PixColors[GET_BGCOLOR(R->rstyle)]; - XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); + ren = (rstyle & (RS_fgMask | RS_bgMask)); + gcvalue.foreground = PixColors[GET_BGCOLOR(rstyle)]; + XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); ERASE_ROWS(row, num); - gcvalue.foreground = R->PixColors[Color_fg]; - XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); + gcvalue.foreground = PixColors[Color_fg]; + XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue); } for (; num--; row++) { - rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, - (unsigned int)(row + row_offset), R->rstyle); - R->screen.tlen[row + row_offset] = 0; - rxvt_blank_line(aR_ - R->drawn_text[row], R->drawn_rend[row], - (unsigned int)R->TermWin.ncol, ren); + scr_blank_screen_mem (screen.text, screen.rend, + (unsigned int)(row + row_offset), rstyle); + screen.tlen[row + row_offset] = 0; + scr_blank_line (drawn_text[row], drawn_rend[row], + (unsigned int)TermWin.ncol, ren); } } @@ -1282,8 +1329,7 @@ } R->screen.flags &= ~Screen_WrapNext; - rxvt_scroll_text(aR_ R->screen.cur.row, R->screen.bscroll, insdel * count, - 0); + R->scr_scroll_text(R->screen.cur.row, R->screen.bscroll, insdel * count, 0); } /* ------------------------------------------------------------------------- */ @@ -1342,15 +1388,15 @@ R->selection.end.col += count; } } - rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), - (unsigned int)count, R->rstyle); + R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), + (unsigned int)count, R->rstyle); break; case ERASE: R->screen.cur.col += count; /* don't worry if > R->TermWin.ncol */ rxvt_selection_check(aR_ 1); R->screen.cur.col -= count; - rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), - (unsigned int)count, R->rstyle); + R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), + (unsigned int)count, R->rstyle); break; case DELETE: tr = srp[R->TermWin.ncol - 1] @@ -1359,10 +1405,9 @@ stp[col] = stp[col + count]; srp[col] = srp[col + count]; } - rxvt_blank_line(aR_ - &(stp[R->TermWin.ncol - count]), - &(srp[R->TermWin.ncol - count]), - (unsigned int)count, tr); + R->scr_blank_line (&(stp[R->TermWin.ncol - count]), + &(srp[R->TermWin.ncol - count]), + (unsigned int)count, tr); if (*slp == -1) /* break line continuation */ *slp = R->TermWin.ncol; *slp -= count; @@ -1517,8 +1562,8 @@ gcvalue.background = R->PixColors[Color_bg]; XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, &gcvalue); - rxvt_scr_clear(aR); - rxvt_scr_touch(aR_ True); + R->scr_clear (); + R->scr_touch (true); } } @@ -1631,55 +1676,54 @@ RC_COUNT }; -/* EXTPROTO */ void -rxvt_scr_expose(pR_ int x, int y, int width, int height, Bool refresh) +rxvt_term::scr_expose (int x, int y, int width, int height, bool refresh) { - int i; - row_col_t rc[RC_COUNT]; + int i; + row_col_t rc[RC_COUNT]; - if (R->drawn_text == NULL) /* sanity check */ - return; + if (drawn_text == NULL) /* sanity check */ + return; #ifdef DEBUG_STRICT - x = max(x, (int)R->TermWin.int_bwidth); - x = min(x, (int)R->TermWin.width); - y = max(y, (int)R->TermWin.int_bwidth); - y = min(y, (int)R->TermWin.height); + x = max(x, (int)TermWin.int_bwidth); + x = min(x, (int)TermWin.width); + y = max(y, (int)TermWin.int_bwidth); + y = min(y, (int)TermWin.height); #endif /* round down */ - rc[PART_BEG].col = Pixel2Col(x); - rc[PART_BEG].row = Pixel2Row(y); + rc[PART_BEG].col = Pixel2Col(x); + rc[PART_BEG].row = Pixel2Row(y); /* round up */ - rc[PART_END].col = Pixel2Width(x + width + R->TermWin.fwidth - 1); - rc[PART_END].row = Pixel2Row(y + height + R->TermWin.fheight - 1); + rc[PART_END].col = Pixel2Width(x + width + TermWin.fwidth - 1); + rc[PART_END].row = Pixel2Row(y + height + TermWin.fheight - 1); /* sanity checks */ - for (i = PART_BEG; i < RC_COUNT; i++) { - MIN_IT(rc[i].col, R->TermWin.ncol - 1); - MIN_IT(rc[i].row, R->TermWin.nrow - 1); + for (i = PART_BEG; i < RC_COUNT; i++) + { + MIN_IT(rc[i].col, TermWin.ncol - 1); + MIN_IT(rc[i].row, TermWin.nrow - 1); } - D_SCREEN((stderr, "rxvt_scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); + D_SCREEN((stderr, "rxvt_scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); - for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) - fill_text (&(R->drawn_text[i][rc[PART_BEG].col]), 0, - (rc[PART_END].col - rc[PART_BEG].col + 1)); + for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) + fill_text (&(drawn_text[i][rc[PART_BEG].col]), 0, + (rc[PART_END].col - rc[PART_BEG].col + 1)); - if (refresh) - rxvt_scr_refresh(aR_ SLOW_REFRESH | REFRESH_BOUNDS); + if (refresh) + scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS); } /* ------------------------------------------------------------------------- */ /* * Refresh the entire screen */ -/* EXTPROTO */ void -rxvt_scr_touch(pR_ Bool refresh) +rxvt_term::scr_touch (bool refresh) { - rxvt_scr_expose(aR_ 0, 0, R->TermWin.width, R->TermWin.height, refresh); + scr_expose (0, 0, TermWin.width, TermWin.height, refresh); } /* ------------------------------------------------------------------------- */ @@ -1826,9 +1870,8 @@ #define IS_FONT_CHAR(X, Y) \ ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) -/* EXTPROTO */ void -rxvt_scr_refresh(pR_ unsigned char refresh_type) +rxvt_term::scr_refresh (unsigned char refresh_type) { unsigned char clearfirst, /* first character writes before cell */ clearlast, /* last character writes beyond cell */ @@ -1851,9 +1894,8 @@ #endif rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ - char *buffer; /* local copy of R->buffer */ - if (refresh_type == NO_REFRESH || !R->TermWin.mapped) + if (refresh_type == NO_REFRESH || !TermWin.mapped) return; /* @@ -1864,49 +1906,48 @@ bfont = 0; #endif - if (R->currmaxcol < R->TermWin.ncol) + if (currmaxcol < TermWin.ncol) { - R->currmaxcol = R->TermWin.ncol; - R->buffer = (char *)rxvt_realloc (R->buffer, - sizeof(char) * (R->currmaxcol + 1) * MB_CUR_MAX); + currmaxcol = TermWin.ncol; + buffer = (char *)rxvt_realloc (buffer, + sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX); } - buffer = R->buffer; - R->refresh_count = 0; + refresh_count = 0; - row_offset = R->TermWin.saveLines - R->TermWin.view_start; + row_offset = TermWin.saveLines - TermWin.view_start; if ((refresh_type & REFRESH_BOUNDS)) { clearfirst = clearlast = 1; - R->refresh_type &= ~REFRESH_BOUNDS; + refresh_type &= ~REFRESH_BOUNDS; } #if defined(XPM_BACKGROUND) - must_clear |= (R->bgPixmap.pixmap != None); + must_clear |= (bgPixmap.pixmap != None); #endif #if defined(TRANSPARENT) - must_clear |= ((R->Options & Opt_transparent) && R->am_transparent); + must_clear |= ((Options & Opt_transparent) && am_transparent); #endif - ocrow = R->oldcursor.row; /* is there an old outline cursor on screen? */ + ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ -/* - * B: reverse any characters which are selected - */ - rxvt_scr_reverse_selection(aR); + /* + * B: reverse any characters which are selected + */ + rxvt_scr_reverse_selection (this); -/* - * C: set the cursor character(s) - */ + /* + * C: set the cursor character(s) + */ { unsigned char setoldcursor; rend_t ccol1, /* Cursor colour */ ccol2; /* Cursor colour2 */ - showcursor = (R->screen.flags & Screen_VisibleCursor); + showcursor = (screen.flags & Screen_VisibleCursor); cursorwidth = 0; #ifdef CURSOR_BLINK - if (R->hidden_cursor) + if (hidden_cursor) showcursor = 0; #endif @@ -1916,27 +1957,27 @@ { cursorwidth++; - srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] - [R->screen.cur.col]); + srp = &(screen.rend[screen.cur.row + TermWin.saveLines] + [screen.cur.col]); - if (showcursor && R->TermWin.focus) + if (showcursor && TermWin.focus) { *srp ^= RS_RVid; #ifndef NO_CURSORCOLOR cc1 = *srp & (RS_fgMask | RS_bgMask); - if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) + if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) ccol1 = Color_cursor; else #ifdef CURSOR_COLOR_IS_RENDITION_COLOR - ccol1 = GET_FGCOLOR(R->rstyle); + ccol1 = GET_FGCOLOR(rstyle); #else ccol1 = Color_fg; #endif - if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor2)) + if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor2)) ccol2 = Color_cursor2; else #ifdef CURSOR_COLOR_IS_RENDITION_COLOR - ccol2 = GET_BGCOLOR(R->rstyle); + ccol2 = GET_BGCOLOR(rstyle); #else ccol2 = Color_bg; #endif @@ -1952,37 +1993,37 @@ /* make sure no outline cursor is left around */ setoldcursor = 0; if (ocrow != -1) { - if (R->screen.cur.row + R->TermWin.view_start != ocrow - || R->screen.cur.col != R->oldcursor.col) { - if (ocrow < R->TermWin.nrow - && R->oldcursor.col < R->TermWin.ncol) { - R->drawn_rend[ocrow][R->oldcursor.col] ^= (RS_RVid | RS_Uline); + if (screen.cur.row + TermWin.view_start != ocrow + || screen.cur.col != oldcursor.col) { + if (ocrow < TermWin.nrow + && oldcursor.col < TermWin.ncol) { + drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline); } - if (R->TermWin.focus || !showcursor) - R->oldcursor.row = -1; + if (TermWin.focus || !showcursor) + oldcursor.row = -1; else setoldcursor = 1; } - } else if (!R->TermWin.focus) + } else if (!TermWin.focus) setoldcursor = 1; if (setoldcursor) { - if (R->screen.cur.row + R->TermWin.view_start >= R->TermWin.nrow) - R->oldcursor.row = -1; + if (screen.cur.row + TermWin.view_start >= TermWin.nrow) + oldcursor.row = -1; else { - R->oldcursor.row = R->screen.cur.row + R->TermWin.view_start; - R->oldcursor.col = R->screen.cur.col; + oldcursor.row = screen.cur.row + TermWin.view_start; + oldcursor.col = screen.cur.col; } } } #ifndef NO_SLOW_LINK_SUPPORT -/* - * D: CopyArea pass - very useful for slower links - * This has been deliberately kept simple. - */ - i = R->num_scr; - if (refresh_type == FAST_REFRESH && R->num_scr_allow && i - && abs(i) < R->TermWin.nrow && !must_clear) + /* + * D: CopyArea pass - very useful for slower links + * This has been deliberately kept simple. + */ + i = num_scr; + if (refresh_type == FAST_REFRESH && num_scr_allow && i + && abs(i) < TermWin.nrow && !must_clear) { int16_t nits; int j; @@ -1990,21 +2031,21 @@ text_t *dtp2; int len, wlen; - j = R->TermWin.nrow; + j = TermWin.nrow; wlen = len = -1; row = i > 0 ? 0 : j - 1; for (; j-- >= 0; row += (i > 0 ? 1 : -1)) { - if (row + i >= 0 && row + i < R->TermWin.nrow && row + i != ocrow) + if (row + i >= 0 && row + i < TermWin.nrow && row + i != ocrow) { - stp = R->screen.text[row + row_offset]; - srp = R->screen.rend[row + row_offset]; - dtp = R->drawn_text[row]; - dtp2 = R->drawn_text[row + i]; - drp = R->drawn_rend[row]; - drp2 = R->drawn_rend[row + i]; + stp = screen.text[row + row_offset]; + srp = screen.rend[row + row_offset]; + dtp = drawn_text[row]; + dtp2 = drawn_text[row + i]; + drp = drawn_rend[row]; + drp2 = drawn_rend[row + i]; - for (nits = 0, col = R->TermWin.ncol; col--; ) + for (nits = 0, col = TermWin.ncol; col--; ) if (stp[col] != dtp2[col] || srp[col] != drp2[col]) nits--; else if (stp[col] != dtp[col] || srp[col] != drp[col]) @@ -2012,7 +2053,7 @@ if (nits > 8) /* XXX: arbitrary choice */ { - for (col = R->TermWin.ncol; col--; ) + for (col = TermWin.ncol; col--; ) { *dtp++ = *dtp2++; *drp++ = *drp2++; @@ -2031,34 +2072,35 @@ /* also comes here at end if needed because of >= above */ if (wlen < len) SWAP_IT(wlen, len, int); + D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); - XCopyArea(R->Xdisplay, R->TermWin.vt, R->TermWin.vt, - R->TermWin.gc, 0, Row2Pixel(len + i), - (unsigned int)TermWin_TotalWidth(), - (unsigned int)Height2Pixel(wlen - len + 1), - 0, Row2Pixel(len)); + XCopyArea (Xdisplay, TermWin.vt, TermWin.vt, + TermWin.gc, 0, Row2Pixel (len + i), + (unsigned int)TermWin_TotalWidth (), + (unsigned int)Height2Pixel (wlen - len + 1), + 0, Row2Pixel (len)); len = -1; } } } #endif -/* - * E: main pass across every character - */ - for (row = 0; row < R->TermWin.nrow; row++) + /* + * E: main pass across every character + */ + for (row = 0; row < TermWin.nrow; row++) { - stp = R->screen.text[row + row_offset]; - srp = R->screen.rend[row + row_offset]; - dtp = R->drawn_text[row]; - drp = R->drawn_rend[row]; + stp = screen.text[row + row_offset]; + srp = screen.rend[row + row_offset]; + dtp = drawn_text[row]; + drp = drawn_rend[row]; -/* - * E2: OK, now the real pass - */ + /* + * E2: OK, now the real pass + */ int ypixel = (int)Row2Pixel(row); - for (col = 0; col < R->TermWin.ncol; col++) + for (col = 0; col < TermWin.ncol; col++) { /* compare new text with old - if exactly the same then continue */ rend_t rend = srp[col]; /* screen rendition (target rendtion) */ @@ -2084,7 +2126,7 @@ // this loop looks very messy, it can probably be optimized // and cleaned a bit by you? - for (i = 0; ++col < R->TermWin.ncol; ) + for (i = 0; ++col < TermWin.ncol; ) { if (stp[col] == NOCHAR) { @@ -2120,9 +2162,9 @@ col--; /* went one too far. move back */ count -= i; /* dump any matching trailing chars */ -/* - * Determine the attributes for the string - */ + /* + * Determine the attributes for the string + */ int fid = GET_FONT(rend); fore = GET_FGCOLOR(rend); back = GET_BGCOLOR(rend); @@ -2132,7 +2174,7 @@ #ifdef OPTION_HC if (!rvid && (rend & RS_Blink)) { - if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_HC)) + if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC)) back = Color_HC; else rvid = !rvid; /* fall back */ @@ -2143,9 +2185,9 @@ SWAP_IT(fore, back, int); #ifndef NO_BOLD_UNDERLINE_REVERSE - if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_RV) + if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_RV) # ifndef NO_CURSORCOLOR - && !ISSET_PIXCOLOR(R, Color_cursor) + && !ISSET_PIXCOLOR (this, Color_cursor) # endif ) back = Color_RV; @@ -2154,7 +2196,7 @@ #ifndef NO_BOLD_UNDERLINE_REVERSE else if (rend & RS_Bold) { - if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_BD)) + if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_BD)) { fore = Color_BD; # ifndef VERYBOLD @@ -2164,7 +2206,7 @@ } else if (rend & RS_Uline) { - if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_UL)) + if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL)) { fore = Color_UL; rend &= ~RS_Uline; /* we've taken care of it */ @@ -2172,10 +2214,10 @@ } #endif -/* - * Actually do the drawing of the string here - */ - rxvt_font *font = (*R->TermWin.fontset)[fid]; + /* + * Actually do the drawing of the string here + */ + rxvt_font *font = (*TermWin.fontset)[fid]; if (back == Color_bg) { @@ -2188,7 +2230,7 @@ goto nodraw; } - CLEAR_CHARS(xpixel, ypixel, count); + CLEAR_CHARS (xpixel, ypixel, count); nodraw: ; } else @@ -2198,94 +2240,97 @@ font->draw (xpixel, ypixel, text, count, fore, back); if ((rend & RS_Uline) && (font->descent > 1)) - XDrawLine(R->Xdisplay, drawBuffer, R->TermWin.gc, + XDrawLine(Xdisplay, drawBuffer, TermWin.gc, xpixel, ypixel + font->ascent + 1, xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); } /* for (col....) */ } /* for (row....) */ -/* - * G: cleanup cursor and display outline cursor if necessary - */ + /* + * G: cleanup cursor and display outline cursor if necessary + */ if (showcursor) { - if (R->TermWin.focus) { - srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] - [R->screen.cur.col]); + if (TermWin.focus) { + srp = &(screen.rend[screen.cur.row + TermWin.saveLines] + [screen.cur.col]); *srp ^= RS_RVid; #ifndef NO_CURSORCOLOR *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; #endif - } else if (R->oldcursor.row >= 0) { + } else if (oldcursor.row >= 0) { #ifndef NO_CURSORCOLOR unsigned long gcmask; /* Graphics Context mask */ - if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) { - XSetForeground (R->Xdisplay, R->TermWin.gc, R->PixColors[Color_cursor]); - } + if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor)) + XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]); #endif - XDrawRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, - Col2Pixel(R->oldcursor.col), - Row2Pixel(R->oldcursor.row), + XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc, + Col2Pixel(oldcursor.col), + Row2Pixel(oldcursor.row), (unsigned int)(Width2Pixel(cursorwidth) - 1), - (unsigned int)(Height2Pixel(1) - R->TermWin.lineSpace - 1)); + (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1)); } } -/* - * H: cleanup selection - */ - rxvt_scr_reverse_selection(aR); -/* - * I: other general cleanup - */ - if (clearfirst && R->TermWin.int_bwidth) + /* + * H: cleanup selection + */ + rxvt_scr_reverse_selection (this); + + /* + * I: other general cleanup + */ + if (clearfirst && TermWin.int_bwidth) /* * clear the whole screen height, note that width == 0 is treated * specially by XClearArea */ - XClearArea(R->Xdisplay, R->TermWin.vt, 0, 0, - (unsigned int)R->TermWin.int_bwidth, + XClearArea(Xdisplay, TermWin.vt, 0, 0, + (unsigned int)TermWin.int_bwidth, (unsigned int)TermWin_TotalHeight(), False); - if (clearlast && R->TermWin.int_bwidth) + if (clearlast && TermWin.int_bwidth) /* * clear the whole screen height, note that width == 0 is treated * specially by XClearArea */ - XClearArea(R->Xdisplay, R->TermWin.vt, - R->TermWin.width + R->TermWin.int_bwidth, 0, - (unsigned int)R->TermWin.int_bwidth, + XClearArea(Xdisplay, TermWin.vt, + TermWin.width + TermWin.int_bwidth, 0, + (unsigned int)TermWin.int_bwidth, (unsigned int)TermWin_TotalHeight(), False); if (refresh_type & SMOOTH_REFRESH) - XSync(R->Xdisplay, False); + XSync(Xdisplay, False); - R->num_scr = 0; - R->num_scr_allow = 1; - R->want_refresh = 0; /* screen is current */ + num_scr = 0; + num_scr_allow = 1; + want_refresh = 0; /* screen is current */ } -/* ------------------------------------------------------------------------- */ -/* EXTPROTO */ +/* ------------------------------------------------------------------------- */ void -rxvt_scr_clear(pR) +rxvt_term::scr_clear() { - if (!R->TermWin.mapped) - return; - R->num_scr_allow = 0; - R->want_refresh = 1; + if (!TermWin.mapped) + return; + + num_scr_allow = 0; + want_refresh = 1; #ifdef TRANSPARENT - if ((R->Options & Opt_transparent) && (R->am_pixmap_trans == 0)) { - int i; + if ((Options & Opt_transparent) && (am_pixmap_trans == 0)) + { + int i; - if (!(R->Options & Opt_transparent_all)) - i = 0; - else - i = (int)(sizeof(R->TermWin.parent) / sizeof(Window)); - for (; i--;) - if (R->TermWin.parent[i] != None) - XClearWindow(R->Xdisplay, R->TermWin.parent[i]); + if (!(Options & Opt_transparent_all)) + i = 0; + else + i = (int)(sizeof(TermWin.parent) / sizeof(Window)); + + while (i--) + if (TermWin.parent[i] != None) + XClearWindow(Xdisplay, TermWin.parent[i]); } #endif - XClearWindow(R->Xdisplay, R->TermWin.vt); + + XClearWindow (Xdisplay, TermWin.vt); } /* ------------------------------------------------------------------------- */ @@ -2403,6 +2448,11 @@ unsigned int i, j, n; unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); +#if 0 + /* a paste should act like the user is typing, so check scrollTtyKeypress */ + ZERO_SCROLLBACK (r); +#endif + /* convert normal newline chars into common keyboard Return key sequence */ for (i = 0; i < len; i += PROP_SIZE) { @@ -2764,23 +2814,22 @@ * Mark or select text based upon number of clicks: 1, 2, or 3 * EXT: button 1 press */ -/* EXTPROTO */ void -rxvt_selection_click(pR_ int clicks, int x, int y) +rxvt_term::selection_click (int clicks, int x, int y) { - D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); + D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); + + clicks = ((clicks - 1) % 3) + 1; + selection.clicks = clicks; /* save clicks so extend will work */ - clicks = ((clicks - 1) % 3) + 1; - R->selection.clicks = clicks; /* save clicks so extend will work */ + rxvt_selection_start_colrow (this, Pixel2Col(x), Pixel2Row(y)); - rxvt_selection_start_colrow(aR_ Pixel2Col(x), Pixel2Row(y)); - if (clicks == 2 || clicks == 3) - rxvt_selection_extend_colrow(aR_ R->selection.mark.col, - R->selection.mark.row - + R->TermWin.view_start, - 0, /* button 3 */ - 1, /* button press */ - 0); /* click change */ + if (clicks == 2 || clicks == 3) + rxvt_selection_extend_colrow (this, selection.mark.col, + selection.mark.row + TermWin.view_start, + 0, /* button 3 */ + 1, /* button press */ + 0); /* click change */ } /* ------------------------------------------------------------------------- */ @@ -2900,44 +2949,47 @@ * flag == 1 ==> button 3 press * flag == 2 ==> button 3 motion */ -/* EXTPROTO */ void -rxvt_selection_extend(pR_ int x, int y, int flag) +rxvt_term::selection_extend (int x, int y, int flag) { - int col, row; + int col, row; + + col = Pixel2Col(x); + row = Pixel2Row(y); + MAX_IT(row, 0); + MIN_IT(row, (int)TermWin.nrow - 1); + MAX_IT(col, 0); + MIN_IT(col, (int)TermWin.ncol); - col = Pixel2Col(x); - row = Pixel2Row(y); - MAX_IT(row, 0); - MIN_IT(row, (int)R->TermWin.nrow - 1); - MAX_IT(col, 0); - MIN_IT(col, (int)R->TermWin.ncol); #ifndef NO_NEW_SELECTION -/* - * If we're selecting characters (single click) then we must check first - * if we are at the same place as the original mark. If we are then - * select nothing. Otherwise, if we're to the right of the mark, you have to - * be _past_ a character for it to be selected. - */ - if (R->selection_style != OLD_SELECT) { - if (((R->selection.clicks % 3) == 1) && !flag - && (col == R->selection.mark.col - && (row == R->selection.mark.row + R->TermWin.view_start))) { - /* select nothing */ - R->selection.beg.row = R->selection.end.row = 0; - R->selection.beg.col = R->selection.end.col = 0; - R->selection.clicks = 4; - R->want_refresh = 1; - D_SELECT((stderr, "rxvt_selection_extend() R->selection.clicks = 4")); - return; + /* + * If we're selecting characters (single click) then we must check first + * if we are at the same place as the original mark. If we are then + * select nothing. Otherwise, if we're to the right of the mark, you have to + * be _past_ a character for it to be selected. + */ + if (selection_style != OLD_SELECT) + { + if (((selection.clicks % 3) == 1) && !flag + && (col == selection.mark.col + && (row == selection.mark.row + TermWin.view_start))) + { + /* select nothing */ + selection.beg.row = selection.end.row = 0; + selection.beg.col = selection.end.col = 0; + selection.clicks = 4; + want_refresh = 1; + D_SELECT((stderr, "rxvt_selection_extend() selection.clicks = 4")); + return; } } #endif - if (R->selection.clicks == 4) - R->selection.clicks = 1; - rxvt_selection_extend_colrow(aR_ col, row, !!flag, /* ? button 3 */ - flag == 1 ? 1 : 0, /* ? button press */ - 0); /* no click change */ + if (selection.clicks == 4) + selection.clicks = 1; + + rxvt_selection_extend_colrow (this, col, row, !!flag, /* ? button 3 */ + flag == 1 ? 1 : 0, /* ? button press */ + 0); /* no click change */ } /* ------------------------------------------------------------------------- */ @@ -3201,12 +3253,11 @@ * Double click on button 3 when already selected * EXT: button 3 double click */ -/* EXTPROTO */ void -rxvt_selection_rotate(pR_ int x, int y) +rxvt_term::selection_rotate (int x, int y) { - R->selection.clicks = R->selection.clicks % 3 + 1; - rxvt_selection_extend_colrow(aR_ Pixel2Col(x), Pixel2Row(y), 1, 0, 1); + selection.clicks = selection.clicks % 3 + 1; + rxvt_selection_extend_colrow (this, Pixel2Col(x), Pixel2Row(y), 1, 0, 1); } /* ------------------------------------------------------------------------- */ @@ -3320,28 +3371,27 @@ /* * return col/row values corresponding to x/y pixel values */ -/* EXTPROTO */ void -rxvt_pixel_position(pR_ int *x, int *y) +rxvt_term::pixel_position (int *x, int *y) { - *x = Pixel2Col(*x); -/* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ - *y = Pixel2Row(*y); -/* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ + *x = Pixel2Col(*x); + /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ + *y = Pixel2Row(*y); + /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ } + /* ------------------------------------------------------------------------- */ #ifdef USE_XIM -/* EXTPROTO */ void -rxvt_setPosition(pR_ XPoint *pos) +rxvt_term::set_position (XPoint *pos) { - XWindowAttributes xwa; + XWindowAttributes xwa; - XGetWindowAttributes(R->Xdisplay, R->TermWin.vt, &xwa); - pos->x = Col2Pixel(R->screen.cur.col) + xwa.x; - pos->y = Height2Pixel((R->screen.cur.row + 1)) + xwa.y - - R->TermWin.lineSpace; + XGetWindowAttributes (Xdisplay, TermWin.vt, &xwa); + pos->x = Col2Pixel (screen.cur.col) + xwa.x; + pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; } + #endif /* ------------------------------------------------------------------------- */