/****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#include <term.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_mvcur.c,v 1.72 2000/10/08 00:58:25 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.86 2002/09/14 23:02:06 Philippe.Blain Exp $")
#define CURRENT_ROW SP->_cursrow /* phys cursor row */
#define CURRENT_COLUMN SP->_curscol /* phys cursor column */
#endif
-int
+NCURSES_EXPORT(int)
_nc_msec_cost(const char *const cap, int affcnt)
/* compute the cost of a given operation */
{
float number = 0.0;
for (cp += 2; *cp != '>'; cp++) {
- if (isdigit(*cp))
+ if (isdigit(UChar(*cp)))
number = number * 10 + (*cp - '0');
else if (*cp == '*')
number *= affcnt;
- else if (*cp == '.' && (*++cp != '>') && isdigit(*cp))
+ else if (*cp == '.' && (*++cp != '>') && isdigit(UChar(*cp)))
number += (*cp - '0') / 10.0;
}
}
}
-void
+NCURSES_EXPORT(void)
_nc_mvcur_resume(void)
/* what to do at initialization time and after each shellout */
{
}
}
-void
+NCURSES_EXPORT(void)
_nc_mvcur_init(void)
/* initialize the cost structure */
{
_nc_mvcur_resume();
}
-void
+NCURSES_EXPORT(void)
_nc_mvcur_wrap(void)
/* wrap up cursor-addressing mode */
{
vcost = SP->_cud_cost;
}
- if (cursor_down && (n * SP->_cud1_cost < vcost)) {
+ if (cursor_down
+ && (*cursor_down != '\n' || SP->_nl)
+ && (n * SP->_cud1_cost < vcost)) {
vcost = repeated_append(_nc_str_copy(target, &save), 0,
SP->_cud1_cost, n, cursor_down);
}
#endif /* USE_HARD_TABS */
#if defined(REAL_ATTR) && defined(WANT_CHAR)
+ if (n <= 0 || n >= (int) check.s_size)
+ ovw = FALSE;
#if BSD_TPUTS
/*
* If we're allowing BSD-style padding in tputs, don't generate
&& n < (int) check.s_size
&& vcost == 0
&& str[0] == '\0'
- && isdigit(TextOf(WANT_CHAR(to_y, from_x))))
+ && isdigit(CharOf(WANT_CHAR(to_y, from_x))))
ovw = FALSE;
#endif
/*
if (ovw) {
int i;
- for (i = 0; i < n; i++)
- if ((WANT_CHAR(to_y, from_x + i) & A_ATTRIBUTES) != CURRENT_ATTR) {
+ for (i = 0; i < n; i++) {
+ NCURSES_CH_T ch = WANT_CHAR(to_y, from_x + i);
+ if (AttrOf(ch) != CURRENT_ATTR
+#if USE_WIDEC_SUPPORT
+ || !Charable(ch)
+#endif
+ ) {
ovw = FALSE;
break;
}
+ }
}
if (ovw) {
int i;
for (i = 0; i < n; i++)
- *check.s_tail++ = WANT_CHAR(to_y, from_x + i);
+ *check.s_tail++ = CharOf(WANT_CHAR(to_y, from_x + i));
*check.s_tail = '\0';
check.s_size -= n;
lhcost += n * SP->_char_padding;
return (ERR);
}
-int
+NCURSES_EXPORT(int)
mvcur(int yold, int xold, int ynew, int xnew)
/* optimized cursor move from (yold, xold) to (ynew, xnew) */
{
- TR(TRACE_MOVE, ("mvcur(%d,%d,%d,%d) called", yold, xold, ynew, xnew));
+ TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%d,%d,%d,%d)"),
+ yold, xold, ynew, xnew));
+
+ if (SP == 0)
+ returnCode(ERR);
if (yold == ynew && xold == xnew)
- return (OK);
+ returnCode(OK);
/*
* Most work here is rounding for terminal boundaries getting the
if (xold >= screen_columns) {
int l;
- l = (xold + 1) / screen_columns;
- yold += l;
- if (yold >= screen_lines)
- l -= (yold - screen_lines - 1);
+ if (SP->_nl) {
+ l = (xold + 1) / screen_columns;
+ yold += l;
+ if (yold >= screen_lines)
+ l -= (yold - screen_lines - 1);
- while (l > 0) {
- if (newline) {
- TPUTS_TRACE("newline");
- tputs(newline, 0, _nc_outch);
- } else
- putchar('\n');
- l--;
- if (xold > 0) {
- if (carriage_return) {
- TPUTS_TRACE("carriage_return");
- tputs(carriage_return, 0, _nc_outch);
+ while (l > 0) {
+ if (newline) {
+ TPUTS_TRACE("newline");
+ tputs(newline, 0, _nc_outch);
} else
- putchar('\r');
- xold = 0;
+ putchar('\n');
+ l--;
+ if (xold > 0) {
+ if (carriage_return) {
+ TPUTS_TRACE("carriage_return");
+ tputs(carriage_return, 0, _nc_outch);
+ } else
+ putchar('\r');
+ xold = 0;
+ }
}
+ } else {
+ /*
+ * If caller set nonl(), we cannot really use newlines to position
+ * to the next row.
+ */
+ xold = -1;
+ yold = -1;
}
}
ynew = screen_lines - 1;
/* destination location is on screen now */
- return (onscreen_mvcur(yold, xold, ynew, xnew, TRUE));
+ returnCode(onscreen_mvcur(yold, xold, ynew, xnew, TRUE));
}
#if defined(TRACE) || defined(NCURSES_TEST)
-int _nc_optimize_enable = OPTIMIZE_ALL;
+NCURSES_EXPORT_VAR(int) _nc_optimize_enable = OPTIMIZE_ALL;
#endif
#if defined(MAIN) || defined(NCURSES_TEST)
#include <tic.h>
#include <dump_entry.h>
-const char *_nc_progname = "mvcur";
+NCURSES_EXPORT_VAR(const char *) _nc_progname = "mvcur";
static unsigned long xmits;
/* these override lib_tputs.c */
-int
+NCURSES_EXPORT(int)
tputs(const char *string, int affcnt GCC_UNUSED, int (*outc) (int) GCC_UNUSED)
/* stub tputs() that dumps sequences in a visible form */
{
return (OK);
}
-int
+NCURSES_EXPORT(int)
putp(const char *string)
{
return (tputs(string, 1, _nc_outch));
}
-int
+NCURSES_EXPORT(int)
_nc_outch(int ch)
{
putc(ch, stdout);
return OK;
}
-char PC = 0; /* used by termcap library */
-short ospeed = 0; /* used by termcap library */
-int _nc_nulls_sent = 0; /* used by 'tack' program */
-
-int
+NCURSES_EXPORT(int)
delay_output(int ms GCC_UNUSED)
{
return OK;
}
} else if (buf[0] == 'i') {
dump_init((char *) NULL, F_TERMINFO, S_TERMINFO, 70, 0, FALSE);
- dump_entry(&cur_term->type, FALSE, TRUE, 0);
+ dump_entry(&cur_term->type, FALSE, TRUE, 0, 0, 0);
putchar('\n');
} else if (buf[0] == 'o') {
if (_nc_optimize_enable & OPTIMIZE_MVCUR) {