… | |
… | |
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 | rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t)); |
249 | rxvt_salloc *old_ra; |
245 | rxvt_salloc *old_ra = ralloc; ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); |
250 | |
246 | |
|
|
247 | #if 0 |
251 | if (nrow < prev_nrow) |
248 | if (nrow < prev_nrow) |
252 | { |
249 | { |
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, 1); |
|
|
257 | |
|
|
258 | for (p = nrow; p < prev_nrow; p++) |
250 | for (int row = nrow; row < prev_nrow; row++) |
259 | { |
251 | { |
260 | lfree (ROW(p)); |
|
|
261 | lfree (swap_save[p]); |
252 | lfree (swap_buf [row]); |
262 | lfree (drawn[p]); |
253 | lfree (drawn_buf[row]); |
263 | } |
254 | } |
|
|
255 | } |
|
|
256 | #endif |
264 | |
257 | |
265 | /* we have fewer rows so fix up cursor position */ |
258 | drawn_buf = (line_t *)rxvt_realloc (drawn_buf, nrow * sizeof (line_t)); |
266 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
259 | temp_buf = (line_t *)rxvt_realloc (temp_buf , nrow * sizeof (line_t)); |
|
|
260 | swap_buf = (line_t *)rxvt_realloc (swap_buf , nrow * sizeof (line_t)); |
267 | |
261 | |
268 | scr_reset_realloc (); /* realloc _last_ */ |
262 | for (int row = min (nrow, prev_nrow); row--; ) |
|
|
263 | { |
|
|
264 | lresize (drawn_buf[row]); |
|
|
265 | lresize (swap_buf [row]); |
|
|
266 | } |
|
|
267 | |
|
|
268 | for (int row = prev_nrow; row < nrow; row++) |
|
|
269 | { |
|
|
270 | swap_buf [row].clear (); scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
|
|
271 | drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
|
|
272 | } |
|
|
273 | |
|
|
274 | line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); |
269 | } |
275 | |
270 | else if (nrow > prev_nrow) |
276 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
271 | { |
277 | int pend = MOD (term_start - nsaved , prev_total_rows); |
272 | /* add rows */ |
278 | int q = total_rows; // rewrapped row |
273 | scr_reset_realloc (); /* realloc _first_ */ |
|
|
274 | |
279 | |
275 | int ocol = ncol; |
280 | if (nsaved) |
276 | ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
281 | { |
|
|
282 | // re-wrap lines, this is rather ugly, possibly because I am too dumb |
|
|
283 | // to come up with a lean and mean algorithm. |
277 | |
284 | |
278 | k = min (nsaved, nrow - prev_nrow); |
285 | row_col_t ocur = screen.cur; |
|
|
286 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
279 | |
287 | |
280 | for (p = prev_total_rows; p < total_rows; p++) |
288 | while (p != pend && q > 0) |
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 | { |
289 | { |
288 | swap_save[p].clear (); scr_blank_screen_mem (swap_save[p], DEFAULT_RSTYLE); |
290 | p = MOD (p - 1, prev_total_rows); |
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, 1); |
|
|
295 | screen.cur.row += k; |
|
|
296 | screen.s_cur.row += k; |
|
|
297 | nsaved -= k; |
|
|
298 | } |
|
|
299 | |
|
|
300 | #ifdef DEBUG_STRICT |
291 | #ifdef DEBUG_STRICT |
301 | assert (screen.cur.row < nrow); |
292 | assert (old_buf [MOD (p, prev_total_rows)].t); |
302 | #else /* drive with your eyes closed */ |
|
|
303 | MIN_IT (screen.cur.row, nrow - 1); |
|
|
304 | #endif |
293 | #endif |
305 | ncol = ocol; // save b/c scr_blank_screen_mem uses this |
|
|
306 | } |
|
|
307 | |
294 | |
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 |
|
|
331 | // 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 | |
|
|
339 | for (p = 0; p < prev_total_rows; p++) printf ("P %p %d\n", save[p].t, save[p].l);//D |
|
|
340 | |
|
|
341 | p = prev_total_rows; |
|
|
342 | q = total_rows; |
|
|
343 | |
|
|
344 | while (p > 0 && q > 0) |
|
|
345 | { |
|
|
346 | --p; |
|
|
347 | |
|
|
348 | printf ("pq %d:%d\n", p, q); |
|
|
349 | if (save[p].t) |
|
|
350 | { |
|
|
351 | int llen = save[p].l; |
295 | int plines = 1; |
|
|
296 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
352 | |
297 | |
353 | assert (llen >= 0); |
298 | while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) |
354 | |
|
|
355 | while (p && save[p - 1].l < 0) |
|
|
356 | { |
299 | { |
|
|
300 | p = MOD (p - 1, prev_total_rows); |
|
|
301 | |
357 | --p; |
302 | plines++; |
358 | llen += prev_ncol; |
303 | llen += prev_ncol; |
359 | } |
304 | } |
360 | |
305 | |
361 | int qlines = llen / ncol + 1; |
306 | int qlines = max (0, (llen - 1) / ncol) + 1; |
|
|
307 | |
|
|
308 | // drop partial lines completely |
|
|
309 | if (q < qlines) |
|
|
310 | break; |
|
|
311 | |
|
|
312 | q -= qlines; |
|
|
313 | |
362 | int lofs = 0; |
314 | int lofs = 0; |
|
|
315 | line_t *qline; |
363 | |
316 | |
364 | q -= qlines; |
317 | // re-assemble the full line by destination lines |
365 | |
|
|
366 | int qrow = q; |
|
|
367 | |
|
|
368 | printf ("QL %d llen %d\n", qlines, llen);//D |
|
|
369 | for (; qlines--; qrow++) |
318 | for (int qrow = q; qlines--; qrow++) |
370 | { |
319 | { |
|
|
320 | qline = row_buf + qrow; |
|
|
321 | lalloc (*qline); |
|
|
322 | qline->set_is_longer (); |
|
|
323 | |
371 | if (qrow >= 0) |
324 | int qcol = 0; |
|
|
325 | |
|
|
326 | // fill a single destination line |
|
|
327 | while (lofs < llen && qcol < ncol) |
372 | { |
328 | { |
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; |
329 | int prow = lofs / prev_ncol; |
382 | int pcol = lofs % prev_ncol; |
330 | int pcol = lofs % prev_ncol; |
383 | |
331 | |
|
|
332 | prow = MOD (p + prow, prev_total_rows); |
|
|
333 | |
|
|
334 | // we only adjust the cursor _row_, as this seems to upset |
|
|
335 | // applications/shells/readline least. |
|
|
336 | if (prow == ocur.row) |
|
|
337 | screen.cur.row = qrow - (total_rows - nrow); |
|
|
338 | |
|
|
339 | line_t &pline = old_buf [prow]; |
|
|
340 | |
384 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
341 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
385 | |
342 | |
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); |
343 | assert (len); |
|
|
344 | assert (pline.t); |
400 | |
345 | |
401 | memcpy (tp [qrow] + qcol, save[prow].t + pcol, len * sizeof (text_t)); |
346 | memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); |
402 | memcpy (rp [qrow] + qcol, save[prow].r + pcol, len * sizeof (rend_t)); |
347 | memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
403 | |
348 | |
404 | lofs += len; |
349 | lofs += len; |
405 | qcol += len; |
350 | qcol += len; |
406 | |
|
|
407 | if (qcol == ncol) |
|
|
408 | break; |
|
|
409 | } |
|
|
410 | } |
351 | } |
411 | else |
|
|
412 | lofs += ncol; |
|
|
413 | } |
352 | } |
|
|
353 | |
|
|
354 | qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; |
|
|
355 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
414 | } |
356 | } |
|
|
357 | |
|
|
358 | term_start = total_rows - nrow; |
|
|
359 | view_start = 0; |
|
|
360 | nsaved = term_start - q; |
|
|
361 | |
|
|
362 | // make sure all terminal lines exist |
|
|
363 | while (nsaved < 0) |
|
|
364 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
|
|
365 | |
|
|
366 | } |
|
|
367 | else |
415 | } |
368 | { |
|
|
369 | // if no scrollback exists (yet), wing, instead of wrap |
|
|
370 | |
|
|
371 | for (int row = min (nrow, prev_nrow); row--; ) |
|
|
372 | { |
|
|
373 | line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; |
|
|
374 | line_t &qline = row_buf [row]; |
416 | |
375 | |
417 | free (screen.text); screen.text = tp; |
376 | qline = pline; |
418 | free (screen.rend); screen.rend = rp; |
377 | lresize (qline); |
419 | free (screen.tlen); screen.tlen = tl; |
378 | } |
420 | |
379 | |
421 | for (p = 0; p < total_rows; p++) printf ("P %p %d\n", save[p].t, save[p].l);//D |
380 | for (int row = prev_nrow; row < nrow; row++) |
|
|
381 | { |
|
|
382 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
|
|
383 | } |
|
|
384 | |
|
|
385 | term_start = 0; |
|
|
386 | view_start = 0; |
|
|
387 | } |
|
|
388 | |
|
|
389 | #ifdef DEBUG_STRICT |
|
|
390 | for (int i = -nsaved; i < nrow; i++) |
|
|
391 | assert (ROW (i).t); |
422 | #endif |
392 | #endif |
|
|
393 | |
|
|
394 | free (old_buf); |
|
|
395 | delete old_ta; |
|
|
396 | delete old_ra; |
|
|
397 | |
|
|
398 | clamp_it (screen.cur.row, 0, nrow - 1); |
|
|
399 | clamp_it (screen.cur.col, 0, ncol - 1); |
423 | |
400 | |
424 | if (tabs) |
401 | if (tabs) |
425 | free (tabs); |
402 | free (tabs); |
426 | } |
403 | } |
427 | |
404 | |
428 | prev_nrow = nrow; |
405 | prev_nrow = nrow; |
429 | prev_ncol = ncol; |
406 | prev_ncol = ncol; |
430 | |
407 | |
431 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
408 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
432 | |
409 | |
433 | for (p = 0; p < ncol; p++) |
410 | for (int col = ncol; col--; ) |
434 | tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
411 | tabs [col] = col % TABSIZE == 0; |
435 | |
412 | |
436 | tt_winch (); |
413 | 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 | } |
414 | } |
447 | |
415 | |
448 | /* ------------------------------------------------------------------------- */ |
416 | /* ------------------------------------------------------------------------- */ |
449 | /* |
417 | /* |
450 | * Free everything. That way malloc debugging can find leakage. |
418 | * Free everything. That way malloc debugging can find leakage. |
… | |
… | |
453 | rxvt_term::scr_release () |
421 | rxvt_term::scr_release () |
454 | { |
422 | { |
455 | delete talloc; talloc = 0; |
423 | delete talloc; talloc = 0; |
456 | delete ralloc; ralloc = 0; |
424 | delete ralloc; ralloc = 0; |
457 | |
425 | |
458 | free (save); |
426 | free (row_buf); |
459 | free (swap_save); |
427 | free (swap_buf); |
460 | free (drawn); |
428 | free (drawn_buf); |
461 | free (buf); |
429 | free (temp_buf); |
462 | free (tabs); |
430 | free (tabs); |
|
|
431 | |
|
|
432 | row_buf = 0; // signal that we freed all the arrays |
463 | } |
433 | } |
464 | |
434 | |
465 | /* ------------------------------------------------------------------------- */ |
435 | /* ------------------------------------------------------------------------- */ |
466 | /* |
436 | /* |
467 | * Hard reset |
437 | * Hard reset |
… | |
… | |
518 | set_font_style (); |
488 | set_font_style (); |
519 | break; |
489 | break; |
520 | } |
490 | } |
521 | |
491 | |
522 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
492 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
523 | MIN_IT (s->cur.row, nrow - 1); |
493 | min_it (s->cur.row, nrow - 1); |
524 | MIN_IT (s->cur.col, ncol - 1); |
494 | min_it (s->cur.col, ncol - 1); |
525 | #ifdef DEBUG_STRICT |
495 | #ifdef DEBUG_STRICT |
526 | assert (s->cur.row >= 0); |
496 | assert (s->cur.row >= 0); |
527 | assert (s->cur.col >= 0); |
497 | assert (s->cur.col >= 0); |
528 | #else /* drive with your eyes closed */ |
|
|
529 | MAX_IT (s->cur.row, 0); |
|
|
530 | MAX_IT (s->cur.col, 0); |
|
|
531 | #endif |
498 | #endif |
532 | } |
499 | } |
533 | |
500 | |
534 | /* ------------------------------------------------------------------------- */ |
501 | /* ------------------------------------------------------------------------- */ |
535 | /* |
502 | /* |
… | |
… | |
538 | * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l |
505 | * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l |
539 | */ |
506 | */ |
540 | int |
507 | int |
541 | rxvt_term::scr_change_screen (int scrn) |
508 | rxvt_term::scr_change_screen (int scrn) |
542 | { |
509 | { |
543 | int i; |
|
|
544 | #if NSCREENS |
|
|
545 | int offset; |
|
|
546 | #endif |
|
|
547 | |
|
|
548 | want_refresh = 1; |
510 | want_refresh = 1; |
549 | |
|
|
550 | view_start = 0; |
511 | view_start = 0; |
551 | |
512 | |
552 | if (current_screen == scrn) |
513 | if (current_screen == scrn) |
553 | return scrn; |
514 | return scrn; |
554 | |
515 | |
555 | selection_check (2); /* check for boundary cross */ |
516 | selection_check (2); /* check for boundary cross */ |
556 | |
517 | |
557 | i = current_screen; current_screen = scrn; scrn = i; |
518 | int i = current_screen; current_screen = scrn; scrn = i; |
558 | |
519 | |
559 | SWAP_IT (screen.cur.row, swap.cur.row, int16_t); |
520 | ::swap (screen.cur.row, swap.cur.row); |
560 | SWAP_IT (screen.cur.col, swap.cur.col, int16_t); |
521 | ::swap (screen.cur.col, swap.cur.col); |
561 | MAX_IT (screen.cur.row, 0); |
522 | |
562 | MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); |
523 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
563 | MAX_IT (screen.cur.col, 0); |
524 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
564 | MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); |
|
|
565 | |
525 | |
566 | #if NSCREENS |
526 | #if NSCREENS |
567 | if (options & Opt_secondaryScreen) |
527 | if (options & Opt_secondaryScreen) |
568 | { |
528 | { |
569 | num_scr = 0; |
529 | num_scr = 0; |
570 | offset = saveLines; |
|
|
571 | |
530 | |
572 | for (i = prev_nrow; i--;) |
531 | for (int i = prev_nrow; i--; ) |
573 | SWAP_IT (ROW(i), swap_save[i], line_t); |
532 | ::swap (ROW(i), swap_buf [i]); |
574 | |
533 | |
575 | SWAP_IT (screen.charset, swap.charset, int16_t); |
534 | ::swap (screen.charset, swap.charset); |
576 | SWAP_IT (screen.flags, swap.flags, int); |
535 | ::swap (screen.flags, swap.flags); |
577 | screen.flags |= Screen_VisibleCursor; |
536 | screen.flags |= Screen_VisibleCursor; |
578 | swap.flags |= Screen_VisibleCursor; |
537 | swap.flags |= Screen_VisibleCursor; |
579 | } |
538 | } |
580 | else |
539 | else |
581 | #endif |
540 | #endif |
582 | if (options & Opt_secondaryScroll) |
541 | if (options & Opt_secondaryScroll) |
583 | scr_scroll_text (0, prev_nrow - 1, prev_nrow, 0); |
542 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
584 | |
543 | |
585 | return scrn; |
544 | return scrn; |
586 | } |
545 | } |
587 | |
546 | |
588 | // clear WrapNext indicator, solidifying position on next line |
547 | // clear WrapNext indicator, solidifying position on next line |
… | |
… | |
595 | screen.flags &= ~Screen_WrapNext; |
554 | screen.flags &= ~Screen_WrapNext; |
596 | |
555 | |
597 | screen.cur.col = 0; |
556 | screen.cur.col = 0; |
598 | |
557 | |
599 | if (screen.cur.row == screen.bscroll) |
558 | if (screen.cur.row == screen.bscroll) |
600 | scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); |
559 | scr_scroll_text (screen.tscroll, screen.bscroll, 1); |
601 | else if (screen.cur.row < nrow - 1) |
560 | else if (screen.cur.row < nrow - 1) |
602 | screen.cur.row++; |
561 | screen.cur.row++; |
603 | } |
562 | } |
604 | |
563 | |
605 | /* ------------------------------------------------------------------------- */ |
564 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
636 | /* ------------------------------------------------------------------------- */ |
595 | /* ------------------------------------------------------------------------- */ |
637 | /* |
596 | /* |
638 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
597 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
639 | * count positive ==> scroll up |
598 | * count positive ==> scroll up |
640 | * count negative ==> scroll down |
599 | * count negative ==> scroll down |
641 | * spec == 0 for normal routines |
|
|
642 | */ |
600 | */ |
643 | int |
601 | int |
644 | rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) |
602 | rxvt_term::scr_scroll_text (int row1, int row2, int count) |
645 | { |
603 | { |
646 | int i, j; |
|
|
647 | |
|
|
648 | if (count == 0 || (row1 > row2)) |
604 | if (count == 0 || (row1 > row2)) |
649 | return 0; |
605 | return 0; |
650 | |
606 | |
651 | want_refresh = 1; |
607 | want_refresh = 1; |
|
|
608 | num_scr += count; |
652 | |
609 | |
653 | if (row1 == 0 && count > 0 |
610 | if (count > 0 |
|
|
611 | && row1 == 0 |
|
|
612 | && row2 == nrow - 1 |
654 | && (current_screen == PRIMARY || options & Opt_secondaryScroll)) |
613 | && (current_screen == PRIMARY || options & Opt_secondaryScroll)) |
655 | { |
614 | { |
656 | nsaved = min (nsaved + count, saveLines); |
615 | nsaved = min (nsaved + count, saveLines); |
657 | term_start = (term_start + count) % total_rows; |
616 | term_start = (term_start + count) % total_rows; |
658 | |
617 | |
659 | if (selection.op && current_screen == selection.screen) |
618 | if (selection.op && current_screen == selection.screen) |
660 | { |
619 | { |
661 | selection.beg.row -= count; |
620 | selection.beg.row -= count; |
662 | selection.end.row -= count; |
621 | selection.end.row -= count; |
663 | selection.mark.row -= count; |
622 | selection.mark.row -= count; |
|
|
623 | |
|
|
624 | selection_check (0); |
664 | } |
625 | } |
665 | |
626 | |
666 | for (int i = count; i--; ) |
627 | for (int i = count; i--; ) |
667 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
628 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
668 | |
629 | |
… | |
… | |
671 | && view_start != saveLines) |
632 | && view_start != saveLines) |
672 | scr_page (UP, count); |
633 | scr_page (UP, count); |
673 | } |
634 | } |
674 | else |
635 | else |
675 | { |
636 | { |
676 | if (!spec) |
|
|
677 | row1 += saveLines; |
|
|
678 | |
|
|
679 | row2 += saveLines; |
|
|
680 | |
|
|
681 | if (selection.op && current_screen == selection.screen) |
637 | if (selection.op && current_screen == selection.screen) |
682 | { |
638 | { |
683 | i = selection.beg.row + saveLines; |
639 | int i = selection.beg.row; |
684 | j = selection.end.row + saveLines; |
640 | int j = selection.end.row; |
685 | |
641 | |
686 | if ((i < row1 && j > row1) |
642 | if ((i < row1 && j > row1) |
687 | || (i < row2 && j > row2) |
643 | || (i < row2 && j > row2) |
688 | || (i - count < row1 && i >= row1) |
644 | || (i - count < row1 && i >= row1) |
689 | || (i - count > row2 && i <= row2) |
645 | || (i - count > row2 && i <= row2) |
… | |
… | |
697 | { |
653 | { |
698 | /* move selected region too */ |
654 | /* move selected region too */ |
699 | selection.beg.row -= count; |
655 | selection.beg.row -= count; |
700 | selection.end.row -= count; |
656 | selection.end.row -= count; |
701 | selection.mark.row -= count; |
657 | selection.mark.row -= count; |
|
|
658 | |
|
|
659 | selection_check (0); |
702 | } |
660 | } |
703 | } |
661 | } |
704 | |
662 | |
705 | selection_check (0); /* _after_ nsaved update */ |
663 | // use a simple and robust scrolling algorithm, this |
|
|
664 | // part of scr_scroll_text is not time-critical. |
706 | |
665 | |
707 | num_scr += count; |
|
|
708 | j = count; |
|
|
709 | |
|
|
710 | if (count < 0) |
|
|
711 | count = -count; |
|
|
712 | |
|
|
713 | i = row2 - row1 + 1; |
666 | int rows = row2 - row1 + 1; |
714 | MIN_IT (count, i); |
|
|
715 | |
667 | |
716 | if (j > 0) |
668 | min_it (count, rows); |
717 | { |
|
|
718 | /* scroll up */ |
|
|
719 | |
669 | |
720 | /* Copy lines that will get clobbered by the rotation */ |
670 | for (int row = 0; row < rows; row++) |
721 | memcpy (buf, save + row1, count * sizeof (line_t)); |
|
|
722 | |
|
|
723 | /* Rotate lines */ |
|
|
724 | i = row2 - row1 - count + 1; |
|
|
725 | memmove (save + row1, save + row1 + count, i * sizeof (line_t)); |
|
|
726 | |
|
|
727 | j = row2 - count + 1, i = count; |
|
|
728 | } |
671 | { |
729 | else /* if (j < 0) */ |
672 | temp_buf [row] = ROW(row1 + (row + count + rows) % rows); |
|
|
673 | |
|
|
674 | if (!IN_RANGE_EXC (row + count, 0, rows)) |
|
|
675 | scr_blank_screen_mem (temp_buf [row], rstyle); |
730 | { |
676 | } |
731 | /* scroll down */ |
|
|
732 | |
677 | |
733 | /* Copy lines that will get clobbered by the rotation */ |
678 | for (int row = 0; row < rows; row++) |
734 | for (i = 0, j = row2; i < count; i++, j--) |
679 | ROW(row1 + row) = temp_buf [row]; |
735 | buf[i] = save[j]; |
|
|
736 | |
|
|
737 | /* Rotate lines */ |
|
|
738 | for (j = row2, i = j - count; i >= row1; i--, j--) |
|
|
739 | save[j] = save[i]; |
|
|
740 | |
|
|
741 | j = row1, i = count; |
|
|
742 | count = -count; |
|
|
743 | } |
|
|
744 | |
|
|
745 | /* Resurrect lines */ |
|
|
746 | memcpy (save + j, buf, i * sizeof (line_t)); |
|
|
747 | |
|
|
748 | if (!spec) /* line length may not equal ncol */ |
|
|
749 | for (; i--; j++) |
|
|
750 | scr_blank_screen_mem (save[j], rstyle); |
|
|
751 | } |
680 | } |
752 | |
681 | |
753 | return count; |
682 | return count; |
754 | } |
683 | } |
755 | |
684 | |
… | |
… | |
773 | last_col = ncol; |
702 | last_col = ncol; |
774 | |
703 | |
775 | if (nlines > 0) |
704 | if (nlines > 0) |
776 | { |
705 | { |
777 | nlines += screen.cur.row - screen.bscroll; |
706 | nlines += screen.cur.row - screen.bscroll; |
778 | if ((nlines > 0) |
707 | if (nlines > 0 |
779 | && (screen.tscroll == 0) |
708 | && screen.tscroll == 0 |
780 | && (screen.bscroll == (nrow - 1))) |
709 | && screen.bscroll == (nrow - 1)) |
781 | { |
710 | { |
782 | /* _at least_ this many lines need to be scrolled */ |
711 | /* _at least_ this many lines need to be scrolled */ |
783 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines, 0); |
712 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines); |
784 | screen.cur.row -= nlines; |
713 | screen.cur.row -= nlines; |
785 | } |
714 | } |
786 | } |
715 | } |
787 | |
716 | |
788 | #ifdef DEBUG_STRICT |
717 | #ifdef DEBUG_STRICT |
789 | assert (screen.cur.col < last_col); |
718 | assert (screen.cur.col < last_col); |
790 | assert ((screen.cur.row < nrow) |
719 | assert (screen.cur.row < nrow |
791 | && (screen.cur.row >= - (int32_t)nsaved)); |
720 | && screen.cur.row >= -nsaved); |
792 | #else /* drive with your eyes closed */ |
|
|
793 | MIN_IT (screen.cur.col, last_col - 1); |
|
|
794 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
|
|
795 | MAX_IT (screen.cur.row, - (int32_t)nsaved); |
|
|
796 | #endif |
721 | #endif |
797 | row = screen.cur.row; |
722 | row = screen.cur.row; |
798 | |
723 | |
799 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
724 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
800 | |
725 | |
… | |
… | |
806 | |
731 | |
807 | if (c < 0x20) |
732 | if (c < 0x20) |
808 | if (c == C0_LF) |
733 | if (c == C0_LF) |
809 | { |
734 | { |
810 | if (!line->is_longer ()) /* XXX: think about this */ |
735 | if (!line->is_longer ()) /* XXX: think about this */ |
811 | MAX_IT (line->l, screen.cur.col); |
736 | max_it (line->l, screen.cur.col); |
812 | |
737 | |
813 | screen.flags &= ~Screen_WrapNext; |
738 | screen.flags &= ~Screen_WrapNext; |
814 | |
739 | |
815 | if (screen.cur.row == screen.bscroll) |
740 | if (screen.cur.row == screen.bscroll) |
816 | scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); |
741 | scr_scroll_text (screen.tscroll, screen.bscroll, 1); |
817 | else if (screen.cur.row < (nrow - 1)) |
742 | else if (screen.cur.row < (nrow - 1)) |
818 | row = ++screen.cur.row; |
743 | row = ++screen.cur.row; |
819 | |
744 | |
820 | line = &ROW(row); /* _must_ refresh */ |
745 | line = &ROW(row); /* _must_ refresh */ |
821 | continue; |
746 | continue; |
822 | } |
747 | } |
823 | else if (c == C0_CR) |
748 | else if (c == C0_CR) |
824 | { |
749 | { |
825 | if (!line->is_longer ()) /* XXX: think about this */ |
750 | if (!line->is_longer ()) /* XXX: think about this */ |
826 | MAX_IT (line->l, screen.cur.col); |
751 | max_it (line->l, screen.cur.col); |
827 | |
752 | |
828 | screen.flags &= ~Screen_WrapNext; |
753 | screen.flags &= ~Screen_WrapNext; |
829 | screen.cur.col = 0; |
754 | screen.cur.col = 0; |
830 | continue; |
755 | continue; |
831 | } |
756 | } |
… | |
… | |
1007 | #endif |
932 | #endif |
1008 | } |
933 | } |
1009 | } |
934 | } |
1010 | |
935 | |
1011 | if (!line->is_longer ()) /* XXX: think about this */ |
936 | if (!line->is_longer ()) /* XXX: think about this */ |
1012 | MAX_IT (line->l, screen.cur.col); |
937 | max_it (line->l, screen.cur.col); |
1013 | |
938 | |
1014 | #ifdef DEBUG_STRICT |
939 | #ifdef DEBUG_STRICT |
1015 | assert (screen.cur.row >= 0); |
940 | assert (screen.cur.row >= 0); |
1016 | #else /* drive with your eyes closed */ |
|
|
1017 | MAX_IT (screen.cur.row, 0); |
|
|
1018 | #endif |
941 | #endif |
1019 | } |
942 | } |
1020 | |
943 | |
1021 | /* ------------------------------------------------------------------------- */ |
944 | /* ------------------------------------------------------------------------- */ |
1022 | /* |
945 | /* |
… | |
… | |
1088 | if (ht && options & Opt_pastableTabs) |
1011 | if (ht && options & Opt_pastableTabs) |
1089 | { |
1012 | { |
1090 | base_rend = SET_FONT (base_rend, 0); |
1013 | base_rend = SET_FONT (base_rend, 0); |
1091 | |
1014 | |
1092 | if (!l.is_longer ()) /* XXX: think about this */ |
1015 | if (!l.is_longer ()) /* XXX: think about this */ |
1093 | MAX_IT (l.l, x); |
1016 | max_it (l.l, x); |
1094 | |
1017 | |
1095 | i = screen.cur.col; |
1018 | i = screen.cur.col; |
1096 | |
1019 | |
1097 | l.t[i] = '\t'; |
1020 | l.t[i] = '\t'; |
1098 | l.r[i] = base_rend; |
1021 | l.r[i] = base_rend; |
… | |
… | |
1177 | { |
1100 | { |
1178 | want_refresh = 1; |
1101 | want_refresh = 1; |
1179 | ZERO_SCROLLBACK (); |
1102 | ZERO_SCROLLBACK (); |
1180 | |
1103 | |
1181 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1104 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1182 | MAX_IT (screen.cur.col, 0); |
1105 | clamp_it (screen.cur.col, 0, ncol - 1); |
1183 | MIN_IT (screen.cur.col, (int32_t)ncol - 1); |
|
|
1184 | |
1106 | |
1185 | screen.flags &= ~Screen_WrapNext; |
1107 | screen.flags &= ~Screen_WrapNext; |
1186 | |
1108 | |
1187 | if (relative & R_RELATIVE) |
1109 | if (relative & R_RELATIVE) |
1188 | { |
1110 | { |
… | |
… | |
1206 | else |
1128 | else |
1207 | { |
1129 | { |
1208 | if (screen.flags & Screen_Relative) |
1130 | if (screen.flags & Screen_Relative) |
1209 | { /* relative origin mode */ |
1131 | { /* relative origin mode */ |
1210 | screen.cur.row = row + screen.tscroll; |
1132 | screen.cur.row = row + screen.tscroll; |
1211 | MIN_IT (screen.cur.row, screen.bscroll); |
1133 | min_it (screen.cur.row, screen.bscroll); |
1212 | } |
1134 | } |
1213 | else |
1135 | else |
1214 | screen.cur.row = row; |
1136 | screen.cur.row = row; |
1215 | } |
1137 | } |
1216 | |
1138 | |
1217 | MAX_IT (screen.cur.row, 0); |
1139 | clamp_it (screen.cur.row, 0, nrow - 1); |
1218 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
|
|
1219 | } |
1140 | } |
1220 | |
1141 | |
1221 | /* ------------------------------------------------------------------------- */ |
1142 | /* ------------------------------------------------------------------------- */ |
1222 | /* |
1143 | /* |
1223 | * direction should be UP or DN |
1144 | * direction should be UP or DN |
… | |
… | |
1234 | |
1155 | |
1235 | screen.flags &= ~Screen_WrapNext; |
1156 | screen.flags &= ~Screen_WrapNext; |
1236 | |
1157 | |
1237 | if ((screen.cur.row == screen.bscroll && direction == UP) |
1158 | if ((screen.cur.row == screen.bscroll && direction == UP) |
1238 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1159 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1239 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn, 0); |
1160 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn); |
1240 | else |
1161 | else |
1241 | screen.cur.row += dirn; |
1162 | screen.cur.row += dirn; |
1242 | |
1163 | |
1243 | MAX_IT (screen.cur.row, 0); |
1164 | clamp_it (screen.cur.row, 0, nrow - 1); |
1244 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
|
|
1245 | selection_check (0); |
1165 | selection_check (0); |
1246 | } |
1166 | } |
1247 | |
1167 | |
1248 | /* ------------------------------------------------------------------------- */ |
1168 | /* ------------------------------------------------------------------------- */ |
1249 | /* |
1169 | /* |
… | |
… | |
1267 | switch (mode) |
1187 | switch (mode) |
1268 | { |
1188 | { |
1269 | case 0: /* erase to end of line */ |
1189 | case 0: /* erase to end of line */ |
1270 | col = screen.cur.col; |
1190 | col = screen.cur.col; |
1271 | num = ncol - col; |
1191 | num = ncol - col; |
1272 | MIN_IT (ROW(row).l, (int16_t)col); |
1192 | min_it (ROW(row).l, col); |
1273 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1193 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1274 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1194 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1275 | CLEAR_SELECTION (); |
1195 | CLEAR_SELECTION (); |
1276 | break; |
1196 | break; |
1277 | case 1: /* erase to beginning of line */ |
1197 | case 1: /* erase to beginning of line */ |
… | |
… | |
1305 | */ |
1225 | */ |
1306 | void |
1226 | void |
1307 | rxvt_term::scr_erase_screen (int mode) |
1227 | rxvt_term::scr_erase_screen (int mode) |
1308 | { |
1228 | { |
1309 | int num; |
1229 | int num; |
1310 | int32_t row, row_offset; |
1230 | int32_t row; |
1311 | rend_t ren; |
1231 | rend_t ren; |
1312 | XGCValues gcvalue; |
1232 | XGCValues gcvalue; |
1313 | |
1233 | |
1314 | want_refresh = 1; |
1234 | want_refresh = 1; |
1315 | ZERO_SCROLLBACK (); |
1235 | ZERO_SCROLLBACK (); |
1316 | |
|
|
1317 | row_offset = (int32_t)saveLines; |
|
|
1318 | |
1236 | |
1319 | switch (mode) |
1237 | switch (mode) |
1320 | { |
1238 | { |
1321 | case 0: /* erase to end of screen */ |
1239 | case 0: /* erase to end of screen */ |
1322 | selection_check (1); |
1240 | selection_check (1); |
… | |
… | |
1346 | CLEAR_SELECTION (); |
1264 | CLEAR_SELECTION (); |
1347 | |
1265 | |
1348 | if (row >= nrow) /* Out Of Bounds */ |
1266 | if (row >= nrow) /* Out Of Bounds */ |
1349 | return; |
1267 | return; |
1350 | |
1268 | |
1351 | MIN_IT (num, (nrow - row)); |
1269 | min_it (num, nrow - row); |
1352 | |
1270 | |
1353 | if (rstyle & (RS_RVid | RS_Uline)) |
1271 | if (rstyle & (RS_RVid | RS_Uline)) |
1354 | ren = (rend_t) ~RS_None; |
1272 | ren = (rend_t) ~RS_None; |
1355 | else if (GET_BASEBG (rstyle) == Color_bg) |
1273 | else if (GET_BASEBG (rstyle) == Color_bg) |
1356 | { |
1274 | { |
… | |
… | |
1367 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1285 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1368 | } |
1286 | } |
1369 | |
1287 | |
1370 | for (; num--; row++) |
1288 | for (; num--; row++) |
1371 | { |
1289 | { |
1372 | scr_blank_screen_mem (save[row + row_offset], rstyle); |
1290 | scr_blank_screen_mem (ROW (row), rstyle); |
1373 | save[row + row_offset].l = 0; |
1291 | ROW (row).l = 0; |
1374 | scr_blank_line (drawn[row], 0, ncol, ren); |
1292 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1375 | } |
1293 | } |
1376 | } |
1294 | } |
1377 | |
1295 | |
1378 | #if ENABLE_FRILLS |
1296 | #if ENABLE_FRILLS |
1379 | void |
1297 | void |
… | |
… | |
1392 | * XTERM_SEQ: Screen Alignment Test: ESC # 8 |
1310 | * XTERM_SEQ: Screen Alignment Test: ESC # 8 |
1393 | */ |
1311 | */ |
1394 | void |
1312 | void |
1395 | rxvt_term::scr_E () |
1313 | rxvt_term::scr_E () |
1396 | { |
1314 | { |
1397 | int i, j, k; |
|
|
1398 | rend_t *r1, fs; |
1315 | rend_t fs; |
1399 | |
1316 | |
1400 | want_refresh = 1; |
1317 | want_refresh = 1; |
1401 | ZERO_SCROLLBACK (); |
1318 | ZERO_SCROLLBACK (); |
1402 | |
1319 | |
1403 | num_scr_allow = 0; |
1320 | num_scr_allow = 0; |
1404 | selection_check (3); |
1321 | selection_check (3); |
1405 | |
1322 | |
1406 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1323 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1407 | for (k = saveLines, i = nrow; i--; k++) |
1324 | for (int row = nrow; row--; ) |
1408 | { |
1325 | { |
1409 | line_t &line = save[k]; |
1326 | line_t &line = ROW(row); |
1410 | |
1327 | |
1411 | fill_text (line.t, 'E', ncol); |
1328 | fill_text (line.t, 'E', ncol); |
|
|
1329 | rend_t *r1 = line.r; |
1412 | |
1330 | |
1413 | for (r1 = line.r, j = ncol; j--; ) |
1331 | for (int j = ncol; j--; ) |
1414 | *r1++ = fs; |
1332 | *r1++ = fs; |
1415 | |
1333 | |
1416 | line.l = ncol; /* make the `E's selectable */ |
1334 | line.l = ncol; /* make the `E's selectable */ |
1417 | } |
1335 | } |
1418 | } |
1336 | } |
… | |
… | |
1442 | count = end; |
1360 | count = end; |
1443 | } |
1361 | } |
1444 | |
1362 | |
1445 | scr_do_wrap (); |
1363 | scr_do_wrap (); |
1446 | |
1364 | |
1447 | scr_scroll_text (screen.cur.row, screen.bscroll, insdel * count, 0); |
1365 | scr_scroll_text (screen.cur.row, screen.bscroll, insdel * count); |
1448 | } |
1366 | } |
1449 | |
1367 | |
1450 | /* ------------------------------------------------------------------------- */ |
1368 | /* ------------------------------------------------------------------------- */ |
1451 | /* |
1369 | /* |
1452 | * Insert/Delete <count> characters from the current position |
1370 | * Insert/Delete <count> characters from the current position |
… | |
… | |
1464 | return; |
1382 | return; |
1465 | |
1383 | |
1466 | scr_do_wrap (); |
1384 | scr_do_wrap (); |
1467 | |
1385 | |
1468 | selection_check (1); |
1386 | selection_check (1); |
1469 | MIN_IT (count, (ncol - screen.cur.col)); |
1387 | min_it (count, ncol - screen.cur.col); |
1470 | |
1388 | |
1471 | row = screen.cur.row + saveLines; |
1389 | row = screen.cur.row; |
1472 | |
1390 | |
1473 | line_t *line = save + row; |
1391 | line_t *line = &ROW(row); |
1474 | |
1392 | |
1475 | switch (insdel) |
1393 | switch (insdel) |
1476 | { |
1394 | { |
1477 | case INSERT: |
1395 | case INSERT: |
1478 | for (col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1396 | for (col = ncol - 1; (col - count) >= screen.cur.col; col--) |
… | |
… | |
1482 | } |
1400 | } |
1483 | |
1401 | |
1484 | if (!line->is_longer ()) |
1402 | if (!line->is_longer ()) |
1485 | { |
1403 | { |
1486 | line->l += count; |
1404 | line->l += count; |
1487 | MIN_IT (line->l, ncol); |
1405 | min_it (line->l, ncol); |
1488 | } |
1406 | } |
1489 | |
1407 | |
1490 | if (selection.op && current_screen == selection.screen |
1408 | if (selection.op && current_screen == selection.screen |
1491 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1409 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1492 | { |
1410 | { |
… | |
… | |
1499 | selection.mark.col += count; /* XXX: yes? */ |
1417 | selection.mark.col += count; /* XXX: yes? */ |
1500 | selection.end.col += count; |
1418 | selection.end.col += count; |
1501 | } |
1419 | } |
1502 | } |
1420 | } |
1503 | |
1421 | |
1504 | scr_blank_line (save[row], screen.cur.col, count, rstyle); |
1422 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1505 | break; |
1423 | break; |
1506 | |
1424 | |
1507 | case ERASE: |
1425 | case ERASE: |
1508 | screen.cur.col += count; /* don't worry if > ncol */ |
1426 | screen.cur.col += count; /* don't worry if > ncol */ |
1509 | selection_check (1); |
1427 | selection_check (1); |
1510 | screen.cur.col -= count; |
1428 | screen.cur.col -= count; |
1511 | scr_blank_line (save[row], screen.cur.col, count, rstyle); |
1429 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1512 | break; |
1430 | break; |
1513 | |
1431 | |
1514 | case DELETE: |
1432 | case DELETE: |
1515 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1433 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1516 | |
1434 | |
… | |
… | |
1523 | scr_blank_line (*line, ncol - count, count, tr); |
1441 | scr_blank_line (*line, ncol - count, count, tr); |
1524 | |
1442 | |
1525 | if (line->is_longer ()) /* break line continuation */ |
1443 | if (line->is_longer ()) /* break line continuation */ |
1526 | line->l = ncol; |
1444 | line->l = ncol; |
1527 | |
1445 | |
1528 | line->l -= count; |
1446 | line->l = max (line->l - count, 0); |
1529 | MAX_IT (line->l, 0); |
|
|
1530 | |
1447 | |
1531 | if (selection.op && current_screen == selection.screen |
1448 | if (selection.op && current_screen == selection.screen |
1532 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1449 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1533 | { |
1450 | { |
1534 | if (selection.end.row != screen.cur.row |
1451 | if (selection.end.row != screen.cur.row |
… | |
… | |
1554 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1471 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1555 | */ |
1472 | */ |
1556 | void |
1473 | void |
1557 | rxvt_term::scr_scroll_region (int top, int bot) |
1474 | rxvt_term::scr_scroll_region (int top, int bot) |
1558 | { |
1475 | { |
1559 | MAX_IT (top, 0); |
1476 | max_it (top, 0); |
1560 | MIN_IT (bot, (int)nrow - 1); |
1477 | min_it (bot, nrow - 1); |
1561 | |
1478 | |
1562 | if (top > bot) |
1479 | if (top > bot) |
1563 | return; |
1480 | return; |
1564 | |
1481 | |
1565 | screen.tscroll = top; |
1482 | screen.tscroll = top; |
… | |
… | |
1663 | XGCValues gcvalue; |
1580 | XGCValues gcvalue; |
1664 | |
1581 | |
1665 | if (rvideo != mode) |
1582 | if (rvideo != mode) |
1666 | { |
1583 | { |
1667 | rvideo = mode; |
1584 | rvideo = mode; |
1668 | SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); |
1585 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1669 | #if XPM_BACKGROUND |
1586 | #if XPM_BACKGROUND |
1670 | if (bgPixmap.pixmap == None) |
1587 | if (bgPixmap.pixmap == None) |
1671 | #endif |
1588 | #endif |
1672 | #if TRANSPARENT |
1589 | #if TRANSPARENT |
1673 | if (! (options & Opt_transparent) || am_transparent == 0) |
1590 | if (! (options & Opt_transparent) || am_transparent == 0) |
… | |
… | |
1769 | bool found = false; |
1686 | bool found = false; |
1770 | |
1687 | |
1771 | for (int i = 0; i < nrow; i++) |
1688 | for (int i = 0; i < nrow; i++) |
1772 | { |
1689 | { |
1773 | int col = 0; |
1690 | int col = 0; |
1774 | rend_t *drp = drawn[i].r; |
1691 | rend_t *drp = drawn_buf[i].r; |
1775 | |
1692 | |
1776 | for (; col < ncol; col++, drp++) |
1693 | for (; col < ncol; col++, drp++) |
1777 | if ((*drp & mask) == value) |
1694 | if ((*drp & mask) == value) |
1778 | { |
1695 | { |
1779 | found = true; |
1696 | found = true; |
… | |
… | |
1797 | rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) |
1714 | rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) |
1798 | { |
1715 | { |
1799 | int i; |
1716 | int i; |
1800 | row_col_t rc[RC_COUNT]; |
1717 | row_col_t rc[RC_COUNT]; |
1801 | |
1718 | |
1802 | if (!drawn) /* sanity check */ |
1719 | if (!drawn_buf) /* sanity check */ |
1803 | return; |
1720 | return; |
1804 | |
1721 | |
1805 | #ifndef NO_SLOW_LINK_SUPPORT |
1722 | #ifndef NO_SLOW_LINK_SUPPORT |
1806 | if (refresh_type == FAST_REFRESH && !display->is_local) |
1723 | if (refresh_type == FAST_REFRESH && !display->is_local) |
1807 | { |
1724 | { |
1808 | y = 0; |
1725 | y = 0; |
1809 | eheight = height; |
1726 | eheight = height; |
1810 | } |
1727 | } |
1811 | #endif |
|
|
1812 | |
|
|
1813 | #ifdef DEBUG_STRICT |
|
|
1814 | x = max (x, 0); |
|
|
1815 | x = min (x, (int)width); |
|
|
1816 | y = max (y, 0); |
|
|
1817 | y = min (y, (int)height); |
|
|
1818 | #endif |
1728 | #endif |
1819 | |
1729 | |
1820 | /* round down */ |
1730 | /* round down */ |
1821 | rc[PART_BEG].col = Pixel2Col (x); |
1731 | rc[PART_BEG].col = Pixel2Col (x); |
1822 | rc[PART_BEG].row = Pixel2Row (y); |
1732 | rc[PART_BEG].row = Pixel2Row (y); |
… | |
… | |
1825 | rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); |
1735 | rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); |
1826 | |
1736 | |
1827 | /* sanity checks */ |
1737 | /* sanity checks */ |
1828 | for (i = PART_BEG; i < RC_COUNT; i++) |
1738 | for (i = PART_BEG; i < RC_COUNT; i++) |
1829 | { |
1739 | { |
1830 | MIN_IT (rc[i].col, ncol - 1); |
1740 | min_it (rc[i].col, ncol - 1); |
1831 | MIN_IT (rc[i].row, nrow - 1); |
1741 | min_it (rc[i].row, nrow - 1); |
1832 | } |
1742 | } |
1833 | |
1743 | |
1834 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1744 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1835 | fill_text (&drawn[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1745 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1836 | |
1746 | |
1837 | if (refresh) |
1747 | if (refresh) |
1838 | scr_refresh (SLOW_REFRESH); |
1748 | scr_refresh (SLOW_REFRESH); |
1839 | } |
1749 | } |
1840 | |
1750 | |
… | |
… | |
1941 | /* ARGSUSED */ |
1851 | /* ARGSUSED */ |
1942 | void |
1852 | void |
1943 | rxvt_term::scr_printscreen (int fullhist) |
1853 | rxvt_term::scr_printscreen (int fullhist) |
1944 | { |
1854 | { |
1945 | #ifdef PRINTPIPE |
1855 | #ifdef PRINTPIPE |
1946 | int i, r1, nrows, row_offset; |
1856 | int nrows, row_start; |
1947 | FILE *fd; |
1857 | FILE *fd; |
1948 | |
1858 | |
1949 | if ((fd = popen_printer ()) == NULL) |
1859 | if ((fd = popen_printer ()) == NULL) |
1950 | return; |
1860 | return; |
1951 | |
1861 | |
1952 | nrows = nrow; |
|
|
1953 | row_offset = saveLines; |
|
|
1954 | |
|
|
1955 | if (!fullhist) |
1862 | if (fullhist) |
1956 | row_offset -= view_start; |
1863 | { |
|
|
1864 | nrows = nrow + nsaved; |
|
|
1865 | row_start = -nsaved; |
|
|
1866 | } |
1957 | else |
1867 | else |
1958 | { |
1868 | { |
1959 | nrows += nsaved; |
1869 | nrows = nrow; |
1960 | row_offset -= nsaved; |
1870 | row_start = -view_start; |
1961 | } |
1871 | } |
1962 | |
1872 | |
1963 | wctomb (0, 0); |
1873 | wctomb (0, 0); |
1964 | |
1874 | |
1965 | for (r1 = 0; r1 < nrows; r1++) |
1875 | for (int r1 = 0; r1 < nrows; r1++) |
1966 | { |
1876 | { |
1967 | text_t *tp = save[r1 + row_offset].t; |
1877 | text_t *tp = ROW(r1).t; |
1968 | int len = save[r1 + row_offset].l; |
1878 | int len = ROW(r1).l; |
1969 | |
1879 | |
1970 | for (i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN |
1880 | for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN |
1971 | { |
1881 | { |
1972 | char mb[MB_LEN_MAX]; |
1882 | char mb[MB_LEN_MAX]; |
1973 | text_t t = *tp++; |
1883 | text_t t = *tp++; |
1974 | if (t == NOCHAR) |
1884 | if (t == NOCHAR) |
1975 | continue; |
1885 | continue; |
… | |
… | |
2003 | { |
1913 | { |
2004 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1914 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
2005 | showcursor; /* show the cursor */ |
1915 | showcursor; /* show the cursor */ |
2006 | int16_t col, row, /* column/row we're processing */ |
1916 | int16_t col, row, /* column/row we're processing */ |
2007 | ocrow; /* old cursor row */ |
1917 | ocrow; /* old cursor row */ |
2008 | int i, /* tmp */ |
1918 | int i; /* tmp */ |
2009 | row_offset; /* basic offset in screen structure */ |
|
|
2010 | #ifndef NO_CURSORCOLOR |
1919 | #ifndef NO_CURSORCOLOR |
2011 | rend_t cc1; /* store colours at cursor position (s) */ |
1920 | rend_t cc1; /* store colours at cursor position (s) */ |
2012 | #endif |
1921 | #endif |
2013 | rend_t *crp; // cursor rendition pointer |
1922 | rend_t *crp; // cursor rendition pointer |
2014 | |
1923 | |
… | |
… | |
2020 | /* |
1929 | /* |
2021 | * A: set up vars |
1930 | * A: set up vars |
2022 | */ |
1931 | */ |
2023 | must_clear = 0; |
1932 | must_clear = 0; |
2024 | refresh_count = 0; |
1933 | refresh_count = 0; |
2025 | |
|
|
2026 | row_offset = term_start - view_start; |
|
|
2027 | |
1934 | |
2028 | #if XPM_BACKGROUND |
1935 | #if XPM_BACKGROUND |
2029 | must_clear |= bgPixmap.pixmap != None; |
1936 | must_clear |= bgPixmap.pixmap != None; |
2030 | #endif |
1937 | #endif |
2031 | #if TRANSPARENT |
1938 | #if TRANSPARENT |
… | |
… | |
2101 | if (screen.cur.row + view_start != ocrow |
2008 | if (screen.cur.row + view_start != ocrow |
2102 | || screen.cur.col != oldcursor.col) |
2009 | || screen.cur.col != oldcursor.col) |
2103 | { |
2010 | { |
2104 | if (ocrow < nrow |
2011 | if (ocrow < nrow |
2105 | && oldcursor.col < ncol) |
2012 | && oldcursor.col < ncol) |
2106 | drawn[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2013 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2107 | |
2014 | |
2108 | if (focus || !showcursor) |
2015 | if (focus || !showcursor) |
2109 | oldcursor.row = -1; |
2016 | oldcursor.row = -1; |
2110 | else |
2017 | else |
2111 | setoldcursor = 1; |
2018 | setoldcursor = 1; |
… | |
… | |
2135 | * D: CopyArea pass - very useful for slower links |
2042 | * D: CopyArea pass - very useful for slower links |
2136 | * This has been deliberately kept simple. |
2043 | * This has been deliberately kept simple. |
2137 | */ |
2044 | */ |
2138 | i = num_scr; |
2045 | i = num_scr; |
2139 | if (!display->is_local |
2046 | if (!display->is_local |
2140 | && refresh_type == FAST_REFRESH && num_scr_allow && i |
2047 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2141 | && abs (i) < nrow && !must_clear) |
2048 | && abs (num_scr) < nrow && !must_clear) |
2142 | { |
2049 | { |
2143 | int16_t nits; |
2050 | int16_t nits; |
2144 | int j; |
2051 | int j; |
2145 | int len, wlen; |
2052 | int len, wlen; |
2146 | |
2053 | |
… | |
… | |
2149 | row = i > 0 ? 0 : j - 1; |
2056 | row = i > 0 ? 0 : j - 1; |
2150 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2057 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2151 | { |
2058 | { |
2152 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2059 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2153 | { |
2060 | { |
2154 | line_t s = save[(row + row_offset) % nlines]; |
2061 | line_t s = ROW(row - view_start); |
2155 | line_t d = drawn[row]; |
2062 | line_t d = drawn_buf[row]; |
2156 | line_t d2 = drawn[row + i]; |
2063 | line_t d2 = drawn_buf[row + i]; |
2157 | |
2064 | |
2158 | for (nits = 0, col = ncol; col--; ) |
2065 | for (nits = 0, col = ncol; col--; ) |
2159 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
2066 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
2160 | nits--; |
2067 | nits--; |
2161 | else if (s.t[col] != d.t[col] || s.r[col] != d.r[col]) |
2068 | else if (s.t[col] != d.t[col] || s.r[col] != d.r[col]) |
… | |
… | |
2179 | |
2086 | |
2180 | if (len != -1) |
2087 | if (len != -1) |
2181 | { |
2088 | { |
2182 | /* also comes here at end if needed because of >= above */ |
2089 | /* also comes here at end if needed because of >= above */ |
2183 | if (wlen < len) |
2090 | if (wlen < len) |
2184 | SWAP_IT (wlen, len, int); |
2091 | ::swap (wlen, len); |
2185 | |
2092 | |
2186 | XCopyArea (display->display, vt, vt, |
2093 | XCopyArea (display->display, vt, vt, |
2187 | gc, 0, Row2Pixel (len + i), |
2094 | gc, 0, Row2Pixel (len + i), |
2188 | (unsigned int)TermWin_TotalWidth (), |
2095 | (unsigned int)TermWin_TotalWidth (), |
2189 | (unsigned int)Height2Pixel (wlen - len + 1), |
2096 | (unsigned int)Height2Pixel (wlen - len + 1), |
… | |
… | |
2197 | /* |
2104 | /* |
2198 | * E: main pass across every character |
2105 | * E: main pass across every character |
2199 | */ |
2106 | */ |
2200 | for (row = 0; row < nrow; row++) |
2107 | for (row = 0; row < nrow; row++) |
2201 | { |
2108 | { |
2202 | text_t *stp = save[(row + row_offset) % total_rows].t; |
2109 | text_t *stp = ROW(row - view_start).t; |
2203 | rend_t *srp = save[(row + row_offset) % total_rows].r; |
2110 | rend_t *srp = ROW(row - view_start).r; |
2204 | text_t *dtp = drawn[row].t; |
2111 | text_t *dtp = drawn_buf[row].t; |
2205 | rend_t *drp = drawn[row].r; |
2112 | rend_t *drp = drawn_buf[row].r; |
2206 | |
2113 | |
2207 | /* |
2114 | /* |
2208 | * E2: OK, now the real pass |
2115 | * E2: OK, now the real pass |
2209 | */ |
2116 | */ |
2210 | int ypixel = (int)Row2Pixel (row); |
2117 | int ypixel = (int)Row2Pixel (row); |
… | |
… | |
2321 | fore = Color_UL; |
2228 | fore = Color_UL; |
2322 | #endif |
2229 | #endif |
2323 | |
2230 | |
2324 | if (invert) |
2231 | if (invert) |
2325 | { |
2232 | { |
2326 | SWAP_IT (fore, back, int); |
2233 | ::swap (fore, back); |
2327 | |
2234 | |
2328 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2235 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2329 | if (ISSET_PIXCOLOR (Color_RV)) |
2236 | if (ISSET_PIXCOLOR (Color_RV)) |
2330 | back = Color_RV; |
2237 | back = Color_RV; |
2331 | |
2238 | |
… | |
… | |
2423 | |
2330 | |
2424 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2331 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2425 | col--; |
2332 | col--; |
2426 | |
2333 | |
2427 | while (col + cursorwidth < ncol |
2334 | while (col + cursorwidth < ncol |
2428 | && drawn[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2335 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2429 | cursorwidth++; |
2336 | cursorwidth++; |
2430 | |
2337 | |
2431 | #ifndef NO_CURSORCOLOR |
2338 | #ifndef NO_CURSORCOLOR |
2432 | if (ISSET_PIXCOLOR (Color_cursor)) |
2339 | if (ISSET_PIXCOLOR (Color_cursor)) |
2433 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
2340 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
… | |
… | |
2465 | |
2372 | |
2466 | void |
2373 | void |
2467 | rxvt_term::scr_remap_chars () |
2374 | rxvt_term::scr_remap_chars () |
2468 | { |
2375 | { |
2469 | for (int i = total_rows; i--; ) |
2376 | for (int i = total_rows; i--; ) |
2470 | scr_remap_chars (save[i]); |
2377 | scr_remap_chars (row_buf [i]); |
2471 | |
2378 | |
2472 | for (int i = nrow; i--; ) |
2379 | for (int i = nrow; i--; ) |
2473 | { |
2380 | { |
2474 | scr_remap_chars (drawn[i]); |
2381 | scr_remap_chars (drawn_buf [i]); |
2475 | scr_remap_chars (swap_save[i]); |
2382 | scr_remap_chars (swap_buf [i]); |
2476 | } |
2383 | } |
2477 | } |
2384 | } |
2478 | |
2385 | |
2479 | void |
2386 | void |
2480 | rxvt_term::scr_recolour () |
2387 | rxvt_term::scr_recolour () |
… | |
… | |
2577 | char r1[] = "\n"; |
2484 | char r1[] = "\n"; |
2578 | |
2485 | |
2579 | for (row = saveLines - nsaved; |
2486 | for (row = saveLines - nsaved; |
2580 | row < saveLines + nrow - 1; row++) |
2487 | row < saveLines + nrow - 1; row++) |
2581 | { |
2488 | { |
2582 | width = save[row].l >= 0 ? save[row].l |
2489 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2583 | : ncol; |
2490 | : ncol; |
2584 | for (towrite = width; towrite; towrite -= wrote) |
2491 | for (towrite = width; towrite; towrite -= wrote) |
2585 | { |
2492 | { |
2586 | wrote = write (fd, & (save[row].t[width - towrite]), |
2493 | wrote = write (fd, & (row_buf[row].t[width - towrite]), |
2587 | towrite); |
2494 | towrite); |
2588 | if (wrote < 0) |
2495 | if (wrote < 0) |
2589 | return; /* XXX: death, no report */ |
2496 | return; /* XXX: death, no report */ |
2590 | } |
2497 | } |
2591 | if (save[row].l >= 0) |
2498 | if (row_buf[row].l >= 0) |
2592 | if (write (fd, r1, 1) <= 0) |
2499 | if (write (fd, r1, 1) <= 0) |
2593 | return; /* XXX: death, no report */ |
2500 | return; /* XXX: death, no report */ |
2594 | } |
2501 | } |
2595 | } |
2502 | } |
2596 | #endif |
2503 | #endif |
… | |
… | |
3073 | want_refresh = 1; |
2980 | want_refresh = 1; |
3074 | |
2981 | |
3075 | selection.mark.row = row - view_start; |
2982 | selection.mark.row = row - view_start; |
3076 | selection.mark.col = col; |
2983 | selection.mark.col = col; |
3077 | |
2984 | |
3078 | selection.mark.row = min (max (selection.mark.row, -nsaved), nrow - 1); |
2985 | selection.mark.row = clamp (selection.mark.row, -nsaved, nrow - 1); |
3079 | selection.mark.col = min (max (selection.mark.col, 0), ncol - 1); |
2986 | selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); |
3080 | |
2987 | |
3081 | while (selection.mark.col > 0 |
2988 | while (selection.mark.col > 0 |
3082 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
2989 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3083 | --selection.mark.col; |
2990 | --selection.mark.col; |
3084 | |
2991 | |
… | |
… | |
3189 | * flag == 2 ==> button 3 motion |
3096 | * flag == 2 ==> button 3 motion |
3190 | */ |
3097 | */ |
3191 | void |
3098 | void |
3192 | rxvt_term::selection_extend (int x, int y, int flag) |
3099 | rxvt_term::selection_extend (int x, int y, int flag) |
3193 | { |
3100 | { |
3194 | int col = min (max (Pixel2Col (x), 0), nrow - 1); |
3101 | int col = clamp (Pixel2Col (x), 0, ncol); |
3195 | int row = min (max (Pixel2Row (y), 0), ncol); |
3102 | int row = clamp (Pixel2Row (y), 0, nrow - 1); |
3196 | |
3103 | |
3197 | /* |
3104 | /* |
3198 | * If we're selecting characters (single click) then we must check first |
3105 | * If we're selecting characters (single click) then we must check first |
3199 | * if we are at the same place as the original mark. If we are then |
3106 | * if we are at the same place as the original mark. If we are then |
3200 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
3107 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
… | |
… | |
3371 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3278 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3372 | { |
3279 | { |
3373 | if (!ROW(end_row).is_longer ()) |
3280 | if (!ROW(end_row).is_longer ()) |
3374 | { |
3281 | { |
3375 | selection.end.row = end_row; |
3282 | selection.end.row = end_row; |
3376 | selection.end.col = save[end_row + saveLines].l; |
3283 | selection.end.col = ROW(end_row).l; |
3377 | selection_remove_trailing_spaces (); |
3284 | selection_remove_trailing_spaces (); |
3378 | break; |
3285 | break; |
3379 | } |
3286 | } |
3380 | } |
3287 | } |
3381 | } |
3288 | } |
… | |
… | |
3413 | } |
3320 | } |
3414 | } |
3321 | } |
3415 | |
3322 | |
3416 | #if ENABLE_FRILLS |
3323 | #if ENABLE_FRILLS |
3417 | if (selection.rect && selection.beg.col > selection.end.col) |
3324 | if (selection.rect && selection.beg.col > selection.end.col) |
3418 | SWAP_IT (selection.beg.col, selection.end.col, int); |
3325 | ::swap (selection.beg.col, selection.end.col); |
3419 | #endif |
3326 | #endif |
3420 | } |
3327 | } |
3421 | |
3328 | |
3422 | #if ENABLE_FRILLS |
3329 | #if ENABLE_FRILLS |
3423 | void |
3330 | void |
… | |
… | |
3621 | */ |
3528 | */ |
3622 | void |
3529 | void |
3623 | rxvt_term::pixel_position (int *x, int *y) |
3530 | rxvt_term::pixel_position (int *x, int *y) |
3624 | { |
3531 | { |
3625 | *x = Pixel2Col (*x); |
3532 | *x = Pixel2Col (*x); |
3626 | /* MAX_IT (*x, 0); MIN_IT (*x, (int)ncol - 1); */ |
3533 | /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ |
3627 | *y = Pixel2Row (*y); |
3534 | *y = Pixel2Row (*y); |
3628 | /* MAX_IT (*y, 0); MIN_IT (*y, (int)nrow - 1); */ |
3535 | /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ |
3629 | } |
3536 | } |
3630 | |
3537 | |
3631 | /* ------------------------------------------------------------------------- */ |
3538 | /* ------------------------------------------------------------------------- */ |
3632 | #ifdef USE_XIM |
3539 | #ifdef USE_XIM |
3633 | void |
3540 | void |
… | |
… | |
3655 | |
3562 | |
3656 | if (x < 0) x = ncol - w; |
3563 | if (x < 0) x = ncol - w; |
3657 | if (y < 0) y = nrow - h; |
3564 | if (y < 0) y = nrow - h; |
3658 | |
3565 | |
3659 | // make space for border |
3566 | // make space for border |
3660 | w += 2; MIN_IT (w, ncol); |
3567 | w += 2; min_it (w, ncol); |
3661 | h += 2; MIN_IT (h, nrow); |
3568 | h += 2; min_it (h, nrow); |
3662 | |
3569 | |
3663 | x -= 1; MAX_IT (x, 0); |
3570 | x -= 1; clamp_it (x, 0, ncol - w); |
3664 | y -= 1; MAX_IT (y, 0); |
3571 | y -= 1; clamp_it (y, 0, nrow - h); |
3665 | |
|
|
3666 | MIN_IT (x, ncol - w); |
|
|
3667 | MIN_IT (y, nrow - h); |
|
|
3668 | |
3572 | |
3669 | ov_x = x; ov_y = y; |
3573 | ov_x = x; ov_y = y; |
3670 | ov_w = w; ov_h = h; |
3574 | ov_w = w; ov_h = h; |
3671 | |
3575 | |
3672 | ov_text = new text_t *[h]; |
3576 | ov_text = new text_t *[h]; |