summaryrefslogtreecommitdiffstats
path: root/crs.c
diff options
context:
space:
mode:
Diffstat (limited to 'crs.c')
-rw-r--r--crs.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/crs.c b/crs.c
index bab7c52..ef1e956 100644
--- a/crs.c
+++ b/crs.c
@@ -54,6 +54,18 @@
int wgetch P((WINDOW *));
#endif
+static int curses_initted = 0;
+
+static SCM scm_linitscr(void);
+
+
+static void do_init_maybe()
+{
+ if(!curses_initted)
+ scm_linitscr();
+ curses_initted = 1;
+}
+
/* define WIN port type */
#define WIN(obj) ((WINDOW*)CDR(obj))
#define WINP(obj) (tc16_window==TYP16(obj))
@@ -84,8 +96,8 @@ static ptobfuns winptob = {
bwaddch,
bwaddstr,
bwwrite,
- wrefresh,
- wgetch,
+ wrefresh, /* warning from compiler is wrefresh(WINDOW*) not (FILE*) */
+ wgetch, /* warning from compiler is wrefresh(WINDOW*) not (FILE*) */
freewindow};
SCM mkwindow(win)
@@ -102,7 +114,7 @@ SCM mkwindow(win)
}
SCM *loc_stdscr = 0;
-SCM linitscr()
+SCM scm_linitscr()
{
WINDOW *win;
if NIMP(*loc_stdscr) {
@@ -110,10 +122,12 @@ SCM linitscr()
return *loc_stdscr;
}
win = initscr();
+ curses_initted = 1;
return *loc_stdscr = mkwindow(win);
}
SCM lendwin()
{
+ do_init_maybe();
if IMP(*loc_stdscr) return BOOL_F;
return ERR==endwin() ? BOOL_F : BOOL_T;
}
@@ -132,6 +146,7 @@ SCM lnewwin(lines, cols, args)
begin_x = CAR(CDR(args));
ASSERT(INUMP(begin_y), begin_y, ARG3, s_newwin);
ASSERT(INUMP(begin_x), begin_y, ARG4, s_newwin);
+ do_init_maybe();
win = newwin(INUM(lines), INUM(cols),
INUM(begin_y), INUM(begin_x));
return mkwindow(win);
@@ -302,7 +317,7 @@ static char s_nonl[] = "nonl", s_nocbreak[] = "nocbreak",
s_noecho[] = "noecho", s_noraw[] = "noraw";
static iproc subr0s[] = {
- {"initscr", linitscr},
+ {"initscr", scm_linitscr},
{"endwin", lendwin},
{&s_nonl[2], lnl},
{s_nonl, lnonl},
@@ -403,5 +418,5 @@ void init_crs()
make_subr(s_mvwin, tc7_subr_3, lmvwin);
make_subr(s_box, tc7_subr_3, lbox);
add_feature("curses");
- add_final(lendwin);
+ /* add_final(lendwin); */
}