| home | contents | previous | next page | send comment | send link | add bookmark |

Scalc.cpp

/*---------------------------------------------------------------------------------*
 *  "scalc.cpp"
 *
 *  Defines the entry point for the spreadsheet application.
 *
 *  Stephen R. Schmitt
 *
 *  January 1999
 */

#include "calculator.h"
#include "textview.h"
#include "scalc.h"

void check_size();

/*---------------------------------------------------------------------------------*
 *  "main" instantiates data and view classes and runs spreadsheet
 *
 *  returns: nothing
 */
void main()
{
    textview tx;
    calculator calc;

    check_size();

    tx.spreadsheet( &calc );
    tx.run();
}

/*---------------------------------------------------------------------------------*
 *  "check_size" verifies that the terminal screen is large enough for
 *  the spread sheet to be displayed.
 *
 *  Note:  The program is terminated if screen size is less than
 *         24 lines * 80 columns.  This can occur when running SCalc
 *         in an xterm window if the user re-sizes the window.
 *
 *  returns: nothing
 */
void check_size()
{
    // use terminfo constants
    if( COLS >= 80 && LINES >= 24 )
        return;

    endwin(); // terminate curses before write to stdout

    printf( "\n\nScreen is too small." );
    printf( "\nSCalc requires 24 lines, 80 columns.\n\n" );

    exit( 1 );
}

| home | contents | previous | next page | send comment | send link | add bookmark |

Copyright © 2004, Stephen R. Schmitt