Beispiel #1
0
/* key press procedure for TextEdit
 */
short NATEkeyp(na_win *winp, long c, short mods)
{
	short status = NA_NOTPROCESSED;
	
	if (!(mods & cmdKey)) {
		status = NA_PROCESSED;
		ObscureCursor();
		TEKey(c, teinfo->hTE);
		NATEsetscroll(winp, false, (Rect*) NULL, (Rect*) NULL);
	}
	
	return (status);
}
Beispiel #2
0
void obscurecursor (void) {
	
	ObscureCursor ();
	} /*obscurecursor*/
Beispiel #3
0
int
tgetch()

{
	char	ch;
	EventRecord	theEvent;
	Rect cursorRect,box,windowRect;
	long	message,cursorTime,start;
	MenuHandle	theMenu;
	register short	keyCode;
	short	temp;
	term_info	*t;
	GrafPtr	oldPort,oldPort1;
	static char nextCommand;
	short aboutBox();
	char mButtonDown();
	Point	mouseLoc;
	WindowPtr	theWindow;
	void	doUpdate();
#define	clearKey	0x47
#define ESCAPEkey	0x1B
	static int see, saw = 0;
	int eye, cursOff = 100;
	boolean cursRectInv;	/* should be a macflag */
	short	fInFront = TRUE;

	t = (term_info *)GetWRefCon(HackWindow);
	mouseLoc.h = (macflags & fMoveWRTMouse) ? t->tcur_x : (u.ux-1);
	mouseLoc.v = (macflags & fMoveWRTMouse) ? t->tcur_y : (u.uy+1);
	cursorRect.left = t->tcur_x * t->charWidth + Screen_Border;
	cursorRect.right = cursorRect.left + t->charWidth - 1;
	cursorRect.top = t->height * t->tcur_y + Screen_Border;
	cursorRect.bottom = cursorRect.top + t->height - 1;
	cursorTime = GetCaretTime();
	box.left = mouseLoc.h * t->charWidth + Screen_Border - 1;
	box.right = box.left + t->charWidth + 2;
	box.top = mouseLoc.v * t->height + Screen_Border - 1;
	box.bottom = box.top + t->height + 2;
	/* permit use of cursor keys and numeric keypad */
	/* does the same translation as in msdos.c but includes cursor keys */
	ch = '\0';
	/* handle extended command from menu */
	if (nextCommand && (macflags & (fExtCmdSeq1 | fExtCmdSeq2 | fExtCmdSeq3))) {
	    if (macflags & fExtCmdSeq1) {
		ch = '#';
		macflags = macflags ^ (fExtCmdSeq1 | fExtCmdSeq2);
	    } else if (macflags & fExtCmdSeq2) {
		ch = nextCommand;
		macflags = macflags ^ (fExtCmdSeq2 | fExtCmdSeq3);
		if (!(macflags & fExtCmdSeq3))
		    nextCommand = '\0';
	    } else if (macflags & fExtCmdSeq3) {
		ch = '\r';
		macflags &= ~fExtCmdSeq3;
	    }
	}
	GetPort(&oldPort);
	SetPort(HackWindow);
	if (!(macflags & fDoNonKeyEvt)) {
		cursorPos = -1;
		if (! flags.wantspace) SetCursor(&ARROW_CURSOR);
	}
	/* initialize cursor blinking */
	message = TickCount() + ((Invisible || (macflags & fMoveWRTMouse)) ? 0L : cursorTime);
	cursRectInv = FALSE;
	while (!ch) {
		(void)WaitNextEvent(everyEvent, &theEvent, (fInFront) ? 0L : 50L, 0L);
		if ((theEvent.what == keyDown || theEvent.what == autoKey) && (FrontWindow() == HackWindow)) {
			ch = 0;
			ObscureCursor();
			/* use raw key codes */
			keyCode = (LoWord(theEvent.message) & keyCodeMask)>>8;
 			if (keyCode == clearKey) {
				macflags = macflags ^ fToggleNumPad;
				SetWTitle(HackWindow,
					(macflags & fToggleNumPad)	? "\016NetHack [MOVE]"
												: "\015NetHack [NUM]");
				ch = 0;
				continue;
			}
			if ((macflags & fToggleNumPad) && (keyCode>0x40 &&keyCode < 0x5D) 
				|| (keyCode > 0x7A && keyCode<0x7F)) {
				ch = t->keyMap[keyCode-65];
				if ((theEvent.modifiers & shiftKey) && (ch)) {
					ch = (ch == '.') ? ':' : (char)toupper(ch);
				}
				if (ch)
					break;
			}
			if (t->system.keyBoardType < 4 && keyCode == 50) {
				ch = (char)ESCAPEkey;	/* ESC */
				break;
			}			/* make the command key = control key on all non-adb keyboards
						 Now, LEAVE it this way ! Otherwise you'll render non-us
keyboards useless, since here is where "<" and ">" are located */
			if ((theEvent.message & 0xFF) == 0x60) {
				ch = (char)ESCAPEkey;
				break;
			} /* This is the way to fix backquote->esc for all macs */
			if (theEvent.modifiers & cmdKey) {
				ch = (char)(theEvent.message & 0x1F);
				if(ch == ('Q' & 0x1F)) ch = 'Q'; /* For Quit */
				break;
			}
			if (theEvent.modifiers & optionKey) {
				for(start = 43; start < 56; start++) {
					if (t->keyMap[start] == (char)(theEvent.message & 0xFFL)) {
						ch = t->keyMap[start - 13];
						break;
					}
				}
			}
			/* not a cursor key or from the numeric keypad */
			if (!ch) {
				ch = (char)(theEvent.message & 0xFF);
			}
		} else {
		/* what other events to handle */
			switch (theEvent.what) {