]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tty/lib_mvcur.c
ncurses 5.7 - patch 20090214
[ncurses.git] / ncurses / tty / lib_mvcur.c
index 4c0ef4a27e3ee90ff84b5956efff31c697f68aab..d5201325e94ccd507b94f82b6f74a88676c5aa86 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2008,2009 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            *
@@ -30,6 +30,7 @@
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
  *     and: Thomas E. Dickey                        1996-on                 *
+ *     and: Juergen Pfeifer                         2009                    *
  ****************************************************************************/
 
 /*
 #include <term.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_mvcur.c,v 1.107 2006/11/25 22:31:59 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.114 2009/02/15 00:50:33 tom Exp $")
 
 #define WANT_CHAR(y, x)        SP->_newscr->_line[y].text[x]   /* desired state */
 #define BAUDRATE       cur_term->_baudrate     /* bits per second */
@@ -230,7 +231,7 @@ _nc_msec_cost(const char *const cap, int affcnt)
                }
 
 #if NCURSES_NO_PADDING
-               if (!(SP->_no_padding))
+               if (!GetNoPadding(SP))
 #endif
                    cum_cost += number * 10;
            } else
@@ -426,8 +427,11 @@ _nc_mvcur_wrap(void)
     mvcur(-1, -1, screen_lines - 1, 0);
 
     /* set cursor to normal mode */
-    if (SP->_cursor != -1)
+    if (SP->_cursor != -1) {
+       int cursor = SP->_cursor;
        curs_set(1);
+       SP->_cursor = cursor;
+    }
 
     if (exit_ca_mode) {
        TPUTS_TRACE("exit_ca_mode");
@@ -628,7 +632,8 @@ relative_move(string_desc * target, int from_y, int from_x, int to_y, int
                    int i;
 
                    for (i = 0; i < n; i++)
-                       *check.s_tail++ = CharOf(WANT_CHAR(to_y, from_x + i));
+                       *check.s_tail++ = (char) CharOf(WANT_CHAR(to_y,
+                                                                 from_x + i));
                    *check.s_tail = '\0';
                    check.s_size -= n;
                    lhcost += n * SP->_char_padding;
@@ -849,9 +854,10 @@ onscreen_mvcur(int yold, int xold, int ynew, int xnew, bool ovw)
        return (ERR);
 }
 
-NCURSES_EXPORT(int)
-mvcur(int yold, int xold, int ynew, int xnew)
 /* optimized cursor move from (yold, xold) to (ynew, xnew) */
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(mvcur) (NCURSES_SP_DCLx
+                       int yold, int xold, int ynew, int xnew)
 {
     NCURSES_CH_T oldattr;
     int code;
@@ -859,7 +865,7 @@ mvcur(int yold, int xold, int ynew, int xnew)
     TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%d,%d,%d,%d)"),
                                  yold, xold, ynew, xnew));
 
-    if (SP == 0) {
+    if (SP_PARM == 0) {
        code = ERR;
     } else if (yold == ynew && xold == xnew) {
        code = OK;
@@ -880,7 +886,7 @@ mvcur(int yold, int xold, int ynew, int xnew)
         * character set -- these have a strong tendency to screw up the CR &
         * LF used for local character motions!
         */
-       oldattr = SCREEN_ATTRS(SP);
+       oldattr = SCREEN_ATTRS(SP_PARM);
        if ((AttrOf(oldattr) & A_ALTCHARSET)
            || (AttrOf(oldattr) && !move_standout_mode)) {
            TR(TRACE_CHARPUT, ("turning off (%#lx) %s before move",
@@ -892,7 +898,7 @@ mvcur(int yold, int xold, int ynew, int xnew)
        if (xold >= screen_columns) {
            int l;
 
-           if (SP->_nl) {
+           if (SP_PARM->_nl) {
                l = (xold + 1) / screen_columns;
                yold += l;
                if (yold >= screen_lines)
@@ -936,7 +942,7 @@ mvcur(int yold, int xold, int ynew, int xnew)
        /*
         * Restore attributes if we disabled them before moving.
         */
-       if (!SameAttrOf(oldattr, SCREEN_ATTRS(SP))) {
+       if (!SameAttrOf(oldattr, SCREEN_ATTRS(SP_PARM))) {
            TR(TRACE_CHARPUT, ("turning on (%#lx) %s after move",
                               (unsigned long) AttrOf(oldattr),
                               _traceattr(AttrOf(oldattr))));
@@ -946,6 +952,14 @@ mvcur(int yold, int xold, int ynew, int xnew)
     returnCode(code);
 }
 
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+mvcur(int yold, int xold, int ynew, int xnew)
+{
+    return NCURSES_SP_NAME(mvcur) (CURRENT_SCREEN, yold, xold, ynew, xnew);
+}
+#endif
+
 #if defined(TRACE) || defined(NCURSES_TEST)
 NCURSES_EXPORT_VAR(int) _nc_optimize_enable = OPTIMIZE_ALL;
 #endif
@@ -959,6 +973,7 @@ NCURSES_EXPORT_VAR(int) _nc_optimize_enable = OPTIMIZE_ALL;
 
 #include <tic.h>
 #include <dump_entry.h>
+#include <time.h>
 
 NCURSES_EXPORT_VAR(const char *) _nc_progname = "mvcur";
 
@@ -1017,7 +1032,7 @@ roll(int n)
 int
 main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 {
-    (void) strcpy(tname, termname());
+    strcpy(tname, getenv("TERM"));
     load_term();
     _nc_setupscreen(lines, columns, stdout, FALSE, 0);
     baudrate();
@@ -1088,7 +1103,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
            load_term();
        } else if (sscanf(buf, "d %s", capname) == 1) {
            struct name_table_entry const *np = _nc_find_entry(capname,
-                                                              _nc_info_hash_table);
+                                                              _nc_get_hash_table(FALSE));
 
            if (np == NULL)
                (void) printf("No such capability as \"%s\"\n", capname);
@@ -1116,7 +1131,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
            }
        } else if (buf[0] == 'i') {
            dump_init((char *) NULL, F_TERMINFO, S_TERMINFO, 70, 0, FALSE);
-           dump_entry(&cur_term->type, FALSE, TRUE, 0, 0, 0);
+           dump_entry(&cur_term->type, FALSE, TRUE, 0, 0);
            putchar('\n');
        } else if (buf[0] == 'o') {
            if (_nc_optimize_enable & OPTIMIZE_MVCUR) {