Click here to Skip to main content
15,886,110 members
Articles / Containers / Virtual Machine

TOOL

Rate me:
Please Sign up or sign in to vote.
4.98/5 (52 votes)
23 Oct 200676 min read 230.2K   5.4K   147  
TOOL (Tiny Object Oriented Language) is an easily-embedded, object-oriented, C++-like-language interpreter. The purpose of this article is to introduce the TOOL interpreter and language from the perspective of a person who has a desire to include a scripting solution as part of his project.
#ifndef VM_CONSOLE_H_INCLUDED
#define VM_CONSOLE_H_INCLUDED
/*****************************************************************************/
/*                              HEADER FILE                                  */
/*****************************************************************************/
/*
       $Archive:   $

      $Revision:   $
          $Date:   $
        $Author:   $

    Description:   Declaration of the class Definition of the CConsole class

                      TOOL And XML FORMS License
                      ==========================

                      Except where otherwise noted, all of the documentation 
                      and software included in the TOOL package is 
                      copyrighted by Michael Swartzendruber.

                      Copyright (C) 2005 Michael John Swartzendruber. 
                      All rights reserved.

                      Access to this code, whether intentional or accidental,
                      does NOT IMPLY any transfer of rights.

                      This software is provided "as-is," without any express 
                      or implied warranty. In no event shall the author be held
                      liable for any damages arising from the use of this software.

                      Permission is granted to anyone to use this software for 
                      any purpose, including commercial applications, and to 
                      alter and redistribute it, provided that the following 
                      conditions are met:

                      1. All redistributions of source code files must retain 
                         all copyright notices that are currently in place, 
                         and this list of conditions without modification.

                      2. The origin of this software must not be misrepresented;
                         you must not claim that you wrote the original software.

                      3. If you use this software in another product, an acknowledgment
                         in the product documentation would be appreciated but is
                         not required.

                      4. Modified versions in source or binary form must be plainly 
                         marked as such, and must not be misrepresented as being 
                         the original software.
*/
/*****************************************************************************/



//Some defines we will be requiring
//
#define SC_LINES    0x0001
#define SC_COLUMNS  0x0002
#define SC_ATTRIB   0x0004
#define SC_MAXLINES 0x0008


#define ERROR_MSG   0
#define WARN_MSG    1
#define INFO_MSG    2


#define NUM_ROWS   25
#define NUM_COLS   80
#define MAX_ROWS   NUM_ROWS
#define RGN_ONE    0

#define RGN_ONE_STATUS_LINE   RGN_ONE + 1
#define RGN_ONE_TOP_MSG_LINE  RGN_ONE + 3

#define MAX_ROW_IDX_RGN_ONE   NUM_ROWS - 1

#define WRAP   TRUE
#define SCROLL FALSE

class VMConsole
{
friend class VMFacade;

public:
  // Constructor & Destructor
  //
  VMConsole();
  VMConsole( BOOL );
  ~VMConsole();

  // Properties
  //
  short GetNumberOfLines( void );
  short SetNumberOfLines( short sLines );
  short SetNumberOfColumns( short sColumns );
  short GetNumberOfColumns( void );
  WORD  GetAttributes( void );
  WORD  SetAttributes( WORD wAttrib,short NumChars = 0 );
  short SetMaxLinesInWindow( short maxLines );
  short GetMaxLinesInWindow( void );

  // Methods
  //
  void   RedirectToConsole( WORD wFlags );
  BOOL   SetupConsole( WORD wFlags );
  HANDLE GetHandle( DWORD dwFlag );
  BOOL   Clear( void );
  BOOL   ApplyAttrib( short NumChars );
  WORD   GetSettings( WORD wFlags );
  BOOL   SetCaption( char* pchText );
  BOOL   ClearScreen( void );
  BOOL   MaximizeConsoleWindow( void );
  BOOL   SetUpMouseCapture( void );
  BOOL   DisplayCursor( BOOL bShowHide );
  void   InvertRectangle( COORD coordStart, COORD coordCur );
  SHORT  GetConsoleXDimension( void );
  SHORT  GetConsoleYDimension( void );
  void   ScrollRect( SMALL_RECT xScrollRect );
  void   DrawRegionBorder( short sYPos );
  BOOL   PutStringAtXY( int iMsgType, SHORT sX, SHORT sY, char* pchString );
  void   PutStatusLineAtY( short sYPos, char* pchText );
  void   ResizeBufferAndWindow( SHORT xSize, SHORT ySize );

  // Set screen colors (three choices).
  //
  void WhiteOnBlack( void );
  void BlackOnWhite( void );
  void RedOnWhite( void ); 

  // Helpers
  //
  BOOL CreateConsole( void );
  BOOL DestroyConsole( void );

protected:
  BOOL        m_bRedirected;
  short       m_sNumColumns;
  short       m_sNumLines;
  WORD        m_wAttrib;
  short       m_sMaxLines;
  DWORD       m_dwError;

  static BOOL sm_bConsole;
};



#endif


/*****************************************************************************/
/* Check-in history */
/*
 *$Log:   $
*/
/*****************************************************************************/


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions