home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-01-19 | 3.2 KB | 123 lines | [TEXT/MMCC] |
- //
- // CTerminalPane.h
- //
- // TerminalPane library
- // Terminal display pane
- // PowerPlant version
- //
- // Copyright © 1993-95, FrostByte Design / Eric Scouten
- //
-
- #pragma once
-
- #include <LPeriodical.h>
- #include <LView.h>
-
-
- //***********************************************************
-
- class CTerminalPane : public LView, public LPeriodical {
-
- // This class provides a rudimentary terminal emulator. It’s nothing fancy or snazzy.
- // It doesn’t do VT100; it doesn’t do scrollback; it doesn’t handle any kind of formatting.
-
- public:
- enum { class_ID = 'TERM' };
- static CTerminalPane* CreateTerminalPaneStream(LStream* inStream);
- CTerminalPane(LStream* inStream);
-
- // configuration
-
- virtual void SetBlinking(Boolean blinkMode);
- virtual void DisableKeyScroll(Boolean disable);
-
- // terminal behaviors
-
- virtual void DoClearScreen();
- virtual void DoWriteChar(char theChar);
- virtual void DoWriteStr(char* theStr);
- virtual void DoWriteBfr(char* theStr, short theSize);
- virtual void DoWriteCharNum(char theChar, char leftBracket, char rightBracket);
- virtual void DoEraseChar();
- virtual void DoEraseLine();
- virtual void ScrollToSelection();
-
- // drawing
-
- protected:
- virtual void DrawSelf();
-
- // scrolling
-
- // virtual void DoKeyDown(char theChar, Byte keyCode, EventRecord* macEvent);
-
- // internal blinking cursor support
-
- virtual void Activate();
- virtual void Deactivate();
- virtual void SpendTime(const EventRecord& inMacEvent);
- // virtual void Dawdle(long* maxSleep);
- // virtual Boolean BecomeGopher(Boolean fBecoming);
-
- // internal screen behaviors
-
- virtual void ClearToEOL(short col, short line);
- virtual void ClearToEOS(short col, short line);
- virtual void ScrollTerm();
- virtual void InvalCharRect(short left, short top, short right, short bottom);
- virtual void CursorMoved();
- virtual void CalcCharRect(short left, short top, short right, short bottom, Rect& theRect);
- virtual void InvertCursor(short col, short line);
-
-
- // define the size of the screen
- // (*sigh*… someday this won’t be hard-coded)
-
- enum {
- maxX = 80, // width of screen
- maxY = 24 // height of screen
- };
-
-
- // data members
-
- protected:
- char theScreen[maxY][maxX]; // contents of the screen
- short theColumn; // terminal cursor column number
- short theLine; // terminal cursor line number
- Boolean blinkCursor; // cursor blinking is enabled
- Boolean cursorVis; // cursor is inverted
- Boolean disableKeyScroll; // disable Home/End/PageUp/PageDown
- short lastCursorCol; // position of displayed cursor
- short lastCursorLine;
- long lastCursorTick; // time at last cursor flash
- short charsToInvalLine; // trigger optimization to invalidate entire line at once
-
-
- // misc. display parameters
-
- enum {
- pixelsX = 6, // default font char width (Monaco 9)
- pixelsY = 11, // default font char height
-
- offsetX = 4, // horizontal offset from screen edge
- offsetY = 4, // vertical offset from screen edge
-
- sizeX = 488, // 80 columns * 6 pixels + 8 margin
- sizeY = 272 // 24 rows * 11 pixels + 8 margin
- };
-
- enum { // standard ASCII keycodes
- charNUL = 0,
- charBEL = 7,
- charBS,
- charHT,
- charLF,
- charVT,
- charFF,
- charCR,
- charDEL = 127
- };
-
- };
-