home *** CD-ROM | disk | FTP | other *** search
- /* #ident "@(#)do_lesson.c - The text and window handling routines." */
-
- #include "tt.h"
- #include "externals.h"
-
- do_lesson()
- {
- int x, y, get_the_data = FALSE, no_of_data_lines = 0;
- void get_data (), paktc ();
- static int first_time = TRUE;
-
- while ( !feof ( lesson ))
- {
- fgets ( ipbuffer, COLS-2, lesson );
- ipbp = ipbuffer;
- no_of_data_lines++;
- x = TEXT_LEFT_SIDE;
-
- if ( ipbuffer[1] == '\n' )
- { /* A single flag character line in lesson file. */
- y = TEXT_TOP_LINE;
- if ( !first_time )
- {
- border ( current_window );
- wnoutrefresh ( current_window );
- doupdate();
- }
- if ( current_window == middle_window )
- {
- border ( bottom_window );
- wnoutrefresh ( bottom_window );
- doupdate();
- }
-
- if ( get_the_data ) get_data (--no_of_data_lines);
-
- switch ( ipbuffer[0] ) /* Is it a line of instructions */
- { /* or data to be copied by the student? */
-
- case INSTRUCTION_FLAG:
- {
- if ( !first_time && !get_the_data )
- { paktc (); /* Press Any Key To Continue. */
- break;
- }
- current_window = top_window;
- get_the_data = FALSE;
- break;
- }
-
- case DATA_FLAG:
- { get_the_data = TRUE;
- current_window = middle_window;
- no_of_data_lines = 0;
- werase ( bottom_window );
- break;
- } /* End of DATA case. */
- } /* End of switch statement. */
-
- first_time = FALSE;
- werase ( current_window );
- continue;
- } /* end of flag character block. */
- else
- { /* there is a line of text from lesson file. */
- wattrset ( current_window, 0 );
- mvwaddstr ( current_window, y, x, ipbuffer );
- if ( current_window == middle_window )
- {
- wattrset ( bottom_window, 0 );
- wmove ( bottom_window, y, x );
- while ( *ipbp != '\n' )
- {
- waddch ( bottom_window, ( *ipbp == SPACE ) ? SPACE : UNDERLINE );
- ipbp++;
- }
- }
- y++;
- }
- }
- }
-
- /*
- * paktc (); - Press A Key To Continue.
- */
-
- #define PAKTC_WINDOW_HEIGHT 3
- #define PAKTC_WINDOW_WIDTH 30
- #define PAKTC_WINDOW_ROW 21
-
- char *paktc_message = {"Press Any Key To Continue."};
-
- void paktc ()
- {
- WINDOW *paktc_window;
- char junk_char;
- int row, column, paktc_window_column;
-
- row = 1;
- column = 2;
- paktc_window_column = ( COLS - PAKTC_WINDOW_WIDTH ) / 2;
-
- paktc_window = newwin ( PAKTC_WINDOW_HEIGHT,
- PAKTC_WINDOW_WIDTH,
- PAKTC_WINDOW_ROW,
- paktc_window_column
- );
-
- werase ( paktc_window );
- wmove ( paktc_window, row, column );
- wprintw ( paktc_window, "%s", paktc_message );
- wnoutrefresh ( paktc_window );
- border ( paktc_window );
- wnoutrefresh ( paktc_window );
- doupdate ();
- junk_char = getch ();
- werase ( paktc_window );
- wnoutrefresh ( paktc_window );
- doupdate ();
- delwin ( paktc_window );
- }
-
-