Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libcurses * Made erasechar and killchar into functions
details: https://anonhg.NetBSD.org/src/rev/179e71546aeb
branches: trunk
changeset: 485580:179e71546aeb
user: blymn <blymn%NetBSD.org@localhost>
date: Mon May 01 12:30:30 2000 +0000
description:
* Made erasechar and killchar into functions
* Modified __init_getch to use termcap handle that has been allocated
(_cursesi_genbuf) instead of refetching it.
* Make wgetstr support erase - this is not a full blown SUSv2 version
but it is a start.
diffstat:
lib/libcurses/curses.3 | 4 +-
lib/libcurses/curses.h | 6 +-
lib/libcurses/curses_private.h | 4 +-
lib/libcurses/getch.c | 85 ++++++++++++++++++++---------------------
lib/libcurses/getstr.c | 25 ++++++++++-
lib/libcurses/initscr.c | 6 +-
lib/libcurses/shlib_version | 4 +-
lib/libcurses/tty.c | 27 +++++++++++-
8 files changed, 100 insertions(+), 61 deletions(-)
diffs (truncated from 353 to 300 lines):
diff -r 943c819c476c -r 179e71546aeb lib/libcurses/curses.3
--- a/lib/libcurses/curses.3 Mon May 01 12:11:50 2000 +0000
+++ b/lib/libcurses/curses.3 Mon May 01 12:30:30 2000 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: curses.3,v 1.25 2000/04/27 00:28:28 jdc Exp $
+.\" $NetBSD: curses.3,v 1.26 2000/05/01 12:30:30 blymn Exp $
.\"
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -130,6 +130,7 @@
.It endwin() end window modes
.It erase() erase
.Em stdscr
+.It erasechar() Return the terminal erase character
.It flash() flash the terminal screen
.It flushinp() flush terminal input
.It flushok(win,boolf) set flush-on-refresh flag for
@@ -166,6 +167,7 @@
.It isendwin() check if endwin() or wrefresh() was called latest
.It keypad(win,boolf) set keypad flag for
.Em win
+.It killchar() Return the terminal kill character.
.It leaveok(win,boolf) set leave flag for
.Em win
.It longname(termbuf,name) get long name from
diff -r 943c819c476c -r 179e71546aeb lib/libcurses/curses.h
--- a/lib/libcurses/curses.h Mon May 01 12:11:50 2000 +0000
+++ b/lib/libcurses/curses.h Mon May 01 12:30:30 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: curses.h,v 1.45 2000/04/27 19:54:40 mycroft Exp $ */
+/* $NetBSD: curses.h,v 1.46 2000/05/01 12:30:30 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -78,8 +78,6 @@
/* Old-style terminal modes access. */
#define baudrate() (cfgetospeed(&__baset))
#define crmode() cbreak()
-#define erasechar() (__baset.c_cc[VERASE])
-#define killchar() (__baset.c_cc[VKILL])
#define nocrmode() nocbreak()
#define ospeed (cfgetospeed(&__baset))
#endif /* _CURSES_PRIVATE */
@@ -506,6 +504,7 @@
int doupdate(void);
int echo(void);
int endwin(void);
+char erasechar(void);
int flash(void);
int flushinp(void);
int flushok(WINDOW *win, bool bf);
@@ -530,6 +529,7 @@
bool is_linetouched(WINDOW *win, int line);
bool is_wintouched(WINDOW *win);
void keypad(WINDOW *win, bool bf);
+char killchar(void);
int leaveok(WINDOW *win, bool bf);
char *longname(void);
int meta(WINDOW *win, bool bf);
diff -r 943c819c476c -r 179e71546aeb lib/libcurses/curses_private.h
--- a/lib/libcurses/curses_private.h Mon May 01 12:11:50 2000 +0000
+++ b/lib/libcurses/curses_private.h Mon May 01 12:30:30 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: curses_private.h,v 1.8 2000/04/29 00:42:26 mycroft Exp $ */
+/* $NetBSD: curses_private.h,v 1.9 2000/05/01 12:30:30 blymn Exp $ */
/*-
* Copyright (c) 1998-2000 Brett Lymn
@@ -104,7 +104,7 @@
int __delay(void);
unsigned int __hash(char *s, int len);
void __id_subwins(WINDOW *orig);
-void __init_getch(char *sp);
+void __init_getch(void);
void __init_acs(void);
char *__longname(char *bp, char *def); /* Original BSD version */
int __mvcur(int ly, int lx, int y, int x, int in_refresh);
diff -r 943c819c476c -r 179e71546aeb lib/libcurses/getch.c
--- a/lib/libcurses/getch.c Mon May 01 12:11:50 2000 +0000
+++ b/lib/libcurses/getch.c Mon May 01 12:30:30 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getch.c,v 1.26 2000/04/27 17:50:01 mycroft Exp $ */
+/* $NetBSD: getch.c,v 1.27 2000/05/01 12:30:30 blymn 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.26 2000/04/27 17:50:01 mycroft Exp $");
+__RCSID("$NetBSD: getch.c,v 1.27 2000/05/01 12:30:30 blymn Exp $");
#endif
#endif /* not lint */
@@ -49,6 +49,9 @@
#include "curses.h"
#include "curses_private.h"
+/* defined in setterm.c */
+extern struct tinfo *_cursesi_genbuf;
+
#define DEFAULT_DELAY 2 /* default delay for timeout() */
/*
@@ -369,10 +372,9 @@
*
*/
void
-__init_getch(char *sp)
+__init_getch(void)
{
- static struct tinfo *termcap;
- char entry[1024], termname[1024], *p;
+ char entry[1024], *p;
int i, j, length, key_ent;
size_t limit;
key_entry_t *tmp_key;
@@ -391,54 +393,49 @@
start = end = working = 0;
/* now do the termcap snarfing ... */
- (void) strncpy(termname, sp, (size_t) 1022);
- termname[1023] = 0;
-
- if (t_getent(&termcap, termname) > 0) {
- for (i = 0; i < num_tcs; i++) {
- p = entry;
- limit = 1023;
- if (t_getstr(termcap, tc[i].name, &p, &limit) != NULL) {
- current = base_keymap; /* always start with
- * base keymap. */
- length = (int) strlen(entry);
+ for (i = 0; i < num_tcs; i++) {
+ p = entry;
+ limit = 1023;
+ if (t_getstr(_cursesi_genbuf, tc[i].name, &p, &limit) != NULL) {
+ current = base_keymap; /* always start with
+ * base keymap. */
+ length = (int) strlen(entry);
#ifdef DEBUG
- __CTRACE("Processing termcap entry %s, sequence ",
- tc[i].name);
- for (k = 0; k <= length -1; k++)
- __CTRACE("%s", unctrl(entry[k]));
- __CTRACE("\n");
+ __CTRACE("Processing termcap entry %s, sequence ",
+ tc[i].name);
+ for (k = 0; k <= length -1; k++)
+ __CTRACE("%s", unctrl(entry[k]));
+ __CTRACE("\n");
#endif
- for (j = 0; j < length - 1; j++) {
- /* add the entry to the struct */
- tmp_key = add_new_key(current,
- entry[j],
- KEYMAP_MULTI, 0);
+ for (j = 0; j < length - 1; j++) {
+ /* add the entry to the struct */
+ tmp_key = add_new_key(current,
+ entry[j],
+ KEYMAP_MULTI, 0);
- /* index into the key array - it's
- clearer if we stash this */
- key_ent = current->mapping[
- (unsigned) entry[j]];
+ /* index into the key array - it's
+ clearer if we stash this */
+ key_ent = current->mapping[
+ (unsigned) entry[j]];
- current->key[key_ent] = tmp_key;
-
- /* next key uses this map... */
- current = current->key[key_ent]->value.next;
- }
+ current->key[key_ent] = tmp_key;
+
+ /* next key uses this map... */
+ current = current->key[key_ent]->value.next;
+ }
/* this is the last key in the sequence (it
* may have been the only one but that does
* not matter) this means it is a leaf key and
* should have a symbol associated with it.
*/
- tmp_key = add_new_key(current,
- entry[length - 1],
- KEYMAP_LEAF,
- tc[i].symbol);
- current->key[
- current->mapping[(int)entry[length - 1]]] =
- tmp_key;
- }
+ tmp_key = add_new_key(current,
+ entry[length - 1],
+ KEYMAP_LEAF,
+ tc[i].symbol);
+ current->key[
+ current->mapping[(int)entry[length - 1]]] =
+ tmp_key;
}
}
}
@@ -766,8 +763,10 @@
}
__restore_termios();
+
if (__echoit)
waddch(win, (chtype) inp);
+
if (weset)
nocbreak();
diff -r 943c819c476c -r 179e71546aeb lib/libcurses/getstr.c
--- a/lib/libcurses/getstr.c Mon May 01 12:11:50 2000 +0000
+++ b/lib/libcurses/getstr.c Mon May 01 12:30:30 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getstr.c,v 1.11 2000/04/15 13:17:03 blymn Exp $ */
+/* $NetBSD: getstr.c,v 1.12 2000/05/01 12:30:30 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getstr.c 8.2 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: getstr.c,v 1.11 2000/04/15 13:17:03 blymn Exp $");
+__RCSID("$NetBSD: getstr.c,v 1.12 2000/05/01 12:30:30 blymn Exp $");
#endif
#endif /* not lint */
@@ -89,8 +89,25 @@
int
wgetstr(WINDOW *win, char *str)
{
- while ((*str = wgetch(win)) != ERR && *str != '\n')
- str++;
+ char *ostr, ec;
+ int oldx;
+
+ ostr = str;
+ ec = erasechar();
+ oldx = win->curx;
+
+ while ((*str = wgetch(win)) != ERR && *str != '\n') {
+ if (*str == ec) {
+ *str = '\0';
+ if (str != ostr) {
+ mvwdelch(win, win->cury, win->curx);
+ str--;
+ } else
+ wmove(win, win->cury, oldx);
+ } else
+ str++;
+ }
+
if (*str == ERR) {
*str = '\0';
return (ERR);
diff -r 943c819c476c -r 179e71546aeb lib/libcurses/initscr.c
--- a/lib/libcurses/initscr.c Mon May 01 12:11:50 2000 +0000
+++ b/lib/libcurses/initscr.c Mon May 01 12:30:30 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: initscr.c,v 1.17 2000/04/27 00:23:01 jdc Exp $ */
+/* $NetBSD: initscr.c,v 1.18 2000/05/01 12:30:30 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)initscr.c 8.2 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: initscr.c,v 1.17 2000/04/27 00:23:01 jdc Exp $");
+__RCSID("$NetBSD: initscr.c,v 1.18 2000/05/01 12:30:30 blymn Exp $");
#endif
#endif /* not lint */
@@ -106,7 +106,7 @@
return (NULL);
}
- __init_getch(sp);
+ __init_getch();
__init_acs();
diff -r 943c819c476c -r 179e71546aeb lib/libcurses/shlib_version
--- a/lib/libcurses/shlib_version Mon May 01 12:11:50 2000 +0000
+++ b/lib/libcurses/shlib_version Mon May 01 12:30:30 2000 +0000
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.14 2000/04/27 00:28:58 jdc Exp $
+# $NetBSD: shlib_version,v 1.15 2000/05/01 12:30:30 blymn Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=3
-minor=4
Home |
Main Index |
Thread Index |
Old Index