From 23231c1a0e61ff8f0ebbfe4aaa24559952d8e9ed Mon Sep 17 00:00:00 2001 From: blymn Date: Sun, 14 Oct 2001 12:36:09 +0000 Subject: [PATCH] Added 2 new functions and a macro: - getparx - getpary - getparyx (macro) Also minor tweak to the man page to correct grammar on a couple of items. --- lib/libcurses/PSD.doc/fns.doc | 25 +++++++++++++++++++++++ lib/libcurses/curses.3 | 15 +++++++++++--- lib/libcurses/curses.h | 5 ++++- lib/libcurses/getyx.c | 38 +++++++++++++++++++++++++++++++++-- 4 files changed, 77 insertions(+), 6 deletions(-) diff --git a/lib/libcurses/PSD.doc/fns.doc b/lib/libcurses/PSD.doc/fns.doc index f8b447596abd..8bebaaebe3b7 100644 --- a/lib/libcurses/PSD.doc/fns.doc +++ b/lib/libcurses/PSD.doc/fns.doc @@ -527,6 +527,31 @@ until a newline or EOF is encountered. The newline stripped off the string. \*(Es .Ds +.Fn getparx "WINDOW *win" +.De +Returns the x location of the given subwindow relative to the parent +window. If the window is not a subwindow then -1 is returned. +.Ds +.Fn getpary "WINDOW *win" +.De +Returns the y location of the given subwindow relative to the parent +window. If the window is not a subwindow then -1 is returned. +.Ds +.Fn getpary "WINDOW *win" "int y" "int x" +Is a macro that sets the +.Vn y +and +.Vn x +parameters to the respective coordinates of the top left hand corner +of the subwindow relative to the parent window. If the given window +.Vn win +is not a subwindow then both +.Vn y +and +.Vn x +will be set to -1. +.De +.Ds .Fn gettmode "" .De Get the tty stats. diff --git a/lib/libcurses/curses.3 b/lib/libcurses/curses.3 index 434a4aef67cb..014bb83707be 100644 --- a/lib/libcurses/curses.3 +++ b/lib/libcurses/curses.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses.3,v 1.33 2001/10/08 10:45:13 blymn Exp $ +.\" $NetBSD: curses.3,v 1.34 2001/10/14 12:36:09 blymn Exp $ .\" .\" Copyright (c) 1985, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -152,9 +152,9 @@ relative to .Em win .It getcurx(win) get current x position on .Em win -.It getbegy(win) get start y position on +.It getbegy(win) get start y position of .Em win -.It getbegx(win) get start x position on +.It getbegx(win) get start x position of .Em win .It getmaxy(win) get maximum y position on .Em win @@ -162,6 +162,15 @@ relative to .Em win .It getnstr(str, len) get a string of maximun len characters through .Em stdscr +.It getpary(win) get start y position of subwindow +.Em win +relative to parent. +.It getparx(win) get start x position of subwindow +.Em win +relative to parent. +.It getparyx(win, y, x) set y and x to position of subwindow +.Em win +relative to parent. .It getstr(str) get a string through .Em stdscr .It gettmode() get tty modes diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h index 28a62c9d128d..a1a45282d545 100644 --- a/lib/libcurses/curses.h +++ b/lib/libcurses/curses.h @@ -1,4 +1,4 @@ -/* $NetBSD: curses.h,v 1.60 2001/10/08 10:45:13 blymn Exp $ */ +/* $NetBSD: curses.h,v 1.61 2001/10/14 12:36:09 blymn Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -608,6 +608,7 @@ __END_DECLS #define getyx(w, y, x) (y) = getcury(w), (x) = getcurx(w) #define getbegyx(w, y, x) (y) = getbegy(w), (x) = getbegx(w) #define getmaxyx(w, y, x) (y) = getmaxy(w), (x) = getmaxx(w) +#define getparyx(w, y, x) (y) = getpary(w), (x) = getparx(w) /* Public function prototypes. */ __BEGIN_DECLS @@ -642,6 +643,8 @@ int getbegy(WINDOW *); int getbegx(WINDOW *); int getmaxy(WINDOW *); int getmaxx(WINDOW *); +int getpary(WINDOW *); +int getparx(WINDOW *); int gettmode(void); bool has_colors(void); bool has_ic(void); diff --git a/lib/libcurses/getyx.c b/lib/libcurses/getyx.c index eb806c545b18..52c0b8dc6caa 100644 --- a/lib/libcurses/getyx.c +++ b/lib/libcurses/getyx.c @@ -1,4 +1,4 @@ -/* $NetBSD: getyx.c,v 1.3 2000/04/24 14:09:43 blymn Exp $ */ +/* $NetBSD: getyx.c,v 1.4 2001/10/14 12:36:09 blymn Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #ifndef lint -__RCSID("$NetBSD: getyx.c,v 1.3 2000/04/24 14:09:43 blymn Exp $"); +__RCSID("$NetBSD: getyx.c,v 1.4 2001/10/14 12:36:09 blymn Exp $"); #endif /* not lint */ #include @@ -46,6 +46,40 @@ __RCSID("$NetBSD: getyx.c,v 1.3 2000/04/24 14:09:43 blymn Exp $"); #include "curses.h" #include "curses_private.h" +/* + * getpary -- + * Get the y postion of the window relative to the parent window + * return -1 if not a subwindow. + */ +int +getpary(WINDOW *win) +{ + if (win == NULL) + return -1; + + if (win->orig == NULL) + return -1; + + return (win->begy - win->orig->begy); +} + +/* + * getparx -- + * Get the x postion of the window relative to the parent window + * return -1 if not a subwindow. + */ +int +getparx(WINDOW *win) +{ + if (win == NULL) + return -1; + + if (win->orig == NULL) + return -1; + + return (win->begx - win->orig->begx); +} + /* * getcury -- * Get current y position on window.