… | |
… | |
83 | #define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \ |
83 | #define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \ |
84 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
84 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
85 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
85 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
86 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
86 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
87 | |
87 | |
88 | #define LINENO(n) (((n) + term_start + total_rows) % total_rows) |
|
|
89 | #define ROW(n) (save [LINENO (n)]) |
|
|
90 | |
|
|
91 | /* |
88 | /* |
92 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
89 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
93 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
90 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
94 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
91 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
95 | */ |
92 | */ |
… | |
… | |
150 | } |
147 | } |
151 | |
148 | |
152 | /* ------------------------------------------------------------------------- * |
149 | /* ------------------------------------------------------------------------- * |
153 | * SCREEN INITIALISATION * |
150 | * SCREEN INITIALISATION * |
154 | * ------------------------------------------------------------------------- */ |
151 | * ------------------------------------------------------------------------- */ |
|
|
152 | |
155 | void |
153 | void |
156 | rxvt_term::scr_reset () |
154 | rxvt_term::scr_reset () |
157 | { |
155 | { |
158 | unsigned int p, q; |
|
|
159 | int k; |
|
|
160 | |
|
|
161 | #if ENABLE_OVERLAY |
156 | #if ENABLE_OVERLAY |
162 | scr_overlay_off (); |
157 | scr_overlay_off (); |
163 | #endif |
158 | #endif |
164 | |
159 | |
165 | view_start = 0; |
160 | view_start = 0; |
… | |
… | |
175 | return; |
170 | return; |
176 | |
171 | |
177 | // we need at least two lines for wrapping to work correctly |
172 | // we need at least two lines for wrapping to work correctly |
178 | if (nrow + saveLines < 2) |
173 | if (nrow + saveLines < 2) |
179 | { |
174 | { |
|
|
175 | //TODO//FIXME |
180 | saveLines++; |
176 | saveLines++; |
181 | prev_nrow--; |
177 | prev_nrow--; |
182 | nsaved++; |
178 | nsaved++; |
183 | } |
179 | } |
184 | |
180 | |
… | |
… | |
188 | total_rows = nrow + saveLines; |
184 | total_rows = nrow + saveLines; |
189 | |
185 | |
190 | screen.tscroll = 0; |
186 | screen.tscroll = 0; |
191 | screen.bscroll = nrow - 1; |
187 | screen.bscroll = nrow - 1; |
192 | |
188 | |
193 | if (!save) |
189 | if (!row_buf) |
194 | { |
190 | { |
195 | /* |
191 | /* |
196 | * first time called so just malloc everything: don't rely on realloc |
192 | * first time called so just malloc everything: don't rely on realloc |
197 | * Note: this is still needed so that all the scrollback lines are NULL |
193 | * Note: this is still needed so that all the scrollback lines are NULL |
198 | */ |
194 | */ |
… | |
… | |
200 | term_start = 0; |
196 | term_start = 0; |
201 | |
197 | |
202 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
198 | talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
203 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
199 | ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
204 | |
200 | |
205 | save = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
|
|
206 | buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
201 | row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
|
|
202 | temp_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
207 | drawn = (line_t *)rxvt_calloc (nrow, sizeof (line_t)); |
203 | drawn_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); |
208 | swap_save = (line_t *)rxvt_calloc (nrow, sizeof (line_t)); |
204 | swap_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t)); |
209 | |
205 | |
210 | for (p = nrow; p--; ) |
206 | for (int row = nrow; row--; ) |
211 | { |
207 | { |
212 | scr_blank_screen_mem (ROW(p), DEFAULT_RSTYLE); |
208 | scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE); |
213 | scr_blank_screen_mem (swap_save[p], DEFAULT_RSTYLE); |
209 | scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
214 | scr_blank_screen_mem (drawn[p], DEFAULT_RSTYLE); |
210 | scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
215 | } |
211 | } |
216 | |
212 | |
217 | memset (charsets, 'B', sizeof (charsets)); |
213 | memset (charsets, 'B', sizeof (charsets)); |
218 | rstyle = DEFAULT_RSTYLE; |
214 | rstyle = DEFAULT_RSTYLE; |
219 | screen.flags = Screen_DefaultFlags; |
215 | screen.flags = Screen_DefaultFlags; |
… | |
… | |
243 | { |
239 | { |
244 | /* |
240 | /* |
245 | * add or delete rows as appropriate |
241 | * add or delete rows as appropriate |
246 | */ |
242 | */ |
247 | |
243 | |
248 | rxvt_salloc *old_ta; |
244 | printf ("resize %d:%d => %d:%d\n", prev_nrow, prev_ncol, nrow, ncol);//D |
249 | rxvt_salloc *old_ra; |
|
|
250 | |
245 | |
|
|
246 | rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
247 | rxvt_salloc *old_ra = ralloc; ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
248 | |
|
|
249 | #if 0 |
251 | if (nrow < prev_nrow) |
250 | if (nrow < prev_nrow) |
252 | { |
251 | { |
253 | /* delete rows */ |
|
|
254 | k = min (nsaved, prev_nrow - nrow); |
|
|
255 | // k = max (0, - ( (nrow - 1) - r->screen.cur.row)); // mmc's http://maruska.dyndns.org/wiki/scrolling-bug //make configurable? //D TODO |
|
|
256 | scr_scroll_text (0, (int)prev_nrow - 1, k); |
|
|
257 | |
|
|
258 | for (p = nrow; p < prev_nrow; p++) |
252 | for (int row = nrow; row < prev_nrow; row++) |
259 | { |
253 | { |
260 | lfree (ROW(p)); |
|
|
261 | lfree (swap_save[p]); |
254 | lfree (swap_buf [row]); |
262 | lfree (drawn[p]); |
255 | lfree (drawn_buf[row]); |
263 | } |
256 | } |
|
|
257 | } |
|
|
258 | #endif |
264 | |
259 | |
265 | /* we have fewer rows so fix up cursor position */ |
260 | drawn_buf = (line_t *) rxvt_realloc (drawn_buf, nrow * sizeof (line_t)); |
266 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
261 | temp_buf = (line_t *) rxvt_realloc (temp_buf , nrow * sizeof (line_t)); |
|
|
262 | swap_buf = (line_t *) rxvt_realloc (swap_buf , nrow * sizeof (line_t)); |
267 | |
263 | |
268 | scr_reset_realloc (); /* realloc _last_ */ |
264 | for (int row = min (nrow, prev_nrow); row--; ) |
|
|
265 | { |
|
|
266 | lresize (drawn_buf[row]); |
|
|
267 | lresize (swap_buf [row]); |
|
|
268 | } |
|
|
269 | |
|
|
270 | for (int row = prev_nrow; row < nrow; row++) |
|
|
271 | { |
|
|
272 | swap_buf [row].clear (); scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
|
|
273 | drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
|
|
274 | } |
|
|
275 | |
|
|
276 | line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
269 | } |
277 | |
270 | else if (nrow > prev_nrow) |
|
|
271 | { |
|
|
272 | /* add rows */ |
|
|
273 | scr_reset_realloc (); /* realloc _first_ */ |
|
|
274 | |
|
|
275 | int ocol = ncol; |
|
|
276 | ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
|
|
277 | |
|
|
278 | k = min (nsaved, nrow - prev_nrow); |
|
|
279 | |
|
|
280 | for (p = prev_total_rows; p < total_rows; p++) |
|
|
281 | save[p].clear (); |
|
|
282 | |
|
|
283 | for (p = prev_total_rows; p < total_rows - k; p++) |
|
|
284 | scr_blank_screen_mem (save[p], DEFAULT_RSTYLE); |
|
|
285 | |
|
|
286 | for (p = prev_nrow; p < nrow; p++) |
|
|
287 | { |
|
|
288 | swap_save[p].clear (); scr_blank_screen_mem (swap_save[p], DEFAULT_RSTYLE); |
|
|
289 | drawn[p].clear (); scr_blank_screen_mem (drawn[p], DEFAULT_RSTYLE); |
|
|
290 | } |
|
|
291 | |
|
|
292 | if (k > 0) |
|
|
293 | { |
|
|
294 | scr_scroll_text (0, (int)nrow - 1, -k); |
|
|
295 | screen.cur.row += k; |
|
|
296 | screen.s_cur.row += k; |
|
|
297 | nsaved -= k; |
|
|
298 | } |
|
|
299 | |
|
|
300 | #ifdef DEBUG_STRICT |
|
|
301 | assert (screen.cur.row < nrow); |
|
|
302 | #else /* drive with your eyes closed */ |
|
|
303 | MIN_IT (screen.cur.row, nrow - 1); |
|
|
304 | #endif |
|
|
305 | ncol = ocol; // save b/c scr_blank_screen_mem uses this |
|
|
306 | } |
|
|
307 | |
|
|
308 | /* resize columns */ |
|
|
309 | if (ncol != prev_ncol) |
|
|
310 | { |
|
|
311 | old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
312 | old_ra = ralloc; ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
313 | |
|
|
314 | for (p = total_rows; p--; ) |
|
|
315 | lresize (save[p]); |
|
|
316 | |
|
|
317 | for (p = nrow; p--; ) |
|
|
318 | { |
|
|
319 | lresize (drawn[p]); |
|
|
320 | lresize (swap_save[p]); |
|
|
321 | } |
|
|
322 | |
|
|
323 | MIN_IT (screen.cur.col, (int16_t)ncol - 1); |
|
|
324 | |
|
|
325 | delete old_ta; |
|
|
326 | delete old_ra; |
|
|
327 | } |
|
|
328 | |
|
|
329 | #if 0 |
|
|
330 | // re-wrap lines, this is rather ugly, possibly because I am too dumb |
278 | // re-wrap lines, this is rather ugly, possibly because I am too dumb |
331 | // to come up with a lean and mean algorithm. |
279 | // to come up with a lean and mean algorithm. |
332 | rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t)); |
|
|
333 | rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t)); |
|
|
334 | |
|
|
335 | text_t **tp = (text_t **)rxvt_calloc (total_rows, sizeof (text_t *)); |
|
|
336 | rend_t **rp = (rend_t **)rxvt_calloc (total_rows, sizeof (rend_t *)); |
|
|
337 | tlen_t *tl = (tlen_t *) rxvt_calloc (total_rows, sizeof (tlen_t)); |
|
|
338 | |
280 | |
339 | for (p = 0; p < prev_total_rows; p++) printf ("P %p %d\n", save[p].t, save[p].l);//D |
281 | int p = MOD (term_start + nrow , prev_total_rows); // previous row |
|
|
282 | int pend = MOD (term_start - nsaved, prev_total_rows); |
|
|
283 | int q = total_rows; // rewrapped row |
340 | |
284 | |
341 | p = prev_total_rows; |
|
|
342 | q = total_rows; |
|
|
343 | |
|
|
344 | while (p > 0 && q > 0) |
285 | while (p != pend && q > 0) |
345 | { |
286 | { |
346 | --p; |
287 | p = MOD (p - 1, prev_total_rows); |
347 | |
288 | |
348 | printf ("pq %d:%d\n", p, q); |
289 | assert (old_buf [MOD (p, prev_total_rows)].t); |
349 | if (save[p].t) |
290 | assert (!old_buf [MOD (p, prev_total_rows)].is_longer ()); |
|
|
291 | |
|
|
292 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
|
|
293 | |
|
|
294 | while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) |
350 | { |
295 | { |
351 | int llen = save[p].l; |
296 | p = MOD (p - 1, prev_total_rows); |
352 | |
297 | |
353 | assert (llen >= 0); |
298 | llen += prev_ncol; |
|
|
299 | } |
354 | |
300 | |
355 | while (p && save[p - 1].l < 0) |
301 | int qlines = llen / ncol + 1; |
|
|
302 | int lofs = 0; |
|
|
303 | |
|
|
304 | q -= qlines; |
|
|
305 | |
|
|
306 | int qrow = q; |
|
|
307 | |
|
|
308 | for (; qlines--; qrow++) |
|
|
309 | { |
|
|
310 | if (qrow >= 0) |
356 | { |
311 | { |
|
|
312 | line_t &qline = row_buf [qrow]; |
|
|
313 | |
|
|
314 | lalloc (qline); |
|
|
315 | qline.set_is_longer (); |
|
|
316 | |
|
|
317 | int qcol = 0; |
|
|
318 | |
|
|
319 | for (;;) |
357 | --p; |
320 | { |
358 | llen += prev_ncol; |
321 | int prow = lofs / prev_ncol + p; |
|
|
322 | int pcol = lofs % prev_ncol; |
|
|
323 | |
|
|
324 | line_t &pline = old_buf [p]; |
|
|
325 | |
|
|
326 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
|
|
327 | |
|
|
328 | printf ("q %d lofs %d>%d len %d pq %d:%d p %d:%d q :%d\n", q, llen, lofs, len, prev_ncol, ncol, prow, pcol, qcol); |
|
|
329 | |
|
|
330 | if (len <= 0) |
|
|
331 | { |
|
|
332 | qline.l = qcol; |
|
|
333 | scr_blank_line (qline, qcol, ncol - qcol, DEFAULT_RSTYLE); |
|
|
334 | break; |
|
|
335 | } |
|
|
336 | |
|
|
337 | assert (lofs < 1000); |
|
|
338 | |
|
|
339 | memcpy (qline.t + qcol, pline.t + pcol, len * sizeof (text_t)); |
|
|
340 | memcpy (qline.r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
|
|
341 | |
|
|
342 | lofs += len; |
|
|
343 | qcol += len; |
|
|
344 | |
|
|
345 | if (qcol == ncol) |
|
|
346 | break; |
|
|
347 | } |
359 | } |
348 | } |
360 | |
|
|
361 | int qlines = llen / ncol + 1; |
|
|
362 | int lofs = 0; |
|
|
363 | |
|
|
364 | q -= qlines; |
|
|
365 | |
|
|
366 | int qrow = q; |
|
|
367 | |
|
|
368 | printf ("QL %d llen %d\n", qlines, llen);//D |
|
|
369 | for (; qlines--; qrow++) |
|
|
370 | { |
|
|
371 | if (qrow >= 0) |
|
|
372 | { |
|
|
373 | tp [qrow] = (text_t *)ta->alloc (); |
|
|
374 | rp [qrow] = (rend_t *)ra->alloc (); |
|
|
375 | tl [qrow] = LINE_CONT1; |
|
|
376 | |
|
|
377 | int qcol = 0; |
|
|
378 | |
|
|
379 | for (;;) |
|
|
380 | { |
|
|
381 | int prow = lofs / prev_ncol + p; |
|
|
382 | int pcol = lofs % prev_ncol; |
|
|
383 | |
|
|
384 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
|
|
385 | |
|
|
386 | printf ("q %d lofs %d>%d len %d pq %d:%d p %d:%d q :%d\n", q, llen, lofs, len, prev_ncol, ncol, prow, pcol, qcol); |
|
|
387 | |
|
|
388 | if (len <= 0) |
|
|
389 | { |
|
|
390 | tl [qrow] = qcol; |
|
|
391 | |
|
|
392 | TODO |
|
|
393 | scr_blank_line (tp [qrow] + qcol, rp [qrow] + qcol, |
|
|
394 | ncol - qcol, DEFAULT_RSTYLE); |
|
|
395 | |
|
|
396 | break; |
|
|
397 | } |
|
|
398 | |
|
|
399 | assert (lofs < 1000); |
|
|
400 | |
|
|
401 | memcpy (tp [qrow] + qcol, save[prow].t + pcol, len * sizeof (text_t)); |
|
|
402 | memcpy (rp [qrow] + qcol, save[prow].r + pcol, len * sizeof (rend_t)); |
|
|
403 | |
|
|
404 | lofs += len; |
|
|
405 | qcol += len; |
|
|
406 | |
|
|
407 | if (qcol == ncol) |
|
|
408 | break; |
|
|
409 | } |
|
|
410 | } |
|
|
411 | else |
349 | else |
412 | lofs += ncol; |
350 | lofs += ncol; |
413 | } |
|
|
414 | } |
351 | } |
415 | } |
352 | } |
416 | |
353 | |
417 | free (screen.text); screen.text = tp; |
354 | free (old_buf); |
418 | free (screen.rend); screen.rend = rp; |
355 | delete old_ta; |
419 | free (screen.tlen); screen.tlen = tl; |
356 | delete old_ra; |
420 | |
357 | |
421 | for (p = 0; p < total_rows; p++) printf ("P %p %d\n", save[p].t, save[p].l);//D |
358 | min_it (screen.cur.row, nrow - 1); |
422 | #endif |
359 | min_it (screen.cur.col, ncol - 1); |
423 | |
360 | |
424 | if (tabs) |
361 | if (tabs) |
425 | free (tabs); |
362 | free (tabs); |
426 | } |
363 | } |
427 | |
364 | |
428 | prev_nrow = nrow; |
365 | prev_nrow = nrow; |
429 | prev_ncol = ncol; |
366 | prev_ncol = ncol; |
430 | |
367 | |
431 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
368 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
432 | |
369 | |
433 | for (p = 0; p < ncol; p++) |
370 | for (int col = ncol; col--; ) |
434 | tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
371 | tabs [col] = col % TABSIZE == 0; |
435 | |
372 | |
436 | tt_winch (); |
373 | tt_winch (); |
437 | } |
|
|
438 | |
|
|
439 | void |
|
|
440 | rxvt_term::scr_reset_realloc () |
|
|
441 | { |
|
|
442 | swap_save = (line_t *) rxvt_realloc (swap_save , nrow * sizeof (line_t)); |
|
|
443 | drawn = (line_t *) rxvt_realloc (drawn , nrow * sizeof (line_t)); |
|
|
444 | buf = (line_t *) rxvt_realloc (buf , nrow * sizeof (line_t)); |
|
|
445 | save = (line_t *) rxvt_realloc (save , total_rows * sizeof (line_t)); |
|
|
446 | } |
374 | } |
447 | |
375 | |
448 | /* ------------------------------------------------------------------------- */ |
376 | /* ------------------------------------------------------------------------- */ |
449 | /* |
377 | /* |
450 | * Free everything. That way malloc debugging can find leakage. |
378 | * Free everything. That way malloc debugging can find leakage. |
… | |
… | |
453 | rxvt_term::scr_release () |
381 | rxvt_term::scr_release () |
454 | { |
382 | { |
455 | delete talloc; talloc = 0; |
383 | delete talloc; talloc = 0; |
456 | delete ralloc; ralloc = 0; |
384 | delete ralloc; ralloc = 0; |
457 | |
385 | |
458 | free (save); |
386 | free (row_buf); |
459 | free (swap_save); |
387 | free (swap_buf); |
460 | free (drawn); |
388 | free (drawn_buf); |
461 | free (buf); |
389 | free (temp_buf); |
462 | free (tabs); |
390 | free (tabs); |
463 | } |
391 | } |
464 | |
392 | |
465 | /* ------------------------------------------------------------------------- */ |
393 | /* ------------------------------------------------------------------------- */ |
466 | /* |
394 | /* |
… | |
… | |
518 | set_font_style (); |
446 | set_font_style (); |
519 | break; |
447 | break; |
520 | } |
448 | } |
521 | |
449 | |
522 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
450 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
523 | MIN_IT (s->cur.row, nrow - 1); |
451 | min_it (s->cur.row, nrow - 1); |
524 | MIN_IT (s->cur.col, ncol - 1); |
452 | min_it (s->cur.col, ncol - 1); |
525 | #ifdef DEBUG_STRICT |
453 | #ifdef DEBUG_STRICT |
526 | assert (s->cur.row >= 0); |
454 | assert (s->cur.row >= 0); |
527 | assert (s->cur.col >= 0); |
455 | assert (s->cur.col >= 0); |
528 | #else /* drive with your eyes closed */ |
456 | #else /* drive with your eyes closed */ |
529 | MAX_IT (s->cur.row, 0); |
457 | max_it (s->cur.row, 0); |
530 | MAX_IT (s->cur.col, 0); |
458 | max_it (s->cur.col, 0); |
531 | #endif |
459 | #endif |
532 | } |
460 | } |
533 | |
461 | |
534 | /* ------------------------------------------------------------------------- */ |
462 | /* ------------------------------------------------------------------------- */ |
535 | /* |
463 | /* |
… | |
… | |
546 | if (current_screen == scrn) |
474 | if (current_screen == scrn) |
547 | return scrn; |
475 | return scrn; |
548 | |
476 | |
549 | selection_check (2); /* check for boundary cross */ |
477 | selection_check (2); /* check for boundary cross */ |
550 | |
478 | |
551 | SWAP_IT (scrn, current_screen, int); |
479 | int i = current_screen; current_screen = scrn; scrn = i; |
552 | |
480 | |
553 | SWAP_IT (screen.cur.row, swap.cur.row, int16_t); |
481 | ::swap (screen.cur.row, swap.cur.row); |
554 | SWAP_IT (screen.cur.col, swap.cur.col, int16_t); |
482 | ::swap (screen.cur.col, swap.cur.col); |
555 | MAX_IT (screen.cur.row, 0); |
483 | |
556 | MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); |
484 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
557 | MAX_IT (screen.cur.col, 0); |
485 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
558 | MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); |
|
|
559 | |
486 | |
560 | #if NSCREENS |
487 | #if NSCREENS |
561 | if (options & Opt_secondaryScreen) |
488 | if (options & Opt_secondaryScreen) |
562 | { |
489 | { |
563 | num_scr = 0; |
490 | num_scr = 0; |
564 | |
491 | |
565 | for (int i = nrow; i--; ) |
492 | for (int i = nrow; i--; ) |
566 | SWAP_IT (ROW(i), swap_save[i], line_t); |
493 | ::swap (ROW(i), swap_buf [i]); |
567 | |
494 | |
568 | SWAP_IT (screen.charset, swap.charset, int16_t); |
495 | ::swap (screen.charset, swap.charset); |
569 | SWAP_IT (screen.flags, swap.flags, int); |
496 | ::swap (screen.flags, swap.flags); |
570 | screen.flags |= Screen_VisibleCursor; |
497 | screen.flags |= Screen_VisibleCursor; |
571 | swap.flags |= Screen_VisibleCursor; |
498 | swap.flags |= Screen_VisibleCursor; |
572 | } |
499 | } |
573 | else |
500 | else |
574 | #endif |
501 | #endif |
… | |
… | |
639 | return 0; |
566 | return 0; |
640 | |
567 | |
641 | want_refresh = 1; |
568 | want_refresh = 1; |
642 | num_scr += count; |
569 | num_scr += count; |
643 | |
570 | |
644 | if (row1 == 0 && count > 0 |
571 | if (count > 0 |
|
|
572 | && row1 == 0 |
|
|
573 | && row2 == nrow - 1 |
645 | && (current_screen == PRIMARY || options & Opt_secondaryScroll)) |
574 | && (current_screen == PRIMARY || options & Opt_secondaryScroll)) |
646 | { |
575 | { |
647 | nsaved = min (nsaved + count, saveLines); |
576 | nsaved = min (nsaved + count, saveLines); |
648 | term_start = (term_start + count) % total_rows; |
577 | term_start = (term_start + count) % total_rows; |
649 | |
578 | |
… | |
… | |
695 | // use a simple and robust scrolling algorithm, this |
624 | // use a simple and robust scrolling algorithm, this |
696 | // part of scr_scroll_text is not time-critical. |
625 | // part of scr_scroll_text is not time-critical. |
697 | |
626 | |
698 | int rows = row2 - row1 + 1; |
627 | int rows = row2 - row1 + 1; |
699 | |
628 | |
|
|
629 | min_it (count, rows); |
|
|
630 | |
700 | for (int row = 0; row < rows; row++) |
631 | for (int row = 0; row < rows; row++) |
701 | { |
632 | { |
702 | buf [row] = ROW(row1 + (row + count + rows) % rows); |
633 | temp_buf [row] = ROW(row1 + (row + count + rows) % rows); |
703 | |
634 | |
704 | if (!IN_RANGE_EXC (row + count, 0, rows)) |
635 | if (!IN_RANGE_EXC (row + count, 0, rows)) |
705 | scr_blank_screen_mem (buf [row], rstyle); |
636 | scr_blank_screen_mem (temp_buf [row], rstyle); |
706 | } |
637 | } |
707 | |
638 | |
708 | for (int row = 0; row < rows; row++) |
639 | for (int row = 0; row < rows; row++) |
709 | ROW(row1 + row) = buf [row]; |
640 | ROW(row1 + row) = temp_buf [row]; |
710 | } |
641 | } |
711 | |
642 | |
712 | return count; |
643 | return count; |
713 | } |
644 | } |
714 | |
645 | |
… | |
… | |
732 | last_col = ncol; |
663 | last_col = ncol; |
733 | |
664 | |
734 | if (nlines > 0) |
665 | if (nlines > 0) |
735 | { |
666 | { |
736 | nlines += screen.cur.row - screen.bscroll; |
667 | nlines += screen.cur.row - screen.bscroll; |
737 | if ((nlines > 0) |
668 | if (nlines > 0 |
738 | && (screen.tscroll == 0) |
669 | && screen.tscroll == 0 |
739 | && (screen.bscroll == (nrow - 1))) |
670 | && screen.bscroll == (nrow - 1)) |
740 | { |
671 | { |
741 | /* _at least_ this many lines need to be scrolled */ |
672 | /* _at least_ this many lines need to be scrolled */ |
742 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines); |
673 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines); |
743 | screen.cur.row -= nlines; |
674 | screen.cur.row -= nlines; |
744 | } |
675 | } |
745 | } |
676 | } |
746 | |
677 | |
747 | #ifdef DEBUG_STRICT |
678 | #ifdef DEBUG_STRICT |
748 | assert (screen.cur.col < last_col); |
679 | assert (screen.cur.col < last_col); |
749 | assert ((screen.cur.row < nrow) |
680 | assert (screen.cur.row < nrow |
750 | && (screen.cur.row >= - (int32_t)nsaved)); |
681 | && screen.cur.row >= -nsaved); |
751 | #else /* drive with your eyes closed */ |
682 | #else /* drive with your eyes closed */ |
752 | MIN_IT (screen.cur.col, last_col - 1); |
683 | min_it (screen.cur.col, last_col - 1); |
753 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
684 | clamp_it (screen.cur.row, -nsaved, nrow - 1); |
754 | MAX_IT (screen.cur.row, - (int32_t)nsaved); |
|
|
755 | #endif |
685 | #endif |
756 | row = screen.cur.row; |
686 | row = screen.cur.row; |
757 | |
687 | |
758 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
688 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
759 | |
689 | |
… | |
… | |
765 | |
695 | |
766 | if (c < 0x20) |
696 | if (c < 0x20) |
767 | if (c == C0_LF) |
697 | if (c == C0_LF) |
768 | { |
698 | { |
769 | if (!line->is_longer ()) /* XXX: think about this */ |
699 | if (!line->is_longer ()) /* XXX: think about this */ |
770 | MAX_IT (line->l, screen.cur.col); |
700 | max_it (line->l, screen.cur.col); |
771 | |
701 | |
772 | screen.flags &= ~Screen_WrapNext; |
702 | screen.flags &= ~Screen_WrapNext; |
773 | |
703 | |
774 | if (screen.cur.row == screen.bscroll) |
704 | if (screen.cur.row == screen.bscroll) |
775 | scr_scroll_text (screen.tscroll, screen.bscroll, 1); |
705 | scr_scroll_text (screen.tscroll, screen.bscroll, 1); |
… | |
… | |
780 | continue; |
710 | continue; |
781 | } |
711 | } |
782 | else if (c == C0_CR) |
712 | else if (c == C0_CR) |
783 | { |
713 | { |
784 | if (!line->is_longer ()) /* XXX: think about this */ |
714 | if (!line->is_longer ()) /* XXX: think about this */ |
785 | MAX_IT (line->l, screen.cur.col); |
715 | max_it (line->l, screen.cur.col); |
786 | |
716 | |
787 | screen.flags &= ~Screen_WrapNext; |
717 | screen.flags &= ~Screen_WrapNext; |
788 | screen.cur.col = 0; |
718 | screen.cur.col = 0; |
789 | continue; |
719 | continue; |
790 | } |
720 | } |
… | |
… | |
966 | #endif |
896 | #endif |
967 | } |
897 | } |
968 | } |
898 | } |
969 | |
899 | |
970 | if (!line->is_longer ()) /* XXX: think about this */ |
900 | if (!line->is_longer ()) /* XXX: think about this */ |
971 | MAX_IT (line->l, screen.cur.col); |
901 | max_it (line->l, screen.cur.col); |
972 | |
902 | |
973 | #ifdef DEBUG_STRICT |
903 | #ifdef DEBUG_STRICT |
974 | assert (screen.cur.row >= 0); |
904 | assert (screen.cur.row >= 0); |
975 | #else /* drive with your eyes closed */ |
905 | #else /* drive with your eyes closed */ |
976 | MAX_IT (screen.cur.row, 0); |
906 | max_it (screen.cur.row, 0); |
977 | #endif |
907 | #endif |
978 | } |
908 | } |
979 | |
909 | |
980 | /* ------------------------------------------------------------------------- */ |
910 | /* ------------------------------------------------------------------------- */ |
981 | /* |
911 | /* |
… | |
… | |
1047 | if (ht && options & Opt_pastableTabs) |
977 | if (ht && options & Opt_pastableTabs) |
1048 | { |
978 | { |
1049 | base_rend = SET_FONT (base_rend, 0); |
979 | base_rend = SET_FONT (base_rend, 0); |
1050 | |
980 | |
1051 | if (!l.is_longer ()) /* XXX: think about this */ |
981 | if (!l.is_longer ()) /* XXX: think about this */ |
1052 | MAX_IT (l.l, x); |
982 | max_it (l.l, x); |
1053 | |
983 | |
1054 | i = screen.cur.col; |
984 | i = screen.cur.col; |
1055 | |
985 | |
1056 | l.t[i] = '\t'; |
986 | l.t[i] = '\t'; |
1057 | l.r[i] = base_rend; |
987 | l.r[i] = base_rend; |
… | |
… | |
1136 | { |
1066 | { |
1137 | want_refresh = 1; |
1067 | want_refresh = 1; |
1138 | ZERO_SCROLLBACK (); |
1068 | ZERO_SCROLLBACK (); |
1139 | |
1069 | |
1140 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1070 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1141 | MAX_IT (screen.cur.col, 0); |
1071 | clamp_it (screen.cur.col, 0, ncol - 1); |
1142 | MIN_IT (screen.cur.col, (int32_t)ncol - 1); |
|
|
1143 | |
1072 | |
1144 | screen.flags &= ~Screen_WrapNext; |
1073 | screen.flags &= ~Screen_WrapNext; |
1145 | |
1074 | |
1146 | if (relative & R_RELATIVE) |
1075 | if (relative & R_RELATIVE) |
1147 | { |
1076 | { |
… | |
… | |
1165 | else |
1094 | else |
1166 | { |
1095 | { |
1167 | if (screen.flags & Screen_Relative) |
1096 | if (screen.flags & Screen_Relative) |
1168 | { /* relative origin mode */ |
1097 | { /* relative origin mode */ |
1169 | screen.cur.row = row + screen.tscroll; |
1098 | screen.cur.row = row + screen.tscroll; |
1170 | MIN_IT (screen.cur.row, screen.bscroll); |
1099 | min_it (screen.cur.row, screen.bscroll); |
1171 | } |
1100 | } |
1172 | else |
1101 | else |
1173 | screen.cur.row = row; |
1102 | screen.cur.row = row; |
1174 | } |
1103 | } |
1175 | |
1104 | |
1176 | MAX_IT (screen.cur.row, 0); |
1105 | clamp_it (screen.cur.row, 0, nrow - 1); |
1177 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
|
|
1178 | } |
1106 | } |
1179 | |
1107 | |
1180 | /* ------------------------------------------------------------------------- */ |
1108 | /* ------------------------------------------------------------------------- */ |
1181 | /* |
1109 | /* |
1182 | * direction should be UP or DN |
1110 | * direction should be UP or DN |
… | |
… | |
1197 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1125 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1198 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn); |
1126 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn); |
1199 | else |
1127 | else |
1200 | screen.cur.row += dirn; |
1128 | screen.cur.row += dirn; |
1201 | |
1129 | |
1202 | MAX_IT (screen.cur.row, 0); |
1130 | clamp_it (screen.cur.row, 0, nrow - 1); |
1203 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
|
|
1204 | selection_check (0); |
1131 | selection_check (0); |
1205 | } |
1132 | } |
1206 | |
1133 | |
1207 | /* ------------------------------------------------------------------------- */ |
1134 | /* ------------------------------------------------------------------------- */ |
1208 | /* |
1135 | /* |
… | |
… | |
1226 | switch (mode) |
1153 | switch (mode) |
1227 | { |
1154 | { |
1228 | case 0: /* erase to end of line */ |
1155 | case 0: /* erase to end of line */ |
1229 | col = screen.cur.col; |
1156 | col = screen.cur.col; |
1230 | num = ncol - col; |
1157 | num = ncol - col; |
1231 | MIN_IT (ROW(row).l, (int16_t)col); |
1158 | min_it (ROW(row).l, col); |
1232 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1159 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1233 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1160 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1234 | CLEAR_SELECTION (); |
1161 | CLEAR_SELECTION (); |
1235 | break; |
1162 | break; |
1236 | case 1: /* erase to beginning of line */ |
1163 | case 1: /* erase to beginning of line */ |
… | |
… | |
1303 | CLEAR_SELECTION (); |
1230 | CLEAR_SELECTION (); |
1304 | |
1231 | |
1305 | if (row >= nrow) /* Out Of Bounds */ |
1232 | if (row >= nrow) /* Out Of Bounds */ |
1306 | return; |
1233 | return; |
1307 | |
1234 | |
1308 | MIN_IT (num, (nrow - row)); |
1235 | min_it (num, nrow - row); |
1309 | |
1236 | |
1310 | if (rstyle & (RS_RVid | RS_Uline)) |
1237 | if (rstyle & (RS_RVid | RS_Uline)) |
1311 | ren = (rend_t) ~RS_None; |
1238 | ren = (rend_t) ~RS_None; |
1312 | else if (GET_BASEBG (rstyle) == Color_bg) |
1239 | else if (GET_BASEBG (rstyle) == Color_bg) |
1313 | { |
1240 | { |
… | |
… | |
1326 | |
1253 | |
1327 | for (; num--; row++) |
1254 | for (; num--; row++) |
1328 | { |
1255 | { |
1329 | scr_blank_screen_mem (ROW (row), rstyle); |
1256 | scr_blank_screen_mem (ROW (row), rstyle); |
1330 | ROW (row).l = 0; |
1257 | ROW (row).l = 0; |
1331 | scr_blank_line (drawn[row], 0, ncol, ren); |
1258 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1332 | } |
1259 | } |
1333 | } |
1260 | } |
1334 | |
1261 | |
1335 | #if ENABLE_FRILLS |
1262 | #if ENABLE_FRILLS |
1336 | void |
1263 | void |
… | |
… | |
1421 | return; |
1348 | return; |
1422 | |
1349 | |
1423 | scr_do_wrap (); |
1350 | scr_do_wrap (); |
1424 | |
1351 | |
1425 | selection_check (1); |
1352 | selection_check (1); |
1426 | MIN_IT (count, (ncol - screen.cur.col)); |
1353 | min_it (count, ncol - screen.cur.col); |
1427 | |
1354 | |
1428 | row = screen.cur.row; |
1355 | row = screen.cur.row; |
1429 | |
1356 | |
1430 | line_t *line = &ROW(row); |
1357 | line_t *line = &ROW(row); |
1431 | |
1358 | |
… | |
… | |
1439 | } |
1366 | } |
1440 | |
1367 | |
1441 | if (!line->is_longer ()) |
1368 | if (!line->is_longer ()) |
1442 | { |
1369 | { |
1443 | line->l += count; |
1370 | line->l += count; |
1444 | MIN_IT (line->l, ncol); |
1371 | min_it (line->l, ncol); |
1445 | } |
1372 | } |
1446 | |
1373 | |
1447 | if (selection.op && current_screen == selection.screen |
1374 | if (selection.op && current_screen == selection.screen |
1448 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1375 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1449 | { |
1376 | { |
… | |
… | |
1510 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1437 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1511 | */ |
1438 | */ |
1512 | void |
1439 | void |
1513 | rxvt_term::scr_scroll_region (int top, int bot) |
1440 | rxvt_term::scr_scroll_region (int top, int bot) |
1514 | { |
1441 | { |
1515 | MAX_IT (top, 0); |
1442 | max_it (top, 0); |
1516 | MIN_IT (bot, (int)nrow - 1); |
1443 | min_it (bot, nrow - 1); |
1517 | |
1444 | |
1518 | if (top > bot) |
1445 | if (top > bot) |
1519 | return; |
1446 | return; |
1520 | |
1447 | |
1521 | screen.tscroll = top; |
1448 | screen.tscroll = top; |
… | |
… | |
1619 | XGCValues gcvalue; |
1546 | XGCValues gcvalue; |
1620 | |
1547 | |
1621 | if (rvideo != mode) |
1548 | if (rvideo != mode) |
1622 | { |
1549 | { |
1623 | rvideo = mode; |
1550 | rvideo = mode; |
1624 | SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); |
1551 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1625 | #if XPM_BACKGROUND |
1552 | #if XPM_BACKGROUND |
1626 | if (bgPixmap.pixmap == None) |
1553 | if (bgPixmap.pixmap == None) |
1627 | #endif |
1554 | #endif |
1628 | #if TRANSPARENT |
1555 | #if TRANSPARENT |
1629 | if (! (options & Opt_transparent) || am_transparent == 0) |
1556 | if (! (options & Opt_transparent) || am_transparent == 0) |
… | |
… | |
1725 | bool found = false; |
1652 | bool found = false; |
1726 | |
1653 | |
1727 | for (int i = 0; i < nrow; i++) |
1654 | for (int i = 0; i < nrow; i++) |
1728 | { |
1655 | { |
1729 | int col = 0; |
1656 | int col = 0; |
1730 | rend_t *drp = drawn[i].r; |
1657 | rend_t *drp = drawn_buf[i].r; |
1731 | |
1658 | |
1732 | for (; col < ncol; col++, drp++) |
1659 | for (; col < ncol; col++, drp++) |
1733 | if ((*drp & mask) == value) |
1660 | if ((*drp & mask) == value) |
1734 | { |
1661 | { |
1735 | found = true; |
1662 | found = true; |
… | |
… | |
1753 | rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) |
1680 | rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) |
1754 | { |
1681 | { |
1755 | int i; |
1682 | int i; |
1756 | row_col_t rc[RC_COUNT]; |
1683 | row_col_t rc[RC_COUNT]; |
1757 | |
1684 | |
1758 | if (!drawn) /* sanity check */ |
1685 | if (!drawn_buf) /* sanity check */ |
1759 | return; |
1686 | return; |
1760 | |
1687 | |
1761 | #ifndef NO_SLOW_LINK_SUPPORT |
1688 | #ifndef NO_SLOW_LINK_SUPPORT |
1762 | if (refresh_type == FAST_REFRESH && !display->is_local) |
1689 | if (refresh_type == FAST_REFRESH && !display->is_local) |
1763 | { |
1690 | { |
… | |
… | |
1765 | eheight = height; |
1692 | eheight = height; |
1766 | } |
1693 | } |
1767 | #endif |
1694 | #endif |
1768 | |
1695 | |
1769 | #ifdef DEBUG_STRICT |
1696 | #ifdef DEBUG_STRICT |
1770 | x = max (x, 0); |
1697 | #if 0 |
1771 | x = min (x, (int)width); |
1698 | // that's not debugging //TODO //FIXME |
1772 | y = max (y, 0); |
1699 | clamp_it (x, 0, width); |
1773 | y = min (y, (int)height); |
1700 | clamp_it (y, 0, height); |
|
|
1701 | #endif |
1774 | #endif |
1702 | #endif |
1775 | |
1703 | |
1776 | /* round down */ |
1704 | /* round down */ |
1777 | rc[PART_BEG].col = Pixel2Col (x); |
1705 | rc[PART_BEG].col = Pixel2Col (x); |
1778 | rc[PART_BEG].row = Pixel2Row (y); |
1706 | rc[PART_BEG].row = Pixel2Row (y); |
… | |
… | |
1781 | rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); |
1709 | rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); |
1782 | |
1710 | |
1783 | /* sanity checks */ |
1711 | /* sanity checks */ |
1784 | for (i = PART_BEG; i < RC_COUNT; i++) |
1712 | for (i = PART_BEG; i < RC_COUNT; i++) |
1785 | { |
1713 | { |
1786 | MIN_IT (rc[i].col, ncol - 1); |
1714 | min_it (rc[i].col, ncol - 1); |
1787 | MIN_IT (rc[i].row, nrow - 1); |
1715 | min_it (rc[i].row, nrow - 1); |
1788 | } |
1716 | } |
1789 | |
1717 | |
1790 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1718 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1791 | fill_text (&drawn[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1719 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1792 | |
1720 | |
1793 | if (refresh) |
1721 | if (refresh) |
1794 | scr_refresh (SLOW_REFRESH); |
1722 | scr_refresh (SLOW_REFRESH); |
1795 | } |
1723 | } |
1796 | |
1724 | |
… | |
… | |
1959 | { |
1887 | { |
1960 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1888 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1961 | showcursor; /* show the cursor */ |
1889 | showcursor; /* show the cursor */ |
1962 | int16_t col, row, /* column/row we're processing */ |
1890 | int16_t col, row, /* column/row we're processing */ |
1963 | ocrow; /* old cursor row */ |
1891 | ocrow; /* old cursor row */ |
1964 | int i, /* tmp */ |
1892 | int i; /* tmp */ |
1965 | row_offset; /* basic offset in screen structure */ |
|
|
1966 | #ifndef NO_CURSORCOLOR |
1893 | #ifndef NO_CURSORCOLOR |
1967 | rend_t cc1; /* store colours at cursor position (s) */ |
1894 | rend_t cc1; /* store colours at cursor position (s) */ |
1968 | #endif |
1895 | #endif |
1969 | rend_t *crp; // cursor rendition pointer |
1896 | rend_t *crp; // cursor rendition pointer |
1970 | |
1897 | |
… | |
… | |
1976 | /* |
1903 | /* |
1977 | * A: set up vars |
1904 | * A: set up vars |
1978 | */ |
1905 | */ |
1979 | must_clear = 0; |
1906 | must_clear = 0; |
1980 | refresh_count = 0; |
1907 | refresh_count = 0; |
1981 | |
|
|
1982 | row_offset = term_start - view_start; |
|
|
1983 | |
1908 | |
1984 | #if XPM_BACKGROUND |
1909 | #if XPM_BACKGROUND |
1985 | must_clear |= bgPixmap.pixmap != None; |
1910 | must_clear |= bgPixmap.pixmap != None; |
1986 | #endif |
1911 | #endif |
1987 | #if TRANSPARENT |
1912 | #if TRANSPARENT |
… | |
… | |
2057 | if (screen.cur.row + view_start != ocrow |
1982 | if (screen.cur.row + view_start != ocrow |
2058 | || screen.cur.col != oldcursor.col) |
1983 | || screen.cur.col != oldcursor.col) |
2059 | { |
1984 | { |
2060 | if (ocrow < nrow |
1985 | if (ocrow < nrow |
2061 | && oldcursor.col < ncol) |
1986 | && oldcursor.col < ncol) |
2062 | drawn[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
1987 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2063 | |
1988 | |
2064 | if (focus || !showcursor) |
1989 | if (focus || !showcursor) |
2065 | oldcursor.row = -1; |
1990 | oldcursor.row = -1; |
2066 | else |
1991 | else |
2067 | setoldcursor = 1; |
1992 | setoldcursor = 1; |
… | |
… | |
2105 | row = i > 0 ? 0 : j - 1; |
2030 | row = i > 0 ? 0 : j - 1; |
2106 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2031 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2107 | { |
2032 | { |
2108 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2033 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2109 | { |
2034 | { |
2110 | line_t s = save[(row + row_offset) % total_rows]; |
2035 | line_t s = ROW(row - view_start); |
2111 | line_t d = drawn[row]; |
2036 | line_t d = drawn_buf[row]; |
2112 | line_t d2 = drawn[row + i]; |
2037 | line_t d2 = drawn_buf[row + i]; |
2113 | |
2038 | |
2114 | for (nits = 0, col = ncol; col--; ) |
2039 | for (nits = 0, col = ncol; col--; ) |
2115 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
2040 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
2116 | nits--; |
2041 | nits--; |
2117 | else if (s.t[col] != d.t[col] || s.r[col] != d.r[col]) |
2042 | else if (s.t[col] != d.t[col] || s.r[col] != d.r[col]) |
… | |
… | |
2135 | |
2060 | |
2136 | if (len != -1) |
2061 | if (len != -1) |
2137 | { |
2062 | { |
2138 | /* also comes here at end if needed because of >= above */ |
2063 | /* also comes here at end if needed because of >= above */ |
2139 | if (wlen < len) |
2064 | if (wlen < len) |
2140 | SWAP_IT (wlen, len, int); |
2065 | ::swap (wlen, len); |
2141 | |
2066 | |
2142 | XCopyArea (display->display, vt, vt, |
2067 | XCopyArea (display->display, vt, vt, |
2143 | gc, 0, Row2Pixel (len + i), |
2068 | gc, 0, Row2Pixel (len + i), |
2144 | (unsigned int)TermWin_TotalWidth (), |
2069 | (unsigned int)TermWin_TotalWidth (), |
2145 | (unsigned int)Height2Pixel (wlen - len + 1), |
2070 | (unsigned int)Height2Pixel (wlen - len + 1), |
… | |
… | |
2153 | /* |
2078 | /* |
2154 | * E: main pass across every character |
2079 | * E: main pass across every character |
2155 | */ |
2080 | */ |
2156 | for (row = 0; row < nrow; row++) |
2081 | for (row = 0; row < nrow; row++) |
2157 | { |
2082 | { |
2158 | text_t *stp = save[(row + row_offset) % total_rows].t; |
2083 | text_t *stp = ROW(row - view_start).t; |
2159 | rend_t *srp = save[(row + row_offset) % total_rows].r; |
2084 | rend_t *srp = ROW(row - view_start).r; |
2160 | text_t *dtp = drawn[row].t; |
2085 | text_t *dtp = drawn_buf[row].t; |
2161 | rend_t *drp = drawn[row].r; |
2086 | rend_t *drp = drawn_buf[row].r; |
2162 | |
2087 | |
2163 | /* |
2088 | /* |
2164 | * E2: OK, now the real pass |
2089 | * E2: OK, now the real pass |
2165 | */ |
2090 | */ |
2166 | int ypixel = (int)Row2Pixel (row); |
2091 | int ypixel = (int)Row2Pixel (row); |
… | |
… | |
2277 | fore = Color_UL; |
2202 | fore = Color_UL; |
2278 | #endif |
2203 | #endif |
2279 | |
2204 | |
2280 | if (invert) |
2205 | if (invert) |
2281 | { |
2206 | { |
2282 | SWAP_IT (fore, back, int); |
2207 | ::swap (fore, back); |
2283 | |
2208 | |
2284 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2209 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2285 | if (ISSET_PIXCOLOR (Color_RV)) |
2210 | if (ISSET_PIXCOLOR (Color_RV)) |
2286 | back = Color_RV; |
2211 | back = Color_RV; |
2287 | |
2212 | |
… | |
… | |
2379 | |
2304 | |
2380 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2305 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2381 | col--; |
2306 | col--; |
2382 | |
2307 | |
2383 | while (col + cursorwidth < ncol |
2308 | while (col + cursorwidth < ncol |
2384 | && drawn[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2309 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2385 | cursorwidth++; |
2310 | cursorwidth++; |
2386 | |
2311 | |
2387 | #ifndef NO_CURSORCOLOR |
2312 | #ifndef NO_CURSORCOLOR |
2388 | if (ISSET_PIXCOLOR (Color_cursor)) |
2313 | if (ISSET_PIXCOLOR (Color_cursor)) |
2389 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
2314 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
… | |
… | |
2421 | |
2346 | |
2422 | void |
2347 | void |
2423 | rxvt_term::scr_remap_chars () |
2348 | rxvt_term::scr_remap_chars () |
2424 | { |
2349 | { |
2425 | for (int i = total_rows; i--; ) |
2350 | for (int i = total_rows; i--; ) |
2426 | scr_remap_chars (save[i]); |
2351 | scr_remap_chars (row_buf [i]); |
2427 | |
2352 | |
2428 | for (int i = nrow; i--; ) |
2353 | for (int i = nrow; i--; ) |
2429 | { |
2354 | { |
2430 | scr_remap_chars (drawn[i]); |
2355 | scr_remap_chars (drawn_buf [i]); |
2431 | scr_remap_chars (swap_save[i]); |
2356 | scr_remap_chars (swap_buf [i]); |
2432 | } |
2357 | } |
2433 | } |
2358 | } |
2434 | |
2359 | |
2435 | void |
2360 | void |
2436 | rxvt_term::scr_recolour () |
2361 | rxvt_term::scr_recolour () |
… | |
… | |
2533 | char r1[] = "\n"; |
2458 | char r1[] = "\n"; |
2534 | |
2459 | |
2535 | for (row = saveLines - nsaved; |
2460 | for (row = saveLines - nsaved; |
2536 | row < saveLines + nrow - 1; row++) |
2461 | row < saveLines + nrow - 1; row++) |
2537 | { |
2462 | { |
2538 | width = save[row].l >= 0 ? save[row].l |
2463 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2539 | : ncol; |
2464 | : ncol; |
2540 | for (towrite = width; towrite; towrite -= wrote) |
2465 | for (towrite = width; towrite; towrite -= wrote) |
2541 | { |
2466 | { |
2542 | wrote = write (fd, & (save[row].t[width - towrite]), |
2467 | wrote = write (fd, & (row_buf[row].t[width - towrite]), |
2543 | towrite); |
2468 | towrite); |
2544 | if (wrote < 0) |
2469 | if (wrote < 0) |
2545 | return; /* XXX: death, no report */ |
2470 | return; /* XXX: death, no report */ |
2546 | } |
2471 | } |
2547 | if (save[row].l >= 0) |
2472 | if (row_buf[row].l >= 0) |
2548 | if (write (fd, r1, 1) <= 0) |
2473 | if (write (fd, r1, 1) <= 0) |
2549 | return; /* XXX: death, no report */ |
2474 | return; /* XXX: death, no report */ |
2550 | } |
2475 | } |
2551 | } |
2476 | } |
2552 | #endif |
2477 | #endif |
… | |
… | |
3029 | want_refresh = 1; |
2954 | want_refresh = 1; |
3030 | |
2955 | |
3031 | selection.mark.row = row - view_start; |
2956 | selection.mark.row = row - view_start; |
3032 | selection.mark.col = col; |
2957 | selection.mark.col = col; |
3033 | |
2958 | |
3034 | selection.mark.row = min (max (selection.mark.row, -nsaved), nrow - 1); |
2959 | selection.mark.row = clamp (selection.mark.row, -nsaved, nrow - 1); |
3035 | selection.mark.col = min (max (selection.mark.col, 0), ncol - 1); |
2960 | selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); |
3036 | |
2961 | |
3037 | while (selection.mark.col > 0 |
2962 | while (selection.mark.col > 0 |
3038 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
2963 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3039 | --selection.mark.col; |
2964 | --selection.mark.col; |
3040 | |
2965 | |
… | |
… | |
3145 | * flag == 2 ==> button 3 motion |
3070 | * flag == 2 ==> button 3 motion |
3146 | */ |
3071 | */ |
3147 | void |
3072 | void |
3148 | rxvt_term::selection_extend (int x, int y, int flag) |
3073 | rxvt_term::selection_extend (int x, int y, int flag) |
3149 | { |
3074 | { |
3150 | int col = min (max (Pixel2Col (x), 0), nrow - 1); |
3075 | int col = clamp (Pixel2Col (x), 0, ncol); |
3151 | int row = min (max (Pixel2Row (y), 0), ncol); |
3076 | int row = clamp (Pixel2Row (y), 0, nrow - 1); |
3152 | |
3077 | |
3153 | /* |
3078 | /* |
3154 | * If we're selecting characters (single click) then we must check first |
3079 | * If we're selecting characters (single click) then we must check first |
3155 | * if we are at the same place as the original mark. If we are then |
3080 | * if we are at the same place as the original mark. If we are then |
3156 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
3081 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
… | |
… | |
3369 | } |
3294 | } |
3370 | } |
3295 | } |
3371 | |
3296 | |
3372 | #if ENABLE_FRILLS |
3297 | #if ENABLE_FRILLS |
3373 | if (selection.rect && selection.beg.col > selection.end.col) |
3298 | if (selection.rect && selection.beg.col > selection.end.col) |
3374 | SWAP_IT (selection.beg.col, selection.end.col, int); |
3299 | ::swap (selection.beg.col, selection.end.col); |
3375 | #endif |
3300 | #endif |
3376 | } |
3301 | } |
3377 | |
3302 | |
3378 | #if ENABLE_FRILLS |
3303 | #if ENABLE_FRILLS |
3379 | void |
3304 | void |
… | |
… | |
3577 | */ |
3502 | */ |
3578 | void |
3503 | void |
3579 | rxvt_term::pixel_position (int *x, int *y) |
3504 | rxvt_term::pixel_position (int *x, int *y) |
3580 | { |
3505 | { |
3581 | *x = Pixel2Col (*x); |
3506 | *x = Pixel2Col (*x); |
3582 | /* MAX_IT (*x, 0); MIN_IT (*x, (int)ncol - 1); */ |
3507 | /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ |
3583 | *y = Pixel2Row (*y); |
3508 | *y = Pixel2Row (*y); |
3584 | /* MAX_IT (*y, 0); MIN_IT (*y, (int)nrow - 1); */ |
3509 | /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ |
3585 | } |
3510 | } |
3586 | |
3511 | |
3587 | /* ------------------------------------------------------------------------- */ |
3512 | /* ------------------------------------------------------------------------- */ |
3588 | #ifdef USE_XIM |
3513 | #ifdef USE_XIM |
3589 | void |
3514 | void |
… | |
… | |
3611 | |
3536 | |
3612 | if (x < 0) x = ncol - w; |
3537 | if (x < 0) x = ncol - w; |
3613 | if (y < 0) y = nrow - h; |
3538 | if (y < 0) y = nrow - h; |
3614 | |
3539 | |
3615 | // make space for border |
3540 | // make space for border |
3616 | w += 2; MIN_IT (w, ncol); |
3541 | w += 2; min_it (w, ncol); |
3617 | h += 2; MIN_IT (h, nrow); |
3542 | h += 2; min_it (h, nrow); |
3618 | |
3543 | |
3619 | x -= 1; MAX_IT (x, 0); |
3544 | x -= 1; clamp_it (x, 0, ncol - w); |
3620 | y -= 1; MAX_IT (y, 0); |
3545 | y -= 1; clamp_it (y, 0, nrow - h); |
3621 | |
|
|
3622 | MIN_IT (x, ncol - w); |
|
|
3623 | MIN_IT (y, nrow - h); |
|
|
3624 | |
3546 | |
3625 | ov_x = x; ov_y = y; |
3547 | ov_x = x; ov_y = y; |
3626 | ov_w = w; ov_h = h; |
3548 | ov_w = w; ov_h = h; |
3627 | |
3549 | |
3628 | ov_text = new text_t *[h]; |
3550 | ov_text = new text_t *[h]; |