home *** CD-ROM | disk | FTP | other *** search
- /*
- * The routines in this file provide support for DJB's Macintosh terminal
- * It compiles into nothing if not a MacTTY device.
- *
- * Extensively modified by Earle R. Horton. Window support is limited to
- * a single Macintosh window for speed. Routines optimized, and mouse
- * action parser which interfaces directly to microemacs routines
- * installed.
- */
- #include <stdio.h>
- #include "estruct.h"
- #include "edef.h"
- #include "epath.h"
-
- #if FINDER
- #if MPW
- #define __ALLNU__
- #include <types.h>
- #include <resources.h>
- #include <quickdraw.h>
- #include <fonts.h>
- #include <events.h>
- #include <windows.h>
- #include <menus.h>
- #include <textedit.h>
- #include <dialogs.h>
- #include <segload.h>
- #include <toolutils.h>
- #include <osutils.h>
- #include <desk.h>
- #include <strings.h>
- #include <controls.h>
- #include <script.h>
- #include <Memory.h>
- #endif
- #if LSC
- #include <QuickDraw.h>
- #include <FontMgr.h>
- #include <EventMgr.h>
- #include <WindowMgr.h>
- #include <MenuMgr.h>
- #include <DialogMgr.h>
- #include <DeskMgr.h>
- #include <controlmgr.h>
- #include <OSUtil.h>
- /*
- * This should be in there somewhere.
- */
- #define normal 0x00
- #define bold 0x01
- #define italic 0x02
- #define underline 0x04
- #define outline 0x08
- #define shadow 0x10
- #define condense 0x20
- #define extend 0x40
- #endif
- #include "TTY_Windows.h"
- #if MPW
- #define CtoPstr c2pstr
- #endif
-
- #if MPW
- #ifdef macintosh
- pascal void XSTDTEXT(count,textAddr,numer,denom)
- short count; /* This is until I find out how to cast */
- Ptr textAddr; /* a constant long to a Point. */
- long numer, denom;
- extern 0xA882;
- #define lmalloc malloc
- #else /* Aztec C, doesn't do prototypes. */
- pascal void XSTDTEXT() = 0xA882;
- #endif
- #undef StdText
- #define StdText XSTDTEXT
- #endif
- #ifndef macintosh
- pascal void TTY_W_ScrollAction();
- #else
- pascal void TTY_W_ScrollAction(ControlHandle, short);
- #endif
-
- /*
- * Globals.
- */
- Rect cursRect;
- Point pen_pt;
-
- static int16 curs_row,curs_column,max_rows,max_columns,
- min_rows,min_columns, act_rows,act_columns,
- top_offset,left_offset,bottom_offset,right_offset,
- window_width,window_height,char_ascent,char_descent,
- curs_width,curs_height,vpos,vmax;
-
- int32 lastCursBlink,lastmouseup;
- Boolean cursBlinkFlag,cursVis,cursHid,resizeme;
- ControlHandle vScrollBar;
- WindowPeek uEmacsTTY_W;
- MenuHandle myMenus[lastMenu+1];
- extern Pattern *popupPat;
- static short rfile;
- #ifdef MPU68000
- long (*KeyInterpreter)();
- #else
- int (*KeyInterpreter)();
- #endif
- RgnHandle junkrgn;
- SysEnvRec theWorld;
-
- int window_is_active = FALSE;
- long malloc_safety = 65000L;
-
- #define __SEG__ mactty
-
- dummy(){}
- /*
- * mac_ttyopen:
- * Set up the TTY Window for uEmacs...
- */
- #define __SEG__ INIT
- mac_ttyopen()
- {
- WindowPtr tempTTY_W;
- Point pt;
- MenuHandle menuH;
- FontInfo fontInfo;
- WStateData **windowstate;
- Rect scrollRect;
- char *lmalloc();
- Rect **windowresource;
- EventRecord theEvent;
- long mem_to_grab;
-
- mem_to_grab = FreeMem()-malloc_safety;
-
- if(mem_to_grab > 524288L){ /* Don't be greedy! */
- mem_to_grab = 524288L;
- }
-
- if(mem_to_grab > 0L)free(lmalloc(mem_to_grab));
-
- (void)SysEnvirons(1,&theWorld);
-
- uEmacsTTY_W = (WindowPeek) malloc(sizeof(WindowRecord));
- if(uEmacsTTY_W == NIL) return (ERR);
-
- windowresource = (Rect **)GetResource('WIND',128);
- if(windowresource == NULL) exit();
-
- if((*windowresource)->top <= GetMBarHeight()){
- (*windowresource)->top = GetMBarHeight()+4;
- }
-
- tempTTY_W = GetNewWindow(128,uEmacsTTY_W,(WindowPtr)-1);
- ReleaseResource(windowresource);
-
- if(tempTTY_W != (WindowPtr)uEmacsTTY_W)exit();
- SetWTitle(tempTTY_W,ourAppName);
- SetPort(uEmacsTTY_W);
- TextFont(monaco);
- TextFace(NIL);
- TextMode(srcCopy);
- TextSize(9);
- GetFontInfo(&fontInfo);
- char_ascent = fontInfo.ascent;
- char_descent = fontInfo.descent;
- curs_width = fontInfo.widMax;
- curs_height = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
-
- max_rows =
- (SCREENBITS.bounds.bottom-SCROLLBARWIDTH)/curs_height;
- max_columns =
- (SCREENBITS.bounds.right-SCROLLBARWIDTH)/curs_width;
- act_rows = (tempTTY_W->portRect.bottom
- - tempTTY_W->portRect.top)
- / curs_height;
- act_columns = (tempTTY_W->portRect.right
- - tempTTY_W->portRect.left
- - SCROLLBARWIDTH)/curs_width;
- if(act_rows > max_rows) {
- act_rows = max_rows - 3;
- }
- if(act_columns > max_columns){
- act_columns = max_columns - 2;
- }
- max_columns += max_columns/2;
- min_rows = 5;
- min_columns = 25;
- top_offset = 0;
- left_offset = 2;
- bottom_offset = 0;
- right_offset = SCROLLBARWIDTH - 1;
- window_width = right_offset + act_columns*curs_width
- + left_offset;
- window_height = top_offset + act_rows*curs_height
- + bottom_offset;
-
- /* Resize the window to the appropriate size */
- SizeWindow(uEmacsTTY_W,window_width,window_height,false);
-
- resizeme = FALSE;
- cursBlinkFlag = TRUE;
-
-
- /* Add inactive unhilighted scroll bars as requested */
-
- scrollRect.left = window_width - SCROLLBARWIDTH + 1;
- scrollRect.top = - 1;
- scrollRect.right = window_width + 1;
- scrollRect.bottom = window_height - SCROLLBARWIDTH + 2;
-
- vScrollBar = NewControl(tempTTY_W, &scrollRect, "", true, 1, 0, 2,
- scrollBarProc, (long) uEmacsTTY_W);
- if(vScrollBar == NIL) exit();
- HiliteControl(vScrollBar, 0);
- /* make the window visible */
- ShowWindow(tempTTY_W);
- DrawGrowIcon(tempTTY_W);
- ShowControl(vScrollBar);
-
- clearleft();
- term.t_mrow = max_rows + 3;
- term.t_nrow = act_rows - 1;
- term.t_mcol = max_columns + 2;
- term.t_ncol = act_columns;
- cursVis = CURS_INVIS;
- cursHid = CURS_SHOW;
- junkrgn = NewRgn();
- if(GetNextEvent((short)app4Mask,&theEvent)){
- theEvent.modifiers = (short)theEvent.message & 1;
- theEvent.what = activateEvt;
- eventparser(&theEvent);
- TTY_WHideCurs();
- }else{
- window_is_active = TRUE;
- SelectWindow(tempTTY_W);
- }
- return (OK);
- }
- #define __SEG__ mactty
- /*
- * mac_ttymove
- *
- * Move cursor to indicated row and column in Macintosh window.
- */
- mac_ttymove(whichRow, whichColumn)
- int whichRow, whichColumn;
- {
- curs_row = (whichRow>act_rows)
- ? act_rows : whichRow;
- curs_column = (whichColumn>act_columns)
- ? act_columns : whichColumn;
-
- TTY_WBlinkCurs(CURS_INVIS);
- SetRect(&cursRect, left_offset + (curs_column)*curs_width
- , top_offset + (curs_row)*curs_height
- , left_offset + (curs_column+1)*curs_width
- , top_offset + (curs_row+1)*curs_height);
- SetPt(&pen_pt, left_offset+(curs_column*curs_width),
- top_offset+char_ascent+(curs_row*curs_height));
-
- MoveTo(pen_pt.h, pen_pt.v);
-
- TTY_WBlinkCurs(CURS_VIS);
- }
- /*
- * mac_ttygetc
- *
- * Get a character from the keyboard on the Mac. Or at least
- * get it from somebody who thinks he knows what it is!
- *
- */
- int mac_ttygetc()
- {
-
- EventRecord theEvent;
- /* if Mouse-Down occurs return a CTRL-G to abort */
- while(!EventAvail((short)(keyDownMask+autoKeyMask+app4Mask), &theEvent)) {
- TTY_WBlinkCurs(CURS_IDLE);
- if(EventAvail((short)(mDownMask+app4Mask), &theEvent)) return (0x07);
- }
- /* Next, look in the event queue */
- GetNextEvent((short)(keyDownMask+autoKeyMask), &theEvent);
- return(*KeyInterpreter)(&theEvent);
- }
- /*
- * mac_ttyeeol
- *
- * Erase to end of current line.
- *
- */
- mac_ttyeeol()
- {
- Rect temp;
- TTY_WBlinkCurs(CURS_INVIS);
- temp = cursRect;
- temp.right = left_offset+
- ((act_columns)*curs_width);
- EraseRect(&temp);
- }
- /*
- * mac_ttyeeop
- *
- * Erase to end of screen.
- *
- */
- mac_ttyeeop()
- {
- Rect temp;
- mac_ttyeeol();
- temp = cursRect;
- temp.right = left_offset+
- ((act_columns)*curs_width);
- temp.top = temp.bottom;
- temp.left = left_offset;
- temp.bottom = left_offset+
- (act_rows*curs_height);
- EraseRect(&temp);
- }
- /*
- * mac_ttybeep
- *
- * Beep.
- *
- */
- mac_ttybeep()
- {
- SysBeep(1);
- }
- mac_ttyscroll(toprow,botrow,nrows)
- int toprow,botrow,nrows;
- {
- Rect scrollrect;
- SetRect(&scrollrect,left_offset,
- toprow * curs_height + top_offset,
- window_width - right_offset,
- botrow * curs_height + top_offset);
- ScrollRect(&scrollrect,0,nrows*curs_height,junkrgn);
- }
- /*
- * uEmacs_Refresh
- *
- * Force an update of the terminal window. (And some other
- * black magic, since we have to move the scroll bars, too.)
- */
- uEmacs_Refresh()
- {
- Rect scrollRect;
- TTY_WRecalcScroll();
- if(resizeme){
- HideControl(vScrollBar);
- scrollRect.left =
- window_width - SCROLLBARWIDTH + 1;
- scrollRect.top = - 1;
- scrollRect.right = window_width + 1;
- scrollRect.bottom =
- window_height - (SCROLLBARWIDTH - 2);
- MoveControl(vScrollBar,
- scrollRect.left,scrollRect.top);
- SizeControl(vScrollBar,
- scrollRect.right-scrollRect.left,
- scrollRect.bottom-scrollRect.top);
- ShowControl(vScrollBar);
- newsize(TRUE,act_rows);
- newwidth(TRUE,act_columns);
- resizeme = FALSE;
- }
- DrawGrowIcon(uEmacsTTY_W);
- clearleft();
- refresh(FALSE, 0);
- update(TRUE);
- ValidRect(&((WindowPtr)uEmacsTTY_W)->portRect);
- }
- clearleft()
- {
- Rect junkRect;
- junkRect.left = 0;
- junkRect.top = - 1;
- junkRect.right = left_offset;
- junkRect.bottom = window_height;
- EraseRect(&junkRect);
- }
- /*
- * uEmacs_Quit
- *
- * Shut down MicroEMACS.
- */
- uEmacs_Quit()
- {
- quit(0,0);
- }
- /*
- * uEmacs_ScrollLine
- *
- * Scroll the current MicroEMACS window one line at a time.
- * The vtscroll() routine takes care of all update.
- */
- uEmacs_ScrollLine(n)
- int n;
- {
- register LINE *lp;
- lp = curwp->w_linep;
- TTY_WBlinkCurs(CURS_INVIS);
- mvupwind(0,n);
- if(n==1 && lp != curwp->w_linep)vtscrollup();
- else if(n== -1)vtscrolldown();
- TTY_WBlinkCurs(CURS_VIS);
- }
- /*
- * uEmacs_VBufPos()
- *
- * Return the current positon in the file. Based on the current line
- * vs. the current number of lines in the buffer.
- */
- uEmacs_VBufPos()
- {
- register LINE *lp; /* current line */
- register int16 numlines; /* # of lines in file */
- register int16 predlines; /* # lines preceding point */
- /* starting at the beginning of the buffer */
- lp = lforw(curbp->b_linep);
- /* start counting chars and lines */
- numlines = 0;
- while (lp != curbp->b_linep) {
- /* can we find the top line in the current window */
- if (lp == curwp->w_linep) {
- predlines = numlines;
- }
- /* on to the next line */
- ++numlines;
- lp = lforw(lp);
- }
- /* if at end of file, record it */
- if (curwp->w_linep == curbp->b_linep) {
- predlines = numlines;
- }
- vmax = numlines;
- vpos = predlines;
- }
- /*
- * mac_ttyrev
- *
- * Set reverse video character attribute
- * (TRUE = reverse, FALSE = normal)
- */
- mac_ttyrev(state)
- int state;
- {
- if(state){
- ForeColor(whiteColor);
- BackColor(blackColor);
- }
- else{
- ForeColor(blackColor);
- BackColor(whiteColor);
- }
- }
- spal(str)char*str;{}
- #if TYPEAH
- /* typahead: Check to see if any characters are already in the
- * Event Queue.
- */
- typahead()
- {
- EventRecord theEvent;
-
- return (EventAvail(keyDownMask+autoKeyMask, &theEvent));
- }
- #endif
- /*
- * GrowTTY_Window() - Let the user drag the specified TTY_Window with the mouse.
- *
- * wPtr - The TTY_Window to be moved.
- * startPt - starting location of the mouse (global coordinates).
- *
- * returns - packed 32 bit int: lower 16 bits = new width
- * upper 16 bits = new height
- * takes into account max and min fields of TTY_Window
- */
- int32 GrowTTY_Window(startPt)
- Point *startPt;
- {
- Rect sizeRect;
-
- sizeRect.left =
- right_offset + min_columns*curs_width + left_offset;
- sizeRect.top =
- top_offset + min_rows*curs_height + bottom_offset;
- sizeRect.right =
- right_offset + max_columns*curs_width + left_offset;
- sizeRect.bottom =
- top_offset + max_rows*curs_height + bottom_offset;
-
- return (GrowWindow(uEmacsTTY_W,*startPt, &sizeRect));
- }
- /*
- * SizeTTY_Window() - Resize the specified TTY_Window.
- * New area generates an update event.
- *
- * wPtr - The TTY_Window to be moved.
- * w, h - new width and height for the TTY_Window.
- *
- */
- SizeTTY_Window(w, h)
- int16 w, h;
- {
- Rect scrollRect;
- /* Assure an even number of rows, columns in the final size */
- w -= (w-left_offset-right_offset) % curs_width;
- h -= (h-top_offset-bottom_offset) % curs_height;
- HideControl(vScrollBar); /* Size the window. */
- SizeWindow(uEmacsTTY_W, w, h, false);
-
- window_width = w; /* Calculate new rows and columns. */
- window_height = h;
- act_rows = (h-top_offset-bottom_offset)/curs_height;
- act_columns = (w-left_offset-right_offset)/curs_width;
- resizeme = TRUE;
- uEmacs_Refresh();
- }
- /*
- * eventparser(event) - Processes events belonging to TTY_Windows.
- *
- * event - Ptr to EventRecord.
- */
- eventparser(event)
- EventRecord *event;
- {
- int16 findResult;
- int32 growResult;
- WStateData **windowstate;
- Point tempPt;
- Rect dragRect,userRect;
- WindowPeek tmppeek;
-
- /* if NULL event idle the cursor. */
- if(event->what == nullEvent) {
- TTY_WBlinkCurs(CURS_IDLE);
- return;
- }
-
- switch(event->what) {
- case mouseDown:
- tempPt = event->where;
- findResult = FindWindow(tempPt,&tmppeek);
- if(tmppeek != uEmacsTTY_W)return;
- /* Handle the mouse-down */
- switch(findResult) {
- case inContent:
- if (uEmacsTTY_W != (WindowPeek)FrontWindow()) {
- SelectWindow(uEmacsTTY_W);
- } else {
- GlobalToLocal(&tempPt);
- /* Check if in scroll-bars */
- if(!DoTTY_WScroll(&tempPt, event))
- mouseparser(&tempPt, event);
- TTY_WRecalcScroll();
- }
- break;
- case inDrag:
- SetRect(&dragRect,
- 4, GetMBarHeight()+4,
- SCREENBITS.bounds.right-4,
- SCREENBITS.bounds.bottom-4);
- DragWindow(uEmacsTTY_W,tempPt, &dragRect);
- /* Application will be notified by an update event */
- break;
- case inGrow:
- growResult = GrowTTY_Window(&tempPt);
- if(growResult != 0) {
- SizeTTY_Window(LoWord(growResult),
- HiWord(growResult), TRUE);
- }
- break;
- case inGoAway:
- if (TrackGoAway(uEmacsTTY_W,tempPt)) {
- /* call the owner's close routine */
- uEmacs_Quit();
- }
- break;
- case inZoomIn:
- if(TrackBox(uEmacsTTY_W,tempPt, inZoomIn)) {
- ZoomWindow(uEmacsTTY_W, inZoomIn, FALSE);
- SizeTTY_Window(((WindowPtr)uEmacsTTY_W)->portRect.right,
- ((WindowPtr)uEmacsTTY_W)->portRect.bottom,TRUE);
- }
- break;
- case inZoomOut:
- if(TrackBox(uEmacsTTY_W,tempPt, inZoomOut)) {
- /*
- * ZoomWindow() resizes our window, but not necessarily to an even number
- * of rows and columns. After correction, the WStateData stored in our
- * WindowRecord.dataHandle must be corrected or the WDEF might become
- * confused about which state we are in.
- */
- userRect = ((WindowPtr)uEmacsTTY_W)->portRect;
- LocalToGlobal(&userRect.top);
- LocalToGlobal(&userRect.bottom);
- ZoomWindow(uEmacsTTY_W, inZoomOut, FALSE);
- SizeTTY_Window(((WindowPtr)uEmacsTTY_W)->portRect.right+3,
- ((WindowPtr)uEmacsTTY_W)->portRect.bottom+3,TRUE);
- windowstate = (WStateData **)uEmacsTTY_W->dataHandle;
- (**windowstate).stdState = ((WindowPtr)uEmacsTTY_W)->portRect;
- (**windowstate).userState = userRect;
- HLock(windowstate);
- LocalToGlobal(&(**windowstate).stdState);
- LocalToGlobal(&(**windowstate).stdState.bottom);
- HUnlock(windowstate);
- }
- break;
- default:
- break;
- }
- break;
-
- case mouseUp:
- lastmouseup = event->when;
- break;
-
- case updateEvt:
- TTY_WHideCurs();
- BeginUpdate(uEmacsTTY_W);
- uEmacs_Refresh();
- EndUpdate(uEmacsTTY_W);
- TTY_WShowCurs();
- break;
- case activateEvt:
- if (event->modifiers & activeFlag) {
- /* Show cursor/range and show controls */
- HiliteControl(vScrollBar, 0);
- window_is_active = TRUE;
- TTY_WShowCurs(uEmacsTTY_W);
- InitCursor();
- } else {
- HiliteControl(vScrollBar, 255);
- window_is_active = FALSE;
- TTY_WHideCurs();
- }
- clearleft();
- break;
-
- default:
- break;
-
- }
- return;
- }
- /*
- * DoTTY_WScroll() - Handle mouse-down events in TTY_W scrollbars
- *
- * pt - location of mousedown.
- * returns: - TRUE - is a scroll-bar event
- * - FALSE - is not a scroll-bar event
- */
- DoTTY_WScroll(pt, event)
- Point *pt;
- EventRecord *event;
- {
- int16 partCode, trackResult;
- ControlHandle whichControl;
- partCode = FindControl(*pt, uEmacsTTY_W, &whichControl);
- if((partCode == NIL) || (whichControl == NIL)) return FALSE;
- TTY_WHideCurs();
- if(partCode == inThumb) {
- trackResult = TrackControl(whichControl,*pt, NIL);
- if(trackResult == inThumb) {
- gotoline(TRUE,GetCtlValue(vScrollBar)+1);
- update(TRUE);
- }
- } else {
- trackResult = TrackControl(whichControl,*pt, TTY_W_ScrollAction);
- }
- TTY_WShowCurs();
- }
- /*
- * TTY_W_ScrollAction() - Handle mouse-down events in TTY_W scrollbars
- *
- * uEmacsTTY_W - TTY_WindowPtr.
- * pt - location of mousedown.
- * returns: - TRUE - is a scroll-bar event
- * - FALSE - is not a scroll-bar event
- */
- pascal void TTY_W_ScrollAction(whichControl, partCode)
- ControlHandle whichControl;
- int16 partCode;
- {
- int16 hval,vval;
- switch (partCode) {
- case inUpButton:
- if(vpos > 0){
- SetCtlValue(vScrollBar,--vpos);
- uEmacs_ScrollLine(1);
- }
- break;
- case inDownButton:
- if(vpos < vmax){
- SetCtlValue(vScrollBar,++vpos);
- uEmacs_ScrollLine(-1);
- }
- break;
- case inPageUp:
- backpage(FALSE,1);
- update(TRUE);
- TTY_WRecalcScroll();
- break;
- case inPageDown:
- forwpage(FALSE,1);
- update(TRUE);
- TTY_WRecalcScroll();
- break;
- }
- }
- /*
- * TTY_WRecalcScroll() - Handle mouse-down events in TTY_W scrollbars
- *
- */
- TTY_WRecalcScroll()
- {
-
- /* Get the position in the window displayed in the TTY_W and adjust control*/
- uEmacs_VBufPos();
- SetCtlMax(vScrollBar, vmax);
- SetCtlValue(vScrollBar, vpos);
- Draw1Control(vScrollBar);
- }
- /*
- * getpos() - Returns row and column corresponding to current mouse point
- * in terminal emulator.
- */
- getpos(row,col)
- int16 *row;
- int16 *col;
- {
- Point pt;
- GetMouse(&pt);
- *row = (pt.v - top_offset)/curs_height;
- *col = (pt.h - left_offset)/curs_width;
- }
- /*
- * mouseparser() - Handle mouse-down events in ╡Emacs window.
- *
- * pt - location of mousedown.
- *
- * Make the window in which the mouse down occured current. If in the
- * text area, then move the cursor to as close to the Point as possible,
- * then wait for a drag. If in a mode line, let the user drag the mode
- * line to resize the window.
- *
- * Since the bottom mode line does not move, resizing the bottom window
- * is a little different. Trying to pull up on the bottom mode line makes
- * the bottom window smaller by moving the next-to-the-bottom mode line
- * down. Trying to pull down on the bottom mode line makes the bottom
- * window larger by making the next-to-the-bottom window smaller.
- * Trying to resize when there is only one window causes it to be split,
- * with the cursor remaining in the bottom window.
- *
- * A window can be deleted by shrinking it within this routine. Other
- * windows cannot, however, be deleted by enlarging the current one.
- *
- * Double-clicks in a mode line call nextbuffer().
- *
- * Double-clicks in the text area move the point to the
- * character clicked on, then swap the mark.
- *
- * Drags have a similar effect as in "regular" Macintosh text editors.
- * A simple drag leaves the mark set to the beginning of the drag, and
- * the point at the end of the drag. A shift drag does not move the mark,
- * only the point.
- *
- * Moves off the end of extended lines are not handled well. This requires
- * tighter coupling with the routines in display.c.
- */
- mouseparser( pt, event)
- Point *pt;
- EventRecord *event;
- {
- #if LSC
- pascal long GetDblTime();
- #else
- long GetDblTime();
- #endif
- register WINDOW *wp;
- register LINE *lp;
- int16 pt_row,pt_col,new_row,new_col;
- int i;
- static int16 last_col,last_row;
- Boolean doubleclick;
- Boolean markset = false;
-
- mlerase();
- getpos(&pt_row,&pt_col);
- pt_row = (pt_row<0) ? 0 : pt_row;
- pt_row = (pt_row>act_rows) ? act_rows : pt_row;
- pt_col = (pt_col<0) ? 0 : pt_col;
- pt_col = (pt_col>act_columns) ? act_columns : pt_col;
-
- doubleclick = (pt_col == last_col && pt_row == last_row &&
- (event->when - lastmouseup) <= GetDblTime());
- last_row = pt_row;
- last_col = pt_col;
-
- /*
- * Find window where mouse down occured.
- * Make it current, fix up mode lines.
- */
- for(wp=wheadp;wp->w_wndp!=NULL;){
- if(wp->w_toprow <= pt_row &&
- wp->w_toprow+wp->w_ntrows >= pt_row)break;
- wp = wp->w_wndp;
- }
- curwp = wp;
- curbp = wp->w_bufp;
- upmode();
- /*
- * Click in a mode line.
- */
- if(wp->w_toprow+wp->w_ntrows == pt_row){
- if(doubleclick){ /* Handle double click. */
- nextbuffer(FALSE);
- update(TRUE);
- }
- while(StillDown()){ /* Check for mode line move. */
- getpos(&new_row,&new_col);
- if(new_row < pt_row){ /* Pull up, shrink current. */
- if (wheadp->w_wndp == NULL) {
- if(splitwind(TRUE,2)==FALSE){
- update(TRUE);
- return;
- }
- }
- else if(shrinkwind(TRUE,1)==FALSE){
- delwind();
- update(TRUE);
- return;
- }
- } /* Pull down, enlarge current window. */
- else if(new_row > pt_row){
- if (wheadp->w_wndp == NULL) {
- if(splitwind(TRUE,2)==FALSE){
- update(TRUE);
- return;
- }
- }
- else if(enlargewind(TRUE,1)==FALSE){
- update(TRUE);
- return;
- }
- } /* Update if mode line changed. */
- if(new_row != pt_row){
- pt_row = wp->w_toprow+wp->w_ntrows;
- update(TRUE);
- }
- }
- /*
- * Click in message line.
- */
- }else if(pt_row == term.t_nrow){
- namedcmd();
- /*
- * Click in text. Drag or move.
- */
- }else{
- cursBlinkFlag = FALSE; /* Shut off cursor blink during drag. */
- if((event->modifiers & shiftKey) != 0){
- markset = true;
- doubleclick = false;
- }
- do{
- getpos(&new_row,&new_col);
- if(new_col < 0)new_col = 0;
- if(!markset && (new_row != pt_row || new_col != pt_col)){
- markset = true;
- doubleclick = false;
- setmark();
- }
- if(new_row >= wp->w_toprow + wp->w_ntrows){
- if(vpos < vmax){
- SetCtlValue(vScrollBar,++vpos);
- uEmacs_ScrollLine(-1);
- }
- new_row = wp->w_toprow + wp->w_ntrows - 1;
- TTY_WHideCurs();
- }
- else if(new_row < wp->w_toprow){
- if(vpos > 0){
- SetCtlValue(vScrollBar,--vpos);
- uEmacs_ScrollLine(1);
- }
- new_row = wp->w_toprow;
- TTY_WHideCurs();
- }else{
- TTY_WShowCurs();
- }
- for(i=wp->w_toprow,lp=wp->w_linep;
- ((i<new_row) && (lp != curbp->b_linep));){
- lp = lforw(lp);i++;
- }
- wp->w_dotp = lp;
- curgoal = new_col;
- wp->w_doto = getgoal(wp->w_dotp);
- pt_row = new_row;
- pt_col = new_col;
- update(TRUE);
- }while(StillDown());
- if(doubleclick){
- swapmark();
- }
- TTY_WShowCurs();
- cursBlinkFlag = TRUE;
- }
- update(TRUE);
- }
- /*
- * mac_ttyputc
- *
- * Put a character to the terminal window for the mac.
- *
- */
- mac_ttyputc(c)
- int c;
- {
- int16 newcol;
-
- c &= 0xFF;
-
- TTY_WBlinkCurs(CURS_INVIS);
- if( c <= 31 || c == '\177') {
- switch(c) {
- case '\012':
- case '\015':
- mac_ttymove( curs_row, 0);
- break;
-
- case '\177':
- mac_ttymove( curs_row,
- (curs_column>0 ? curs_column-1 : 0));
- mac_ttyputc(' ');
- mac_ttymove( curs_row,
- (curs_column>0 ? curs_column-1 : 0));
- break;
-
- case '\b':
- mac_ttymove( curs_row,
- (curs_column>0 ?
- curs_column-1 : 0));
- break;
-
- default:
- break;
- }
- } else {
- if(curs_column+1 < act_columns) {
- DrawChar((short)c);
- OffsetRect(&cursRect, curs_width, (short)0);
- TTY_WBlinkCurs(CURS_VIS);
- curs_column += 1;
- } else {
- DrawChar(c);
- TTY_WBlinkCurs(CURS_VIS);
- GetPen(&pen_pt);
- pen_pt.h -= curs_width;
- MoveTo(pen_pt.h, pen_pt.v);
- }
- }
- TTY_WBlinkCurs(CURS_VIS);
- GetPen(&pen_pt);
- }
- /*
- * TTY_WPutText() - Put a character to the given TTY_Window at the
- * current cursor location, advance the cursor.
- *
- * arow, acol - position of first character to draw.
- * n - number of characters to draw.
- * buf - ptr to buffer containing the characters.
- */
- TTY_WPutText(arow, acol, n, buf)
- int arow, acol, n;
- Ptr buf;
- {
- Point oldpen_pt;
- if(n <= 0) return;
-
- /* save pen position and move to new point */
- GetPen(&oldpen_pt);
-
- SetPt(&pen_pt,
- left_offset+(acol*curs_width),
- top_offset+char_ascent+
- (arow*curs_height));
- MoveTo(pen_pt.h, pen_pt.v);
-
- TTY_WBlinkCurs(CURS_INVIS);
- StdText(n,buf,0x00010001,0x00010001);
- /* restore pen position */
- MoveTo(oldpen_pt.h, oldpen_pt.v);
- GetPen(&pen_pt);
-
- }
- /*
- * TTY_WBlinkCurs - Change the cursor state every GetCaretTime() ticks...
- *
- * flag - CURS_IDLE idle the cursor
- * CURS_VIS make cursor immediately "visible"
- * CURS_INVIS make cursor immediately "invisible"
- *
- * (cursBlinkFlag: ZERO means no blinking)
- * (cursVis: CURS_VIS means cursor is invisible)
- * ( CURS_INVIS means cursor is visible)
- */
- TTY_WBlinkCurs(flag)
- int16 flag;
- {
- if(!window_is_active){
- flag = CURS_INVIS;
- }
- switch(flag){
- case CURS_VIS:
- if((cursVis == CURS_INVIS) && (cursHid == CURS_SHOW)) {
- InvertRect(&cursRect);
- cursVis = CURS_VIS;
- lastCursBlink = TickCount();
- }
- break;
- case CURS_INVIS:
- if((cursVis == CURS_VIS) && (cursHid == CURS_SHOW)) {
- InvertRect(&cursRect);
- cursVis = CURS_INVIS;
- lastCursBlink = TickCount();
- }
- break;
- default:
- if((cursBlinkFlag) && (cursHid == CURS_SHOW) &&
- (TickCount() > lastCursBlink + GetCaretTime())) {
- InvertRect(&cursRect);
- cursVis = (cursVis?CURS_INVIS:CURS_VIS);
- lastCursBlink = TickCount();
- }
- break;
- }
- }
- /*
- * TTY_WShowCurs - Allow the terminal cursor to be seen
- *
- * (cursHid: CURS_HIDE means cursor is hidden)
- * ( CURS_SHOW means cursor is not hidden)
- */
- TTY_WShowCurs()
- {
- if(FrontWindow() == (WindowPtr) uEmacsTTY_W) {
- cursHid = CURS_SHOW;
- TTY_WBlinkCurs(CURS_VIS);
- }
- }
- /*
- * TTY_WHideCurs - Supress the terminal cursor
- *
- * ttywPtr - TTY_WindowPtr to be affected.
- *
- * (cursHid: CURS_HIDE means cursor is hidden)
- * ( CURS_SHOW means cursor is not hidden)
- */
- TTY_WHideCurs()
- {
- TTY_WBlinkCurs(CURS_INVIS);
- cursHid = CURS_HIDE;
- }
- /*
- * Hook for exit. Perform any post-processing desired, then call
- * ExitToShell().
- */
- exit(){
- Rect **origwindow,**savewindow;
- char fname[256];
- /*
- * The next section saves the current window location and size in the
- * resource fork of the startup file, creating it if necessary.
- */
- if(rfile == -1){
- if(flook(pathname[0]) != NULL){
- strcpy(fname,pathname[0]);
- c2pstr(fname);
- SetVol(nil,_iovrefnum);
- CreateResFile(fname);
- rfile = OpenRFPerm(fname,_iovrefnum,fsCurPerm);
- }
- }
- if(rfile != -1){
- origwindow = (Rect**)GetResource('WIND',128);
- if(HomeResFile(origwindow) == rfile){
- savewindow = origwindow;
- }else{
- UseResFile(rfile);
- savewindow = (Rect **)NewHandle(GetHandleSize(origwindow));
- HLock(origwindow);
- HLock(savewindow);
- BlockMove(*origwindow,*savewindow,GetHandleSize(origwindow));
- AddResource(savewindow,'WIND',128,"\012App Window");
- }
- **savewindow = ((WindowPtr)uEmacsTTY_W)->portRect;
- LocalToGlobal(*savewindow);
- LocalToGlobal(&((**savewindow).bottom));
- ChangedResource(savewindow);
- UpdateResFile(rfile);
- }
- ExitToShell();
- }
- maineventloop() /* Used to be main(). */
- {
- int32 growResult;
- int16 windowCode, dialogItemHit;
- Boolean GNEResult, dialogResult;
- WindowPtr whichWindow;
- DialogPtr whichDialog;
- WindowPeek tempWPeek;
- EventRecord anEvent;
- GrafPtr oldPort;
- int mine;
- char vname[256];
- Boolean done = false;
- char *flook();
- char fname[256];
- ProcPtr *GetC_Resource;
-
- Handle ourHandle;
- int i;
-
- #ifdef macintosh
- ReleaseResource(GetNamedResource('CODE',"\007%A5Init"));
- #endif
-
- /* Load the keyboard Event Record interpreter. */
- GetC_Resource = (ProcPtr *)GetResource('GetC',606);
- LoadResource(GetC_Resource);
- HNoPurge(GetC_Resource);
- #ifdef macintosh /* MPW╤code at top of heap; Aztec╤code at bottom. */
- HUnlock(GetC_Resource);
- MoveHHi(GetC_Resource);
- #endif
- HLock(GetC_Resource);
- KeyInterpreter = *GetC_Resource;
-
- MoreMasters();
- MoreMasters();
- MoreMasters();
- MoreMasters();
-
- GetAppParms(ourAppName,&ourRefNum,&ourHandle);
-
- GetVol(vname,&ourVRefNum);
- /*
- * If we find a startup file in the normal place, we open the resource
- * fork and use it as the current resource file.
- */
- if(flook(pathname[0]) != NULL){
- strcpy(fname,pathname[0]);
- c2pstr(fname);
- rfile = OpenRFPerm(fname,_iovrefnum,fsCurPerm);
- UseResFile(rfile);
- }
-
- SetUpMenus();
- InitEmacs();
-
- #ifdef macintosh
- UnloadSeg(InitEmacs);
- ReleaseResource(GetNamedResource('CODE',"\004INIT"));
- #endif
-
- /*
- * This was a "for(;;)" but the compiler optimized out the return part of the
- * function and MacsBug couldn't see the debugger label for main().
- */
- do{
-
- SystemTask();
-
- GetPort(&oldPort);
- /* Check for keyboard input to TTY_Windows */
- if((whichWindow=FrontWindow()) == (WindowPtr)uEmacsTTY_W) {
- /* Keyboard event or non-empty owner char buffer? */
- if( EventAvail((short)(keyDownMask+autoKeyMask), &anEvent) ) {
- SetPort(uEmacsTTY_W);
- Do_Emacs_Char();
- update(TRUE);
- TTY_WRecalcScroll();
- }
- } else if(whichWindow != NIL) {
- if(EventAvail((short)(keyDownMask+autoKeyMask), &anEvent))
- GetNextEvent((short)(keyDownMask+autoKeyMask), &anEvent);
- }
- GNEResult = GetNextEvent(
- (short)(everyEvent-keyDownMask-keyUpMask-autoKeyMask), &anEvent);
- /* Pass NIL ptr to trigger insertion pt updates in TTY_W's and Dialogs */
- (void)FindWindow(anEvent.where,&tempWPeek);
- mine = (uEmacsTTY_W == tempWPeek ||
- uEmacsTTY_W == (WindowPeek)anEvent.message ||
- anEvent.what == app4Evt);
- if(!GNEResult) {
- anEvent.what = nullEvent;
- SetPort(uEmacsTTY_W);
- eventparser(&anEvent);
- } else if(mine) {
- SetPort(uEmacsTTY_W);
- if(anEvent.what == app4Evt){ /* Suspend/Resume */
- anEvent.what = activateEvt;
- anEvent.modifiers = (short)(anEvent.message & 1);
- } /* Cast to activateEvt for ╡Emacs window */
- eventparser(&anEvent);
- } else {
- /* Main event processor */
- switch (anEvent.what) {
- case mouseDown:
- windowCode = FindWindow(anEvent.where, &whichWindow);
- switch (windowCode) {
- case inMenuBar:
- BuildBufferMenu();/* Fix-up Menus */
- SetPort(whichWindow);
- menuparser(MenuSelect(anEvent.where));
- break;
- case inSysWindow:
- SetPort(whichWindow);
- SystemClick(&anEvent, whichWindow);
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- SetPort(oldPort);
- }
- }while(!done);
- }
-
- /*
- * menuparser() - Process mouse clicks in menu bar
- */
-
- menuparser(mResult)
- long int mResult;
- {
- char name[256];
- char bufname[256];
- short i,j;
- short theMenu, theItem;
- int (*fncmatch())();
- register int (*kfunc)(); /* ptr to a named menu function */
- short length; /* length of a menu command string */
- short extendedcmd; /* simple command or extended? */
-
- SetPort(uEmacsTTY_W);
-
- theMenu = HiWord(mResult); /* This is the RSRC ID */
- theItem = LoWord(mResult); /* This is the item number */
- switch (theMenu-MENUBASE) {
- case appleMenu:
- if (theItem == aboutMeItem) {
- /* Put up the credits */;
- DoAbout();
- } else {
- long driversize;
- GetItem(myMenus[appleMenu], theItem, name);
- (void) OpenDeskAcc(name); /* Argh! */
- SetPort(uEmacsTTY_W);
- }
- break;
- case editMenu:
- /*
- * If this is for a 'standard' edit item,
- * run it through SystemEdit first.
- * SystemEdit will return FALSE if it's not a system window.
- */
- if ((theItem <= clearItem) && SystemEdit(theItem-1)) {
- break;
- }
- /*
- * Otherwise, it's my window.
- */
- switch (theItem) {
- case undoItem:
- /* can't undo */
- break;
- case cutItem:
- emacs_cut();
- break;
- case copyItem:
- emacs_copy();
- break;
- case pasteItem:
- emacs_paste();
- break;
- case clearItem:
- break;
- default:
- break;
- } /*endsw theItem*/
- break;
-
- case bufferMenu:
- GetItem(myMenus[bufferMenu], theItem, name);
- PtoCstr(name);
- /* See note below regarding '-' as first character in menu item. */
- if(SwitchToBuffer(name[0] == '\0' ? &name[1] : name))
- {
- CheckItem(myMenus[bufferMenu], theItem, true);
- update(FALSE);
- }
- break;
- case fileMenu: /* User-configured menus, all. */
- case commands1Menu: /* Content is significant. */
- case commands2Menu:
- case commands3Menu:
- case commands4Menu:
- GetItem(myMenus[theMenu-MENUBASE],theItem,name);
- length = name[0];
- PtoCstr(name);
- extendedcmd = FALSE;
- for(;--length;){
- if(name[length]==' ')extendedcmd = TRUE;
- }
- if(extendedcmd) docmd(name); /* execute a command line */
- else{
- kfunc=fncmatch(name);
- if (kfunc == NULL) {
- mlwrite("[No such function]");
- return(FALSE);
- }
- (*kfunc)(FALSE, 0); /* execute a named command */
- }
- update(FALSE);
- break;
- }
- HiliteMenu(0);
- return;
- }
-
-
- BuildBufferMenu()
- {
- BUFFER *bp;
- char bname[256];
- int16 i,j,buf_items;
-
- /* Empty out the menu >128K ROMs only*/
- buf_items = CountMItems(myMenus[bufferMenu]);
- for(i=buf_items; i>0; i--) DelMenuItem(myMenus[bufferMenu], i);
- i=0;
-
- /*
- * Cycle through the buffer list.
- * First time for active buffers, second time for inactive.
- * This puts the list of active buffers together at the top
- * of the menu.
- */
- bp = bheadp;
- while (bp != NULL) {
- /* Don't display internal buffers */
- /* Don't display inactive buffers */
- if((bp->b_flag & BFINVS) || (bp->b_active != TRUE)) {
- bp = bp->b_bufp;
- continue;
- }
- /*
- * The following subterfuge is necessary because any menu item whose title
- * begins with '-' will appear as a gray line. In the event of a buffer
- * name beginning with '-', we put a NUL in front of the name to keep
- * the MDEF from seeing the '-'.
- */
- bname[0] = '\0';
- strcpy(bp->b_bname[0] == '-' ? &bname[1] : &bname[0], bp->b_bname);
- CtoPstr(bname[0] == '\0' && bname[1] == '-' ? &bname[1] : &bname[0]);
- if(bname[0] == '\0' && bname[2] == '-'){
- bname[0] = bname[1] + 1;
- bname[1] = '\0';
- }
- /*
- * Add/Set menu item to the buffer name. Try to avoid the effect
- * of possible Menu Meta-characters in buffer names.
- */
- i++;
-
- AppendMenu(myMenus[bufferMenu], "\001 ");
- SetItem(myMenus[bufferMenu], i,bname);
- /* Check the current buffer */
- if(bp == curbp) {
- CheckItem(myMenus[bufferMenu], i, true);
- }
- /* Italicize the name if the buffer is modified. */
- if(bp->b_flag & BFCHG){
- SetItemStyle(myMenus[bufferMenu], i, italic);
- }
- bp = bp->b_bufp;
- }
- /*
- * Once again through the list, looking for inactive buffers.
- */
- bp = bheadp;
- while (bp != NULL) {
- /* Don't display active buffers */
- if(bp->b_active == TRUE) {
- bp = bp->b_bufp;
- continue;
- }
- bname[0] = '\0';
- strcpy(bp->b_bname[0] == '-' ? &bname[1] : &bname[0], bp->b_bname);
- CtoPstr(bname[0] == '\0' && bname[1] == '-' ? &bname[1] : &bname[0]);
- if(bname[0] == '\0' && bname[2] == '-'){
- bname[0] = bname[1] + 1;
- bname[1] = '\0';
- }
- i++;
-
- AppendMenu(myMenus[bufferMenu], "\001 ");
- SetItem(myMenus[bufferMenu], i,bname);
- /* Display in outline if not in memory. */
- SetItemStyle(myMenus[bufferMenu], i, outline);
- bp = bp->b_bufp;
- }
-
- }
-
-
- /*
- * SwitchToBuffer()
- *
- * Change to the named buffer.
- */
- SwitchToBuffer(name)
- char *name;
- {
- register BUFFER *bp;
- register int s;
-
- if ((bp=bfind(name, TRUE, 0)) == NULL)
- return (FALSE);
- return(swbuffer(bp));
- }
-
- /*
- * Set up the user menus. Called only once.
- */
- #define __SEG__ INIT
-
- SetUpMenus()
- {
- int menu;
-
- myMenus[appleMenu] = GetMenu(appleMenu+MENUBASE);
- AddResMenu(myMenus[appleMenu], (ResType) 'DRVR');
- myMenus[fileMenu] = GetMenu(fileMenu+MENUBASE);
- myMenus[editMenu] = GetMenu(editMenu+MENUBASE);
- myMenus[bufferMenu] = GetMenu(bufferMenu+MENUBASE);
- myMenus[commands1Menu] = GetMenu(commands1Menu+MENUBASE);
- myMenus[commands2Menu] = GetMenu(commands2Menu+MENUBASE);
- myMenus[commands3Menu] = GetMenu(commands3Menu+MENUBASE);
- myMenus[commands4Menu] = GetMenu(commands4Menu+MENUBASE);
- for (menu=0; menu <= lastMenu; ++menu) InsertMenu(myMenus[menu], 0);
- DrawMenuBar();
-
- return;
- }
- #define __SEG__ mactty
- /*
- * DoAbout:
- *
- * Dialog box handler for extended about box. Put up a dialog
- * box with help information. Cycle through a string list
- * (STR# ID HLIST) to change the contents of a statText item.
- * Help information is updated by changing the contents of the
- * STR#, making things easier to localize.
- */
- #define HDLOG 128
- #define HLIST 957
- #define HITEM 5
- #define MORE 1
- #define BACK 2
- #define ENOUGH 3
- DoAbout()
- {
- int16 res,i,helptype,nlimit;
- DialogPtr helpdialog;
- WindowPtr tempport;
- char helpstring[256];
- StringHandle creatorstring;
- Handle helpitem;
- Rect helpbox;
- int16 **stringlist;
- int16 moretype;
- Handle moreitem;
- Rect morebox;
- /* Prepare to use dialog box. */
- helpdialog = GetNewDialog(HDLOG,(long)0,(WindowPtr) -1);
- GetDItem(helpdialog,HITEM,&helptype,&helpitem,&helpbox);
- GetDItem(helpdialog,MORE,&moretype,&moreitem,&morebox);
- GetPort(&tempport);
- SetPort(helpdialog);
- ForeColor(redColor);
- PenSize(3,3);
- InsetRect(&morebox,-4,-4);
- FrameRoundRect(&morebox,16,16);
- /* How many strings? */
- stringlist = (int16 **)GetResource('STR#',HLIST);
- LoadResource(stringlist);
- if((creatorstring = (StringHandle)GetResource('Earl',0)) != NULL){
- LoadResource(creatorstring);
- GetDItem(helpdialog,HITEM - 1,&moretype,&moreitem,&morebox);
- HLock(creatorstring);
- SetIText(moreitem,*creatorstring);
- ReleaseResource(creatorstring);
- }
- nlimit = (int16) **stringlist;
- i = 0;
- res = 1;
- while(res != ENOUGH){ /* Done when quit button selected. */
- if (res == BACK) i--; /* Cycle back. */
- else i++; /* Cycle forwards. */
- if (i<1) i=nlimit; /* Choose < 1, use last string. */
- GetIndString(helpstring,HLIST,i); /* Get the string. */
- if(helpstring[0] == '\0'){ /* Out of range, last string. */
- i=1; /* Cycle back to first one. */
- GetIndString(helpstring,HLIST,i); /* Get it. */
- }
- ForeColor(blueColor);
- SetIText(helpitem,helpstring); /* Use it. */
- ModalDialog(0L,&res); /* ModalDialog handles events. */
- }
- DisposDialog(helpdialog); /* Done, clean up. */
- SetPort(tempport);
- ReleaseResource(GetResource('DLOG',128));
- ReleaseResource(GetResource('DITL',128));
- ReleaseResource(stringlist);
- }
- /*
- * Default item filter for print dialogs.
- */
- pascal short MyFilter(tp,theEvent,itemhit)
- DialogPtr tp;
- EventRecord *theEvent;
- int16 *itemhit;
- {
- char c;
- GrafPtr port;
- int16 type;
- Handle item;
- Rect box;
- if(theEvent->what == keyDown){
- c = (theEvent->message & charCodeMask);
- if( (c == 'y') || (c == 'Y') || (c == 13) || (c == 3)){ /* Return or Enter. */
- *itemhit = 1;
- }
- if( (c == 'n') || (c == 'N') ){
- *itemhit = 2;
- }
- if(*itemhit == 1 || *itemhit == 2){
- GetPort(&port);
- GetDItem(port,*itemhit,&type,&item,&box);
- HiliteControl(item,1);
- return 0x0100;
- }
- }
- return FALSE;
- }
-
- int mlyesno(prompt)
- char *prompt;
- {
- DialogPtr dlg;
- int16 type,itemhit;
- Handle item;
- Rect box;
- GrafPtr tmpport;
- char name[256];
- DialogRecord x;
-
- dlg = GetNewDialog(129,0L,(WindowPtr)-1);
- GetDItem(dlg,1,&type,&item,&box);
- GetPort(&tmpport);
- SetPort(dlg);
- ForeColor(redColor);
- PenSize(3,3);
- InsetRect(&box,-4,-4);
- FrameRoundRect(&box,16,16);
- ForeColor(blackColor);
- GetDItem(dlg,1,&type,&item,&box);
- strcpy(name,prompt);
- strcat(name,"?");
- c2pstr(name);
- GetDItem(dlg,3,&type,&item,&box);
- SetIText(item,name);
- itemhit = 0;
- while(itemhit != 1 && itemhit != 2){
- ModalDialog(MyFilter,&itemhit);
- }
- DisposDialog(dlg);
- SetPort(tmpport);
- if(itemhit == 1)return TRUE;
- else return FALSE;
- }
- #endif
-