mac.c
来自「大名鼎鼎的远程登录软件putty的Symbian版源码」· C语言 代码 · 共 792 行 · 第 1/2 页
C
792 行
#if !TARGET_API_MAC_CARBON if (GetWindowKind(window) < 0) return wDA;#endif return ((WinInfo *)GetWRefCon(window))->wtype;}/* * Handle a key press */static void mac_keypress(EventRecord *event) { WindowPtr window; window = mac_frontwindow(); /* * Check for a command-key combination, but ignore it if it counts * as a meta-key combination and we're in a terminal window. */ if (event->what == keyDown && (event->modifiers & cmdKey) /*&& !((event->modifiers & cfg.meta_modifiers) == cfg.meta_modifiers && mac_windowtype(window) == wTerminal)*/) { mac_adjustmenus(); mac_menucommand(MenuKey(event->message & charCodeMask)); } else { if (window != NULL && mac_wininfo(window)->key != NULL) (*mac_wininfo(window)->key)(window, event); } }static void mac_menucommand(long result) { short menu, item; WindowPtr window;#if !TARGET_API_MAC_CARBON Str255 da;#endif menu = HiWord(result); item = LoWord(result); window = mac_frontwindow(); /* Things which do the same whatever window we're in. */ switch (menu) { case mApple: switch (item) { case iAbout: mac_openabout(); goto done;#if !TARGET_API_MAC_CARBON default: GetMenuItemText(GetMenuHandle(mApple), item, da); OpenDeskAcc(da); goto done;#endif } break; case mFile: switch (item) { case iNew: mac_newsession(); goto done; case iOpen: mac_opensession(); goto done; case iClose: mac_closewindow(window); goto done; case iSave: mac_savesession(); goto done; case iSaveAs: mac_savesessionas(); goto done; case iDuplicate: mac_dupsession(); goto done; case iQuit: cleanup_exit(0); goto done; } break; } /* If we get here, handling is up to window-specific code. */ if (window != NULL && mac_wininfo(window)->menu != NULL) (*mac_wininfo(window)->menu)(window, menu, item); done: HiliteMenu(0);}static void mac_closewindow(WindowPtr window) { switch (mac_windowtype(window)) {#if !TARGET_API_MAC_CARBON case wDA: CloseDeskAcc(GetWindowKind(window)); break;#endif default: if (mac_wininfo(window)->close != NULL) (*mac_wininfo(window)->close)(window); break; }}static void mac_suspendresume(EventRecord *event){ WindowPtr front; EventRecord fakeevent; /* * We're called either before we're suspended or after we're * resumed, so we're the front application at this point. */ front = FrontWindow(); if (front != NULL) { fakeevent.what = activateEvt; fakeevent.message = (UInt32)front; fakeevent.when = event->when; fakeevent.where = event->where; fakeevent.modifiers = (event->message & resumeFlag) ? activeFlag : 0; mac_activatewindow(front, &fakeevent); }}static void mac_zoomwindow(WindowPtr window, short part) { /* FIXME: do something */}/* * Make the menus look right before the user gets to see them. */#if TARGET_API_MAC_CARBON#define EnableItem EnableMenuItem#define DisableItem DisableMenuItem#endifstatic void mac_adjustmenus(void) { WindowPtr window; MenuHandle menu; window = mac_frontwindow(); menu = GetMenuHandle(mApple); EnableItem(menu, 0); EnableItem(menu, iAbout); menu = GetMenuHandle(mFile); EnableItem(menu, 0); EnableItem(menu, iNew); if (window != NULL) EnableItem(menu, iClose); else DisableItem(menu, iClose); EnableItem(menu, iQuit); if (window != NULL && mac_wininfo(window)->adjustmenus != NULL) (*mac_wininfo(window)->adjustmenus)(window); else { DisableItem(menu, iSave); DisableItem(menu, iSaveAs); DisableItem(menu, iDuplicate); menu = GetMenuHandle(mEdit); DisableItem(menu, 0); menu = GetMenuHandle(mWindow); DisableItem(menu, 0); /* Until we get more than 1 item on it. */ } DrawMenuBar();}/* * Make sure the right cursor's being displayed. */static void mac_adjustcursor(RgnHandle cursrgn) { Point mouse; WindowPtr window, front; short part;#if TARGET_API_MAC_CARBON Cursor arrow; RgnHandle visrgn;#endif GetMouse(&mouse); LocalToGlobal(&mouse); part = FindWindow(mouse, &window); front = FrontWindow(); if (part != inContent || window == NULL || window != front) { /* Cursor isn't in the front window, so switch to arrow */#if TARGET_API_MAC_CARBON GetQDGlobalsArrow(&arrow); SetCursor(&arrow);#else SetCursor(&qd.arrow);#endif SetRectRgn(cursrgn, SHRT_MIN, SHRT_MIN, SHRT_MAX, SHRT_MAX); if (front != NULL) {#if TARGET_API_MAC_CARBON visrgn = NewRgn(); GetPortVisibleRegion(GetWindowPort(front), visrgn); DiffRgn(cursrgn, visrgn, cursrgn); DisposeRgn(visrgn);#else DiffRgn(cursrgn, front->visRgn, cursrgn);#endif } } else { if (mac_wininfo(window)->adjustcursor != NULL) (*mac_wininfo(window)->adjustcursor)(window, mouse, cursrgn); else {#if TARGET_API_MAC_CARBON GetQDGlobalsArrow(&arrow); SetCursor(&arrow); GetPortVisibleRegion(GetWindowPort(window), cursrgn);#else SetCursor(&qd.arrow); CopyRgn(window->visRgn, cursrgn);#endif } }}pascal OSErr mac_aevt_quit(const AppleEvent *req, AppleEvent *reply, long refcon){ DescType type; Size size; if (AEGetAttributePtr(req, keyMissedKeywordAttr, typeWildCard, &type, NULL, 0, &size) == noErr) return errAEParamMissed; borednow = 1; return noErr;}void cleanup_exit(int status){#if !TARGET_RT_MAC_CFM if (mac_gestalts.encvvers != 0) TerminateUnicodeConverter();#endif sk_cleanup(); exit(status);}/* This should only kill the current session, not the whole application. */void connection_fatal(void *fontend, char *fmt, ...) { va_list ap; Str255 stuff; va_start(ap, fmt); /* We'd like stuff to be a Pascal string */ stuff[0] = vsprintf((char *)(&stuff[1]), fmt, ap); va_end(ap); ParamText(stuff, NULL, NULL, NULL); StopAlert(128, NULL); cleanup_exit(1);}/* Null SSH agent client -- never finds an agent. */int agent_exists(void){ return FALSE;}int agent_query(void *in, int inlen, void **out, int *outlen, void (*callback)(void *, void *, int), void *callback_ctx){ *out = NULL; *outlen = 0; return 1;}/* Temporary null routines for testing. */void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype, char *keystr, char *fingerprint){ Str255 stuff; Session *s = frontend; /* * This function is horribly wrong. For one thing, the alert * shouldn't be modal, it should be movable modal, or a sheet in * Aqua. Also, PuTTY might be in the background, in which case we * should use the Notification Manager to wake up the user. In * any case, we shouldn't hold up processing of other connections' * data just because this one's waiting for the user. It should * also handle a host key cache, of course, and see the note below * about closing the connection. All in all, a bit of a mess * really. */ stuff[0] = sprintf((char *)(&stuff[1]), "The server's key fingerprint is: %s\n" "Continue connecting?", fingerprint); ParamText(stuff, NULL, NULL, NULL); if (CautionAlert(wQuestion, NULL) == 2) { /* * User chose "Cancel". Unfortunately, if I tear the * connection down here, Bad Things happen when I return. I * think this function should actually return something * telling the SSH code to abandon the connection. */ }}void askcipher(void *frontend, char *ciphername, int cs){}void old_keyfile_warning(void){}FontSpec platform_default_fontspec(char const *name){ FontSpec ret; long smfs; if (!strcmp(name, "Font")) { smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize); if (smfs == 0) smfs = GetScriptVariable(smRoman, smScriptMonoFondSize); if (smfs != 0) { GetFontName(HiWord(smfs), ret.name); if (ret.name[0] == 0) memcpy(ret.name, "\pMonaco", 7); ret.size = LoWord(smfs); } else { memcpy(ret.name, "\pMonaco", 7); ret.size = 9; } ret.face = 0; } else { ret.name[0] = 0; } return ret;}Filename platform_default_filename(const char *name){ Filename ret; if (!strcmp(name, "LogFileName")) FSMakeFSSpec(0, 0, "\pputty.log", &ret.fss); else memset(&ret, 0, sizeof(ret)); return ret;}char *platform_default_s(char const *name){ return NULL;}int platform_default_i(char const *name, int def){ /* Non-raw cut and paste of line-drawing chars works badly on the * current Unix stub implementation of the Unicode functions. * So I'm going to temporarily set the default to raw mode so * that the failure mode isn't quite so drastically horrid. * When Unicode comes in, this can all be put right. */ if (!strcmp(name, "RawCNP")) return 1; return def;}void platform_get_x11_auth(char *display, int *proto, unsigned char *data, int *datalen){ /* SGT: I have no idea whether Mac X servers need anything here. */}void update_specials_menu(void *frontend){ Session *s = frontend; WindowPtr front; front = mac_frontwindow(); if (front != NULL && mac_windowsession(front) == s) mac_adjustmenus();}/* * Local Variables: * c-file-style: "simon" * End: */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?