1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*--------------------------------*-C-*--------------------------------------* |
2 | * File: screen.c |
2 | * File: screen.c |
3 | *---------------------------------------------------------------------------* |
3 | *---------------------------------------------------------------------------* |
4 | * $Id: screen.C,v 1.7 2003/12/16 23:04:13 pcg Exp $ |
4 | * $Id: screen.C,v 1.8 2003/12/17 09:00:35 pcg Exp $ |
5 | * |
5 | * |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
31 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
31 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
32 | |
32 | |
33 | #include <stdint.h> |
33 | #include <stdint.h> |
34 | #include <wchar.h> |
34 | #include <wchar.h> |
35 | |
35 | |
|
|
36 | #include "salloc.C" // HACK!! |
|
|
37 | |
36 | inline void fill_text (text_t *start, text_t value, int len) |
38 | inline void fill_text (text_t *start, text_t value, int len) |
37 | { |
39 | { |
38 | while (len--) |
40 | while (len--) |
39 | *start++ = value; |
41 | *start++ = value; |
40 | } |
42 | } |
… | |
… | |
111 | |
113 | |
112 | /* ------------------------------------------------------------------------- * |
114 | /* ------------------------------------------------------------------------- * |
113 | * SCREEN `COMMON' ROUTINES * |
115 | * SCREEN `COMMON' ROUTINES * |
114 | * ------------------------------------------------------------------------- */ |
116 | * ------------------------------------------------------------------------- */ |
115 | /* Fill part/all of a line with blanks. */ |
117 | /* Fill part/all of a line with blanks. */ |
116 | /* INTPROTO */ |
|
|
117 | void |
118 | void |
118 | rxvt_blank_line(pR_ text_t *et, rend_t *er, unsigned int width, rend_t efs) |
119 | rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) |
119 | { |
120 | { |
120 | efs &= ~RS_baseattrMask; |
121 | efs &= ~RS_baseattrMask; |
121 | efs = SET_FONT (efs, R->TermWin.fontset->find_font (' ')); |
122 | efs = SET_FONT (efs, TermWin.fontset->find_font (' ')); |
122 | |
123 | |
123 | while (width--) |
124 | while (width--) |
124 | { |
125 | { |
125 | *et++ = ' '; |
126 | *et++ = ' '; |
126 | *er++ = efs; |
127 | *er++ = efs; |
127 | } |
128 | } |
128 | } |
129 | } |
129 | |
130 | |
130 | /* ------------------------------------------------------------------------- */ |
131 | /* ------------------------------------------------------------------------- */ |
131 | /* Fill a full line with blanks - make sure it is allocated first */ |
132 | /* Fill a full line with blanks - make sure it is allocated first */ |
132 | /* INTPROTO */ |
|
|
133 | void |
133 | void |
134 | rxvt_blank_screen_mem(pR_ text_t **tp, rend_t **rp, unsigned int row, rend_t efs) |
134 | rxvt_term::scr_blank_screen_mem (text_t **tp, rend_t **rp, unsigned int row, rend_t efs) |
135 | { |
135 | { |
136 | int width = R->TermWin.ncol; |
|
|
137 | rend_t *er; |
|
|
138 | |
|
|
139 | #ifdef DEBUG_STRICT |
136 | #ifdef DEBUG_STRICT |
140 | assert((tp[row] && rp[row]) || (tp[row] == NULL && rp[row] == NULL)); |
137 | assert((tp[row] && rp[row]) || (tp[row] == NULL && rp[row] == NULL)); |
141 | #endif |
138 | #endif |
142 | if (tp[row] == NULL) { |
139 | if (tp[row] == NULL) |
143 | tp[row] = (text_t *)rxvt_malloc(sizeof(text_t) * width); |
|
|
144 | rp[row] = (rend_t *)rxvt_malloc(sizeof(rend_t) * width); |
|
|
145 | } |
140 | { |
|
|
141 | tp[row] = (text_t *)talloc->alloc (); |
|
|
142 | rp[row] = (rend_t *)ralloc->alloc (); |
|
|
143 | } |
|
|
144 | |
146 | rxvt_blank_line (aR_ tp[row], rp[row], width, efs); |
145 | scr_blank_line (tp[row], rp[row], TermWin.ncol, efs); |
147 | } |
146 | } |
148 | |
147 | |
149 | /* ------------------------------------------------------------------------- * |
148 | /* ------------------------------------------------------------------------- * |
150 | * SCREEN INITIALISATION * |
149 | * SCREEN INITIALISATION * |
151 | * ------------------------------------------------------------------------- */ |
150 | * ------------------------------------------------------------------------- */ |
152 | /* EXTPROTO */ |
|
|
153 | void |
151 | void |
154 | rxvt_scr_reset(pR) |
152 | rxvt_term::scr_reset () |
155 | { |
153 | { |
156 | unsigned int ncol, nrow, prev_ncol, prev_nrow, |
154 | unsigned int ncol, nrow, total_rows, prev_total_rows; |
157 | total_rows, prev_total_rows; |
|
|
158 | unsigned int p, q; |
155 | unsigned int p, q; |
159 | int k; |
156 | int k; |
160 | rend_t setrstyle; |
157 | rend_t setrstyle; |
161 | |
158 | |
162 | D_SCREEN((stderr, "rxvt_scr_reset()")); |
159 | D_SCREEN((stderr, "rxvt_scr_reset()")); |
163 | |
160 | |
164 | R->TermWin.view_start = 0; |
161 | TermWin.view_start = 0; |
165 | R->num_scr = 0; |
162 | num_scr = 0; |
166 | |
163 | |
167 | prev_ncol = R->prev_ncol; |
|
|
168 | prev_nrow = R->prev_nrow; |
|
|
169 | if (R->TermWin.ncol == 0) |
164 | if (TermWin.ncol == 0) |
170 | R->TermWin.ncol = 80; |
165 | TermWin.ncol = 80; |
|
|
166 | |
171 | if (R->TermWin.nrow == 0) |
167 | if (TermWin.nrow == 0) |
172 | R->TermWin.nrow = 24; |
168 | TermWin.nrow = 24; |
|
|
169 | |
173 | ncol = R->TermWin.ncol; |
170 | ncol = TermWin.ncol; |
174 | nrow = R->TermWin.nrow; |
171 | nrow = TermWin.nrow; |
|
|
172 | |
175 | if (ncol == prev_ncol && nrow == prev_nrow) |
173 | if (ncol == prev_ncol && nrow == prev_nrow) |
176 | return; |
174 | return; |
177 | |
175 | |
178 | R->want_refresh = 1; |
176 | want_refresh = 1; |
179 | |
177 | |
180 | total_rows = nrow + R->TermWin.saveLines; |
178 | total_rows = nrow + TermWin.saveLines; |
181 | prev_total_rows = prev_nrow + R->TermWin.saveLines; |
179 | prev_total_rows = prev_nrow + TermWin.saveLines; |
182 | |
180 | |
183 | R->screen.tscroll = 0; |
181 | screen.tscroll = 0; |
184 | R->screen.bscroll = nrow - 1; |
182 | screen.bscroll = nrow - 1; |
185 | |
183 | |
|
|
184 | if (!talloc) |
|
|
185 | { |
|
|
186 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
187 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
188 | } |
|
|
189 | |
186 | if (prev_nrow == 0) { |
190 | if (prev_nrow == 0) |
187 | /* |
191 | { |
|
|
192 | /* |
188 | * A: first time called so just malloc everything : don't rely on realloc |
193 | * first time called so just malloc everything : don't rely on realloc |
189 | * Note: this is still needed so that all the scrollback lines are NULL |
194 | * Note: this is still needed so that all the scrollback lines are NULL |
190 | */ |
195 | */ |
191 | R->screen.text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
196 | screen.text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
192 | R->buf_text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
197 | buf_text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); |
193 | R->drawn_text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
198 | drawn_text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
194 | R->swap.text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
199 | swap.text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); |
195 | |
200 | |
196 | R->screen.tlen = (int16_t *)rxvt_calloc(total_rows, sizeof(int16_t)); |
201 | screen.tlen = (int16_t *)rxvt_calloc(total_rows, sizeof(int16_t)); |
197 | R->swap.tlen = (int16_t *)rxvt_calloc(nrow, sizeof(int16_t)); |
202 | swap.tlen = (int16_t *)rxvt_calloc(nrow, sizeof(int16_t)); |
198 | |
203 | |
199 | R->screen.rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
204 | screen.rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
200 | R->buf_rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
205 | buf_rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); |
201 | R->drawn_rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
206 | drawn_rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
202 | R->swap.rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
207 | swap.rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); |
203 | |
208 | |
204 | for (p = 0; p < nrow; p++) { |
209 | for (p = 0; p < nrow; p++) |
|
|
210 | { |
205 | q = p + R->TermWin.saveLines; |
211 | q = p + TermWin.saveLines; |
206 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
212 | scr_blank_screen_mem (screen.text, screen.rend, q, DEFAULT_RSTYLE); |
207 | q, DEFAULT_RSTYLE); |
213 | scr_blank_screen_mem (swap.text, swap.rend, p, DEFAULT_RSTYLE); |
208 | rxvt_blank_screen_mem(aR_ R->swap.text, R->swap.rend, |
|
|
209 | p, DEFAULT_RSTYLE); |
|
|
210 | R->screen.tlen[q] = R->swap.tlen[p] = 0; |
214 | screen.tlen[q] = swap.tlen[p] = 0; |
211 | rxvt_blank_screen_mem(aR_ R->drawn_text, R->drawn_rend, |
215 | scr_blank_screen_mem (drawn_text, drawn_rend, p, DEFAULT_RSTYLE); |
212 | p, DEFAULT_RSTYLE); |
|
|
213 | } |
216 | } |
|
|
217 | |
214 | MEMSET(R->charsets, 'B', sizeof(R->charsets)); |
218 | MEMSET(charsets, 'B', sizeof(charsets)); |
215 | R->TermWin.nscrolled = 0; /* no saved lines */ |
219 | TermWin.nscrolled = 0; /* no saved lines */ |
216 | R->rstyle = DEFAULT_RSTYLE; |
220 | rstyle = DEFAULT_RSTYLE; |
217 | R->screen.flags = Screen_DefaultFlags; |
221 | screen.flags = Screen_DefaultFlags; |
218 | R->screen.cur.row = R->screen.cur.col = 0; |
222 | screen.cur.row = screen.cur.col = 0; |
219 | R->screen.charset = 0; |
223 | screen.charset = 0; |
220 | R->current_screen = PRIMARY; |
224 | current_screen = PRIMARY; |
221 | rxvt_scr_cursor(aR_ SAVE); |
225 | rxvt_scr_cursor (this, SAVE); |
|
|
226 | |
222 | #if NSCREENS |
227 | #if NSCREENS |
223 | R->swap.flags = Screen_DefaultFlags; |
228 | swap.flags = Screen_DefaultFlags; |
224 | R->swap.cur.row = R->swap.cur.col = 0; |
229 | swap.cur.row = swap.cur.col = 0; |
225 | R->swap.charset = 0; |
230 | swap.charset = 0; |
226 | R->current_screen = SECONDARY; |
231 | current_screen = SECONDARY; |
227 | rxvt_scr_cursor(aR_ SAVE); |
232 | rxvt_scr_cursor(aR_ SAVE); |
228 | R->current_screen = PRIMARY; |
233 | current_screen = PRIMARY; |
229 | #endif |
234 | #endif |
|
|
235 | |
230 | R->selection.text = NULL; |
236 | selection.text = NULL; |
231 | R->selection.len = 0; |
237 | selection.len = 0; |
232 | R->selection.op = SELECTION_CLEAR; |
238 | selection.op = SELECTION_CLEAR; |
233 | R->selection.screen = PRIMARY; |
239 | selection.screen = PRIMARY; |
234 | R->selection.clicks = 0; |
240 | selection.clicks = 0; |
235 | CLEAR_ALL_SELECTION(R); |
241 | CLEAR_ALL_SELECTION (this); |
236 | R->rvideo = 0; |
242 | rvideo = 0; |
237 | |
243 | } |
238 | } else { |
244 | else |
239 | /* |
245 | { |
|
|
246 | /* |
240 | * B1: add or delete rows as appropriate |
247 | * add or delete rows as appropriate |
241 | */ |
248 | */ |
242 | setrstyle = DEFAULT_RSTYLE; |
249 | setrstyle = DEFAULT_RSTYLE; |
243 | |
250 | |
244 | if (nrow < prev_nrow) { |
251 | if (nrow < prev_nrow) |
|
|
252 | { |
245 | /* delete rows */ |
253 | /* delete rows */ |
246 | k = min(R->TermWin.nscrolled, prev_nrow - nrow); |
254 | k = min (TermWin.nscrolled, prev_nrow - nrow); |
247 | rxvt_scroll_text(aR_ 0, (int)prev_nrow - 1, k, 1); |
255 | scr_scroll_text (0, (int)prev_nrow - 1, k, 1); |
|
|
256 | |
248 | for (p = nrow; p < prev_nrow; p++) { |
257 | for (p = nrow; p < prev_nrow; p++) |
|
|
258 | { |
249 | q = p + R->TermWin.saveLines; |
259 | q = p + TermWin.saveLines; |
250 | if (R->screen.text[q]) { |
260 | if (screen.text[q]) |
|
|
261 | { |
251 | #ifdef DEBUG_STRICT |
262 | #ifdef DEBUG_STRICT |
252 | assert(R->screen.rend[q]); |
263 | assert (screen.rend[q]); |
253 | #endif |
264 | #endif |
254 | free(R->screen.text[q]); |
265 | talloc->free (screen.text[q]); |
255 | free(R->screen.rend[q]); |
266 | ralloc->free (screen.rend[q]); |
256 | } |
267 | } |
257 | if (R->swap.text[p]) { |
268 | if (swap.text[p]) |
|
|
269 | { |
258 | #ifdef DEBUG_STRICT |
270 | #ifdef DEBUG_STRICT |
259 | assert(R->swap.rend[p]); |
271 | assert (swap.rend[p]); |
260 | #endif |
272 | #endif |
261 | free(R->swap.text[p]); |
273 | talloc->free (swap.text[p]); |
262 | free(R->swap.rend[p]); |
274 | ralloc->free (swap.rend[p]); |
263 | } |
275 | } |
264 | #ifdef DEBUG_STRICT |
276 | #ifdef DEBUG_STRICT |
265 | assert(R->drawn_text[p] && R->drawn_rend[p]); |
277 | assert (drawn_text[p] && drawn_rend[p]); |
266 | #endif |
278 | #endif |
267 | free(R->drawn_text[p]); |
279 | talloc->free (drawn_text[p]); |
268 | free(R->drawn_rend[p]); |
280 | ralloc->free (drawn_rend[p]); |
269 | } |
281 | } |
|
|
282 | |
270 | /* we have fewer rows so fix up cursor position */ |
283 | /* we have fewer rows so fix up cursor position */ |
271 | MIN_IT(R->screen.cur.row, (int32_t)nrow - 1); |
284 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
272 | MIN_IT(R->swap.cur.row, (int32_t)nrow - 1); |
285 | MIN_IT (swap.cur.row, (int32_t)nrow - 1); |
273 | |
286 | |
274 | rxvt_scr_reset_realloc(aR); /* realloc _last_ */ |
287 | scr_reset_realloc (); /* realloc _last_ */ |
275 | |
288 | } |
276 | } else if (nrow > prev_nrow) { |
289 | else if (nrow > prev_nrow) |
|
|
290 | { |
277 | /* add rows */ |
291 | /* add rows */ |
278 | rxvt_scr_reset_realloc(aR); /* realloc _first_ */ |
292 | scr_reset_realloc (); /* realloc _first_ */ |
279 | |
293 | |
|
|
294 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
|
|
295 | |
280 | k = min(R->TermWin.nscrolled, nrow - prev_nrow); |
296 | k = min (TermWin.nscrolled, nrow - prev_nrow); |
|
|
297 | |
281 | for (p = prev_total_rows; p < total_rows; p++) { |
298 | for (p = prev_total_rows; p < total_rows; p++) |
|
|
299 | { |
282 | R->screen.tlen[p] = 0; |
300 | screen.tlen[p] = 0; |
283 | R->screen.text[p] = NULL; |
301 | screen.text[p] = NULL; |
284 | R->screen.rend[p] = NULL; |
302 | screen.rend[p] = NULL; |
285 | } |
303 | } |
|
|
304 | |
286 | for (p = prev_total_rows; p < total_rows - k; p++) |
305 | for (p = prev_total_rows; p < total_rows - k; p++) |
287 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
306 | scr_blank_screen_mem (screen.text, screen.rend, p, setrstyle); |
288 | p, setrstyle); |
307 | |
289 | for (p = prev_nrow; p < nrow; p++) { |
308 | for (p = prev_nrow; p < nrow; p++) |
|
|
309 | { |
290 | R->swap.tlen[p] = 0; |
310 | swap.tlen[p] = 0; |
291 | R->swap.text[p] = NULL; |
311 | swap.text[p] = NULL; |
292 | R->swap.rend[p] = NULL; |
312 | swap.rend[p] = NULL; |
293 | R->drawn_text[p] = NULL; |
313 | drawn_text[p] = NULL; |
294 | R->drawn_rend[p] = NULL; |
314 | drawn_rend[p] = NULL; |
295 | rxvt_blank_screen_mem(aR_ R->swap.text, R->swap.rend, |
315 | scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle); |
296 | p, setrstyle); |
|
|
297 | rxvt_blank_screen_mem(aR_ R->drawn_text, R->drawn_rend, |
316 | scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle); |
298 | p, setrstyle); |
|
|
299 | } |
317 | } |
|
|
318 | |
300 | if (k > 0) { |
319 | if (k > 0) |
|
|
320 | { |
301 | rxvt_scroll_text(aR_ 0, (int)nrow - 1, -k, 1); |
321 | scr_scroll_text (0, (int)nrow - 1, -k, 1); |
302 | R->screen.cur.row += k; |
322 | screen.cur.row += k; |
303 | R->screen.s_cur.row += k; |
323 | screen.s_cur.row += k; |
304 | R->TermWin.nscrolled -= k; |
324 | TermWin.nscrolled -= k; |
305 | } |
325 | } |
306 | #ifdef DEBUG_STRICT |
326 | #ifdef DEBUG_STRICT |
307 | assert(R->screen.cur.row < R->TermWin.nrow); |
327 | assert(screen.cur.row < TermWin.nrow); |
308 | assert(R->swap.cur.row < R->TermWin.nrow); |
328 | assert(swap.cur.row < TermWin.nrow); |
309 | #else /* drive with your eyes closed */ |
329 | #else /* drive with your eyes closed */ |
|
|
330 | |
310 | MIN_IT(R->screen.cur.row, nrow - 1); |
331 | MIN_IT(screen.cur.row, nrow - 1); |
311 | MIN_IT(R->swap.cur.row, nrow - 1); |
332 | MIN_IT(swap.cur.row, nrow - 1); |
312 | #endif |
333 | #endif |
|
|
334 | TermWin.ncol = ncol; // save b/c scr_blank_screen_mem uses this |
313 | } |
335 | } |
|
|
336 | |
314 | /* B2: resize columns */ |
337 | /* resize columns */ |
315 | if (ncol != prev_ncol) { |
338 | if (ncol != prev_ncol) |
|
|
339 | { |
|
|
340 | int common = min (prev_ncol, ncol); |
|
|
341 | rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
342 | rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
343 | |
316 | for (p = 0; p < total_rows; p++) { |
344 | for (p = 0; p < total_rows; p++) |
|
|
345 | { |
317 | if (R->screen.text[p]) { |
346 | if (screen.text[p]) |
318 | R->screen.text[p] = (text_t *)rxvt_realloc(R->screen.text[p], ncol * sizeof(text_t)); |
347 | { |
319 | R->screen.rend[p] = (rend_t *)rxvt_realloc(R->screen.rend[p], ncol * sizeof(rend_t)); |
348 | text_t *t = (text_t *)ta->alloc (); memcpy (t, screen.text[p], common * sizeof (text_t)); screen.text[p] = t; |
|
|
349 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, screen.rend[p], common * sizeof (rend_t)); screen.rend[p] = r; |
|
|
350 | |
320 | MIN_IT(R->screen.tlen[p], (int16_t)ncol); |
351 | MIN_IT(screen.tlen[p], (int16_t)ncol); |
|
|
352 | |
321 | if (ncol > prev_ncol) |
353 | if (ncol > prev_ncol) |
322 | rxvt_blank_line(aR_ |
354 | scr_blank_line (&(screen.text[p][prev_ncol]), |
323 | &(R->screen.text[p][prev_ncol]), |
|
|
324 | &(R->screen.rend[p][prev_ncol]), |
355 | &(screen.rend[p][prev_ncol]), |
325 | ncol - prev_ncol, |
356 | ncol - prev_ncol, |
326 | setrstyle); |
357 | setrstyle); |
327 | } |
358 | } |
328 | } |
359 | } |
|
|
360 | |
329 | for (p = 0; p < nrow; p++) { |
361 | for (p = 0; p < nrow; p++) |
330 | R->drawn_text[p] = (text_t *)rxvt_realloc(R->drawn_text[p], ncol * sizeof(text_t)); |
362 | { |
331 | R->drawn_rend[p] = (rend_t *)rxvt_realloc(R->drawn_rend[p], ncol * sizeof(rend_t)); |
363 | text_t *t = (text_t *)ta->alloc (); memcpy (t, drawn_text[p], common * sizeof (text_t)); drawn_text[p] = t; |
|
|
364 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, drawn_rend[p], common * sizeof (rend_t)); drawn_rend[p] = r; |
|
|
365 | |
|
|
366 | if (ncol > prev_ncol) |
|
|
367 | scr_blank_line (&(drawn_text[p][prev_ncol]), |
|
|
368 | &(drawn_rend[p][prev_ncol]), |
|
|
369 | ncol - prev_ncol, setrstyle); |
|
|
370 | |
332 | if (R->swap.text[p]) { |
371 | if (swap.text[p]) |
333 | R->swap.text[p] = (text_t *)rxvt_realloc(R->swap.text[p], ncol * sizeof(text_t)); |
372 | { |
334 | R->swap.rend[p] = (rend_t *)rxvt_realloc(R->swap.rend[p], ncol * sizeof(rend_t)); |
373 | text_t *t = (text_t *)ta->alloc (); memcpy (t, swap.text[p], common * sizeof (text_t)); swap.text[p] = t; |
|
|
374 | rend_t *r = (rend_t *)ra->alloc (); memcpy (r, swap.rend[p], common * sizeof (rend_t)); swap.rend[p] = r; |
|
|
375 | |
335 | MIN_IT(R->swap.tlen[p], (int16_t)ncol); |
376 | MIN_IT(swap.tlen[p], (int16_t)ncol); |
|
|
377 | |
336 | if (ncol > prev_ncol) |
378 | if (ncol > prev_ncol) |
337 | rxvt_blank_line(aR_ |
379 | scr_blank_line (&(swap.text[p][prev_ncol]), |
338 | &(R->swap.text[p][prev_ncol]), |
|
|
339 | &(R->swap.rend[p][prev_ncol]), |
380 | &(swap.rend[p][prev_ncol]), |
340 | ncol - prev_ncol, setrstyle); |
381 | ncol - prev_ncol, setrstyle); |
341 | } |
382 | } |
342 | if (ncol > prev_ncol) |
383 | |
343 | rxvt_blank_line(aR_ |
|
|
344 | &(R->drawn_text[p][prev_ncol]), |
|
|
345 | &(R->drawn_rend[p][prev_ncol]), |
|
|
346 | ncol - prev_ncol, setrstyle); |
|
|
347 | } |
384 | } |
|
|
385 | |
348 | MIN_IT(R->screen.cur.col, (int16_t)ncol - 1); |
386 | MIN_IT (screen.cur.col, (int16_t)ncol - 1); |
349 | MIN_IT(R->swap.cur.col, (int16_t)ncol - 1); |
387 | MIN_IT (swap.cur.col, (int16_t)ncol - 1); |
|
|
388 | |
|
|
389 | delete talloc; talloc = ta; |
|
|
390 | delete ralloc; ralloc = ra; |
350 | } |
391 | } |
|
|
392 | |
351 | if (R->tabs) |
393 | if (tabs) |
352 | free(R->tabs); |
394 | free(tabs); |
353 | } |
395 | } |
354 | |
396 | |
|
|
397 | prev_nrow = nrow; |
|
|
398 | prev_ncol = ncol; |
|
|
399 | |
355 | R->tabs = (char *)rxvt_malloc(ncol * sizeof(char)); |
400 | tabs = (char *)rxvt_malloc (ncol * sizeof(char)); |
356 | |
401 | |
357 | for (p = 0; p < ncol; p++) |
402 | for (p = 0; p < ncol; p++) |
358 | R->tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
403 | tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
359 | |
404 | |
360 | R->prev_nrow = nrow; |
|
|
361 | R->prev_ncol = ncol; |
|
|
362 | |
|
|
363 | R->tt_winch (); |
405 | tt_winch (); |
364 | } |
406 | } |
365 | |
407 | |
366 | /* INTPROTO */ |
|
|
367 | void |
408 | void |
368 | rxvt_scr_reset_realloc(pR) |
409 | rxvt_term::scr_reset_realloc() |
369 | { |
410 | { |
370 | uint16_t total_rows, nrow; |
411 | uint16_t total_rows, nrow; |
371 | |
412 | |
372 | nrow = R->TermWin.nrow; |
413 | nrow = TermWin.nrow; |
373 | total_rows = nrow + R->TermWin.saveLines; |
414 | total_rows = nrow + TermWin.saveLines; |
374 | /* *INDENT-OFF* */ |
415 | /* *INDENT-OFF* */ |
375 | R->screen.text = (text_t **)rxvt_realloc(R->screen.text, total_rows * sizeof(text_t *)); |
416 | screen.text = (text_t **)rxvt_realloc(screen.text, total_rows * sizeof(text_t *)); |
376 | R->buf_text = (text_t **)rxvt_realloc(R->buf_text , total_rows * sizeof(text_t *)); |
417 | buf_text = (text_t **)rxvt_realloc(buf_text , total_rows * sizeof(text_t *)); |
377 | R->drawn_text = (text_t **)rxvt_realloc(R->drawn_text , nrow * sizeof(text_t *)); |
418 | drawn_text = (text_t **)rxvt_realloc(drawn_text , nrow * sizeof(text_t *)); |
378 | R->swap.text = (text_t **)rxvt_realloc(R->swap.text , nrow * sizeof(text_t *)); |
419 | swap.text = (text_t **)rxvt_realloc(swap.text , nrow * sizeof(text_t *)); |
379 | |
420 | |
380 | R->screen.tlen = (int16_t *)rxvt_realloc(R->screen.tlen, total_rows * sizeof(int16_t)); |
421 | screen.tlen = (int16_t *)rxvt_realloc(screen.tlen, total_rows * sizeof(int16_t)); |
381 | R->swap.tlen = (int16_t *)rxvt_realloc(R->swap.tlen , total_rows * sizeof(int16_t)); |
422 | swap.tlen = (int16_t *)rxvt_realloc(swap.tlen , total_rows * sizeof(int16_t)); |
382 | |
423 | |
383 | R->screen.rend = (rend_t **)rxvt_realloc(R->screen.rend, total_rows * sizeof(rend_t *)); |
424 | screen.rend = (rend_t **)rxvt_realloc(screen.rend, total_rows * sizeof(rend_t *)); |
384 | R->buf_rend = (rend_t **)rxvt_realloc(R->buf_rend , total_rows * sizeof(rend_t *)); |
425 | buf_rend = (rend_t **)rxvt_realloc(buf_rend , total_rows * sizeof(rend_t *)); |
385 | R->drawn_rend = (rend_t **)rxvt_realloc(R->drawn_rend , nrow * sizeof(rend_t *)); |
426 | drawn_rend = (rend_t **)rxvt_realloc(drawn_rend , nrow * sizeof(rend_t *)); |
386 | R->swap.rend = (rend_t **)rxvt_realloc(R->swap.rend , nrow * sizeof(rend_t *)); |
427 | swap.rend = (rend_t **)rxvt_realloc(swap.rend , nrow * sizeof(rend_t *)); |
387 | /* *INDENT-ON* */ |
428 | /* *INDENT-ON* */ |
388 | } |
429 | } |
389 | |
430 | |
390 | /* ------------------------------------------------------------------------- */ |
431 | /* ------------------------------------------------------------------------- */ |
391 | /* |
432 | /* |
392 | * Free everything. That way malloc debugging can find leakage. |
433 | * Free everything. That way malloc debugging can find leakage. |
393 | */ |
434 | */ |
394 | /* EXTPROTO */ |
|
|
395 | void |
435 | void |
396 | rxvt_scr_release(pR) |
436 | rxvt_term::scr_release() |
397 | { |
437 | { |
398 | uint16_t total_rows; |
438 | uint16_t total_rows; |
399 | int i; |
439 | int i; |
400 | |
440 | |
401 | total_rows = R->TermWin.nrow + R->TermWin.saveLines; |
441 | total_rows = TermWin.nrow + TermWin.saveLines; |
402 | for (i = 0; i < total_rows; i++) { |
442 | |
403 | if (R->screen.text[i]) { /* then so is R->screen.rend[i] */ |
|
|
404 | free(R->screen.text[i]); |
|
|
405 | #ifdef DEBUG_STRICT |
443 | #ifdef DEBUG_STRICT |
|
|
444 | for (i = 0; i < total_rows; i++) |
|
|
445 | { |
|
|
446 | if (screen.text[i]) |
|
|
447 | /* then so is screen.rend[i] */ |
406 | assert(R->screen.rend[i]); |
448 | assert(screen.rend[i]); |
407 | #endif |
|
|
408 | free(R->screen.rend[i]); |
|
|
409 | } |
|
|
410 | } |
449 | } |
411 | for (i = 0; i < R->TermWin.nrow; i++) { |
450 | #endif |
412 | free(R->drawn_text[i]); |
451 | |
413 | free(R->drawn_rend[i]); |
452 | delete talloc; |
414 | free(R->swap.text[i]); |
453 | delete ralloc; |
415 | free(R->swap.rend[i]); |
454 | |
416 | } |
|
|
417 | free(R->screen.text); |
455 | free (screen.text); |
418 | free(R->screen.tlen); |
456 | free (screen.tlen); |
419 | free(R->screen.rend); |
457 | free (screen.rend); |
420 | free(R->drawn_text); |
458 | free (drawn_text); |
421 | free(R->drawn_rend); |
459 | free (drawn_rend); |
422 | free(R->swap.text); |
460 | free (swap.text); |
423 | free(R->swap.tlen); |
461 | free (swap.tlen); |
424 | free(R->swap.rend); |
462 | free (swap.rend); |
425 | free(R->buf_text); |
463 | free (buf_text); |
426 | free(R->buf_rend); |
464 | free (buf_rend); |
427 | free(R->tabs); |
465 | free (tabs); |
428 | |
466 | |
429 | /* NULL these so if anything tries to use them, we'll know about it */ |
467 | /* NULL these so if anything tries to use them, we'll know about it */ |
430 | R->screen.text = R->drawn_text = R->swap.text = NULL; |
468 | screen.text = drawn_text = swap.text = NULL; |
431 | R->screen.rend = R->drawn_rend = R->swap.rend = NULL; |
469 | screen.rend = drawn_rend = swap.rend = NULL; |
432 | R->screen.tlen = R->swap.tlen = NULL; |
470 | screen.tlen = swap.tlen = NULL; |
433 | R->buf_text = NULL; |
471 | buf_text = NULL; |
434 | R->buf_rend = NULL; |
472 | buf_rend = NULL; |
435 | R->tabs = NULL; |
473 | tabs = NULL; |
436 | } |
474 | } |
437 | |
475 | |
438 | /* ------------------------------------------------------------------------- */ |
476 | /* ------------------------------------------------------------------------- */ |
439 | /* |
477 | /* |
440 | * Hard reset |
478 | * Hard reset |
441 | */ |
479 | */ |
442 | /* EXTPROTO */ |
480 | /* EXTPROTO */ |
443 | void |
481 | void |
444 | rxvt_scr_poweron(pR) |
482 | rxvt_scr_poweron(pR) |
445 | { |
483 | { |
446 | D_SCREEN((stderr, "rxvt_scr_poweron()")); |
484 | D_SCREEN((stderr, "rxvt_scr_poweron()")); |
447 | |
485 | |
448 | rxvt_scr_release(aR); |
486 | R->scr_release (); |
449 | R->prev_nrow = R->prev_ncol = 0; |
487 | R->prev_nrow = R->prev_ncol = 0; |
450 | rxvt_scr_reset(aR); |
488 | R->scr_reset (); |
451 | |
489 | |
452 | rxvt_scr_clear(aR); |
490 | rxvt_scr_clear (aR); |
453 | rxvt_scr_refresh(aR_ SLOW_REFRESH); |
491 | rxvt_scr_refresh (aR_ SLOW_REFRESH); |
454 | #ifdef RXVT_GRAPHICS |
492 | #ifdef RXVT_GRAPHICS |
455 | rxvt_Gr_reset(aR); |
493 | rxvt_Gr_reset (aR); |
456 | #endif |
494 | #endif |
457 | } |
495 | } |
458 | |
496 | |
459 | /* ------------------------------------------------------------------------- * |
497 | /* ------------------------------------------------------------------------- * |
460 | * PROCESS SCREEN COMMANDS * |
498 | * PROCESS SCREEN COMMANDS * |
… | |
… | |
576 | if (R->current_screen == PRIMARY |
614 | if (R->current_screen == PRIMARY |
577 | # ifdef RXVT_GRAPHICS |
615 | # ifdef RXVT_GRAPHICS |
578 | && !rxvt_Gr_Displayed(aR) |
616 | && !rxvt_Gr_Displayed(aR) |
579 | # endif |
617 | # endif |
580 | ) |
618 | ) |
581 | rxvt_scroll_text(aR_ 0, (R->prev_nrow - 1), R->prev_nrow, 0); |
619 | R->scr_scroll_text(0, (R->prev_nrow - 1), R->prev_nrow, 0); |
582 | # endif |
620 | # endif |
583 | #endif |
621 | #endif |
584 | return scrn; |
622 | return scrn; |
585 | } |
623 | } |
586 | |
624 | |
… | |
… | |
620 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
658 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
621 | * count positive ==> scroll up |
659 | * count positive ==> scroll up |
622 | * count negative ==> scroll down |
660 | * count negative ==> scroll down |
623 | * spec == 0 for normal routines |
661 | * spec == 0 for normal routines |
624 | */ |
662 | */ |
625 | /* EXTPROTO */ |
|
|
626 | int |
663 | int |
627 | rxvt_scroll_text(pR_ int row1, int row2, int count, int spec) |
664 | rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) |
628 | { |
665 | { |
629 | int i, j; |
666 | int i, j; |
630 | long nscrolled; |
667 | long nscrolled; |
631 | |
668 | |
632 | if (count == 0 || (row1 > row2)) |
669 | if (count == 0 || (row1 > row2)) |
633 | return 0; |
670 | return 0; |
634 | |
671 | |
635 | R->want_refresh = 1; |
672 | want_refresh = 1; |
636 | D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (R->current_screen == PRIMARY) ? "Primary" : "Secondary")); |
673 | D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (current_screen == PRIMARY) ? "Primary" : "Secondary")); |
637 | |
674 | |
638 | if ((count > 0) && (row1 == 0) && (R->current_screen == PRIMARY)) { |
675 | if ((count > 0) && (row1 == 0) && (current_screen == PRIMARY)) |
|
|
676 | { |
639 | nscrolled = (long)R->TermWin.nscrolled + (long)count;; |
677 | nscrolled = (long)TermWin.nscrolled + (long)count; |
|
|
678 | |
640 | if (nscrolled > (long)R->TermWin.saveLines) |
679 | if (nscrolled > (long)TermWin.saveLines) |
641 | R->TermWin.nscrolled = R->TermWin.saveLines; |
680 | TermWin.nscrolled = TermWin.saveLines; |
642 | else |
681 | else |
643 | R->TermWin.nscrolled = (uint16_t)nscrolled; |
682 | TermWin.nscrolled = (uint16_t)nscrolled; |
|
|
683 | |
644 | if ((R->Options & Opt_scrollWithBuffer) |
684 | if ((Options & Opt_scrollWithBuffer) |
645 | && R->TermWin.view_start != 0 |
685 | && TermWin.view_start != 0 |
646 | && R->TermWin.view_start != R->TermWin.saveLines) |
686 | && TermWin.view_start != TermWin.saveLines) |
647 | rxvt_scr_page(aR_ UP, count); |
687 | rxvt_scr_page (this, UP, count); |
|
|
688 | } |
648 | } else if (!spec) |
689 | else if (!spec) |
649 | row1 += R->TermWin.saveLines; |
|
|
650 | row2 += R->TermWin.saveLines; |
690 | row1 += TermWin.saveLines; |
651 | |
691 | |
|
|
692 | row2 += TermWin.saveLines; |
|
|
693 | |
652 | if (R->selection.op && R->current_screen == R->selection.screen) { |
694 | if (selection.op && current_screen == selection.screen) |
|
|
695 | { |
653 | i = R->selection.beg.row + R->TermWin.saveLines; |
696 | i = selection.beg.row + TermWin.saveLines; |
654 | j = R->selection.end.row + R->TermWin.saveLines; |
697 | j = selection.end.row + TermWin.saveLines; |
655 | if ((i < row1 && j > row1) |
698 | if ((i < row1 && j > row1) |
656 | || (i < row2 && j > row2) |
699 | || (i < row2 && j > row2) |
657 | || (i - count < row1 && i >= row1) |
700 | || (i - count < row1 && i >= row1) |
658 | || (i - count > row2 && i <= row2) |
701 | || (i - count > row2 && i <= row2) |
659 | || (j - count < row1 && j >= row1) |
702 | || (j - count < row1 && j >= row1) |
660 | || (j - count > row2 && j <= row2)) { |
703 | || (j - count > row2 && j <= row2)) |
|
|
704 | { |
661 | CLEAR_ALL_SELECTION(R); |
705 | CLEAR_ALL_SELECTION (this); |
662 | R->selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
706 | selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
|
|
707 | } |
663 | } else if (j >= row1 && j <= row2) { |
708 | else if (j >= row1 && j <= row2) |
|
|
709 | { |
664 | /* move selected region too */ |
710 | /* move selected region too */ |
665 | R->selection.beg.row -= count; |
711 | selection.beg.row -= count; |
666 | R->selection.end.row -= count; |
712 | selection.end.row -= count; |
667 | R->selection.mark.row -= count; |
713 | selection.mark.row -= count; |
668 | } |
714 | } |
669 | } |
715 | } |
|
|
716 | |
670 | rxvt_selection_check(aR_ 0); /* _after_ R->TermWin.nscrolled update */ |
717 | rxvt_selection_check (this, 0); /* _after_ TermWin.nscrolled update */ |
671 | |
718 | |
672 | R->num_scr += count; |
719 | num_scr += count; |
673 | j = count; |
720 | j = count; |
|
|
721 | |
674 | if (count < 0) |
722 | if (count < 0) |
675 | count = -count; |
723 | count = -count; |
|
|
724 | |
676 | i = row2 - row1 + 1; |
725 | i = row2 - row1 + 1; |
677 | MIN_IT(count, i); |
726 | MIN_IT(count, i); |
678 | |
727 | |
679 | if (j > 0) { |
728 | if (j > 0) |
|
|
729 | { |
680 | /* A: scroll up */ |
730 | /* A: scroll up */ |
681 | |
731 | |
682 | /* A1: Copy lines that will get clobbered by the rotation */ |
732 | /* A1: Copy lines that will get clobbered by the rotation */ |
683 | for (i = 0, j = row1; i < count; i++, j++) { |
733 | for (i = 0, j = row1; i < count; i++, j++) |
|
|
734 | { |
684 | R->buf_text[i] = R->screen.text[j]; |
735 | buf_text[i] = screen.text[j]; |
685 | R->buf_rend[i] = R->screen.rend[j]; |
736 | buf_rend[i] = screen.rend[j]; |
686 | } |
737 | } |
687 | /* A2: Rotate lines */ |
738 | /* A2: Rotate lines */ |
688 | for (j = row1, i = j + count; i <= row2; i++, j++) { |
739 | for (j = row1, i = j + count; i <= row2; i++, j++) |
|
|
740 | { |
689 | R->screen.tlen[j] = R->screen.tlen[i]; |
741 | screen.tlen[j] = screen.tlen[i]; |
690 | R->screen.text[j] = R->screen.text[i]; |
742 | screen.text[j] = screen.text[i]; |
691 | R->screen.rend[j] = R->screen.rend[i]; |
743 | screen.rend[j] = screen.rend[i]; |
692 | } |
744 | } |
693 | j = row2 - count + 1, i = count; |
745 | j = row2 - count + 1, i = count; |
|
|
746 | } |
694 | } else /* if (j < 0) */ { |
747 | else /* if (j < 0) */ |
|
|
748 | { |
695 | /* B: scroll down */ |
749 | /* B: scroll down */ |
696 | |
750 | |
697 | /* B1: Copy lines that will get clobbered by the rotation */ |
751 | /* B1: Copy lines that will get clobbered by the rotation */ |
698 | for (i = 0, j = row2; i < count; i++, j--) { |
752 | for (i = 0, j = row2; i < count; i++, j--) |
|
|
753 | { |
699 | R->buf_text[i] = R->screen.text[j]; |
754 | buf_text[i] = screen.text[j]; |
700 | R->buf_rend[i] = R->screen.rend[j]; |
755 | buf_rend[i] = screen.rend[j]; |
701 | } |
756 | } |
702 | /* B2: Rotate lines */ |
757 | /* B2: Rotate lines */ |
703 | for (j = row2, i = j - count; i >= row1; i--, j--) { |
758 | for (j = row2, i = j - count; i >= row1; i--, j--) |
|
|
759 | { |
704 | R->screen.tlen[j] = R->screen.tlen[i]; |
760 | screen.tlen[j] = screen.tlen[i]; |
705 | R->screen.text[j] = R->screen.text[i]; |
761 | screen.text[j] = screen.text[i]; |
706 | R->screen.rend[j] = R->screen.rend[i]; |
762 | screen.rend[j] = screen.rend[i]; |
707 | } |
763 | } |
708 | j = row1, i = count; |
764 | j = row1, i = count; |
709 | count = -count; |
765 | count = -count; |
710 | } |
766 | } |
711 | |
767 | |
712 | /* C: Resurrect lines */ |
768 | /* C: Resurrect lines */ |
713 | for (; i--; j++) { |
769 | for (; i--; j++) |
|
|
770 | { |
714 | R->screen.tlen[j] = 0; |
771 | screen.tlen[j] = 0; |
715 | R->screen.text[j] = R->buf_text[i]; |
772 | screen.text[j] = buf_text[i]; |
716 | R->screen.rend[j] = R->buf_rend[i]; |
773 | screen.rend[j] = buf_rend[i]; |
|
|
774 | |
717 | if (!spec) /* line length may not equal TermWin.ncol */ |
775 | if (!spec) /* line length may not equal TermWin.ncol */ |
718 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
776 | scr_blank_screen_mem (screen.text, screen.rend, |
719 | (unsigned int)j, R->rstyle); |
777 | (unsigned int)j, rstyle); |
720 | } |
778 | } |
721 | |
779 | |
722 | #ifdef RXVT_GRAPHICS |
780 | #ifdef RXVT_GRAPHICS |
723 | if (rxvt_Gr_Displayed(aR)) |
781 | if (rxvt_Gr_Displayed (this)) |
724 | rxvt_Gr_scroll(aR_ count); |
782 | rxvt_Gr_scroll(this, count); |
725 | #endif |
783 | #endif |
|
|
784 | |
726 | return count; |
785 | return count; |
727 | } |
786 | } |
728 | |
787 | |
729 | /* ------------------------------------------------------------------------- */ |
788 | /* ------------------------------------------------------------------------- */ |
730 | /* |
789 | /* |
731 | * Add text given in <str> of length <len> to screen struct |
790 | * Add text given in <str> of length <len> to screen struct |
… | |
… | |
752 | nlines += (R->screen.cur.row - R->screen.bscroll); |
811 | nlines += (R->screen.cur.row - R->screen.bscroll); |
753 | if ((nlines > 0) |
812 | if ((nlines > 0) |
754 | && (R->screen.tscroll == 0) |
813 | && (R->screen.tscroll == 0) |
755 | && (R->screen.bscroll == (R->TermWin.nrow - 1))) { |
814 | && (R->screen.bscroll == (R->TermWin.nrow - 1))) { |
756 | /* _at least_ this many lines need to be scrolled */ |
815 | /* _at least_ this many lines need to be scrolled */ |
757 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, nlines, |
816 | R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, nlines, 0); |
758 | 0); |
|
|
759 | R->screen.cur.row -= nlines; |
817 | R->screen.cur.row -= nlines; |
760 | } |
818 | } |
761 | } |
819 | } |
762 | #ifdef DEBUG_STRICT |
820 | #ifdef DEBUG_STRICT |
763 | assert(R->screen.cur.col < last_col); |
821 | assert(R->screen.cur.col < last_col); |
… | |
… | |
779 | |
837 | |
780 | for (i = 0; i < len;) { |
838 | for (i = 0; i < len;) { |
781 | c = str[i++]; |
839 | c = str[i++]; |
782 | switch (c) { |
840 | switch (c) { |
783 | case '\t': |
841 | case '\t': |
784 | rxvt_scr_tab(aR_ 1); |
842 | rxvt_scr_tab (aR_ 1); |
785 | continue; |
843 | continue; |
786 | case '\n': |
844 | case '\n': |
787 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
845 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
788 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
846 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
789 | R->screen.flags &= ~Screen_WrapNext; |
847 | R->screen.flags &= ~Screen_WrapNext; |
790 | if (R->screen.cur.row == R->screen.bscroll) |
848 | if (R->screen.cur.row == R->screen.bscroll) |
791 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); |
849 | R->scr_scroll_text (R->screen.tscroll, R->screen.bscroll, 1, 0); |
792 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
850 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
793 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
851 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
794 | stp = R->screen.text[row]; /* _must_ refresh */ |
852 | stp = R->screen.text[row]; /* _must_ refresh */ |
795 | srp = R->screen.rend[row]; /* _must_ refresh */ |
853 | srp = R->screen.rend[row]; /* _must_ refresh */ |
796 | continue; |
854 | continue; |
… | |
… | |
813 | clearsel = 1; |
871 | clearsel = 1; |
814 | } |
872 | } |
815 | if (R->screen.flags & Screen_WrapNext) { |
873 | if (R->screen.flags & Screen_WrapNext) { |
816 | R->screen.tlen[row] = -1; |
874 | R->screen.tlen[row] = -1; |
817 | if (R->screen.cur.row == R->screen.bscroll) |
875 | if (R->screen.cur.row == R->screen.bscroll) |
818 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); |
876 | R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, 1, 0); |
819 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
877 | else if (R->screen.cur.row < (R->TermWin.nrow - 1)) |
820 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
878 | row = (++R->screen.cur.row) + R->TermWin.saveLines; |
821 | stp = R->screen.text[row]; /* _must_ refresh */ |
879 | stp = R->screen.text[row]; /* _must_ refresh */ |
822 | srp = R->screen.rend[row]; /* _must_ refresh */ |
880 | srp = R->screen.rend[row]; /* _must_ refresh */ |
823 | R->screen.cur.col = 0; |
881 | R->screen.cur.col = 0; |
… | |
… | |
1075 | #endif |
1133 | #endif |
1076 | |
1134 | |
1077 | R->screen.flags &= ~Screen_WrapNext; |
1135 | R->screen.flags &= ~Screen_WrapNext; |
1078 | if ((R->screen.cur.row == R->screen.bscroll && direction == UP) |
1136 | if ((R->screen.cur.row == R->screen.bscroll && direction == UP) |
1079 | || (R->screen.cur.row == R->screen.tscroll && direction == DN)) |
1137 | || (R->screen.cur.row == R->screen.tscroll && direction == DN)) |
1080 | rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, dirn, 0); |
1138 | R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, dirn, 0); |
1081 | else |
1139 | else |
1082 | R->screen.cur.row += dirn; |
1140 | R->screen.cur.row += dirn; |
1083 | MAX_IT(R->screen.cur.row, 0); |
1141 | MAX_IT(R->screen.cur.row, 0); |
1084 | MIN_IT(R->screen.cur.row, (int32_t)R->TermWin.nrow - 1); |
1142 | MIN_IT(R->screen.cur.row, (int32_t)R->TermWin.nrow - 1); |
1085 | rxvt_selection_check(aR_ 0); |
1143 | rxvt_selection_check(aR_ 0); |
… | |
… | |
1094 | */ |
1152 | */ |
1095 | /* EXTPROTO */ |
1153 | /* EXTPROTO */ |
1096 | void |
1154 | void |
1097 | rxvt_scr_erase_line(pR_ int mode) |
1155 | rxvt_scr_erase_line(pR_ int mode) |
1098 | { |
1156 | { |
1099 | unsigned int row, col, num; |
1157 | unsigned int row, col, num; |
1100 | |
1158 | |
1101 | R->want_refresh = 1; |
1159 | R->want_refresh = 1; |
1102 | D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); |
1160 | D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); |
1103 | ZERO_SCROLLBACK(R); |
1161 | ZERO_SCROLLBACK (R); |
1104 | |
1162 | |
1105 | #ifdef RXVT_GRAPHICS |
1163 | #ifdef RXVT_GRAPHICS |
1106 | if (rxvt_Gr_Displayed(aR)) |
1164 | if (rxvt_Gr_Displayed (aR)) |
1107 | rxvt_Gr_scroll(aR_ 0); |
1165 | rxvt_Gr_scroll (aR_ 0); |
1108 | #endif |
1166 | #endif |
1109 | |
1167 | |
1110 | rxvt_selection_check(aR_ 1); |
1168 | rxvt_selection_check (aR_ 1); |
1111 | |
1169 | |
1112 | R->screen.flags &= ~Screen_WrapNext; |
1170 | R->screen.flags &= ~Screen_WrapNext; |
1113 | |
1171 | |
1114 | row = R->TermWin.saveLines + R->screen.cur.row; |
1172 | row = R->TermWin.saveLines + R->screen.cur.row; |
1115 | switch (mode) { |
1173 | switch (mode) |
|
|
1174 | { |
1116 | case 0: /* erase to end of line */ |
1175 | case 0: /* erase to end of line */ |
1117 | col = R->screen.cur.col; |
1176 | col = R->screen.cur.col; |
1118 | num = R->TermWin.ncol - col; |
1177 | num = R->TermWin.ncol - col; |
1119 | MIN_IT(R->screen.tlen[row], (int16_t)col); |
1178 | MIN_IT(R->screen.tlen[row], (int16_t)col); |
1120 | if (ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur) |
1179 | if (ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur) |
1121 | || ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.end, R->screen.cur)) |
1180 | || ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.end, R->screen.cur)) |
1122 | CLEAR_SELECTION(R); |
1181 | CLEAR_SELECTION(R); |
1123 | break; |
1182 | break; |
1124 | case 1: /* erase to beginning of line */ |
1183 | case 1: /* erase to beginning of line */ |
1125 | col = 0; |
1184 | col = 0; |
1126 | num = R->screen.cur.col + 1; |
1185 | num = R->screen.cur.col + 1; |
1127 | if (ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.beg, R->screen.cur) |
1186 | if (ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.beg, R->screen.cur) |
1128 | || ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.end, R->screen.cur)) |
1187 | || ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.end, R->screen.cur)) |
1129 | CLEAR_SELECTION(R); |
1188 | CLEAR_SELECTION(R); |
1130 | break; |
1189 | break; |
1131 | case 2: /* erase whole line */ |
1190 | case 2: /* erase whole line */ |
1132 | col = 0; |
1191 | col = 0; |
1133 | num = R->TermWin.ncol; |
1192 | num = R->TermWin.ncol; |
1134 | R->screen.tlen[row] = 0; |
1193 | R->screen.tlen[row] = 0; |
1135 | if (R->selection.beg.row <= R->screen.cur.row |
1194 | if (R->selection.beg.row <= R->screen.cur.row |
1136 | && R->selection.end.row >= R->screen.cur.row) |
1195 | && R->selection.end.row >= R->screen.cur.row) |
1137 | CLEAR_SELECTION(R); |
1196 | CLEAR_SELECTION(R); |
1138 | break; |
1197 | break; |
1139 | default: |
1198 | default: |
1140 | return; |
1199 | return; |
1141 | } |
1200 | } |
|
|
1201 | |
1142 | if (R->screen.text[row]) |
1202 | if (R->screen.text[row]) |
1143 | rxvt_blank_line(aR_ |
1203 | R->scr_blank_line (&(R->screen.text[row][col]), |
1144 | &(R->screen.text[row][col]), |
|
|
1145 | &(R->screen.rend[row][col]), num, R->rstyle); |
1204 | &(R->screen.rend[row][col]), num, R->rstyle); |
1146 | else |
1205 | else |
1147 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, row, |
1206 | R->scr_blank_screen_mem (R->screen.text, R->screen.rend, row, R->rstyle); |
1148 | R->rstyle); |
|
|
1149 | } |
1207 | } |
1150 | |
1208 | |
1151 | /* ------------------------------------------------------------------------- */ |
1209 | /* ------------------------------------------------------------------------- */ |
1152 | /* |
1210 | /* |
1153 | * Erase part of whole of the screen |
1211 | * Erase part of whole of the screen |
… | |
… | |
1214 | ERASE_ROWS(row, num); |
1272 | ERASE_ROWS(row, num); |
1215 | gcvalue.foreground = R->PixColors[Color_fg]; |
1273 | gcvalue.foreground = R->PixColors[Color_fg]; |
1216 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1274 | XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); |
1217 | } |
1275 | } |
1218 | for (; num--; row++) { |
1276 | for (; num--; row++) { |
1219 | rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, |
1277 | R->scr_blank_screen_mem (R->screen.text, R->screen.rend, |
1220 | (unsigned int)(row + row_offset), R->rstyle); |
1278 | (unsigned int)(row + row_offset), R->rstyle); |
1221 | R->screen.tlen[row + row_offset] = 0; |
1279 | R->screen.tlen[row + row_offset] = 0; |
1222 | rxvt_blank_line(aR_ |
1280 | R->scr_blank_line (R->drawn_text[row], R->drawn_rend[row], |
1223 | R->drawn_text[row], R->drawn_rend[row], |
|
|
1224 | (unsigned int)R->TermWin.ncol, ren); |
1281 | (unsigned int)R->TermWin.ncol, ren); |
1225 | } |
1282 | } |
1226 | } |
1283 | } |
1227 | |
1284 | |
1228 | /* ------------------------------------------------------------------------- */ |
1285 | /* ------------------------------------------------------------------------- */ |
1229 | /* |
1286 | /* |
… | |
… | |
1280 | else if (insdel == INSERT) |
1337 | else if (insdel == INSERT) |
1281 | count = end; |
1338 | count = end; |
1282 | } |
1339 | } |
1283 | R->screen.flags &= ~Screen_WrapNext; |
1340 | R->screen.flags &= ~Screen_WrapNext; |
1284 | |
1341 | |
1285 | rxvt_scroll_text(aR_ R->screen.cur.row, R->screen.bscroll, insdel * count, |
1342 | R->scr_scroll_text(R->screen.cur.row, R->screen.bscroll, insdel * count, 0); |
1286 | 0); |
|
|
1287 | } |
1343 | } |
1288 | |
1344 | |
1289 | /* ------------------------------------------------------------------------- */ |
1345 | /* ------------------------------------------------------------------------- */ |
1290 | /* |
1346 | /* |
1291 | * Insert/Delete <count> characters from the current position |
1347 | * Insert/Delete <count> characters from the current position |
… | |
… | |
1340 | R->selection.beg.col += count; |
1396 | R->selection.beg.col += count; |
1341 | R->selection.mark.col += count; /* XXX: yes? */ |
1397 | R->selection.mark.col += count; /* XXX: yes? */ |
1342 | R->selection.end.col += count; |
1398 | R->selection.end.col += count; |
1343 | } |
1399 | } |
1344 | } |
1400 | } |
1345 | rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1401 | R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1346 | (unsigned int)count, R->rstyle); |
1402 | (unsigned int)count, R->rstyle); |
1347 | break; |
1403 | break; |
1348 | case ERASE: |
1404 | case ERASE: |
1349 | R->screen.cur.col += count; /* don't worry if > R->TermWin.ncol */ |
1405 | R->screen.cur.col += count; /* don't worry if > R->TermWin.ncol */ |
1350 | rxvt_selection_check(aR_ 1); |
1406 | rxvt_selection_check(aR_ 1); |
1351 | R->screen.cur.col -= count; |
1407 | R->screen.cur.col -= count; |
1352 | rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1408 | R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), |
1353 | (unsigned int)count, R->rstyle); |
1409 | (unsigned int)count, R->rstyle); |
1354 | break; |
1410 | break; |
1355 | case DELETE: |
1411 | case DELETE: |
1356 | tr = srp[R->TermWin.ncol - 1] |
1412 | tr = srp[R->TermWin.ncol - 1] |
1357 | & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1413 | & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1358 | for (col = R->screen.cur.col; (col + count) < R->TermWin.ncol; col++) { |
1414 | for (col = R->screen.cur.col; (col + count) < R->TermWin.ncol; col++) { |
1359 | stp[col] = stp[col + count]; |
1415 | stp[col] = stp[col + count]; |
1360 | srp[col] = srp[col + count]; |
1416 | srp[col] = srp[col + count]; |
1361 | } |
1417 | } |
1362 | rxvt_blank_line(aR_ |
1418 | R->scr_blank_line (&(stp[R->TermWin.ncol - count]), |
1363 | &(stp[R->TermWin.ncol - count]), |
|
|
1364 | &(srp[R->TermWin.ncol - count]), |
1419 | &(srp[R->TermWin.ncol - count]), |
1365 | (unsigned int)count, tr); |
1420 | (unsigned int)count, tr); |
1366 | if (*slp == -1) /* break line continuation */ |
1421 | if (*slp == -1) /* break line continuation */ |
1367 | *slp = R->TermWin.ncol; |
1422 | *slp = R->TermWin.ncol; |
1368 | *slp -= count; |
1423 | *slp -= count; |
1369 | MAX_IT(*slp, 0); |
1424 | MAX_IT(*slp, 0); |
1370 | if (R->selection.op && R->current_screen == R->selection.screen |
1425 | if (R->selection.op && R->current_screen == R->selection.screen |