home *** CD-ROM | disk | FTP | other *** search
- /* #ident "@(#) init.c - Typing Tutor initialisation." */
-
- #include "tt.h"
- #include "externals.h"
-
- static char *title={"Christopher Sawtell's Typing Tutor"},
- *lesson_file_name={"/usr/local/lib/tt.text"};
-
- static char *copyright[] = {
- "Copyright (C) 1993 Christopher Sawtell.",
- "Permission is granted to any individual or institution to use, copy, or",
- "redistribute this package of programs so long as it is not modified in",
- "any way whatsoever without the author's knowledge or sold for profit.",
- NULL
- };
-
- static char *disclaimer[] = {
- "LIKE ANYTHING ELSE WHICH IS FREE, \"TT\" AND ITS ASSOCIATED FILES ARE",
- "PROVIDED \"AS IS\" AND COME WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED OR",
- "IMPLIED. IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DAMAGES",
- "RESULTING FROM THE USE OF THIS SOFTWARE.",
- NULL
- };
-
- init()
- {
- int x, y;
- char **ch_pp;
-
- /*
- * First open a screen and then two curses windows
- * - the top one for lesson instructions
- * and the bottom for the fields into which to type.
- */
-
- /* allocate an input buffer */
-
- if (( ipbp = ipbuffer = ( char * ) malloc ( COLS + 1 )) == NULL )
- { perror ( title );
- exit ( ERR );
- }
-
- /* open lesson text file */
-
- if (( lesson = ( FILE * ) fopen ( lesson_file_name, "r" )) == NULL )
- { perror ( title );
- exit ( ERR );
- }
-
- initscr();
- refresh ();
- nonl();
- noecho();
- cbreak();
-
- /* Create windows */
-
- attron ( A_UNDERLINE );
- move ( TITLE_LINE, (COLS-strlen(title))/2); /* Put program title up. */
- printw ( title ); /* Do it this way so that the title is always */
- /* in the middle of top line irrespective of */
- /* the number of screen columns. */
- attroff ( A_UNDERLINE );
- wnoutrefresh ( stdscr );
- top_window = newwin ( TOP_WINDOW_HEIGHT,
- TOP_WINDOW_WIDTH,
- TOP_WINDOW_ROW,
- TOP_WINDOW_COLUMN
- );
- wattrset ( top_window, A_NORMAL );
- werase ( top_window );
- middle_window = newwin ( MIDDLE_WINDOW_HEIGHT,
- MIDDLE_WINDOW_WIDTH,
- MIDDLE_WINDOW_ROW,
- MIDDLE_WINDOW_COLUMN
- );
- wattrset ( middle_window, A_NORMAL );
- werase ( middle_window );
- bottom_window = newwin ( BOTTOM_WINDOW_HEIGHT,
- BOTTOM_WINDOW_WIDTH,
- BOTTOM_WINDOW_ROW,
- BOTTOM_WINDOW_COLUMN
- );
- wattrset ( bottom_window, A_NORMAL );
- werase ( bottom_window );
- current_window = top_window;
- }
-
-