… | |
… | |
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); |
|
|
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 |
|
|
277 | int pend = MOD (term_start - nsaved , prev_total_rows); |
|
|
278 | int q = total_rows; // rewrapped row |
|
|
279 | |
|
|
280 | if (nsaved) |
|
|
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. |
|
|
284 | |
|
|
285 | row_col_t ocur = screen.cur; |
|
|
286 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
|
|
287 | |
271 | { |
288 | do |
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 | { |
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); |
|
|
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_ and put it into |
|
|
335 | // the topmost line of "long line" it was in, as |
|
|
336 | // this seems to upset applications/shells/readline |
|
|
337 | // least. |
|
|
338 | if (prow == ocur.row) |
|
|
339 | screen.cur.row = q - (total_rows - nrow); |
|
|
340 | |
|
|
341 | line_t &pline = old_buf [prow]; |
|
|
342 | |
384 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
343 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
385 | |
344 | |
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); |
345 | assert (len); |
|
|
346 | assert (pline.t); |
400 | |
347 | |
401 | memcpy (tp [qrow] + qcol, save[prow].t + pcol, len * sizeof (text_t)); |
348 | memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); |
402 | memcpy (rp [qrow] + qcol, save[prow].r + pcol, len * sizeof (rend_t)); |
349 | memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); |
403 | |
350 | |
404 | lofs += len; |
351 | lofs += len; |
405 | qcol += len; |
352 | qcol += len; |
406 | |
|
|
407 | if (qcol == ncol) |
|
|
408 | break; |
|
|
409 | } |
|
|
410 | } |
353 | } |
411 | else |
|
|
412 | lofs += ncol; |
|
|
413 | } |
354 | } |
|
|
355 | |
|
|
356 | qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0; |
|
|
357 | #ifdef DEBUG_STRICT //TODO//FIXME//TEMPORARY |
|
|
358 | if (qline->l < 0) |
|
|
359 | { |
|
|
360 | fprintf (stderr, "ERROR, PLEASE REPORT to rxvt-unicode@plan9.de: qline->l %d = llen %d < ncol %d ? %d : MOD %d\n", qline->l,llen,ncol,llen,MOD (llen - 1, ncol) + 1);//D |
|
|
361 | qline->l = 0; |
|
|
362 | } |
|
|
363 | #endif |
|
|
364 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
414 | } |
365 | } |
|
|
366 | while (p != pend && q > 0); |
|
|
367 | |
|
|
368 | term_start = total_rows - nrow; |
|
|
369 | nsaved = term_start - q; |
|
|
370 | |
|
|
371 | // make sure all terminal lines exist |
|
|
372 | while (nsaved < 0) |
|
|
373 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
|
|
374 | |
|
|
375 | } |
|
|
376 | else |
415 | } |
377 | { |
|
|
378 | // if no scrollback exists (yet), wing, instead of wrap |
|
|
379 | |
|
|
380 | for (int row = min (nrow, prev_nrow); row--; ) |
|
|
381 | { |
|
|
382 | line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; |
|
|
383 | line_t &qline = row_buf [row]; |
416 | |
384 | |
417 | free (screen.text); screen.text = tp; |
385 | qline = pline; |
418 | free (screen.rend); screen.rend = rp; |
386 | lresize (qline); |
419 | free (screen.tlen); screen.tlen = tl; |
387 | } |
420 | |
388 | |
421 | for (p = 0; p < total_rows; p++) printf ("P %p %d\n", save[p].t, save[p].l);//D |
389 | for (int row = prev_nrow; row < nrow; row++) |
|
|
390 | { |
|
|
391 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
|
|
392 | } |
|
|
393 | |
|
|
394 | term_start = 0; |
|
|
395 | } |
|
|
396 | |
|
|
397 | #ifdef DEBUG_STRICT //TODO: remove |
|
|
398 | for (int i = -nsaved; i < nrow; i++) |
|
|
399 | assert (ROW (i).t); |
422 | #endif |
400 | #endif |
|
|
401 | |
|
|
402 | free (old_buf); |
|
|
403 | delete old_ta; |
|
|
404 | delete old_ra; |
|
|
405 | |
|
|
406 | clamp_it (screen.cur.row, 0, nrow - 1); |
|
|
407 | clamp_it (screen.cur.col, 0, ncol - 1); |
423 | |
408 | |
424 | if (tabs) |
409 | if (tabs) |
425 | free (tabs); |
410 | free (tabs); |
426 | } |
411 | } |
427 | |
412 | |
428 | prev_nrow = nrow; |
413 | prev_nrow = nrow; |
429 | prev_ncol = ncol; |
414 | prev_ncol = ncol; |
430 | |
415 | |
431 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
416 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
432 | |
417 | |
433 | for (p = 0; p < ncol; p++) |
418 | for (int col = ncol; col--; ) |
434 | tabs[p] = (p % TABSIZE == 0) ? 1 : 0; |
419 | tabs [col] = col % TABSIZE == 0; |
435 | |
420 | |
436 | tt_winch (); |
421 | 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 | } |
422 | } |
447 | |
423 | |
448 | /* ------------------------------------------------------------------------- */ |
424 | /* ------------------------------------------------------------------------- */ |
449 | /* |
425 | /* |
450 | * Free everything. That way malloc debugging can find leakage. |
426 | * Free everything. That way malloc debugging can find leakage. |
… | |
… | |
453 | rxvt_term::scr_release () |
429 | rxvt_term::scr_release () |
454 | { |
430 | { |
455 | delete talloc; talloc = 0; |
431 | delete talloc; talloc = 0; |
456 | delete ralloc; ralloc = 0; |
432 | delete ralloc; ralloc = 0; |
457 | |
433 | |
458 | free (save); |
434 | free (row_buf); |
459 | free (swap_save); |
435 | free (swap_buf); |
460 | free (drawn); |
436 | free (drawn_buf); |
461 | free (buf); |
437 | free (temp_buf); |
462 | free (tabs); |
438 | free (tabs); |
|
|
439 | |
|
|
440 | row_buf = 0; // signal that we freed all the arrays |
463 | } |
441 | } |
464 | |
442 | |
465 | /* ------------------------------------------------------------------------- */ |
443 | /* ------------------------------------------------------------------------- */ |
466 | /* |
444 | /* |
467 | * Hard reset |
445 | * Hard reset |
… | |
… | |
518 | set_font_style (); |
496 | set_font_style (); |
519 | break; |
497 | break; |
520 | } |
498 | } |
521 | |
499 | |
522 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
500 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
523 | MIN_IT (s->cur.row, nrow - 1); |
501 | min_it (s->cur.row, nrow - 1); |
524 | MIN_IT (s->cur.col, ncol - 1); |
502 | min_it (s->cur.col, ncol - 1); |
525 | #ifdef DEBUG_STRICT |
503 | #ifdef DEBUG_STRICT |
526 | assert (s->cur.row >= 0); |
504 | assert (s->cur.row >= 0); |
527 | assert (s->cur.col >= 0); |
505 | 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 |
506 | #endif |
532 | } |
507 | } |
533 | |
508 | |
534 | /* ------------------------------------------------------------------------- */ |
509 | /* ------------------------------------------------------------------------- */ |
535 | /* |
510 | /* |
… | |
… | |
546 | if (current_screen == scrn) |
521 | if (current_screen == scrn) |
547 | return scrn; |
522 | return scrn; |
548 | |
523 | |
549 | selection_check (2); /* check for boundary cross */ |
524 | selection_check (2); /* check for boundary cross */ |
550 | |
525 | |
551 | SWAP_IT (scrn, current_screen, int); |
526 | int i = current_screen; current_screen = scrn; scrn = i; |
552 | |
527 | |
553 | SWAP_IT (screen.cur.row, swap.cur.row, int16_t); |
528 | ::swap (screen.cur.row, swap.cur.row); |
554 | SWAP_IT (screen.cur.col, swap.cur.col, int16_t); |
529 | ::swap (screen.cur.col, swap.cur.col); |
555 | MAX_IT (screen.cur.row, 0); |
530 | |
556 | MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); |
531 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
557 | MAX_IT (screen.cur.col, 0); |
532 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
558 | MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); |
|
|
559 | |
533 | |
560 | #if NSCREENS |
534 | #if NSCREENS |
561 | if (options & Opt_secondaryScreen) |
535 | if (options & Opt_secondaryScreen) |
562 | { |
536 | { |
563 | num_scr = 0; |
537 | num_scr = 0; |
564 | |
538 | |
565 | for (int i = nrow; i--; ) |
539 | for (int i = prev_nrow; i--; ) |
566 | SWAP_IT (ROW(i), swap_save[i], line_t); |
540 | ::swap (ROW(i), swap_buf [i]); |
567 | |
541 | |
568 | SWAP_IT (screen.charset, swap.charset, int16_t); |
542 | ::swap (screen.charset, swap.charset); |
569 | SWAP_IT (screen.flags, swap.flags, int); |
543 | ::swap (screen.flags, swap.flags); |
570 | screen.flags |= Screen_VisibleCursor; |
544 | screen.flags |= Screen_VisibleCursor; |
571 | swap.flags |= Screen_VisibleCursor; |
545 | swap.flags |= Screen_VisibleCursor; |
572 | } |
546 | } |
573 | else |
547 | else |
574 | #endif |
548 | #endif |
… | |
… | |
653 | { |
627 | { |
654 | selection.beg.row -= count; |
628 | selection.beg.row -= count; |
655 | selection.end.row -= count; |
629 | selection.end.row -= count; |
656 | selection.mark.row -= count; |
630 | selection.mark.row -= count; |
657 | |
631 | |
658 | selection_check (0); |
632 | if (selection.beg.row < -nsaved |
|
|
633 | || selection.end.row < -nsaved |
|
|
634 | || selection.mark.row < -nsaved) |
|
|
635 | { |
|
|
636 | CLEAR_ALL_SELECTION (); |
|
|
637 | selection.op = SELECTION_CLEAR; |
|
|
638 | } |
659 | } |
639 | } |
660 | |
640 | |
661 | for (int i = count; i--; ) |
641 | for (int i = count; i--; ) |
|
|
642 | { |
|
|
643 | ROW(row2 - i).l = 0; |
662 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
644 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
|
|
645 | } |
663 | |
646 | |
664 | if ((options & Opt_scrollWithBuffer) |
647 | if ((options & Opt_scrollWithBuffer) |
665 | && view_start != 0 |
648 | && view_start != 0 |
666 | && view_start != saveLines) |
649 | && view_start != saveLines) |
667 | scr_page (UP, count); |
650 | scr_page (UP, count); |
668 | } |
651 | } |
669 | else |
652 | else |
670 | { |
653 | { |
671 | if (selection.op && current_screen == selection.screen) |
654 | if (selection.op && current_screen == selection.screen) |
672 | { |
655 | { |
673 | int i = selection.beg.row; |
656 | if ((selection.beg.row < row1 && selection.end.row > row1) |
674 | int j = selection.end.row; |
657 | || (selection.beg.row < row2 && selection.end.row > row2) |
675 | |
|
|
676 | if ((i < row1 && j > row1) |
|
|
677 | || (i < row2 && j > row2) |
|
|
678 | || (i - count < row1 && i >= row1) |
658 | || (selection.beg.row - count < row1 && selection.beg.row >= row1) |
679 | || (i - count > row2 && i <= row2) |
659 | || (selection.beg.row - count > row2 && selection.beg.row <= row2) |
680 | || (j - count < row1 && j >= row1) |
660 | || (selection.end.row - count < row1 && selection.end.row >= row1) |
681 | || (j - count > row2 && j <= row2)) |
661 | || (selection.end.row - count > row2 && selection.end.row <= row2)) |
682 | { |
662 | { |
683 | CLEAR_ALL_SELECTION (); |
663 | CLEAR_ALL_SELECTION (); |
684 | selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
664 | selection.op = SELECTION_CLEAR; |
685 | } |
665 | } |
686 | else if (j >= row1 && j <= row2) |
666 | else if (selection.end.row >= row1 && selection.end.row <= row2) |
687 | { |
667 | { |
688 | /* move selected region too */ |
668 | /* move selected region too */ |
689 | selection.beg.row -= count; |
669 | selection.beg.row -= count; |
690 | selection.end.row -= count; |
670 | selection.end.row -= count; |
691 | selection.mark.row -= count; |
671 | selection.mark.row -= count; |
… | |
… | |
697 | // use a simple and robust scrolling algorithm, this |
677 | // use a simple and robust scrolling algorithm, this |
698 | // part of scr_scroll_text is not time-critical. |
678 | // part of scr_scroll_text is not time-critical. |
699 | |
679 | |
700 | int rows = row2 - row1 + 1; |
680 | int rows = row2 - row1 + 1; |
701 | |
681 | |
|
|
682 | min_it (count, rows); |
|
|
683 | |
702 | for (int row = 0; row < rows; row++) |
684 | for (int row = 0; row < rows; row++) |
703 | { |
685 | { |
704 | buf [row] = ROW(row1 + (row + count + rows) % rows); |
686 | temp_buf [row] = ROW(row1 + (row + count + rows) % rows); |
705 | |
687 | |
706 | if (!IN_RANGE_EXC (row + count, 0, rows)) |
688 | if (!IN_RANGE_EXC (row + count, 0, rows)) |
707 | scr_blank_screen_mem (buf [row], rstyle); |
689 | scr_blank_screen_mem (temp_buf [row], rstyle); |
708 | } |
690 | } |
709 | |
691 | |
710 | for (int row = 0; row < rows; row++) |
692 | for (int row = 0; row < rows; row++) |
711 | ROW(row1 + row) = buf [row]; |
693 | ROW(row1 + row) = temp_buf [row]; |
712 | } |
694 | } |
713 | |
695 | |
714 | return count; |
696 | return count; |
715 | } |
697 | } |
716 | |
698 | |
… | |
… | |
724 | if (len <= 0) /* sanity */ |
706 | if (len <= 0) /* sanity */ |
725 | return; |
707 | return; |
726 | |
708 | |
727 | unsigned char checksel; |
709 | unsigned char checksel; |
728 | unicode_t c; |
710 | unicode_t c; |
729 | int row, last_col; |
711 | int last_col; |
730 | const unicode_t *strend = str + len; |
712 | const unicode_t *strend = str + len; |
731 | |
713 | |
732 | want_refresh = 1; |
714 | want_refresh = 1; |
733 | ZERO_SCROLLBACK (); |
715 | ZERO_SCROLLBACK (); |
734 | last_col = ncol; |
716 | last_col = ncol; |
735 | |
717 | |
736 | if (nlines > 0) |
718 | if (nlines > 0) |
737 | { |
719 | { |
738 | nlines += screen.cur.row - screen.bscroll; |
720 | nlines += screen.cur.row - screen.bscroll; |
739 | if ((nlines > 0) |
721 | if (nlines > 0 |
740 | && (screen.tscroll == 0) |
722 | && screen.tscroll == 0 |
741 | && (screen.bscroll == (nrow - 1))) |
723 | && screen.bscroll == (nrow - 1)) |
742 | { |
724 | { |
743 | /* _at least_ this many lines need to be scrolled */ |
725 | /* _at least_ this many lines need to be scrolled */ |
744 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines); |
726 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines); |
745 | screen.cur.row -= nlines; |
727 | screen.cur.row -= nlines; |
746 | } |
728 | } |
747 | } |
729 | } |
748 | |
730 | |
749 | #ifdef DEBUG_STRICT |
731 | #ifdef DEBUG_STRICT |
750 | assert (screen.cur.col < last_col); |
732 | assert (screen.cur.col < last_col); |
751 | assert ((screen.cur.row < nrow) |
733 | assert (screen.cur.row < nrow |
752 | && (screen.cur.row >= - (int32_t)nsaved)); |
734 | && screen.cur.row >= -nsaved); |
753 | #else /* drive with your eyes closed */ |
|
|
754 | MIN_IT (screen.cur.col, last_col - 1); |
|
|
755 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
|
|
756 | MAX_IT (screen.cur.row, - (int32_t)nsaved); |
|
|
757 | #endif |
735 | #endif |
758 | row = screen.cur.row; |
736 | int row = screen.cur.row; |
759 | |
737 | |
760 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
738 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
761 | |
739 | |
762 | line_t *line = &ROW(row); |
740 | line_t *line = &ROW(row); |
763 | |
741 | |
… | |
… | |
765 | { |
743 | { |
766 | c = *str++; |
744 | c = *str++; |
767 | |
745 | |
768 | if (c < 0x20) |
746 | if (c < 0x20) |
769 | if (c == C0_LF) |
747 | if (c == C0_LF) |
770 | { |
748 | { |
771 | if (!line->is_longer ()) /* XXX: think about this */ |
749 | if (!line->is_longer ()) /* XXX: think about this */ |
772 | MAX_IT (line->l, screen.cur.col); |
750 | max_it (line->l, screen.cur.col); |
773 | |
751 | |
774 | screen.flags &= ~Screen_WrapNext; |
752 | screen.flags &= ~Screen_WrapNext; |
775 | |
753 | |
776 | if (screen.cur.row == screen.bscroll) |
754 | if (screen.cur.row == screen.bscroll) |
777 | scr_scroll_text (screen.tscroll, screen.bscroll, 1); |
755 | scr_scroll_text (screen.tscroll, screen.bscroll, 1); |
… | |
… | |
782 | continue; |
760 | continue; |
783 | } |
761 | } |
784 | else if (c == C0_CR) |
762 | else if (c == C0_CR) |
785 | { |
763 | { |
786 | if (!line->is_longer ()) /* XXX: think about this */ |
764 | if (!line->is_longer ()) /* XXX: think about this */ |
787 | MAX_IT (line->l, screen.cur.col); |
765 | max_it (line->l, screen.cur.col); |
788 | |
766 | |
789 | screen.flags &= ~Screen_WrapNext; |
767 | screen.flags &= ~Screen_WrapNext; |
790 | screen.cur.col = 0; |
768 | screen.cur.col = 0; |
791 | continue; |
769 | continue; |
792 | } |
770 | } |
… | |
… | |
968 | #endif |
946 | #endif |
969 | } |
947 | } |
970 | } |
948 | } |
971 | |
949 | |
972 | if (!line->is_longer ()) /* XXX: think about this */ |
950 | if (!line->is_longer ()) /* XXX: think about this */ |
973 | MAX_IT (line->l, screen.cur.col); |
951 | max_it (line->l, screen.cur.col); |
974 | |
952 | |
975 | #ifdef DEBUG_STRICT |
953 | #ifdef DEBUG_STRICT |
976 | assert (screen.cur.row >= 0); |
954 | assert (screen.cur.row >= 0); |
977 | #else /* drive with your eyes closed */ |
|
|
978 | MAX_IT (screen.cur.row, 0); |
|
|
979 | #endif |
955 | #endif |
980 | } |
956 | } |
981 | |
957 | |
982 | /* ------------------------------------------------------------------------- */ |
958 | /* ------------------------------------------------------------------------- */ |
983 | /* |
959 | /* |
… | |
… | |
1022 | |
998 | |
1023 | if (count == 0) |
999 | if (count == 0) |
1024 | return; |
1000 | return; |
1025 | else if (count > 0) |
1001 | else if (count > 0) |
1026 | { |
1002 | { |
1027 | int row = screen.cur.row; |
|
|
1028 | |
|
|
1029 | line_t &l = ROW(row); |
1003 | line_t &l = ROW(screen.cur.row); |
1030 | rend_t base_rend = l.r[i]; |
1004 | rend_t base_rend = l.r[i]; |
1031 | ht &= l.t[i] == ' '; |
1005 | ht &= l.t[i] == ' '; |
1032 | |
1006 | |
1033 | for (; ++i < ncol; ) |
1007 | for (; ++i < ncol; ) |
1034 | if (tabs[i]) |
1008 | if (tabs[i]) |
… | |
… | |
1049 | if (ht && options & Opt_pastableTabs) |
1023 | if (ht && options & Opt_pastableTabs) |
1050 | { |
1024 | { |
1051 | base_rend = SET_FONT (base_rend, 0); |
1025 | base_rend = SET_FONT (base_rend, 0); |
1052 | |
1026 | |
1053 | if (!l.is_longer ()) /* XXX: think about this */ |
1027 | if (!l.is_longer ()) /* XXX: think about this */ |
1054 | MAX_IT (l.l, x); |
1028 | max_it (l.l, x); |
1055 | |
1029 | |
1056 | i = screen.cur.col; |
1030 | i = screen.cur.col; |
1057 | |
1031 | |
1058 | l.t[i] = '\t'; |
1032 | l.t[i] = '\t'; |
1059 | l.r[i] = base_rend; |
1033 | l.r[i] = base_rend; |
… | |
… | |
1109 | */ |
1083 | */ |
1110 | #if ENABLE_FRILLS |
1084 | #if ENABLE_FRILLS |
1111 | void |
1085 | void |
1112 | rxvt_term::scr_forwardindex () |
1086 | rxvt_term::scr_forwardindex () |
1113 | { |
1087 | { |
1114 | int row; |
|
|
1115 | |
|
|
1116 | if (screen.cur.col < ncol - 1) |
1088 | if (screen.cur.col < ncol - 1) |
1117 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1089 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1118 | else |
1090 | else |
1119 | { |
1091 | { |
1120 | row = screen.cur.row; |
|
|
1121 | |
|
|
1122 | if (ROW(row).is_longer ()) //TODO//FIXME//LEN |
1092 | if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN |
1123 | ROW(row).l = ncol; |
1093 | ROW(screen.cur.row).l = ncol; |
1124 | |
1094 | |
1125 | scr_gotorc (0, 0, R_RELATIVE); |
1095 | scr_gotorc (0, 0, R_RELATIVE); |
1126 | scr_insdel_chars (1, DELETE); |
1096 | scr_insdel_chars (1, DELETE); |
1127 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1097 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1128 | } |
1098 | } |
… | |
… | |
1138 | { |
1108 | { |
1139 | want_refresh = 1; |
1109 | want_refresh = 1; |
1140 | ZERO_SCROLLBACK (); |
1110 | ZERO_SCROLLBACK (); |
1141 | |
1111 | |
1142 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1112 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1143 | MAX_IT (screen.cur.col, 0); |
1113 | clamp_it (screen.cur.col, 0, ncol - 1); |
1144 | MIN_IT (screen.cur.col, (int32_t)ncol - 1); |
|
|
1145 | |
1114 | |
1146 | screen.flags &= ~Screen_WrapNext; |
1115 | screen.flags &= ~Screen_WrapNext; |
1147 | |
1116 | |
1148 | if (relative & R_RELATIVE) |
1117 | if (relative & R_RELATIVE) |
1149 | { |
1118 | { |
… | |
… | |
1167 | else |
1136 | else |
1168 | { |
1137 | { |
1169 | if (screen.flags & Screen_Relative) |
1138 | if (screen.flags & Screen_Relative) |
1170 | { /* relative origin mode */ |
1139 | { /* relative origin mode */ |
1171 | screen.cur.row = row + screen.tscroll; |
1140 | screen.cur.row = row + screen.tscroll; |
1172 | MIN_IT (screen.cur.row, screen.bscroll); |
1141 | min_it (screen.cur.row, screen.bscroll); |
1173 | } |
1142 | } |
1174 | else |
1143 | else |
1175 | screen.cur.row = row; |
1144 | screen.cur.row = row; |
1176 | } |
1145 | } |
1177 | |
1146 | |
1178 | MAX_IT (screen.cur.row, 0); |
1147 | clamp_it (screen.cur.row, 0, nrow - 1); |
1179 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
|
|
1180 | } |
1148 | } |
1181 | |
1149 | |
1182 | /* ------------------------------------------------------------------------- */ |
1150 | /* ------------------------------------------------------------------------- */ |
1183 | /* |
1151 | /* |
1184 | * direction should be UP or DN |
1152 | * direction should be UP or DN |
… | |
… | |
1199 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1167 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1200 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn); |
1168 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn); |
1201 | else |
1169 | else |
1202 | screen.cur.row += dirn; |
1170 | screen.cur.row += dirn; |
1203 | |
1171 | |
1204 | MAX_IT (screen.cur.row, 0); |
1172 | clamp_it (screen.cur.row, 0, nrow - 1); |
1205 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
|
|
1206 | selection_check (0); |
1173 | selection_check (0); |
1207 | } |
1174 | } |
1208 | |
1175 | |
1209 | /* ------------------------------------------------------------------------- */ |
1176 | /* ------------------------------------------------------------------------- */ |
1210 | /* |
1177 | /* |
… | |
… | |
1214 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1181 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1215 | */ |
1182 | */ |
1216 | void |
1183 | void |
1217 | rxvt_term::scr_erase_line (int mode) |
1184 | rxvt_term::scr_erase_line (int mode) |
1218 | { |
1185 | { |
1219 | unsigned int row, col, num; |
1186 | unsigned int col, num; |
1220 | |
1187 | |
1221 | want_refresh = 1; |
1188 | want_refresh = 1; |
1222 | ZERO_SCROLLBACK (); |
1189 | ZERO_SCROLLBACK (); |
1223 | |
1190 | |
1224 | selection_check (1); |
1191 | selection_check (1); |
1225 | |
1192 | |
1226 | row = screen.cur.row; |
1193 | line_t &line = ROW(screen.cur.row); |
1227 | |
1194 | |
1228 | switch (mode) |
1195 | switch (mode) |
1229 | { |
1196 | { |
1230 | case 0: /* erase to end of line */ |
1197 | case 0: /* erase to end of line */ |
1231 | col = screen.cur.col; |
1198 | col = screen.cur.col; |
1232 | num = ncol - col; |
1199 | num = ncol - col; |
1233 | MIN_IT (ROW(row).l, (int16_t)col); |
1200 | min_it (line.l, col); |
1234 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1201 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1235 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1202 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1236 | CLEAR_SELECTION (); |
1203 | CLEAR_SELECTION (); |
1237 | break; |
1204 | break; |
1238 | case 1: /* erase to beginning of line */ |
1205 | case 1: /* erase to beginning of line */ |
… | |
… | |
1243 | CLEAR_SELECTION (); |
1210 | CLEAR_SELECTION (); |
1244 | break; |
1211 | break; |
1245 | case 2: /* erase whole line */ |
1212 | case 2: /* erase whole line */ |
1246 | col = 0; |
1213 | col = 0; |
1247 | num = ncol; |
1214 | num = ncol; |
1248 | ROW(row).l = 0; |
1215 | line.l = 0; |
1249 | if (selection.beg.row <= screen.cur.row |
1216 | if (selection.beg.row <= screen.cur.row |
1250 | && selection.end.row >= screen.cur.row) |
1217 | && selection.end.row >= screen.cur.row) |
1251 | CLEAR_SELECTION (); |
1218 | CLEAR_SELECTION (); |
1252 | break; |
1219 | break; |
1253 | default: |
1220 | default: |
1254 | return; |
1221 | return; |
1255 | } |
1222 | } |
1256 | |
1223 | |
1257 | scr_blank_line (ROW(row), col, num, rstyle); |
1224 | scr_blank_line (line, col, num, rstyle); |
1258 | } |
1225 | } |
1259 | |
1226 | |
1260 | /* ------------------------------------------------------------------------- */ |
1227 | /* ------------------------------------------------------------------------- */ |
1261 | /* |
1228 | /* |
1262 | * Erase part of whole of the screen |
1229 | * Erase part of whole of the screen |
… | |
… | |
1305 | CLEAR_SELECTION (); |
1272 | CLEAR_SELECTION (); |
1306 | |
1273 | |
1307 | if (row >= nrow) /* Out Of Bounds */ |
1274 | if (row >= nrow) /* Out Of Bounds */ |
1308 | return; |
1275 | return; |
1309 | |
1276 | |
1310 | MIN_IT (num, (nrow - row)); |
1277 | min_it (num, nrow - row); |
1311 | |
1278 | |
1312 | if (rstyle & (RS_RVid | RS_Uline)) |
1279 | if (rstyle & (RS_RVid | RS_Uline)) |
1313 | ren = (rend_t) ~RS_None; |
1280 | ren = (rend_t) ~RS_None; |
1314 | else if (GET_BASEBG (rstyle) == Color_bg) |
1281 | else if (GET_BASEBG (rstyle) == Color_bg) |
1315 | { |
1282 | { |
… | |
… | |
1326 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1293 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1327 | } |
1294 | } |
1328 | |
1295 | |
1329 | for (; num--; row++) |
1296 | for (; num--; row++) |
1330 | { |
1297 | { |
|
|
1298 | ROW (row).l = 0; |
1331 | scr_blank_screen_mem (ROW (row), rstyle); |
1299 | scr_blank_screen_mem (ROW (row), rstyle); |
1332 | ROW (row).l = 0; |
|
|
1333 | scr_blank_line (drawn[row], 0, ncol, ren); |
1300 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1334 | } |
1301 | } |
1335 | } |
1302 | } |
1336 | |
1303 | |
1337 | #if ENABLE_FRILLS |
1304 | #if ENABLE_FRILLS |
1338 | void |
1305 | void |
… | |
… | |
1423 | return; |
1390 | return; |
1424 | |
1391 | |
1425 | scr_do_wrap (); |
1392 | scr_do_wrap (); |
1426 | |
1393 | |
1427 | selection_check (1); |
1394 | selection_check (1); |
1428 | MIN_IT (count, (ncol - screen.cur.col)); |
1395 | min_it (count, ncol - screen.cur.col); |
1429 | |
1396 | |
1430 | row = screen.cur.row; |
1397 | row = screen.cur.row; |
1431 | |
1398 | |
1432 | line_t *line = &ROW(row); |
1399 | line_t *line = &ROW(row); |
1433 | |
1400 | |
… | |
… | |
1441 | } |
1408 | } |
1442 | |
1409 | |
1443 | if (!line->is_longer ()) |
1410 | if (!line->is_longer ()) |
1444 | { |
1411 | { |
1445 | line->l += count; |
1412 | line->l += count; |
1446 | MIN_IT (line->l, ncol); |
1413 | min_it (line->l, ncol); |
1447 | } |
1414 | } |
1448 | |
1415 | |
1449 | if (selection.op && current_screen == selection.screen |
1416 | if (selection.op && current_screen == selection.screen |
1450 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1417 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1451 | { |
1418 | { |
… | |
… | |
1512 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1479 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1513 | */ |
1480 | */ |
1514 | void |
1481 | void |
1515 | rxvt_term::scr_scroll_region (int top, int bot) |
1482 | rxvt_term::scr_scroll_region (int top, int bot) |
1516 | { |
1483 | { |
1517 | MAX_IT (top, 0); |
1484 | max_it (top, 0); |
1518 | MIN_IT (bot, (int)nrow - 1); |
1485 | min_it (bot, nrow - 1); |
1519 | |
1486 | |
1520 | if (top > bot) |
1487 | if (top > bot) |
1521 | return; |
1488 | return; |
1522 | |
1489 | |
1523 | screen.tscroll = top; |
1490 | screen.tscroll = top; |
… | |
… | |
1621 | XGCValues gcvalue; |
1588 | XGCValues gcvalue; |
1622 | |
1589 | |
1623 | if (rvideo != mode) |
1590 | if (rvideo != mode) |
1624 | { |
1591 | { |
1625 | rvideo = mode; |
1592 | rvideo = mode; |
1626 | SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); |
1593 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1627 | #if XPM_BACKGROUND |
1594 | #if XPM_BACKGROUND |
1628 | if (bgPixmap.pixmap == None) |
1595 | if (bgPixmap.pixmap == None) |
1629 | #endif |
1596 | #endif |
1630 | #if TRANSPARENT |
1597 | #if TRANSPARENT |
1631 | if (! (options & Opt_transparent) || am_transparent == 0) |
1598 | if (! (options & Opt_transparent) || am_transparent == 0) |
… | |
… | |
1727 | bool found = false; |
1694 | bool found = false; |
1728 | |
1695 | |
1729 | for (int i = 0; i < nrow; i++) |
1696 | for (int i = 0; i < nrow; i++) |
1730 | { |
1697 | { |
1731 | int col = 0; |
1698 | int col = 0; |
1732 | rend_t *drp = drawn[i].r; |
1699 | rend_t *drp = drawn_buf[i].r; |
1733 | |
1700 | |
1734 | for (; col < ncol; col++, drp++) |
1701 | for (; col < ncol; col++, drp++) |
1735 | if ((*drp & mask) == value) |
1702 | if ((*drp & mask) == value) |
1736 | { |
1703 | { |
1737 | found = true; |
1704 | found = true; |
… | |
… | |
1755 | rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) |
1722 | rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) |
1756 | { |
1723 | { |
1757 | int i; |
1724 | int i; |
1758 | row_col_t rc[RC_COUNT]; |
1725 | row_col_t rc[RC_COUNT]; |
1759 | |
1726 | |
1760 | if (!drawn) /* sanity check */ |
1727 | if (!drawn_buf) /* sanity check */ |
1761 | return; |
1728 | return; |
1762 | |
1729 | |
1763 | #ifndef NO_SLOW_LINK_SUPPORT |
1730 | #ifndef NO_SLOW_LINK_SUPPORT |
1764 | if (refresh_type == FAST_REFRESH && !display->is_local) |
1731 | if (refresh_type == FAST_REFRESH && !display->is_local) |
1765 | { |
1732 | { |
1766 | y = 0; |
1733 | y = 0; |
1767 | eheight = height; |
1734 | eheight = height; |
1768 | } |
1735 | } |
1769 | #endif |
|
|
1770 | |
|
|
1771 | #ifdef DEBUG_STRICT |
|
|
1772 | x = max (x, 0); |
|
|
1773 | x = min (x, (int)width); |
|
|
1774 | y = max (y, 0); |
|
|
1775 | y = min (y, (int)height); |
|
|
1776 | #endif |
1736 | #endif |
1777 | |
1737 | |
1778 | /* round down */ |
1738 | /* round down */ |
1779 | rc[PART_BEG].col = Pixel2Col (x); |
1739 | rc[PART_BEG].col = Pixel2Col (x); |
1780 | rc[PART_BEG].row = Pixel2Row (y); |
1740 | rc[PART_BEG].row = Pixel2Row (y); |
… | |
… | |
1783 | rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); |
1743 | rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); |
1784 | |
1744 | |
1785 | /* sanity checks */ |
1745 | /* sanity checks */ |
1786 | for (i = PART_BEG; i < RC_COUNT; i++) |
1746 | for (i = PART_BEG; i < RC_COUNT; i++) |
1787 | { |
1747 | { |
1788 | MIN_IT (rc[i].col, ncol - 1); |
1748 | min_it (rc[i].col, ncol - 1); |
1789 | MIN_IT (rc[i].row, nrow - 1); |
1749 | min_it (rc[i].row, nrow - 1); |
1790 | } |
1750 | } |
1791 | |
1751 | |
1792 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1752 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1793 | fill_text (&drawn[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1753 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1794 | |
1754 | |
1795 | if (refresh) |
1755 | if (refresh) |
1796 | scr_refresh (SLOW_REFRESH); |
1756 | scr_refresh (SLOW_REFRESH); |
1797 | } |
1757 | } |
1798 | |
1758 | |
… | |
… | |
1961 | { |
1921 | { |
1962 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1922 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1963 | showcursor; /* show the cursor */ |
1923 | showcursor; /* show the cursor */ |
1964 | int16_t col, row, /* column/row we're processing */ |
1924 | int16_t col, row, /* column/row we're processing */ |
1965 | ocrow; /* old cursor row */ |
1925 | ocrow; /* old cursor row */ |
1966 | int i, /* tmp */ |
1926 | int i; /* tmp */ |
1967 | row_offset; /* basic offset in screen structure */ |
|
|
1968 | #ifndef NO_CURSORCOLOR |
1927 | #ifndef NO_CURSORCOLOR |
1969 | rend_t cc1; /* store colours at cursor position (s) */ |
1928 | rend_t cc1; /* store colours at cursor position (s) */ |
1970 | #endif |
1929 | #endif |
1971 | rend_t *crp; // cursor rendition pointer |
1930 | rend_t *crp; // cursor rendition pointer |
1972 | |
1931 | |
… | |
… | |
1978 | /* |
1937 | /* |
1979 | * A: set up vars |
1938 | * A: set up vars |
1980 | */ |
1939 | */ |
1981 | must_clear = 0; |
1940 | must_clear = 0; |
1982 | refresh_count = 0; |
1941 | refresh_count = 0; |
1983 | |
|
|
1984 | row_offset = term_start - view_start; |
|
|
1985 | |
1942 | |
1986 | #if XPM_BACKGROUND |
1943 | #if XPM_BACKGROUND |
1987 | must_clear |= bgPixmap.pixmap != None; |
1944 | must_clear |= bgPixmap.pixmap != None; |
1988 | #endif |
1945 | #endif |
1989 | #if TRANSPARENT |
1946 | #if TRANSPARENT |
… | |
… | |
2059 | if (screen.cur.row + view_start != ocrow |
2016 | if (screen.cur.row + view_start != ocrow |
2060 | || screen.cur.col != oldcursor.col) |
2017 | || screen.cur.col != oldcursor.col) |
2061 | { |
2018 | { |
2062 | if (ocrow < nrow |
2019 | if (ocrow < nrow |
2063 | && oldcursor.col < ncol) |
2020 | && oldcursor.col < ncol) |
2064 | drawn[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2021 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2065 | |
2022 | |
2066 | if (focus || !showcursor) |
2023 | if (focus || !showcursor) |
2067 | oldcursor.row = -1; |
2024 | oldcursor.row = -1; |
2068 | else |
2025 | else |
2069 | setoldcursor = 1; |
2026 | setoldcursor = 1; |
… | |
… | |
2107 | row = i > 0 ? 0 : j - 1; |
2064 | row = i > 0 ? 0 : j - 1; |
2108 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2065 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2109 | { |
2066 | { |
2110 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2067 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2111 | { |
2068 | { |
2112 | line_t s = save[(row + row_offset) % total_rows]; |
2069 | line_t s = ROW(row - view_start); |
2113 | line_t d = drawn[row]; |
2070 | line_t d = drawn_buf[row]; |
2114 | line_t d2 = drawn[row + i]; |
2071 | line_t d2 = drawn_buf[row + i]; |
2115 | |
2072 | |
2116 | for (nits = 0, col = ncol; col--; ) |
2073 | for (nits = 0, col = ncol; col--; ) |
2117 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
2074 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
2118 | nits--; |
2075 | nits--; |
2119 | else if (s.t[col] != d.t[col] || s.r[col] != d.r[col]) |
2076 | else if (s.t[col] != d.t[col] || s.r[col] != d.r[col]) |
… | |
… | |
2137 | |
2094 | |
2138 | if (len != -1) |
2095 | if (len != -1) |
2139 | { |
2096 | { |
2140 | /* also comes here at end if needed because of >= above */ |
2097 | /* also comes here at end if needed because of >= above */ |
2141 | if (wlen < len) |
2098 | if (wlen < len) |
2142 | SWAP_IT (wlen, len, int); |
2099 | ::swap (wlen, len); |
2143 | |
2100 | |
2144 | XCopyArea (display->display, vt, vt, |
2101 | XCopyArea (display->display, vt, vt, |
2145 | gc, 0, Row2Pixel (len + i), |
2102 | gc, 0, Row2Pixel (len + i), |
2146 | (unsigned int)TermWin_TotalWidth (), |
2103 | (unsigned int)TermWin_TotalWidth (), |
2147 | (unsigned int)Height2Pixel (wlen - len + 1), |
2104 | (unsigned int)Height2Pixel (wlen - len + 1), |
… | |
… | |
2155 | /* |
2112 | /* |
2156 | * E: main pass across every character |
2113 | * E: main pass across every character |
2157 | */ |
2114 | */ |
2158 | for (row = 0; row < nrow; row++) |
2115 | for (row = 0; row < nrow; row++) |
2159 | { |
2116 | { |
2160 | text_t *stp = save[(row + row_offset) % total_rows].t; |
2117 | text_t *stp = ROW(row - view_start).t; |
2161 | rend_t *srp = save[(row + row_offset) % total_rows].r; |
2118 | rend_t *srp = ROW(row - view_start).r; |
2162 | text_t *dtp = drawn[row].t; |
2119 | text_t *dtp = drawn_buf[row].t; |
2163 | rend_t *drp = drawn[row].r; |
2120 | rend_t *drp = drawn_buf[row].r; |
2164 | |
2121 | |
2165 | /* |
2122 | /* |
2166 | * E2: OK, now the real pass |
2123 | * E2: OK, now the real pass |
2167 | */ |
2124 | */ |
2168 | int ypixel = (int)Row2Pixel (row); |
2125 | int ypixel = (int)Row2Pixel (row); |
… | |
… | |
2233 | * Determine the attributes for the string |
2190 | * Determine the attributes for the string |
2234 | */ |
2191 | */ |
2235 | int fore = GET_FGCOLOR (rend); // desired foreground |
2192 | int fore = GET_FGCOLOR (rend); // desired foreground |
2236 | int back = GET_BGCOLOR (rend); // desired background |
2193 | int back = GET_BGCOLOR (rend); // desired background |
2237 | |
2194 | |
2238 | // only do special processing if any attributes are set, which is rare |
2195 | // only do special processing if any attributes are set, which is unlikely |
2239 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2196 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2240 | { |
2197 | { |
2241 | #if ENABLE_STYLES |
2198 | #if ENABLE_STYLES |
2242 | // force redraw after "careful" characters to avoid pixel droppings |
2199 | // force redraw after "careful" characters to avoid pixel droppings |
2243 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
2200 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
… | |
… | |
2279 | fore = Color_UL; |
2236 | fore = Color_UL; |
2280 | #endif |
2237 | #endif |
2281 | |
2238 | |
2282 | if (invert) |
2239 | if (invert) |
2283 | { |
2240 | { |
2284 | SWAP_IT (fore, back, int); |
2241 | ::swap (fore, back); |
2285 | |
2242 | |
2286 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2243 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2287 | if (ISSET_PIXCOLOR (Color_RV)) |
2244 | if (ISSET_PIXCOLOR (Color_RV)) |
2288 | back = Color_RV; |
2245 | back = Color_RV; |
2289 | |
2246 | |
… | |
… | |
2381 | |
2338 | |
2382 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2339 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2383 | col--; |
2340 | col--; |
2384 | |
2341 | |
2385 | while (col + cursorwidth < ncol |
2342 | while (col + cursorwidth < ncol |
2386 | && drawn[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2343 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2387 | cursorwidth++; |
2344 | cursorwidth++; |
2388 | |
2345 | |
2389 | #ifndef NO_CURSORCOLOR |
2346 | #ifndef NO_CURSORCOLOR |
2390 | if (ISSET_PIXCOLOR (Color_cursor)) |
2347 | if (ISSET_PIXCOLOR (Color_cursor)) |
2391 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
2348 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
… | |
… | |
2423 | |
2380 | |
2424 | void |
2381 | void |
2425 | rxvt_term::scr_remap_chars () |
2382 | rxvt_term::scr_remap_chars () |
2426 | { |
2383 | { |
2427 | for (int i = total_rows; i--; ) |
2384 | for (int i = total_rows; i--; ) |
2428 | scr_remap_chars (save[i]); |
2385 | scr_remap_chars (row_buf [i]); |
2429 | |
2386 | |
2430 | for (int i = nrow; i--; ) |
2387 | for (int i = nrow; i--; ) |
2431 | { |
2388 | { |
2432 | scr_remap_chars (drawn[i]); |
2389 | scr_remap_chars (drawn_buf [i]); |
2433 | scr_remap_chars (swap_save[i]); |
2390 | scr_remap_chars (swap_buf [i]); |
2434 | } |
2391 | } |
2435 | } |
2392 | } |
2436 | |
2393 | |
2437 | void |
2394 | void |
2438 | rxvt_term::scr_recolour () |
2395 | rxvt_term::scr_recolour () |
… | |
… | |
2505 | row = selection.beg.row; |
2462 | row = selection.beg.row; |
2506 | } |
2463 | } |
2507 | else |
2464 | else |
2508 | { |
2465 | { |
2509 | col = 0; |
2466 | col = 0; |
2510 | row = view_start; |
2467 | row = -view_start; |
2511 | } |
2468 | } |
2512 | |
2469 | |
2513 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2470 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2514 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2471 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2515 | srp[col] ^= RS_RVid; |
2472 | srp[col] ^= RS_RVid; |
… | |
… | |
2535 | char r1[] = "\n"; |
2492 | char r1[] = "\n"; |
2536 | |
2493 | |
2537 | for (row = saveLines - nsaved; |
2494 | for (row = saveLines - nsaved; |
2538 | row < saveLines + nrow - 1; row++) |
2495 | row < saveLines + nrow - 1; row++) |
2539 | { |
2496 | { |
2540 | width = save[row].l >= 0 ? save[row].l |
2497 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2541 | : ncol; |
2498 | : ncol; |
2542 | for (towrite = width; towrite; towrite -= wrote) |
2499 | for (towrite = width; towrite; towrite -= wrote) |
2543 | { |
2500 | { |
2544 | wrote = write (fd, & (save[row].t[width - towrite]), |
2501 | wrote = write (fd, & (row_buf[row].t[width - towrite]), |
2545 | towrite); |
2502 | towrite); |
2546 | if (wrote < 0) |
2503 | if (wrote < 0) |
2547 | return; /* XXX: death, no report */ |
2504 | return; /* XXX: death, no report */ |
2548 | } |
2505 | } |
2549 | if (save[row].l >= 0) |
2506 | if (row_buf[row].l >= 0) |
2550 | if (write (fd, r1, 1) <= 0) |
2507 | if (write (fd, r1, 1) <= 0) |
2551 | return; /* XXX: death, no report */ |
2508 | return; /* XXX: death, no report */ |
2552 | } |
2509 | } |
2553 | } |
2510 | } |
2554 | #endif |
2511 | #endif |
… | |
… | |
3031 | want_refresh = 1; |
2988 | want_refresh = 1; |
3032 | |
2989 | |
3033 | selection.mark.row = row - view_start; |
2990 | selection.mark.row = row - view_start; |
3034 | selection.mark.col = col; |
2991 | selection.mark.col = col; |
3035 | |
2992 | |
3036 | selection.mark.row = min (max (selection.mark.row, -nsaved), nrow - 1); |
2993 | selection.mark.row = clamp (selection.mark.row, -nsaved, nrow - 1); |
3037 | selection.mark.col = min (max (selection.mark.col, 0), ncol - 1); |
2994 | selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); |
3038 | |
2995 | |
3039 | while (selection.mark.col > 0 |
2996 | while (selection.mark.col > 0 |
3040 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
2997 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3041 | --selection.mark.col; |
2998 | --selection.mark.col; |
3042 | |
2999 | |
… | |
… | |
3147 | * flag == 2 ==> button 3 motion |
3104 | * flag == 2 ==> button 3 motion |
3148 | */ |
3105 | */ |
3149 | void |
3106 | void |
3150 | rxvt_term::selection_extend (int x, int y, int flag) |
3107 | rxvt_term::selection_extend (int x, int y, int flag) |
3151 | { |
3108 | { |
3152 | int col = min (max (Pixel2Col (x), 0), nrow - 1); |
3109 | int col = clamp (Pixel2Col (x), 0, ncol); |
3153 | int row = min (max (Pixel2Row (y), 0), ncol); |
3110 | int row = clamp (Pixel2Row (y), 0, nrow - 1); |
3154 | |
3111 | |
3155 | /* |
3112 | /* |
3156 | * If we're selecting characters (single click) then we must check first |
3113 | * If we're selecting characters (single click) then we must check first |
3157 | * if we are at the same place as the original mark. If we are then |
3114 | * if we are at the same place as the original mark. If we are then |
3158 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
3115 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
… | |
… | |
3371 | } |
3328 | } |
3372 | } |
3329 | } |
3373 | |
3330 | |
3374 | #if ENABLE_FRILLS |
3331 | #if ENABLE_FRILLS |
3375 | if (selection.rect && selection.beg.col > selection.end.col) |
3332 | if (selection.rect && selection.beg.col > selection.end.col) |
3376 | SWAP_IT (selection.beg.col, selection.end.col, int); |
3333 | ::swap (selection.beg.col, selection.end.col); |
3377 | #endif |
3334 | #endif |
3378 | } |
3335 | } |
3379 | |
3336 | |
3380 | #if ENABLE_FRILLS |
3337 | #if ENABLE_FRILLS |
3381 | void |
3338 | void |
… | |
… | |
3579 | */ |
3536 | */ |
3580 | void |
3537 | void |
3581 | rxvt_term::pixel_position (int *x, int *y) |
3538 | rxvt_term::pixel_position (int *x, int *y) |
3582 | { |
3539 | { |
3583 | *x = Pixel2Col (*x); |
3540 | *x = Pixel2Col (*x); |
3584 | /* MAX_IT (*x, 0); MIN_IT (*x, (int)ncol - 1); */ |
3541 | /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ |
3585 | *y = Pixel2Row (*y); |
3542 | *y = Pixel2Row (*y); |
3586 | /* MAX_IT (*y, 0); MIN_IT (*y, (int)nrow - 1); */ |
3543 | /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ |
3587 | } |
3544 | } |
3588 | |
3545 | |
3589 | /* ------------------------------------------------------------------------- */ |
3546 | /* ------------------------------------------------------------------------- */ |
3590 | #ifdef USE_XIM |
3547 | #ifdef USE_XIM |
3591 | void |
3548 | void |
… | |
… | |
3613 | |
3570 | |
3614 | if (x < 0) x = ncol - w; |
3571 | if (x < 0) x = ncol - w; |
3615 | if (y < 0) y = nrow - h; |
3572 | if (y < 0) y = nrow - h; |
3616 | |
3573 | |
3617 | // make space for border |
3574 | // make space for border |
3618 | w += 2; MIN_IT (w, ncol); |
3575 | w += 2; min_it (w, ncol); |
3619 | h += 2; MIN_IT (h, nrow); |
3576 | h += 2; min_it (h, nrow); |
3620 | |
3577 | |
3621 | x -= 1; MAX_IT (x, 0); |
3578 | x -= 1; clamp_it (x, 0, ncol - w); |
3622 | y -= 1; MAX_IT (y, 0); |
3579 | y -= 1; clamp_it (y, 0, nrow - h); |
3623 | |
|
|
3624 | MIN_IT (x, ncol - w); |
|
|
3625 | MIN_IT (y, nrow - h); |
|
|
3626 | |
3580 | |
3627 | ov_x = x; ov_y = y; |
3581 | ov_x = x; ov_y = y; |
3628 | ov_w = w; ov_h = h; |
3582 | ov_w = w; ov_h = h; |
3629 | |
3583 | |
3630 | ov_text = new text_t *[h]; |
3584 | ov_text = new text_t *[h]; |
… | |
… | |
3722 | for (int y = ov_h; y--; ) |
3676 | for (int y = ov_h; y--; ) |
3723 | { |
3677 | { |
3724 | text_t *t1 = ov_text[y]; |
3678 | text_t *t1 = ov_text[y]; |
3725 | rend_t *r1 = ov_rend[y]; |
3679 | rend_t *r1 = ov_rend[y]; |
3726 | |
3680 | |
3727 | text_t *t2 = ROW(y - view_start).t + ov_x; |
3681 | text_t *t2 = ROW(y + ov_y - view_start).t + ov_x; |
3728 | rend_t *r2 = ROW(y - view_start).r + ov_x; |
3682 | rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x; |
3729 | |
3683 | |
3730 | for (int x = ov_w; x--; ) |
3684 | for (int x = ov_w; x--; ) |
3731 | { |
3685 | { |
3732 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3686 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3733 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
3687 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |