#include <term.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_mvcur.c,v 1.50 1998/02/11 12:13:56 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.60 1999/10/03 01:08:27 Alexander.V.Lukyanov Exp $")
#define STRLEN(s) (s != 0) ? strlen(s) : 0
static int normalized_cost(const char *const cap, int affcnt);
+#if !HAVE_STRSTR
+char * _nc_strstr(const char *haystack, const char *needle)
+{
+ size_t len1 = strlen(haystack);
+ size_t len2 = strlen(needle);
+ char *result = 0;
+
+ while ((len1 != 0) && (len1-- >= len2)) {
+ if (!strncmp(haystack, needle, len2)) {
+ result = haystack;
+ break;
+ }
+ haystack++;
+ }
+ return result;
+}
+#endif
+
/****************************************************************************
*
* Initialization/wrapup (including cost pre-computation)
{
if (isdigit(*cp))
number = number * 10 + (*cp - '0');
- else if (*cp == '.')
- number += (*++cp - 10) / 10.0;
else if (*cp == '*')
number *= affcnt;
+ else if (*cp == '.' && (*++cp != '>') && isdigit(*cp))
+ number += (*cp - '0') / 10.0;
}
cum_cost += number * 10;
*/
reset_scroll_region();
SP->_cursrow = SP->_curscol = -1;
-
+
/* restore cursor shape */
if (SP->_cursor != -1)
{
SP->_cud1_cost = CostOf(cursor_down, 0);
SP->_cuu1_cost = CostOf(cursor_up, 0);
+ SP->_smir_cost = CostOf(enter_insert_mode, 0);
+ SP->_rmir_cost = CostOf(exit_insert_mode, 0);
+ SP->_ip_cost = 0;
+ if (insert_padding) {
+ SP->_ip_cost = CostOf(insert_padding, 0);
+ }
+
/*
* Assumption: if the terminal has memory_relative addressing, the
* initialization strings or smcup will set single-page mode so we
SP->_cursor_home_length = STRLEN(cursor_home);
SP->_cursor_to_ll_length = STRLEN(cursor_to_ll);
+ /*
+ * If save_cursor is used within enter_ca_mode, we should not use it for
+ * scrolling optimization, since the corresponding restore_cursor is not
+ * nested on the various terminals (vt100, xterm, etc.) which use this
+ * feature.
+ */
+ if (save_cursor != 0
+ && enter_ca_mode != 0
+ && strstr(enter_ca_mode, save_cursor) != 0) {
+ T(("...suppressed sc/rc capability due to conflict with smcup/rmcup"));
+ save_cursor = 0;
+ restore_cursor = 0;
+ }
+
/*
* A different, possibly better way to arrange this would be to set
* SP->_endwin = TRUE at window initialization time and let this be
#endif /* USE_HARD_TABS */
#if defined(REAL_ATTR) && defined(WANT_CHAR)
+#ifdef BSD_TPUTS
+ /*
+ * If we're allowing BSD-style padding in tputs, don't generate
+ * a string with a leading digit. Otherwise, that will be
+ * interpreted as a padding value rather than sent to the
+ * screen.
+ */
+ if (ovw
+ && n > 0
+ && vcost == 0
+ && str[0] == '\0'
+ && isdigit(TextOf(WANT_CHAR(to_y, from_x))))
+ ovw = FALSE;
+#endif
/*
* If we have no attribute changes, overwrite is cheaper.
* Note: must suppress this by passing in ovw = FALSE whenever
*sp++ = WANT_CHAR(to_y, from_x + i);
*sp = '\0';
lhcost += n * SP->_char_padding;
- }
+ }
else
#endif /* defined(REAL_ATTR) && defined(WANT_CHAR) */
{
{
char use[OPT_SIZE], *sp;
int tactic = 0, newcost, usecost = INFINITY;
+ int t5_cr_cost;
#if defined(MAIN) || defined(NCURSES_TEST)
struct timeval before, after;
* tactic #5: use left margin for wrap to right-hand side,
* unless strange wrap behavior indicated by xenl might hose us.
*/
+ t5_cr_cost = (xold>0 ? SP->_cr_cost : 0);
if (auto_left_margin && !eat_newline_glitch
&& yold > 0 && cursor_left
&& ((newcost=relative_move(NULL, yold-1, screen_columns-1, ynew, xnew, ovw)) != INFINITY)
- && SP->_cr_cost + SP->_cub1_cost + newcost + newcost < usecost)
+ && t5_cr_cost + SP->_cub1_cost + newcost < usecost)
{
tactic = 5;
- usecost = SP->_cr_cost + SP->_cub1_cost + newcost;
+ usecost = t5_cr_cost + SP->_cub1_cost + newcost;
}
/*
return(onscreen_mvcur(yold, xold, ynew, xnew, TRUE));
}
+#if defined(TRACE) || defined(NCURSES_TEST)
+int _nc_optimize_enable = OPTIMIZE_ALL;
+#endif
+
#if defined(MAIN) || defined(NCURSES_TEST)
/****************************************************************************
*
baudrate();
_nc_mvcur_init();
-#if HAVE_SETVBUF || HAVE_SETBUFFER
- /*
- * Undo the effects of our optimization hack, otherwise our interactive
- * prompts don't flush properly.
- */
-#if HAVE_SETVBUF
- (void) setvbuf(SP->_ofp, malloc(BUFSIZ), _IOLBF, BUFSIZ);
-#elif HAVE_SETBUFFER
- (void) setbuffer(SP->_ofp, malloc(BUFSIZ), BUFSIZ);
-#endif
-#endif /* HAVE_SETVBUF || HAVE_SETBUFFER */
+ NC_BUFFERED(FALSE);
(void) puts("The mvcur tester. Type ? for help");
}
else if (buf[0] == 'i')
{
- dump_init((char *)NULL, F_TERMINFO, S_TERMINFO, 70, 0);
- dump_entry(&cur_term->type, 0, 0);
+ dump_init((char *)NULL, F_TERMINFO, S_TERMINFO, 70, 0, FALSE);
+ dump_entry(&cur_term->type, FALSE, TRUE, 0);
putchar('\n');
}
else if (buf[0] == 'o')