Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses Keep the cr->nl translation state in a separat...



details:   https://anonhg.NetBSD.org/src/rev/a406b9bdeb65
branches:  trunk
changeset: 545228:a406b9bdeb65
user:      jdc <jdc%NetBSD.org@localhost>
date:      Sat Apr 05 10:06:59 2003 +0000

description:
Keep the cr->nl translation state in a separate variable, so that we can
do the translation ourselves (if the tty didn't do it for us).
Add debugging to track functions that change tty state.

Fixes PR 20834 by Stephen Borrill.

diffstat:

 lib/libcurses/curses_private.h |   3 ++-
 lib/libcurses/getch.c          |  11 +++++++----
 lib/libcurses/screen.c         |   6 +++---
 lib/libcurses/tty.c            |  30 ++++++++++++++++++++++++++++--
 4 files changed, 40 insertions(+), 10 deletions(-)

diffs (197 lines):

diff -r 04ae8e92cfc0 -r a406b9bdeb65 lib/libcurses/curses_private.h
--- a/lib/libcurses/curses_private.h    Sat Apr 05 09:22:22 2003 +0000
+++ b/lib/libcurses/curses_private.h    Sat Apr 05 10:06:59 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses_private.h,v 1.29 2003/02/17 11:07:19 dsl Exp $  */
+/*     $NetBSD: curses_private.h,v 1.30 2003/04/05 10:06:59 jdc Exp $  */
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -227,6 +227,7 @@
        int echoit;
        int pfast;
        int rawmode;
+       int nl;
        int noqch;
        int clearok;
        int useraw;
diff -r 04ae8e92cfc0 -r a406b9bdeb65 lib/libcurses/getch.c
--- a/lib/libcurses/getch.c     Sat Apr 05 09:22:22 2003 +0000
+++ b/lib/libcurses/getch.c     Sat Apr 05 10:06:59 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getch.c,v 1.39 2003/02/17 11:07:20 dsl Exp $   */
+/*     $NetBSD: getch.c,v 1.40 2003/04/05 10:06:59 jdc Exp $   */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)getch.c    8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: getch.c,v 1.39 2003/02/17 11:07:20 dsl Exp $");
+__RCSID("$NetBSD: getch.c,v 1.40 2003/04/05 10:06:59 jdc Exp $");
 #endif
 #endif                                 /* not lint */
 
@@ -847,8 +847,8 @@
        if (is_wintouched(win))
                wrefresh(win);
 #ifdef DEBUG
-       __CTRACE("wgetch: __echoit = %d, __rawmode = %d, flags = %#.4x\n",
-           __echoit, __rawmode, win->flags);
+       __CTRACE("wgetch: __echoit = %d, __rawmode = %d, __nl = %d, flags = %#.4x\n",
+           __echoit, __rawmode, _cursesi_screen->nl, win->flags);
 #endif
        if (__echoit && !__rawmode) {
                cbreak();
@@ -933,6 +933,9 @@
        if (weset)
                nocbreak();
 
+       if (_cursesi_screen->nl && inp == 13)
+               inp = 10;
+
        return ((inp < 0) || (inp == ERR) ? ERR : inp);
 }
 
diff -r 04ae8e92cfc0 -r a406b9bdeb65 lib/libcurses/screen.c
--- a/lib/libcurses/screen.c    Sat Apr 05 09:22:22 2003 +0000
+++ b/lib/libcurses/screen.c    Sat Apr 05 10:06:59 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: screen.c,v 1.12 2003/02/17 11:07:21 dsl Exp $  */
+/*     $NetBSD: screen.c,v 1.13 2003/04/05 10:07:00 jdc Exp $  */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)screen.c   8.2 (blymn) 11/27/2001";
 #else
-__RCSID("$NetBSD: screen.c,v 1.12 2003/02/17 11:07:21 dsl Exp $");
+__RCSID("$NetBSD: screen.c,v 1.13 2003/04/05 10:07:00 jdc Exp $");
 #endif
 #endif                                 /* not lint */
 
@@ -125,7 +125,7 @@
 
        new_screen->infd = infd;
        new_screen->outfd = outfd;
-       new_screen->echoit = 1;
+       new_screen->echoit = new_screen->nl = 1;
         new_screen->pfast = new_screen->rawmode = new_screen->noqch = 0;
        new_screen->nca = A_NORMAL;
        new_screen->color_type = COLOR_NONE;
diff -r 04ae8e92cfc0 -r a406b9bdeb65 lib/libcurses/tty.c
--- a/lib/libcurses/tty.c       Sat Apr 05 09:22:22 2003 +0000
+++ b/lib/libcurses/tty.c       Sat Apr 05 10:06:59 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.31 2003/01/09 21:47:39 atatat Exp $  */
+/*     $NetBSD: tty.c,v 1.32 2003/04/05 10:07:00 jdc Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)tty.c      8.6 (Berkeley) 1/10/95";
 #else
-__RCSID("$NetBSD: tty.c,v 1.31 2003/01/09 21:47:39 atatat Exp $");
+__RCSID("$NetBSD: tty.c,v 1.32 2003/04/05 10:07:00 jdc Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -169,6 +169,9 @@
 int
 raw(void)
 {
+#ifdef DEBUG
+       __CTRACE("raw()\n");
+#endif
        /* Check if we need to restart ... */
        if (_cursesi_screen->endwin)
                __restartwin();
@@ -185,6 +188,9 @@
 int
 noraw(void)
 {
+#ifdef DEBUG
+       __CTRACE("noraw()\n");
+#endif
        /* Check if we need to restart ... */
        if (_cursesi_screen->endwin)
                __restartwin();
@@ -201,6 +207,9 @@
 int
 cbreak(void)
 {
+#ifdef DEBUG
+       __CTRACE("cbreak()\n");
+#endif
        /* Check if we need to restart ... */
        if (_cursesi_screen->endwin)
                __restartwin();
@@ -218,6 +227,9 @@
 int
 nocbreak(void)
 {
+#ifdef DEBUG
+       __CTRACE("nocbreak()\n");
+#endif
        /* Check if we need to restart ... */
        if (_cursesi_screen->endwin)
                __restartwin();
@@ -376,6 +388,9 @@
 int
 echo(void)
 {
+#ifdef DEBUG
+       __CTRACE("echo()\n");
+#endif
        /* Check if we need to restart ... */
        if (_cursesi_screen->endwin)
                __restartwin();
@@ -387,6 +402,9 @@
 int
 noecho(void)
 {
+#ifdef DEBUG
+       __CTRACE("noecho()\n");
+#endif
        /* Check if we need to restart ... */
        if (_cursesi_screen->endwin)
                __restartwin();
@@ -398,6 +416,9 @@
 int
 nl(void)
 {
+#ifdef DEBUG
+       __CTRACE("nl()\n");
+#endif
        /* Check if we need to restart ... */
        if (_cursesi_screen->endwin)
                __restartwin();
@@ -411,6 +432,7 @@
        _cursesi_screen->baset.c_iflag |= ICRNL;
        _cursesi_screen->baset.c_oflag |= ONLCR;
 
+       _cursesi_screen->nl = 1;
        _cursesi_screen->pfast = _cursesi_screen->rawmode;
        return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ?
                          TCSASOFT | TCSADRAIN : TCSADRAIN,
@@ -420,6 +442,9 @@
 int
 nonl(void)
 {
+#ifdef DEBUG
+       __CTRACE("nonl()\n");
+#endif
        /* Check if we need to restart ... */
        if (_cursesi_screen->endwin)
                __restartwin();
@@ -433,6 +458,7 @@
        _cursesi_screen->baset.c_iflag &= ~ICRNL;
        _cursesi_screen->baset.c_oflag &= ~ONLCR;
 
+       _cursesi_screen->nl = 0;
        __pfast = 1;
        return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ?
                          TCSASOFT | TCSADRAIN : TCSADRAIN,



Home | Main Index | Thread Index | Old Index