📄 textwind.h
字号:
// ******************* START OF TEXTWIN.H ********************
//
//
// Text windows are used by utility and test programs to provide
// a convenient set of display functions under MS-DOS.
#ifndef _TEXTWIN_DOT_H
#define _TEXTWIN_DOT_H
#include <dos.h>
#include <conio.h>
#include "BaseWind.h"
#ifdef _MSC_VER
# pragma warning( disable : 4505 )
#endif
// The TextWindow class is a very limited display class that
// uses the BIOS for all of its input and output. It supports
// just a few basic operations, but these are enough for test
// and demonstration programs.
class TextWindow : public BaseWindow {
protected:
static int count;
unsigned char start_row;
unsigned char start_col;
unsigned char width;
unsigned char height;
int border;
unsigned char row;
unsigned char col;
unsigned int *save_buffer;
void write_char( unsigned char c );
void write_repeated_chars( unsigned char c, int count );
void position( int r, int c );
void save_window();
void save_border();
void restore_window();
void restore_border();
public :
TextWindow( int r, int c, int w, int h );
~TextWindow();
BaseWindow& operator<<( char c );
BaseWindow& operator<<( int c );
BaseWindow& operator<<( char *s );
virtual void Clear( void );
void AddBorder( void );
void DisplayTitle( char *title );
void Scroll( unsigned char line_count );
int SetPosition( int row, int col );
void GetPosition( int &rol, int &col );
virtual void GetDimensions( int &width, int &height );
virtual void SetAttribute( int a )
{
attribute = (DisplayAttribute) a;
}
virtual void Goto( void );
int ReadKey( void );
};
// A couple of simple access routines that are short enough
// to define as inline.
inline void TextWindow::GetPosition( int &r, int &c )
{
r = row;
c = col;
}
inline void TextWindow::GetDimensions( int &w, int &h )
{
w = width;
h = height;
}
// This class provides a very handy way to save a cursor position
// and restore it later.
class SaveCursor {
protected :
unsigned char row;
unsigned char col;
public :
SaveCursor();
~SaveCursor();
};
inline SaveCursor::SaveCursor( void )
{
union REGS r;
r.h.ah = 3;
r.h.bh = 0;
int86( 0x10, &r, &r );
row = r.h.dh;
col = r.h.dl;
}
inline SaveCursor::~SaveCursor( void )
{
union REGS r;
r.h.ah = 2;
r.h.dh = row;
r.h.dl = col;
r.h.bh = 0;
int86( 0x10, &r, &r );
}
// PopupWindow is a class derived from TextWindow. It is almost
// identical, except for the fact that it saves the underlying
// text when created and restores it when destroyed.
class PopupWindow : public TextWindow {
protected :
SaveCursor saved_cursor;
public :
PopupWindow( int r, int c, int w, int h );
};
// A couple of handy support routines
int Menu( char *menu[] );
int ReadLine( char *prompt, char *buffer, int length );
void Set43LineMode( int control );
#endif // #ifdef _TEXTWIN_DOT_H
// ********************* END OF TEXTWIN.H ********************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -