108
104
/* #define POSITION_DEBUG */
110
static NCURSES_INLINE NCURSES_CH_T ClrBlank(NCURSES_SP_DCLx WINDOW *win);
113
static int ClrBottom(SCREEN *, int total);
114
static void ClearScreen(SCREEN *, NCURSES_CH_T blank);
115
static void ClrUpdate(SCREEN *);
116
static void DelChar(SCREEN *, int count);
117
static void InsStr(SCREEN *, NCURSES_CH_T * line, int count);
118
static void TransformLine(SCREEN *, int const lineno);
106
static NCURSES_INLINE NCURSES_CH_T ClrBlank(WINDOW *win);
120
107
static int ClrBottom(int total);
121
108
static void ClearScreen(NCURSES_CH_T blank);
122
109
static void ClrUpdate(void);
123
110
static void DelChar(int count);
124
111
static void InsStr(NCURSES_CH_T * line, int count);
125
112
static void TransformLine(int const lineno);
128
114
#ifdef POSITION_DEBUG
129
115
/****************************************************************************
190
172
****************************************************************************/
192
174
static NCURSES_INLINE void
193
GoTo(NCURSES_SP_DCLx int const row, int const col)
175
GoTo(int const row, int const col)
195
177
TR(TRACE_MOVE, ("GoTo(%d, %d) from (%d, %d)",
196
row, col, SP_PARM->_cursrow, SP_PARM->_curscol));
198
position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "GoTo");
200
mvcur(SP_PARM->_cursrow, SP_PARM->_curscol, row, col);
201
position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "GoTo2");
178
row, col, SP->_cursrow, SP->_curscol));
180
position_check(SP->_cursrow, SP->_curscol, "GoTo");
182
mvcur(SP->_cursrow, SP->_curscol, row, col);
183
position_check(SP->_cursrow, SP->_curscol, "GoTo2");
204
186
static NCURSES_INLINE void
205
PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
187
PutAttrChar(CARG_CH_T ch)
208
190
NCURSES_CH_T my_ch;
365
347
ktimeout.tv_usec = 0;
368
FD_SET(SP_PARM->_checkfd, &fdset);
369
if (select(SP_PARM->_checkfd + 1, &fdset, NULL, NULL, &ktimeout) != 0) {
350
FD_SET(SP->_checkfd, &fdset);
351
if (select(SP->_checkfd + 1, &fdset, NULL, NULL, &ktimeout) != 0) {
370
352
have_pending = TRUE;
374
356
if (have_pending) {
375
SP_PARM->_fifohold = 5;
376
NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
381
363
/* put char at lower right corner */
383
PutCharLR(NCURSES_SP_DCLx const ARG_CH_T ch)
365
PutCharLR(const ARG_CH_T ch)
385
367
if (!auto_right_margin) {
386
368
/* we can put the char directly */
387
PutAttrChar(NCURSES_SP_ARGx ch);
388
370
} else if (enter_am_mode && exit_am_mode) {
389
371
/* we can suppress automargin */
390
372
TPUTS_TRACE("exit_am_mode");
391
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_am_mode);
393
PutAttrChar(NCURSES_SP_ARGx ch);
395
position_check(SP_PARM,
377
position_check(SP->_cursrow, SP->_curscol, "exit_am_mode");
400
379
TPUTS_TRACE("enter_am_mode");
401
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx enter_am_mode);
402
381
} else if ((enter_insert_mode && exit_insert_mode)
403
382
|| insert_character || parm_ich) {
405
screen_lines(SP_PARM) - 1,
406
screen_columns(SP_PARM) - 2);
407
PutAttrChar(NCURSES_SP_ARGx ch);
409
screen_lines(SP_PARM) - 1,
410
screen_columns(SP_PARM) - 2);
411
InsStr(NCURSES_SP_ARGx
412
NewScreen(SP_PARM)->_line[screen_lines(SP_PARM) - 1].text +
413
screen_columns(SP_PARM) - 2, 1);
383
GoTo(screen_lines - 1, screen_columns - 2);
385
GoTo(screen_lines - 1, screen_columns - 2);
386
InsStr(newscr->_line[screen_lines - 1].text + screen_columns - 2, 1);
434
407
* it's safe to just tell the code that the cursor is in hyperspace and
435
408
* let the next mvcur() call straighten things out.
437
SP_PARM->_curscol = -1;
438
SP_PARM->_cursrow = -1;
439
412
} else if (auto_right_margin) {
440
SP_PARM->_curscol = 0;
443
416
* We've actually moved - but may have to work around problems with
444
417
* video attributes not working.
446
if (!move_standout_mode && AttrOf(SCREEN_ATTRS(SP_PARM))) {
419
if (!move_standout_mode && AttrOf(SCREEN_ATTRS(SP))) {
447
420
TR(TRACE_CHARPUT, ("turning off (%#lx) %s before wrapping",
448
(unsigned long) AttrOf(SCREEN_ATTRS(SP_PARM)),
449
_traceattr(AttrOf(SCREEN_ATTRS(SP_PARM)))));
450
(void) VIDATTR(SP_PARM, A_NORMAL, 0);
421
(unsigned long) AttrOf(SCREEN_ATTRS(SP)),
422
_traceattr(AttrOf(SCREEN_ATTRS(SP)))));
423
(void) VIDATTR(A_NORMAL, 0);
455
position_check(SP_PARM,
428
position_check(SP->_cursrow, SP->_curscol, "wrap_cursor");
461
431
static NCURSES_INLINE void
462
PutChar(NCURSES_SP_DCLx const ARG_CH_T ch)
432
PutChar(const ARG_CH_T ch)
463
433
/* insert character, handling automargin stuff */
465
if (SP_PARM->_cursrow == screen_lines(SP_PARM) - 1 &&
466
SP_PARM->_curscol == screen_columns(SP_PARM) - 1) {
467
PutCharLR(NCURSES_SP_ARGx ch);
469
PutAttrChar(NCURSES_SP_ARGx ch);
472
if (SP_PARM->_curscol >= screen_columns(SP_PARM))
473
wrap_cursor(NCURSES_SP_ARG);
475
position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "PutChar");
435
if (SP->_cursrow == screen_lines - 1 && SP->_curscol == screen_columns - 1)
440
if (SP->_curscol >= screen_columns)
443
position_check(SP->_cursrow, SP->_curscol, "PutChar");
566
534
* last update on the line.
568
536
if (runcount < num) {
571
SP_PARM->_curscol + runcount);
537
GoTo(SP->_cursrow, SP->_curscol + runcount);
573
539
return 1; /* cursor stays in the middle */
575
} else if (repeat_char && runcount > SP_PARM->_rep_cost) {
576
bool wrap_possible = (SP_PARM->_curscol + runcount >=
577
screen_columns(SP_PARM));
541
} else if (repeat_char && runcount > SP->_rep_cost) {
542
bool wrap_possible = (SP->_curscol + runcount >= screen_columns);
578
543
int rep_count = runcount;
580
545
if (wrap_possible)
583
UpdateAttrs(SP_PARM, ntext0);
584
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
589
NCURSES_SP_NAME(_nc_outch));
590
SP_PARM->_curscol += rep_count;
549
tputs(TPARM_2(repeat_char, CharOf(ntext0), rep_count),
550
rep_count, _nc_outch);
551
SP->_curscol += rep_count;
592
553
if (wrap_possible)
593
PutChar(NCURSES_SP_ARGx CHREF(ntext0));
554
PutChar(CHREF(ntext0));
595
556
for (i = 0; i < runcount; i++)
596
PutChar(NCURSES_SP_ARGx CHREF(ntext[i]));
557
PutChar(CHREF(ntext[i]));
598
559
ntext += runcount;
615
576
* Returns: same as EmitRange
618
PutRange(NCURSES_SP_DCLx
619
const NCURSES_CH_T * otext,
579
PutRange(const NCURSES_CH_T * otext,
620
580
const NCURSES_CH_T * ntext,
622
582
int first, int last)
626
TR(TRACE_CHARPUT, ("PutRange(%p, %p, %p, %d, %d, %d)",
627
SP_PARM, otext, ntext, row, first, last));
586
TR(TRACE_CHARPUT, ("PutRange(%p, %p, %d, %d, %d)",
587
otext, ntext, row, first, last));
629
589
if (otext != ntext
630
&& (last - first + 1) > SP_PARM->_inline_cost) {
590
&& (last - first + 1) > SP->_inline_cost) {
631
591
for (j = first, same = 0; j <= last; j++) {
632
592
if (!same && isWidecExt(otext[j]))
634
594
if (CharEq(otext[j], ntext[j])) {
637
if (same > SP_PARM->_inline_cost) {
638
EmitRange(NCURSES_SP_ARGx ntext + first, j - same - first);
639
GoTo(NCURSES_SP_ARGx row, first = j);
597
if (same > SP->_inline_cost) {
598
EmitRange(ntext + first, j - same - first);
599
GoTo(row, first = j);
644
i = EmitRange(NCURSES_SP_ARGx ntext + first, j - same - first);
604
i = EmitRange(ntext + first, j - same - first);
646
606
* Always return 1 for the next GoTo() after a PutRange() if we found
647
607
* identical characters at end of interval
649
609
return (same == 0 ? i : 1);
651
return EmitRange(NCURSES_SP_ARGx ntext + first, last - first + 1);
611
return EmitRange(ntext + first, last - first + 1);
654
614
/* leave unbracketed here so 'indent' works */
669
629
T((T_CALLED("doupdate()")));
673
* It is "legal" but unlikely that an application could assign a new
674
* value to one of the standard windows. Check for that possibility
675
* and try to recover.
677
* We do not allow applications to assign new values in the reentrant
680
#define SyncScreens(internal,exported) \
681
if (internal == 0) internal = exported; \
682
if (internal != exported) exported = internal
684
SyncScreens(CurScreen(SP_PARM), curscr);
685
SyncScreens(NewScreen(SP_PARM), newscr);
686
SyncScreens(StdScreen(SP_PARM), stdscr);
689
if (CurScreen(SP_PARM) == 0
690
|| NewScreen(SP_PARM) == 0
691
|| StdScreen(SP_PARM) == 0)
695
636
if (USE_TRACEF(TRACE_UPDATE)) {
696
if (CurScreen(SP_PARM)->_clear)
697
638
_tracef("curscr is clear");
699
_tracedump("curscr", CurScreen(SP_PARM));
700
_tracedump("newscr", NewScreen(SP_PARM));
640
_tracedump("curscr", curscr);
641
_tracedump("newscr", newscr);
701
642
_nc_unlock_global(tracef);
703
644
#endif /* TRACE */
705
646
_nc_signal_handler(FALSE);
707
if (SP_PARM->_fifohold)
708
SP_PARM->_fifohold--;
710
651
#if USE_SIZECHANGE
711
if (SP_PARM->_endwin || _nc_handle_sigwinch(SP_PARM)) {
652
if (SP->_endwin || _nc_handle_sigwinch(SP)) {
713
654
* This is a transparent extension: XSI does not address it,
714
655
* and applications need not know that ncurses can do it.
908
845
#endif /* USE_XMC_SUPPORT */
911
if (CurScreen(SP_PARM)->_clear || NewScreen(SP_PARM)->_clear) { /* force refresh ? */
912
ClrUpdate(NCURSES_SP_ARG);
913
CurScreen(SP_PARM)->_clear = FALSE; /* reset flag */
914
NewScreen(SP_PARM)->_clear = FALSE; /* reset flag */
848
if (curscr->_clear || newscr->_clear) { /* force refresh ? */
850
curscr->_clear = FALSE; /* reset flag */
851
newscr->_clear = FALSE; /* reset flag */
916
853
int changedlines = CHECK_INTERVAL;
918
if (check_pending(NCURSES_SP_ARG))
921
nonempty = min(screen_lines(SP_PARM), NewScreen(SP_PARM)->_maxy + 1);
858
nonempty = min(screen_lines, newscr->_maxy + 1);
923
if (SP_PARM->_scrolling) {
860
if (SP->_scrolling) {
924
861
_nc_scroll_optimize();
927
nonempty = ClrBottom(NCURSES_SP_ARGx nonempty);
864
nonempty = ClrBottom(nonempty);
929
866
TR(TRACE_UPDATE, ("Transforming lines, nonempty %d", nonempty));
930
867
for (i = 0; i < nonempty; i++) {
932
869
* Here is our line-breakout optimization.
934
871
if (changedlines == CHECK_INTERVAL) {
935
if (check_pending(NCURSES_SP_ARG))
937
874
changedlines = 0;
941
* newscr.line[i].firstchar is normally set
942
* by wnoutrefresh. curscr.line[i].firstchar
878
* newscr->line[i].firstchar is normally set
879
* by wnoutrefresh. curscr->line[i].firstchar
943
880
* is normally set by _nc_scroll_window in the
944
881
* vertical-movement optimization code,
946
if (NewScreen(SP_PARM)->_line[i].firstchar != _NOCHANGE
947
|| CurScreen(SP_PARM)->_line[i].firstchar != _NOCHANGE) {
948
TransformLine(NCURSES_SP_ARGx i);
883
if (newscr->_line[i].firstchar != _NOCHANGE
884
|| curscr->_line[i].firstchar != _NOCHANGE) {
952
889
/* mark line changed successfully */
953
if (i <= NewScreen(SP_PARM)->_maxy) {
954
MARK_NOCHANGE(NewScreen(SP_PARM), i);
890
if (i <= newscr->_maxy) {
891
MARK_NOCHANGE(newscr, i);
956
if (i <= CurScreen(SP_PARM)->_maxy) {
957
MARK_NOCHANGE(CurScreen(SP_PARM), i);
893
if (i <= curscr->_maxy) {
894
MARK_NOCHANGE(curscr, i);
962
899
/* put everything back in sync */
963
for (i = nonempty; i <= NewScreen(SP_PARM)->_maxy; i++) {
964
MARK_NOCHANGE(NewScreen(SP_PARM), i);
966
for (i = nonempty; i <= CurScreen(SP_PARM)->_maxy; i++) {
967
MARK_NOCHANGE(CurScreen(SP_PARM), i);
970
if (!NewScreen(SP_PARM)->_leaveok) {
971
CurScreen(SP_PARM)->_curx = NewScreen(SP_PARM)->_curx;
972
CurScreen(SP_PARM)->_cury = NewScreen(SP_PARM)->_cury;
974
GoTo(NCURSES_SP_ARGx CurScreen(SP_PARM)->_cury, CurScreen(SP_PARM)->_curx);
900
for (i = nonempty; i <= newscr->_maxy; i++) {
901
MARK_NOCHANGE(newscr, i);
903
for (i = nonempty; i <= curscr->_maxy; i++) {
904
MARK_NOCHANGE(curscr, i);
907
if (!newscr->_leaveok) {
908
curscr->_curx = newscr->_curx;
909
curscr->_cury = newscr->_cury;
911
GoTo(curscr->_cury, curscr->_curx);
1044
ClrUpdate(NCURSES_SP_DCL0)
976
NCURSES_CH_T blank = ClrBlank(stdscr);
977
int nonempty = min(screen_lines, newscr->_maxy + 1);
1046
979
TR(TRACE_UPDATE, (T_CALLED("ClrUpdate")));
1049
NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM));
1050
int nonempty = min(screen_lines(SP_PARM),
1051
NewScreen(SP_PARM)->_maxy + 1);
1053
ClearScreen(NCURSES_SP_ARGx blank);
1055
TR(TRACE_UPDATE, ("updating screen from scratch"));
1057
nonempty = ClrBottom(NCURSES_SP_ARGx nonempty);
1059
for (i = 0; i < nonempty; i++)
1060
TransformLine(NCURSES_SP_ARGx i);
983
TR(TRACE_UPDATE, ("updating screen from scratch"));
985
nonempty = ClrBottom(nonempty);
987
for (i = 0; i < nonempty; i++)
1062
990
TR(TRACE_UPDATE, (T_RETURN("")));
1113
ClrToEOS(NCURSES_SP_DCLx NCURSES_CH_T blank)
1040
ClrToEOS(NCURSES_CH_T blank)
1120
row = SP_PARM->_cursrow;
1121
col = SP_PARM->_curscol;
1123
UpdateAttrs(SP_PARM, blank);
1124
1048
TPUTS_TRACE("clr_eos");
1125
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1127
screen_lines(SP_PARM) - row,
1128
NCURSES_SP_NAME(_nc_outch));
1130
while (col < screen_columns(SP_PARM))
1131
CurScreen(SP_PARM)->_line[row].text[col++] = blank;
1133
for (row++; row < screen_lines(SP_PARM); row++) {
1134
for (col = 0; col < screen_columns(SP_PARM); col++)
1135
CurScreen(SP_PARM)->_line[row].text[col] = blank;
1049
tputs(clr_eos, screen_lines - row, _nc_outch);
1051
while (col < screen_columns)
1052
curscr->_line[row].text[col++] = blank;
1054
for (row++; row < screen_lines; row++) {
1055
for (col = 0; col < screen_columns; col++)
1056
curscr->_line[row].text[col] = blank;
1144
1065
* screen, checking if each is blank, and one or more are changed.
1147
ClrBottom(NCURSES_SP_DCLx int total)
1068
ClrBottom(int total)
1151
1072
int top = total;
1152
int last = min(screen_columns(SP_PARM), NewScreen(SP_PARM)->_maxx + 1);
1153
NCURSES_CH_T blank = NewScreen(SP_PARM)->_line[total - 1].text[last - 1];
1073
int last = min(screen_columns, newscr->_maxx + 1);
1074
NCURSES_CH_T blank = newscr->_line[total - 1].text[last - 1];
1156
if (clr_eos && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {
1077
if (clr_eos && can_clear_with(CHREF(blank))) {
1158
1079
for (row = total - 1; row >= 0; row--) {
1159
1080
for (col = 0, ok = TRUE; ok && col < last; col++) {
1160
ok = (CharEq(NewScreen(SP_PARM)->_line[row].text[col], blank));
1081
ok = (CharEq(newscr->_line[row].text[col], blank));
1165
1086
for (col = 0; ok && col < last; col++) {
1166
ok = (CharEq(CurScreen(SP_PARM)->_line[row].text[col], blank));
1087
ok = (CharEq(curscr->_line[row].text[col], blank));
1185
1106
#if USE_XMC_SUPPORT
1186
1107
#if USE_WIDEC_SUPPORT
1187
#define check_xmc_transition(sp, a, b) \
1188
((((a)->attr ^ (b)->attr) & ~((a)->attr) & (sp)->_xmc_triggers) != 0)
1189
#define xmc_turn_on(sp,a,b) check_xmc_transition(sp,&(a), &(b))
1108
#define check_xmc_transition(a, b) \
1109
((((a)->attr ^ (b)->attr) & ~((a)->attr) & SP->_xmc_triggers) != 0)
1110
#define xmc_turn_on(a,b) check_xmc_transition(&(a), &(b))
1191
#define xmc_turn_on(sp,a,b) ((((a)^(b)) & ~(a) & (sp)->_xmc_triggers) != 0)
1112
#define xmc_turn_on(a,b) ((((a)^(b)) & ~(a) & SP->_xmc_triggers) != 0)
1194
#define xmc_new(sp,r,c) NewScreen(SP_PARM)->_line[r].text[c]
1195
#define xmc_turn_off(sp,a,b) xmc_turn_on(sp,b,a)
1115
#define xmc_new(r,c) newscr->_line[r].text[c]
1116
#define xmc_turn_off(a,b) xmc_turn_on(b,a)
1196
1117
#endif /* USE_XMC_SUPPORT */
1217
TransformLine(NCURSES_SP_DCLx int const lineno)
1138
TransformLine(int const lineno)
1219
1140
int firstChar, oLastChar, nLastChar;
1220
NCURSES_CH_T *newLine = NewScreen(SP_PARM)->_line[lineno].text;
1221
NCURSES_CH_T *oldLine = CurScreen(SP_PARM)->_line[lineno].text;
1141
NCURSES_CH_T *newLine = newscr->_line[lineno].text;
1142
NCURSES_CH_T *oldLine = curscr->_line[lineno].text;
1223
1144
bool attrchanged = FALSE;
1225
TR(TRACE_UPDATE, (T_CALLED("TransformLine(%p, %d)"), SP_PARM, lineno));
1146
TR(TRACE_UPDATE, (T_CALLED("TransformLine(%d)"), lineno));
1227
1148
/* copy new hash value to old one */
1228
if (SP_PARM->oldhash && SP_PARM->newhash)
1229
SP_PARM->oldhash[lineno] = SP_PARM->newhash[lineno];
1149
if (SP->oldhash && SP->newhash)
1150
SP->oldhash[lineno] = SP->newhash[lineno];
1232
1153
* If we have colors, there is the possibility of having two color pairs
1301
1217
if (ISBLANK(newLine[n])
1303
&& xmc_turn_on(SP_PARM, newLine[n - 1], newLine[n]))
1219
&& xmc_turn_on(newLine[n - 1], newLine[n]))
1306
&& xmc_turn_on(SP_PARM,
1307
xmc_new(SP_PARM, lineno - 1,
1308
screen_columns(SP_PARM) - 1),
1222
&& xmc_turn_on(xmc_new(lineno - 1, screen_columns - 1),
1309
1223
newLine[n])))) {
1313
PutChar(NCURSES_SP_ARGx CHREF(newLine[n]));
1227
PutChar(CHREF(newLine[n]));
1315
1229
/* check for turn-off:
1316
1230
* If we are writing an attributed non-blank, where the
1317
1231
* next cell is blank, and not attributed.
1319
1233
if (!ISBLANK(newLine[n])
1320
&& ((n + 1 < screen_columns(SP_PARM)
1321
&& xmc_turn_off(SP_PARM, newLine[n], newLine[n + 1]))
1322
|| (n + 1 >= screen_columns(SP_PARM)
1323
&& lineno + 1 < screen_lines(SP_PARM)
1324
&& xmc_turn_off(SP_PARM,
1326
xmc_new(SP_PARM, lineno + 1, 0))))) {
1234
&& ((n + 1 < screen_columns
1235
&& xmc_turn_off(newLine[n], newLine[n + 1]))
1236
|| (n + 1 >= screen_columns
1237
&& lineno + 1 < screen_lines
1238
&& xmc_turn_off(newLine[n], xmc_new(lineno + 1, 0))))) {
1335
1247
/* it may be cheap to clear leading whitespace with clr_bol */
1336
1248
blank = newLine[0];
1337
if (clr_bol && can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {
1249
if (clr_bol && can_clear_with(CHREF(blank))) {
1338
1250
int oFirstChar, nFirstChar;
1340
for (oFirstChar = 0;
1341
oFirstChar < screen_columns(SP_PARM);
1252
for (oFirstChar = 0; oFirstChar < screen_columns; oFirstChar++)
1343
1253
if (!CharEq(oldLine[oFirstChar], blank))
1345
for (nFirstChar = 0;
1346
nFirstChar < screen_columns(SP_PARM);
1255
for (nFirstChar = 0; nFirstChar < screen_columns; nFirstChar++)
1348
1256
if (!CharEq(newLine[nFirstChar], blank))
1351
1259
if (nFirstChar == oFirstChar) {
1352
1260
firstChar = nFirstChar;
1353
1261
/* find the first differing character */
1354
while (firstChar < screen_columns(SP_PARM)
1262
while (firstChar < screen_columns
1355
1263
&& CharEq(newLine[firstChar], oldLine[firstChar]))
1357
1265
} else if (oFirstChar > nFirstChar) {
1358
1266
firstChar = nFirstChar;
1359
1267
} else { /* oFirstChar < nFirstChar */
1360
1268
firstChar = oFirstChar;
1361
if (SP_PARM->_el1_cost < nFirstChar - oFirstChar) {
1362
if (nFirstChar >= screen_columns(SP_PARM)
1363
&& SP_PARM->_el_cost <= SP_PARM->_el1_cost) {
1364
GoTo(NCURSES_SP_ARGx lineno, 0);
1365
UpdateAttrs(SP_PARM, blank);
1269
if (SP->_el1_cost < nFirstChar - oFirstChar) {
1270
if (nFirstChar >= screen_columns
1271
&& SP->_el_cost <= SP->_el1_cost) {
1366
1274
TPUTS_TRACE("clr_eol");
1367
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx clr_eol);
1369
GoTo(NCURSES_SP_ARGx lineno, nFirstChar - 1);
1370
UpdateAttrs(SP_PARM, blank);
1277
GoTo(lineno, nFirstChar - 1);
1371
1279
TPUTS_TRACE("clr_bol");
1372
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx clr_bol);
1375
1283
while (firstChar < nFirstChar)
1380
1288
/* find the first differing character */
1381
while (firstChar < screen_columns(SP_PARM)
1289
while (firstChar < screen_columns
1382
1290
&& CharEq(newLine[firstChar], oldLine[firstChar]))
1385
1293
/* if there wasn't one, we're done */
1386
if (firstChar >= screen_columns(SP_PARM)) {
1294
if (firstChar >= screen_columns) {
1387
1295
TR(TRACE_UPDATE, (T_RETURN("")));
1391
blank = newLine[screen_columns(SP_PARM) - 1];
1299
blank = newLine[screen_columns - 1];
1393
if (!can_clear_with(NCURSES_SP_ARGx CHREF(blank))) {
1301
if (!can_clear_with(CHREF(blank))) {
1394
1302
/* find the last differing character */
1395
nLastChar = screen_columns(SP_PARM) - 1;
1303
nLastChar = screen_columns - 1;
1397
1305
while (nLastChar > firstChar
1398
1306
&& CharEq(newLine[nLastChar], oldLine[nLastChar]))
1401
1309
if (nLastChar >= firstChar) {
1402
GoTo(NCURSES_SP_ARGx lineno, firstChar);
1403
PutRange(NCURSES_SP_ARGx
1310
GoTo(lineno, firstChar);
1311
PutRange(oldLine, newLine, lineno, firstChar, nLastChar);
1409
1312
memcpy(oldLine + firstChar,
1410
1313
newLine + firstChar,
1411
1314
(nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));
1417
1320
/* find last non-blank character on old line */
1418
oLastChar = screen_columns(SP_PARM) - 1;
1321
oLastChar = screen_columns - 1;
1419
1322
while (oLastChar > firstChar && CharEq(oldLine[oLastChar], blank))
1422
1325
/* find last non-blank character on new line */
1423
nLastChar = screen_columns(SP_PARM) - 1;
1326
nLastChar = screen_columns - 1;
1424
1327
while (nLastChar > firstChar && CharEq(newLine[nLastChar], blank))
1427
1330
if ((nLastChar == firstChar)
1428
&& (SP_PARM->_el_cost < (oLastChar - nLastChar))) {
1429
GoTo(NCURSES_SP_ARGx lineno, firstChar);
1331
&& (SP->_el_cost < (oLastChar - nLastChar))) {
1332
GoTo(lineno, firstChar);
1430
1333
if (!CharEq(newLine[firstChar], blank))
1431
PutChar(NCURSES_SP_ARGx CHREF(newLine[firstChar]));
1432
ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
1334
PutChar(CHREF(newLine[firstChar]));
1335
ClrToEOL(blank, FALSE);
1433
1336
} else if ((nLastChar != oLastChar)
1434
1337
&& (!CharEq(newLine[nLastChar], oldLine[oLastChar])
1435
1338
|| !(_nc_idcok && has_ic()))) {
1436
GoTo(NCURSES_SP_ARGx lineno, firstChar);
1437
if ((oLastChar - nLastChar) > SP_PARM->_el_cost) {
1438
if (PutRange(NCURSES_SP_ARGx
1444
GoTo(NCURSES_SP_ARGx lineno, nLastChar + 1);
1446
ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
1339
GoTo(lineno, firstChar);
1340
if ((oLastChar - nLastChar) > SP->_el_cost) {
1341
if (PutRange(oldLine, newLine, lineno, firstChar, nLastChar))
1342
GoTo(lineno, nLastChar + 1);
1343
ClrToEOL(blank, FALSE);
1448
1345
n = max(nLastChar, oLastChar);
1449
PutRange(NCURSES_SP_ARGx
1346
PutRange(oldLine, newLine, lineno, firstChar, n);
1457
1349
int nLastNonblank = nLastChar;
1492
GoTo(NCURSES_SP_ARGx lineno, n + 1);
1379
GoTo(lineno, n + 1);
1493
1380
if ((nLastChar < nLastNonblank)
1494
|| InsCharCost(SP_PARM, nLastChar - oLastChar) > (m - n)) {
1495
PutRange(NCURSES_SP_ARGx
1381
|| InsCharCost(nLastChar - oLastChar) > (m - n)) {
1382
PutRange(oldLine, newLine, lineno, n + 1, m);
1502
InsStr(NCURSES_SP_ARGx &newLine[n + 1], nLastChar - oLastChar);
1384
InsStr(&newLine[n + 1], nLastChar - oLastChar);
1504
1386
} else if (oLastChar > nLastChar) {
1505
GoTo(NCURSES_SP_ARGx lineno, n + 1);
1506
if (DelCharCost(SP_PARM, oLastChar - nLastChar)
1507
> SP_PARM->_el_cost + nLastNonblank - (n + 1)) {
1508
if (PutRange(NCURSES_SP_ARGx oldLine, newLine, lineno,
1387
GoTo(lineno, n + 1);
1388
if (DelCharCost(oLastChar - nLastChar)
1389
> SP->_el_cost + nLastNonblank - (n + 1)) {
1390
if (PutRange(oldLine, newLine, lineno,
1509
1391
n + 1, nLastNonblank))
1510
GoTo(NCURSES_SP_ARGx lineno, nLastNonblank + 1);
1511
ClrToEOL(NCURSES_SP_ARGx blank, FALSE);
1392
GoTo(lineno, nLastNonblank + 1);
1393
ClrToEOL(blank, FALSE);
1514
1396
* The delete-char sequence will
1566
1444
if (fast_clear) {
1567
1445
if (clear_screen) {
1568
UpdateAttrs(SP_PARM, blank);
1569
1447
TPUTS_TRACE("clear_screen");
1570
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx clear_screen);
1571
SP_PARM->_cursrow = SP_PARM->_curscol = 0;
1572
position_check(SP_PARM,
1449
SP->_cursrow = SP->_curscol = 0;
1450
position_check(SP->_cursrow, SP->_curscol, "ClearScreen");
1576
1451
} else if (clr_eos) {
1577
SP_PARM->_cursrow = SP_PARM->_curscol = -1;
1578
GoTo(NCURSES_SP_ARGx 0, 0);
1452
SP->_cursrow = SP->_curscol = -1;
1580
UpdateAttrs(SP_PARM, blank);
1581
1456
TPUTS_TRACE("clr_eos");
1582
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1584
screen_lines(SP_PARM),
1585
NCURSES_SP_NAME(_nc_outch));
1457
tputs(clr_eos, screen_lines, _nc_outch);
1586
1458
} else if (clr_eol) {
1587
SP_PARM->_cursrow = SP_PARM->_curscol = -1;
1459
SP->_cursrow = SP->_curscol = -1;
1589
UpdateAttrs(SP_PARM, blank);
1590
for (i = 0; i < screen_lines(SP_PARM); i++) {
1591
GoTo(NCURSES_SP_ARGx i, 0);
1462
for (i = 0; i < screen_lines; i++) {
1592
1464
TPUTS_TRACE("clr_eol");
1593
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx clr_eol);
1595
GoTo(NCURSES_SP_ARGx 0, 0);
1598
UpdateAttrs(SP_PARM, blank);
1599
for (i = 0; i < screen_lines(SP_PARM); i++) {
1600
GoTo(NCURSES_SP_ARGx i, 0);
1601
for (j = 0; j < screen_columns(SP_PARM); j++)
1602
PutChar(NCURSES_SP_ARGx CHREF(blank));
1471
for (i = 0; i < screen_lines; i++) {
1473
for (j = 0; j < screen_columns; j++)
1474
PutChar(CHREF(blank));
1604
GoTo(NCURSES_SP_ARGx 0, 0);
1607
for (i = 0; i < screen_lines(SP_PARM); i++) {
1608
for (j = 0; j < screen_columns(SP_PARM); j++)
1609
CurScreen(SP_PARM)->_line[i].text[j] = blank;
1479
for (i = 0; i < screen_lines; i++) {
1480
for (j = 0; j < screen_columns; j++)
1481
curscr->_line[i].text[j] = blank;
1612
1484
TR(TRACE_UPDATE, ("screen cleared"));
1623
InsStr(NCURSES_SP_DCLx NCURSES_CH_T * line, int count)
1495
InsStr(NCURSES_CH_T * line, int count)
1625
TR(TRACE_UPDATE, ("InsStr(%p, %p,%d) called", SP_PARM, line, count));
1497
TR(TRACE_UPDATE, ("InsStr(%p,%d) called", line, count));
1627
1499
/* Prefer parm_ich as it has the smallest cost - no need to shift
1628
1500
* the whole line on each character. */
1629
1501
/* The order must match that of InsCharCost. */
1630
1502
if (parm_ich) {
1631
1503
TPUTS_TRACE("parm_ich");
1632
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1633
TPARM_1(parm_ich, count),
1635
NCURSES_SP_NAME(_nc_outch));
1504
tputs(TPARM_1(parm_ich, count), count, _nc_outch);
1636
1505
while (count) {
1637
PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
1506
PutAttrChar(CHREF(*line));
1641
1510
} else if (enter_insert_mode && exit_insert_mode) {
1642
1511
TPUTS_TRACE("enter_insert_mode");
1643
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx enter_insert_mode);
1512
putp(enter_insert_mode);
1644
1513
while (count) {
1645
PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
1514
PutAttrChar(CHREF(*line));
1646
1515
if (insert_padding) {
1647
1516
TPUTS_TRACE("insert_padding");
1648
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_padding);
1517
putp(insert_padding);
1653
1522
TPUTS_TRACE("exit_insert_mode");
1654
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_insert_mode);
1523
putp(exit_insert_mode);
1656
1525
while (count) {
1657
1526
TPUTS_TRACE("insert_character");
1658
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_character);
1659
PutAttrChar(NCURSES_SP_ARGx CHREF(*line));
1527
putp(insert_character);
1528
PutAttrChar(CHREF(*line));
1660
1529
if (insert_padding) {
1661
1530
TPUTS_TRACE("insert_padding");
1662
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_padding);
1531
putp(insert_padding);
1668
position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "InsStr");
1537
position_check(SP->_cursrow, SP->_curscol, "InsStr");
1679
DelChar(NCURSES_SP_DCLx int count)
1683
TR(TRACE_UPDATE, ("DelChar(%p, %d) called, position = (%ld,%ld)",
1685
(long) NewScreen(SP_PARM)->_cury,
1686
(long) NewScreen(SP_PARM)->_curx));
1552
TR(TRACE_UPDATE, ("DelChar(%d) called, position = (%ld,%ld)",
1554
(long) newscr->_cury,
1555
(long) newscr->_curx));
1688
1557
if (parm_dch) {
1689
1558
TPUTS_TRACE("parm_dch");
1690
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1691
TPARM_1(parm_dch, count),
1693
NCURSES_SP_NAME(_nc_outch));
1559
tputs(TPARM_1(parm_dch, count), count, _nc_outch);
1695
1561
for (n = 0; n < count; n++) {
1696
1562
TPUTS_TRACE("delete_character");
1697
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx delete_character);
1563
putp(delete_character);
1734
1600
/* Try to scroll up assuming given csr (miny, maxy). Returns ERR on failure */
1736
scroll_csr_forward(NCURSES_SP_DCLx
1602
scroll_csr_forward(int n, int top, int bot, int miny, int maxy, NCURSES_CH_T blank)
1746
1606
if (n == 1 && scroll_forward && top == miny && bot == maxy) {
1747
GoTo(NCURSES_SP_ARGx bot, 0);
1748
UpdateAttrs(SP_PARM, blank);
1749
1609
TPUTS_TRACE("scroll_forward");
1750
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx scroll_forward);
1610
putp(scroll_forward);
1751
1611
} else if (n == 1 && delete_line && bot == maxy) {
1752
GoTo(NCURSES_SP_ARGx top, 0);
1753
UpdateAttrs(SP_PARM, blank);
1754
1614
TPUTS_TRACE("delete_line");
1755
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx delete_line);
1756
1616
} else if (parm_index && top == miny && bot == maxy) {
1757
GoTo(NCURSES_SP_ARGx bot, 0);
1758
UpdateAttrs(SP_PARM, blank);
1759
1619
TPUTS_TRACE("parm_index");
1760
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1761
TPARM_2(parm_index, n, 0),
1763
NCURSES_SP_NAME(_nc_outch));
1620
tputs(TPARM_2(parm_index, n, 0), n, _nc_outch);
1764
1621
} else if (parm_delete_line && bot == maxy) {
1765
GoTo(NCURSES_SP_ARGx top, 0);
1766
UpdateAttrs(SP_PARM, blank);
1767
1624
TPUTS_TRACE("parm_delete_line");
1768
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1769
TPARM_2(parm_delete_line, n, 0),
1771
NCURSES_SP_NAME(_nc_outch));
1625
tputs(TPARM_2(parm_delete_line, n, 0), n, _nc_outch);
1772
1626
} else if (scroll_forward && top == miny && bot == maxy) {
1773
GoTo(NCURSES_SP_ARGx bot, 0);
1774
UpdateAttrs(SP_PARM, blank);
1775
1629
for (i = 0; i < n; i++) {
1776
1630
TPUTS_TRACE("scroll_forward");
1777
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx scroll_forward);
1631
putp(scroll_forward);
1779
1633
} else if (delete_line && bot == maxy) {
1780
GoTo(NCURSES_SP_ARGx top, 0);
1781
UpdateAttrs(SP_PARM, blank);
1782
1636
for (i = 0; i < n; i++) {
1783
1637
TPUTS_TRACE("delete_line");
1784
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx delete_line);
1789
1643
#if NCURSES_EXT_FUNCS
1790
if (FILL_BCE(SP_PARM)) {
1792
1646
for (i = 0; i < n; i++) {
1793
GoTo(NCURSES_SP_ARGx bot - i, 0);
1794
for (j = 0; j < screen_columns(SP_PARM); j++)
1795
PutChar(NCURSES_SP_ARGx CHREF(blank));
1648
for (j = 0; j < screen_columns; j++)
1649
PutChar(CHREF(blank));
1802
1656
/* Try to scroll down assuming given csr (miny, maxy). Returns ERR on failure */
1805
scroll_csr_backward(NCURSES_SP_DCLx
1659
scroll_csr_backward(int n, int top, int bot, int miny, int maxy,
1811
1660
NCURSES_CH_T blank)
1815
1664
if (n == 1 && scroll_reverse && top == miny && bot == maxy) {
1816
GoTo(NCURSES_SP_ARGx top, 0);
1817
UpdateAttrs(SP_PARM, blank);
1818
1667
TPUTS_TRACE("scroll_reverse");
1819
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx scroll_reverse);
1668
putp(scroll_reverse);
1820
1669
} else if (n == 1 && insert_line && bot == maxy) {
1821
GoTo(NCURSES_SP_ARGx top, 0);
1822
UpdateAttrs(SP_PARM, blank);
1823
1672
TPUTS_TRACE("insert_line");
1824
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_line);
1825
1674
} else if (parm_rindex && top == miny && bot == maxy) {
1826
GoTo(NCURSES_SP_ARGx top, 0);
1827
UpdateAttrs(SP_PARM, blank);
1828
1677
TPUTS_TRACE("parm_rindex");
1829
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1830
TPARM_2(parm_rindex, n, 0),
1832
NCURSES_SP_NAME(_nc_outch));
1678
tputs(TPARM_2(parm_rindex, n, 0), n, _nc_outch);
1833
1679
} else if (parm_insert_line && bot == maxy) {
1834
GoTo(NCURSES_SP_ARGx top, 0);
1835
UpdateAttrs(SP_PARM, blank);
1836
1682
TPUTS_TRACE("parm_insert_line");
1837
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1838
TPARM_2(parm_insert_line, n, 0),
1840
NCURSES_SP_NAME(_nc_outch));
1683
tputs(TPARM_2(parm_insert_line, n, 0), n, _nc_outch);
1841
1684
} else if (scroll_reverse && top == miny && bot == maxy) {
1842
GoTo(NCURSES_SP_ARGx top, 0);
1843
UpdateAttrs(SP_PARM, blank);
1844
1687
for (i = 0; i < n; i++) {
1845
1688
TPUTS_TRACE("scroll_reverse");
1846
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx scroll_reverse);
1689
putp(scroll_reverse);
1848
1691
} else if (insert_line && bot == maxy) {
1849
GoTo(NCURSES_SP_ARGx top, 0);
1850
UpdateAttrs(SP_PARM, blank);
1851
1694
for (i = 0; i < n; i++) {
1852
1695
TPUTS_TRACE("insert_line");
1853
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_line);
1858
1701
#if NCURSES_EXT_FUNCS
1859
if (FILL_BCE(SP_PARM)) {
1861
1704
for (i = 0; i < n; i++) {
1862
GoTo(NCURSES_SP_ARGx top + i, 0);
1863
for (j = 0; j < screen_columns(SP_PARM); j++)
1864
PutChar(NCURSES_SP_ARGx CHREF(blank));
1706
for (j = 0; j < screen_columns; j++)
1707
PutChar(CHREF(blank));
1871
1714
/* scroll by using delete_line at del and insert_line at ins */
1874
scroll_idl(NCURSES_SP_DCLx int n, int del, int ins, NCURSES_CH_T blank)
1717
scroll_idl(int n, int del, int ins, NCURSES_CH_T blank)
1878
1721
if (!((parm_delete_line || delete_line) && (parm_insert_line || insert_line)))
1881
GoTo(NCURSES_SP_ARGx del, 0);
1882
UpdateAttrs(SP_PARM, blank);
1883
1726
if (n == 1 && delete_line) {
1884
1727
TPUTS_TRACE("delete_line");
1885
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx delete_line);
1886
1729
} else if (parm_delete_line) {
1887
1730
TPUTS_TRACE("parm_delete_line");
1888
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1889
TPARM_2(parm_delete_line, n, 0),
1891
NCURSES_SP_NAME(_nc_outch));
1731
tputs(TPARM_2(parm_delete_line, n, 0), n, _nc_outch);
1892
1732
} else { /* if (delete_line) */
1893
1733
for (i = 0; i < n; i++) {
1894
1734
TPUTS_TRACE("delete_line");
1895
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx delete_line);
1899
GoTo(NCURSES_SP_ARGx ins, 0);
1900
UpdateAttrs(SP_PARM, blank);
1901
1741
if (n == 1 && insert_line) {
1902
1742
TPUTS_TRACE("insert_line");
1903
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_line);
1904
1744
} else if (parm_insert_line) {
1905
1745
TPUTS_TRACE("parm_insert_line");
1906
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
1907
TPARM_2(parm_insert_line, n, 0),
1909
NCURSES_SP_NAME(_nc_outch));
1746
tputs(TPARM_2(parm_insert_line, n, 0), n, _nc_outch);
1910
1747
} else { /* if (insert_line) */
1911
1748
for (i = 0; i < n; i++) {
1912
1749
TPUTS_TRACE("insert_line");
1913
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx insert_line);
1954
1787
* Explicitly clear if stuff pushed off top of region might
1955
1788
* be saved by the terminal.
1957
res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, 0, maxy, blank);
1790
res = scroll_csr_forward(n, top, bot, 0, maxy, blank);
1959
1792
if (res == ERR && change_scroll_region) {
1960
1793
if ((((n == 1 && scroll_forward) || parm_index)
1961
&& (SP_PARM->_cursrow == bot || SP_PARM->_cursrow == bot - 1))
1794
&& (SP->_cursrow == bot || SP->_cursrow == bot - 1))
1962
1795
&& save_cursor && restore_cursor) {
1963
1796
cursor_saved = TRUE;
1964
1797
TPUTS_TRACE("save_cursor");
1965
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx save_cursor);
1967
1800
TPUTS_TRACE("change_scroll_region");
1968
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx
1969
TPARM_2(change_scroll_region, top, bot));
1801
putp(TPARM_2(change_scroll_region, top, bot));
1970
1802
if (cursor_saved) {
1971
1803
TPUTS_TRACE("restore_cursor");
1972
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx restore_cursor);
1804
putp(restore_cursor);
1974
SP_PARM->_cursrow = SP_PARM->_curscol = -1;
1806
SP->_cursrow = SP->_curscol = -1;
1977
res = scroll_csr_forward(NCURSES_SP_ARGx n, top, bot, top, bot, blank);
1809
res = scroll_csr_forward(n, top, bot, top, bot, blank);
1979
1811
TPUTS_TRACE("change_scroll_region");
1980
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx
1981
TPARM_2(change_scroll_region, 0, maxy));
1982
SP_PARM->_cursrow = SP_PARM->_curscol = -1;
1812
putp(TPARM_2(change_scroll_region, 0, maxy));
1813
SP->_cursrow = SP->_curscol = -1;
1985
1816
if (res == ERR && _nc_idlok)
1986
res = scroll_idl(NCURSES_SP_ARGx n, top, bot - n + 1, blank);
1817
res = scroll_idl(n, top, bot - n + 1, blank);
1989
1820
* Clear the newly shifted-in text.
1992
1823
&& (non_dest_scroll_region || (memory_below && bot == maxy))) {
1993
1824
static const NCURSES_CH_T blank2 = NewChar(BLANK_TEXT);
1994
1825
if (bot == maxy && clr_eos) {
1995
GoTo(NCURSES_SP_ARGx bot - n + 1, 0);
1996
ClrToEOS(NCURSES_SP_ARGx blank2);
1826
GoTo(bot - n + 1, 0);
1998
1829
for (i = 0; i < n; i++) {
1999
GoTo(NCURSES_SP_ARGx bot - i, 0);
2000
ClrToEOL(NCURSES_SP_ARGx blank2, FALSE);
1831
ClrToEOL(blank2, FALSE);
2005
1836
} else { /* (n < 0) - scroll down (backward) */
2006
res = scroll_csr_backward(NCURSES_SP_ARGx -n, top, bot, 0, maxy, blank);
1837
res = scroll_csr_backward(-n, top, bot, 0, maxy, blank);
2008
1839
if (res == ERR && change_scroll_region) {
2010
&& (SP_PARM->_cursrow == top ||
2011
SP_PARM->_cursrow == top - 1)
1840
if (top != 0 && (SP->_cursrow == top || SP->_cursrow == top - 1)
2012
1841
&& save_cursor && restore_cursor) {
2013
1842
cursor_saved = TRUE;
2014
1843
TPUTS_TRACE("save_cursor");
2015
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx save_cursor);
2017
1846
TPUTS_TRACE("change_scroll_region");
2018
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx
2019
TPARM_2(change_scroll_region, top, bot));
1847
putp(TPARM_2(change_scroll_region, top, bot));
2020
1848
if (cursor_saved) {
2021
1849
TPUTS_TRACE("restore_cursor");
2022
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx restore_cursor);
1850
putp(restore_cursor);
2024
SP_PARM->_cursrow = SP_PARM->_curscol = -1;
1852
SP->_cursrow = SP->_curscol = -1;
2027
res = scroll_csr_backward(NCURSES_SP_ARGx
2028
-n, top, bot, top, bot, blank);
1855
res = scroll_csr_backward(-n, top, bot, top, bot, blank);
2030
1857
TPUTS_TRACE("change_scroll_region");
2031
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx
2032
TPARM_2(change_scroll_region, 0, maxy));
2033
SP_PARM->_cursrow = SP_PARM->_curscol = -1;
1858
putp(TPARM_2(change_scroll_region, 0, maxy));
1859
SP->_cursrow = SP->_curscol = -1;
2036
1862
if (res == ERR && _nc_idlok)
2037
res = scroll_idl(NCURSES_SP_ARGx -n, bot + n + 1, top, blank);
1863
res = scroll_idl(-n, bot + n + 1, top, blank);
2040
1866
* Clear the newly shifted-in text.
2052
1878
if (res == ERR)
2055
_nc_scroll_window(CurScreen(SP_PARM), n, top, bot, blank);
1881
_nc_scroll_window(curscr, n, top, bot, blank);
2057
1883
/* shift hash values too - they can be reused */
2058
NCURSES_SP_NAME(_nc_scroll_oldhash) (NCURSES_SP_ARGx n, top, bot);
1884
_nc_scroll_oldhash(n, top, bot);
2063
#if NCURSES_SP_FUNCS
2065
_nc_scrolln(int n, int top, int bot, int maxy)
2067
return NCURSES_SP_NAME(_nc_scrolln) (CURRENT_SCREEN, n, top, bot, maxy);
2071
1889
NCURSES_EXPORT(void)
2072
NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_DCL0)
1890
_nc_screen_resume(void)
2076
1892
/* make sure terminal is in a sane known state */
2077
SetAttr(SCREEN_ATTRS(SP_PARM), A_NORMAL);
2078
NewScreen(SP_PARM)->_clear = TRUE;
1893
SetAttr(SCREEN_ATTRS(SP), A_NORMAL);
1894
newscr->_clear = TRUE;
2080
1896
/* reset color pairs and definitions */
2081
if (SP_PARM->_coloron || SP_PARM->_color_defs)
1897
if (SP->_coloron || SP->_color_defs)
2082
1898
_nc_reset_colors();
2084
1900
/* restore user-defined colors, if any */
2085
if (SP_PARM->_color_defs < 0) {
1901
if (SP->_color_defs < 0) {
2087
SP_PARM->_color_defs = -(SP_PARM->_color_defs);
2088
for (n = 0; n < SP_PARM->_color_defs; ++n) {
2089
if (SP_PARM->_color_table[n].init) {
2090
NCURSES_SP_NAME(init_color) (NCURSES_SP_ARGx n,
2091
SP_PARM->_color_table[n].r,
2092
SP_PARM->_color_table[n].g,
2093
SP_PARM->_color_table[n].b);
1903
SP->_color_defs = -(SP->_color_defs);
1904
for (n = 0; n < SP->_color_defs; ++n) {
1905
if (SP->_color_table[n].init) {
1907
SP->_color_table[n].r,
1908
SP->_color_table[n].g,
1909
SP->_color_table[n].b);
2098
1914
if (exit_attribute_mode)
2099
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_attribute_mode);
1915
putp(exit_attribute_mode);
2101
1917
/* turn off attributes */
2102
1918
if (exit_alt_charset_mode)
2103
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_alt_charset_mode);
1919
putp(exit_alt_charset_mode);
2104
1920
if (exit_standout_mode)
2105
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_standout_mode);
1921
putp(exit_standout_mode);
2106
1922
if (exit_underline_mode)
2107
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_underline_mode);
1923
putp(exit_underline_mode);
2109
1925
if (exit_insert_mode)
2110
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx exit_insert_mode);
1926
putp(exit_insert_mode);
2111
1927
if (enter_am_mode && exit_am_mode)
2112
NCURSES_SP_NAME(putp) (NCURSES_SP_ARGx
2118
#if NCURSES_SP_FUNCS
2119
NCURSES_EXPORT(void)
2120
_nc_screen_resume(void)
2122
NCURSES_SP_NAME(_nc_screen_resume) (CURRENT_SCREEN);
2126
NCURSES_EXPORT(void)
2127
NCURSES_SP_NAME(_nc_screen_init) (NCURSES_SP_DCL0)
2129
NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG);
2132
#if NCURSES_SP_FUNCS
1928
putp(auto_right_margin ? enter_am_mode : exit_am_mode);
2133
1931
NCURSES_EXPORT(void)
2134
1932
_nc_screen_init(void)
2136
NCURSES_SP_NAME(_nc_screen_init) (CURRENT_SCREEN);
1934
_nc_screen_resume();
2140
1937
/* wrap up screen handling */
2141
1938
NCURSES_EXPORT(void)
2142
NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0)
2147
UpdateAttrs(SP_PARM, normal);
2148
#if NCURSES_EXT_FUNCS
2149
if (SP_PARM->_coloron
2150
&& !SP_PARM->_default_color) {
2151
static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
2152
SP_PARM->_default_color = TRUE;
2153
NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx
2156
NCURSES_SP_NAME(_nc_outch));
2157
SP_PARM->_default_color = FALSE;
2159
mvcur(SP_PARM->_cursrow,
2161
screen_lines(SP_PARM) - 1, 0);
2163
ClrToEOL(NCURSES_SP_ARGx blank, TRUE);
2166
if (SP_PARM->_color_defs) {
2171
#if NCURSES_SP_FUNCS
2172
NCURSES_EXPORT(void)
2173
1939
_nc_screen_wrap(void)
2175
NCURSES_SP_NAME(_nc_screen_wrap) (CURRENT_SCREEN);
1941
UpdateAttrs(normal);
1942
#if NCURSES_EXT_FUNCS
1944
&& !SP->_default_color) {
1945
static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
1946
SP->_default_color = TRUE;
1947
_nc_do_color(-1, 0, FALSE, _nc_outch);
1948
SP->_default_color = FALSE;
1950
mvcur(SP->_cursrow, SP->_curscol, screen_lines - 1, 0);
1952
ClrToEOL(blank, TRUE);
1955
if (SP->_color_defs) {
2179
1960
#if USE_XMC_SUPPORT
2180
1961
NCURSES_EXPORT(void)
2181
NCURSES_SP_NAME(_nc_do_xmc_glitch) (NCURSES_SP_DCLx attr_t previous)
2184
attr_t chg = XMC_CHANGES(previous ^ AttrOf(SCREEN_ATTRS(SP_PARM)));
2188
SP_PARM->_curscol += magic_cookie_glitch;
2189
if (SP_PARM->_curscol >= SP_PARM->_columns)
2190
wrap_cursor(NCURSES_SP_ARG);
2191
TR(TRACE_UPDATE, ("bumped to %d,%d after cookie",
2192
SP_PARM->_cursrow, SP_PARM->_curscol));
2199
#if NCURSES_SP_FUNCS
2200
NCURSES_EXPORT(void)
2201
1962
_nc_do_xmc_glitch(attr_t previous)
2203
NCURSES_SP_NAME(_nc_do_xmc_glitch) (CURRENT_SCREEN, previous);
1964
attr_t chg = XMC_CHANGES(previous ^ AttrOf(SCREEN_ATTRS(SP)));
1968
SP->_curscol += magic_cookie_glitch;
1969
if (SP->_curscol >= SP->_columns)
1971
TR(TRACE_UPDATE, ("bumped to %d,%d after cookie", SP->_cursrow, SP->_curscol));
2207
1976
#endif /* USE_XMC_SUPPORT */