home *** CD-ROM | disk | FTP | other *** search
- #include "StrangeGlove.h"
- #include "Terminal.h"
-
- extern WindowPtr gTermWindow;
- extern Boolean gTerminal;
-
- static int curRow, curCol, maxRow, maxCol;
-
-
- /***** WriteTermWindow *****/
- void WriteTermWindow(char c)
- {
- GrafPtr oldPort;
- Point curPen;
-
- GetPort(&oldPort);
- SetPort(gTermWindow);
- if ((c != 10) && (c != ESCAPECHAR)) /* 10 is some bad control-character */
- {
- GetPen(&curPen);
- if (c == '\r')
- {
- if (curRow > maxRow)
- {
- ScrollWindow();
- MoveTo(SIDEMARGIN, curRow);
- }
- else
- MoveTo(SIDEMARGIN, (curRow += ROWHEIGHT));
- }
- else
- {
- if (curPen.h > maxCol)
- {
- if (curRow > maxRow)
- {
- ScrollWindow();
- MoveTo(SIDEMARGIN, curRow);
- }
- else
- MoveTo(SIDEMARGIN, (curRow += ROWHEIGHT));
- }
- DrawChar(c);
- }
- }
- SetPort(oldPort);
- }
-
-
- /***** ScrollWindow *****/
- ScrollWindow()
- {
- RgnHandle tempRgn;
-
- tempRgn = NewRgn();
- ScrollRect(&gTermWindow->portRect, HORIZONTAL_OFFSET, -ROWHEIGHT, tempRgn);
- DisposeRgn(tempRgn);
- }
-
-
- /***** StartTerm *****/
- StartTerm()
- {
- Rect termRect;
-
- gTerminal = TRUE;
-
- SetPort(gTermWindow);
-
- termRect = gTermWindow->portRect;
- maxRow = termRect.bottom - termRect.top - (ROWHEIGHT + BOTTOM_MARGIN);
- maxCol = termRect.right - termRect.left - (2 * SIDEMARGIN);
- curRow = STARTROW;
- curCol = SIDEMARGIN;
-
- TextFont(monaco);
- TextSize(TEXT_FONT_SIZE);
-
- MoveTo(SIDEMARGIN, STARTROW);
-
- ShowWindow(gTermWindow);
- SelectWindow(gTermWindow);
- AdjustTerminalMenu();
- }
-
-
- /***** StopTerm *****/
- StopTerm()
- {
- gTerminal = FALSE;
- HideWindow(gTermWindow);
- AdjustTerminalMenu();
- }
-
-
-