home *** CD-ROM | disk | FTP | other *** search
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
-
- CTermPane.c
-
- Commtoolbox terminal emulation class.
-
- SUPERCLASS = CPanorama.
-
- Copyright © 1992-93 Romain Vignes. All rights reserved.
-
- ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
-
- #include <CommResources.h> /* Apple includes */
-
- #include <CBartender.h> /* TCL includes */
- #include <CClipboard.h>
- #include <CCluster.h>
- #include <CError.h>
- #include <Commands.h>
- #include <Constants.h>
- #include <CWindow.h>
- #include <Global.h>
- #include <LongQD.h>
- #include <TBUtilities.h>
- #include <TCLUtilities.h>
-
- #include "CTermPane.h" /* Other includes */
-
-
- /* Constants & Macros */
-
- #define TERM_STR_RES_ID 2200 /* Emulation messages resource ID */
-
- #define NO_TOOL_STR_INDEX 1 /* No terminal tool */
- #define BAD_TOOL_STR_INDEX 2 /* Bad terminal tool */
- #define NO_REC_STR_INDEX 3 /* Terminal record allocation error */
- #define CHOOSE_STR_INDEX 4 /* Tool setup error */
-
- #define H_CHOOSE_POS 10 /* Setup dialog position */
- #define V_CHOOSE_POS 40
-
- #define SPACE 0x20 /* Space char */
- #define TAB 0x09 /* Tab char */
-
- #define CHAR_DELAY_TICKS 15
-
- #define RESET_ALRT_ID 2200
-
-
- /* Application globals */
-
- extern CBartender *gBartender;
- extern CClipboard *gClipboard;
- extern CError *gError;
- extern EventRecord gLastMouseUp;
-
-
- /* Class Variables Initialization */
-
- CCluster *CTermPane::cTermList = NULL;
-
-
-
- /*
- * cTermIdle
- *
- * Idle time for each terminal object
- *
- *
- */
-
- /* Idle routine for each terminal object */
-
- static void Term_Idle(CTermPane *theTerm)
- {
- theTerm->DoIdle();
- }
-
-
- void CTermPane::cTermIdle(void)
- {
- if (cTermList != NULL) /* List exists ? */
- cTermList->DoForEach((EachFunc) Term_Idle);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * cInitManager
- *
- * Terminal Manager Initialization
- *
- */
-
- void CTermPane::cInitManager(void)
- {
- InitTM();
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * cGetTMVersion
- *
- * return the version of the Terminal Manager
- *
- */
-
- short CTermPane::cGetTMVersion(void)
- {
- return TMGetTMVersion();
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * cCheckToolName
- *
- * Existence tool checking
- *
- * toolName: name of the tool
- *
- * Return tmGenericError if the tool is not found
- *
- */
-
- OSErr CTermPane::cCheckToolName(Str63 toolName)
- {
- return(TMGetProcID(toolName));
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * cTestToolMenu
- *
- * Test if the selected menu belongs to a terminal tool
- *
- * theMenu: selected menu ID
- * theItem: selected item ID
- *
- * Return TRUE if the menu is a terminal tool menu
- */
-
-
- /* Test routine */
-
- static Boolean TermMenuTest(CTermPane *theTerm)
- {
- return theTerm->active;
- }
-
-
- Boolean CTermPane::cTestToolMenu(short theMenu, short theItem)
- {
- CTermPane *current;
-
- if (cTermList == NULL)
- return FALSE;
- else {
- current = (CTermPane *) cTermList->FindItem((TestFunc) TermMenuTest);
-
- if (current == NULL)
- return FALSE;
- else
- return current->DoMenu(theMenu,theItem);
- }
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * cTestToolEvent
- *
- * Test if the event is related to a terminal tool
- *
- * macEvent: pointer on the event record
- * theWindow: pointer on the window record
- *
- * Return TRUE if the event is a terminal event
- */
-
- typedef struct {
- EventRecord *theEvent;
- WindowPtr theWindow;
- Boolean isToolEvent;
- } TestParamRec;
-
-
- /* Test routine */
-
- static void TermEvtTest(CTermPane *theTerm,TestParamRec *params)
- {
- if (params->isToolEvent == FALSE)
- params->isToolEvent = theTerm->DoEvent(params->theEvent,
- params->theWindow);
- }
-
-
- Boolean CTermPane::cTestToolEvent(EventRecord *macEvent,WindowPtr theWindow)
- {
- TestParamRec params;
-
- params.theEvent = macEvent;
- params.theWindow = theWindow;
- params.isToolEvent = FALSE;
-
- if (cTermList == NULL)
- return FALSE;
- else {
- cTermList->DoForEach1((EachFunc1) TermEvtTest,(long) ¶ms);
-
- return params.isToolEvent;
- }
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * ITermPane
- *
- * Terminal pane object Initialization
- *
- * anEnclosure: its enclosure view
- * aSupervisor: its supervisor in the chain of command
- * toolName: Terminal tool name ("" -> default tool)
- * flags(TM): How to use the tool
- * sendProc(TM): Pointer on the chars sending procedure
- * cacheProc(TM): Pointer on the cach managing procedure
- * breakProc(TM): Pointer on the BREAK signal sending procedure
- * clickLoop(TM): Pointer on the clics handling sending procedure
- * environsProc(TM):Pointer on the environnement description procedure
- * refCon(TM): undefined (application can use it)
- * userData(TM): undefined (application can use it)
- *
- * Parameters followed by TM are exactly matching the ones used for the
- * terminal record creation.
- *
- */
-
- void CTermPane::ITermPane(CView *anEnclosure, CBureaucrat *aSupervisor,
- Str63 toolName,TMFlags flags,ProcPtr sendProc,
- ProcPtr cacheProc,ProcPtr breakProc,
- ProcPtr clickLoop,ProcPtr environsProc,long refCon,
- long userData)
-
- {
- LongRect lRect,newBounds;
- Rect termRect,viewRect;
- OSErr theErr;
- short toolProcID;
- WindowPtr owner;
- Boolean savedAlloc;
- TermHandle hTerm;
- Str63 tName;
- TermEnvironRec theEnvirons;
-
- CPanorama::IPanorama(anEnclosure, aSupervisor,0,0,0,0,
- sizELASTIC, sizELASTIC); /* Initialize
- its superclass */
-
- termRect.top = 0; /* visible terminal rect */
- termRect.left = 0;
- termRect.bottom = 0;
- termRect.right = 0;
-
- owner = (WindowPtr) this->GetMacPort(); /* Window port */
-
- if (toolName[0] == 0) { /* Default tool ? */
-
- theErr = CRMGetIndToolName(classTM,1,tName);
- if ((theErr != noErr) || (tName[0] == 0)) /* No tool */
- Failure(tmNoTools,SpecifyMsg(TERM_STR_RES_ID,NO_TOOL_STR_INDEX));
-
- toolProcID = TMGetProcID(tName); /* Default tool ID */
- }
- else
- toolProcID = TMGetProcID(toolName); /* Chosen tool ID */
-
- if (toolProcID == tmGenericError) /* Bad tool */
- Failure(tmNoTools,SpecifyMsg(TERM_STR_RES_ID,BAD_TOOL_STR_INDEX));
-
- savedAlloc = SetAllocation(kAllocCanFail);
-
- hTerm = TMNew(&termRect,&termRect,flags,toolProcID,owner,
- sendProc,cacheProc,breakProc,clickLoop,environsProc,
- refCon,userData);
-
- SetAllocation(savedAlloc);
-
- FailNIL(hTerm); /* Terminal record created ? */
-
- MoveHHi((Handle)hTerm); /* Heap fragmentation… */
-
- this->itsTerm = hTerm;
-
- this->changedConfig(); /* Configuration update */
-
- this->SetWantsClicks(TRUE);
-
- this->SetCanBeGopher(TRUE);
-
- if (cTermList == NULL) { /* First Terminal Object ? */
- cTermList = new(CCluster);
- cTermList->ICluster();
- }
-
- cTermList->Add(this); /* Terminal addition */
- }
-
-
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * Dispose
- *
- * Terminal pane object disposal
- *
- */
-
- void CTermPane::Dispose(void)
- {
- ASSERT(cTermList != NULL);
-
- cTermList->Remove(this); /* Dispose of the terminal */
-
- if (cTermList->IsEmpty())
- ForgetObject(cTermList); /* Dispose of the cluster */
-
- TMDispose(itsTerm); /* Terminal record removal */
- itsTerm = NULL;
-
- inherited::Dispose(); /* Pass message to its superclass */
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * Draw
- *
- * Terminal pane drawing
- *
- * area: Pointer on the region to be updated
- *
- */
-
- void CTermPane::Draw(Rect *area)
- {
- RgnHandle updateRgn;
-
- Prepare();
-
- updateRgn = NewRgn();
- FailNIL(updateRgn);
-
- RectRgn(updateRgn,area); /* Transform rect into region */
-
- TMUpdate(itsTerm,updateRgn);
-
- DisposeRgn(updateRgn);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * DoCommand
- *
- * Terminal pane related commands handling
- *
- * theCommand: Command to be executed
- *
- */
-
- void CTermPane::DoCommand(long theCommand)
- {
- Handle selectionHdl;
- ResType selectionType;
- short scrapLength,i;
- EventRecord theEvent;
-
- switch (theCommand) {
-
- case cmdTermChoose: /* Terminal tool setup */
- this->TermChoose();
- break;
-
- case cmdTermClear: /* Screen clearing */
- this->TermClear();
- break;
-
- case cmdTermReset: /* Terminal reset */
- this->Reset();
- break;
-
- case cmdCopy: /* Copy */
- selectionHdl = NewHandle(0);
- TMGetSelect(itsTerm,selectionHdl,&selectionType);
-
- gClipboard->EmptyScrap();
- gClipboard->PutData(selectionType,selectionHdl);
-
- DisposHandle(selectionHdl);
-
- break;
-
- case cmdTabCopy: /* Table copy */
- this->DoTabCopy();
- break;
-
- case cmdPaste: /* Paste */
-
- theEvent.what = keyDown;
-
- gClipboard->GetData('TEXT',&selectionHdl);
-
- scrapLength = gClipboard->DataSize('TEXT');
-
- for (i = 0;i < scrapLength;i ++) { /* For each char… */
- theEvent.message = (*selectionHdl)[i];
- theEvent.modifiers = 0;
- TMKey(itsTerm,&theEvent);
- }
- DisposHandle(selectionHdl);
-
- break;
-
- case cmdSelectAll: /* Complete pane selection */
- this->DoSelectAll();
- break;
-
- default:
- inherited::DoCommand(theCommand);
- break;
- }
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * UpdateMenus
- *
- * Terminal tool menus updating
- *
- */
-
- void CTermPane::UpdateMenus(void)
- {
- Rect nullRect;
- SignedByte savedState;
-
- savedState = HGetState(itsTerm);
- HLock(itsTerm);
-
- inherited::UpdateMenus(); /* Pass message to its superclass */
-
- gBartender->EnableCmd(cmdSelectAll); /* Complete selection */
-
- gBartender->EnableCmd(cmdTermChoose); /* Terminal tool setup */
-
- gBartender->EnableCmd(cmdTermClear); /* Screen clearing */
-
- gBartender->EnableCmd(cmdTermReset); /* Terminal reset */
-
- SetRect(&nullRect,0,0,0,0);
-
- if (!EqualRect(&nullRect,&(((*itsTerm)->selection).selRect))) {
- gBartender->EnableCmd(cmdCopy); /* Copier */
-
- if (((*itsTerm)->selType == selTextNormal) ||
- ((*itsTerm)->selType == selTextBoxed))
- gBartender->EnableCmd(cmdTabCopy); /* Table copy */
-
- }
-
- if (gClipboard->DataSize('TEXT') > 0) /* Paste */
- gBartender->EnableCmd(cmdPaste);
-
- HSetState(itsTerm,savedState);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * TermChoose
- *
- * Terminal tool setup
- *
- */
-
- void CTermPane::TermChoose(void)
- {
- short retCode;
- Point where;
- TermHandle hTerm;
-
- hTerm = this->itsTerm;
- HUnlock((Handle)hTerm);
-
- SetPt(&where,H_CHOOSE_POS,V_CHOOSE_POS); /* Dialog position */
-
- retCode = TMChoose(&hTerm,where,NULL);
-
- HLock((Handle)hTerm);
- this->itsTerm = hTerm;
-
- switch (retCode) {
- case chooseCancel: /* Canceled setup */
- break;
-
- case chooseOKMinor: /* Same tool, changed config */
- case chooseOKMajor: /* Changed tool */
-
- this->changedConfig();
-
- TMActivate(itsTerm,TRUE);
-
- itsSupervisor->Notify(NULL); /* Notify document… */
-
- break;
-
- default: /* Unknown code (error) */
- FailOSErr(retCode);
- break;
- }
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * DoIdle
- *
- * Application idle time
- *
- */
-
- void CTermPane::DoIdle(void)
- {
- Prepare();
-
- TMIdle(itsTerm);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * AdjustCursor
- *
- * Cursor shape update
- *
- * where: cursor position
- * mouseRgn: mouse region
- *
- */
-
- void CTermPane::AdjustCursor(Point where,RgnHandle mouseRgn)
- {
- /* The cursor shape is updated by the tool during the idle time */
-
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * Activate
- *
- * Terminal pane activating
- *
- */
-
- void CTermPane::Activate(void)
- {
- inherited::Activate(); /* Pass message to its superclass */
-
- Prepare();
-
- TMActivate(itsTerm,TRUE); /* Tool activation */
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * Deactivate
- *
- * Terminal pane deactivation
- *
- */
-
- void CTermPane::Deactivate(void)
- {
- Prepare();
-
- TMActivate(itsTerm,FALSE); /* tool deactivation */
-
- inherited::Deactivate(); /* Pass message to its superclass */
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * Mouse clic in the terminal pane
- *
- * hitPt: Click position
- * modifierKeys: Keyboard stat
- * when: click instant
- *
- */
-
- void CTermPane::DoClick(Point hitPt,short modifierKeys,long when)
- {
- EventRecord theEvent;
-
- theEvent.what = mouseDown;
- theEvent.where = hitPt;
- LocalToGlobal(&theEvent.where); /* Conversion */
- theEvent.modifiers = modifierKeys;
- theEvent.when = when;
-
- TMClick(itsTerm,&theEvent); /* Tool handles clicks… */
-
- gLastMouseUp.what = mouseUp; /* MouseUp… simulation */
- gLastMouseUp.when = TickCount();
- gLastMouseUp.where = hitPt;
- LocalToGlobal( &gLastMouseUp.where); /* Conversion */
- gLastMouseUp.modifiers = modifierKeys;
-
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * ResizeFrame
- *
- * Changing of the terminal pane size
- *
- * delta: updates rect
- *
- */
-
- void CTermPane::ResizeFrame(Rect *delta)
- {
- Rect newTermRect;
-
- inherited::ResizeFrame(delta); /* Pass message to its superclass */
-
- FrameToWindR(&frame,&newTermRect); /* Visible region */
-
- TMResize(itsTerm,&newTermRect); /* tool handles resizing… */
- }
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * DoKeyDown
- *
- * Keyboard handling
- *
- * theChar: Typed char
- * keyCode: Code of the corresponding key
- * macEvent: Pointer on the related event
- *
- */
-
- void CTermPane::DoKeyDown(char theChar,Byte keyCode,EventRecord *macEvent)
- {
- TMKey(itsTerm,macEvent); /* Tool handles keys… */
-
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * TypeChar
- *
- * Type simulation
- *
- * theChar: char to be typed
- *
- */
-
- void CTermPane::TypeChar(unsigned char theChar)
- {
- EventRecord theEvent;
- long finalTicks;
-
- theEvent.what = keyDown;
- theEvent.message = theChar;
- theEvent.modifiers = 0;
-
- Delay(CHAR_DELAY_TICKS,&finalTicks);
-
- this->DoKeyDown(theChar,0,&theEvent);
-
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * DoAutoKey
- *
- * Key repetition
- *
- * theChar: typed char
- * keyCode: code of the related code
- * macEvent: Pointer on the corresponding event
- *
- */
-
- void CTermPane::DoAutoKey(char theChar,Byte keyCode,EventRecord *macEvent)
- {
- this->DoKeyDown(theChar,keyCode,macEvent);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * SetConfig
- *
- * Terminal tool configuration
- *
- * theConfig: configuration C string
- *
- * Return: Negative value: error (-1 -> unknown)
- * Positive value: Parser stop index
- * tmNoErr if all is OK
- *
- */
-
- short CTermPane::SetConfig(char *theConfig)
- {
- short retCode;
-
- retCode = TMSetConfig(itsTerm,theConfig);
-
- this->changedConfig(); /* Config update */
-
- return retCode;
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * GetToolName
- *
- * Return the name of the current tool
- *
- * toolName: name of the current tool (pascal string)
- *
- */
-
- void CTermPane::GetToolName(Str63 toolName)
- {
- SignedByte savedState;
-
- savedState = HGetState(itsTerm);
- HLock(itsTerm);
-
- TMGetToolName((*itsTerm)->procID,toolName);
-
- HSetState(itsTerm, savedState);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * GetConfig
- *
- * Return the configuration string of the current tool
- *
- * Reeturn a pointer on the C string
- *
- */
-
- Ptr CTermPane::GetConfig(void)
- {
- return(TMGetConfig(itsTerm));
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * DoMenu
- *
- * Terminal tool menus handling
- *
- * theMenu: selected menu
- * theItem: selected item
- *
- * Return TRUE if the menu belongs to the tool
- *
- */
-
- Boolean CTermPane::DoMenu(short theMenu,short theItem)
- {
- return(TMMenu(itsTerm,theMenu,theItem));
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * DoEvent
- *
- * Terminal tool related events
- *
- * theEvent: Pointeur on the event
- * theWindow: Window associated with the event
- *
- * Return TRUE if it is a tool event
- *
- */
-
- Boolean CTermPane::DoEvent(EventRecord *theEvent,WindowPtr theWindow)
- {
- Boolean isToolEvent;
- TermHandle theTerm;
-
- isToolEvent = FALSE;
-
- theTerm = (TermHandle) GetWRefCon(theWindow);
-
- if (theTerm == itsTerm) { /* Tool window ? */
- TMEvent(itsTerm,theEvent);
- isToolEvent = TRUE;
- }
-
- return isToolEvent;
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * GetTermHandle
- *
- * Return a Handle on the current terminal record
- *
- * Return the Handle
- *
- */
-
- TermHandle CTermPane::GetTermHandle(void)
- {
- return(itsTerm);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * DoStream
- *
- * Received data handling
- *
- * buffer: Receiving buffer
- * buffSize: buffer size
- * flags: end of message
- *
- * Return the nb of chars handled
- *
- */
-
- long CTermPane::DoStream(Ptr buffer,long buffSize,CMFlags flags)
- {
- Prepare();
-
- return (TMStream(itsTerm,buffer,buffSize,flags));
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * TermClear
- *
- * Terminal pane clearing
- *
- */
-
- void CTermPane::TermClear(void)
- {
- Prepare();
-
- TMClear(itsTerm);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * Reset
- *
- * Terminal reset
- *
- */
-
- void CTermPane::Reset(void)
- {
- short response;
-
- PositionDialog('ALRT', RESET_ALRT_ID);
-
- InitCursor();
-
- response = Alert(RESET_ALRT_ID, NULL);
-
- if (response == answerNO) {
- Prepare();
-
- TMReset(itsTerm);
-
- this->changedConfig(); /* Configuration update */
- }
-
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * DoTabCopy
- *
- * Table copy
- *
- */
-
- void CTermPane::DoTabCopy(void)
- {
- Handle selectionHdl,scrapHdl;
- ResType selectionType;
- long selectionLength,scrapLength;
- short i,scrapIndex,spacePending;
- unsigned char theChar;
-
- selectionHdl = NewHandle(0);
- selectionLength = TMGetSelect(itsTerm,selectionHdl,&selectionType);
-
- scrapHdl = NewHandle(selectionLength);
- scrapLength = selectionLength;
-
- spacePending = 0;
-
- scrapIndex = 0;
-
- for (i = 0;i < selectionLength;i ++) { /* For each char… */
-
- theChar = (*selectionHdl)[i];
-
- if (theChar == SPACE) /* Space char ? */
- spacePending ++;
- else {
-
- if (spacePending > 1) { /* More than one space ? */
- (*scrapHdl)[scrapIndex] = TAB;
-
- scrapIndex ++;
- scrapLength -= (spacePending - 1);
-
- (*scrapHdl)[scrapIndex] = theChar;
- scrapIndex ++;
- spacePending = 0;
- }
- else if (spacePending == 1) { /* Exactly one space ? */
- (*scrapHdl)[scrapIndex] = TAB;
- scrapIndex ++;
- (*scrapHdl)[scrapIndex] = theChar;
- scrapIndex ++;
- spacePending = 0;
- }
- else {
- (*scrapHdl)[scrapIndex] = theChar;
- scrapIndex ++;
- }
- }
- }
-
- SetHandleSize(scrapHdl,scrapLength);
-
- gClipboard->EmptyScrap();
- gClipboard->PutData(selectionType,scrapHdl);
-
- DisposHandle(selectionHdl);
- DisposHandle(scrapHdl);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * GetExtent
- *
- * Return the size (in char rows and columns) of the terminal pane
- *
- * theHExtent: Nb of columns
- * theVExtent: Nb of rows
- *
- */
-
- void CTermPane::GetExtent(long *theHExtent,long *theVExtent)
- {
- TermEnvironRec theEnvirons;
-
- this->GetEnvirons(&theEnvirons);
-
- *theHExtent = theEnvirons.textCols;
- *theVExtent = theEnvirons.textRows;
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * GetEnvirons
- *
- * Terminal parameters
- *
- * theEnvirons: Pointer on the environment record
- *
- * Return an error code
- *
- */
-
- OSErr CTermPane::GetEnvirons(TermEnvironRec *theEnvirons)
- {
- theEnvirons->version = curTermEnvRecVers;/* Record version */
-
- return (TMGetTermEnvirons(itsTerm,theEnvirons));
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * GetLine
- *
- * Content of a terminal screen line
- *
- * lineNo: line number
- * theTermData: Pointer on the content of the line
- *
- * Renturn an error code
- *
- */
-
- void CTermPane::GetLine(short lineNo,TermDataBlock *theTermData)
- {
- theTermData->theData = NewHandleCanFail(0);
-
- TMGetLine(itsTerm,lineNo,theTermData);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * Scroll
- *
- * Terminal pane scrolling
- *
- * hDelta: Horizontal scrolling
- * vDelta: vertical scrolling
- * redraw: flag of redrawing
- *
- */
-
- void CTermPane::Scroll(long hDelta,long vDelta,Boolean redraw)
- {
- long hPixels,vPixels;
-
- hPixels = hDelta * hScale;
- vPixels = vDelta * vScale;
-
- if ((Abs(hPixels) < width) && (Abs(vPixels) < height)) {
- Prepare();
- TMScroll(itsTerm,-(hDelta * hScale),-(vDelta * vScale));
- }
- else
- Refresh();
-
- position.h += hDelta;
- position.v += vDelta;
-
- if (redraw)
- ((CWindow *) (((WindowPeek) macPort)->refCon))->Update();
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * changedConfig
- *
- * Terminal tool configuration update
- *
- */
-
- void CTermPane::changedConfig(void)
- {
- TermEnvironRec theEnvirons;
- Rect viewRect;
- LongRect newBounds;
- SignedByte savedState;
-
- savedState = HGetState(itsTerm);
- HLock(itsTerm);
-
- QDToLongRect(&((*itsTerm)->viewRect),&newBounds); /* New dimensions */
- OffsetLongRect(&newBounds,-(newBounds.left),-(newBounds.top));
- this->SetBounds(&newBounds);
-
- this->GetEnvirons(&theEnvirons); /* Environment */
-
- hScale = theEnvirons.cellSize.h; /* Chars size */
- vScale = theEnvirons.cellSize.v;
-
- BroadcastChange(termSizeChangedInd, NULL);
-
- HSetState(itsTerm,savedState);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-
- /*
- * DoSelectAll
- *
- * Complete selection
- *
- */
-
- void CTermPane::DoSelectAll(void)
- {
- TermEnvironRec theEnvirons;
- TMSelection newSelection;
- TMSelTypes newSelType;
-
- Prepare();
-
- this->GetEnvirons(&theEnvirons); /* Environment */
-
- SetRect(&(newSelection.selRect),1,1,theEnvirons.textCols,
- theEnvirons.textRows);
-
- newSelType = selTextNormal;
-
- TMSetSelection(itsTerm,&newSelection,newSelType);
- }
-
-
- /* ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ */
-