📄 global.cpp
字号:
// Initialize the winsock interface
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD (1, 1);
if (WSAStartup(wVersionRequested, &wsaData) != 0)
scream_and_die(EC_WinSock, ERR_WinSockMissing);
if (NULL == WSASetBlockingHook(Global::BlockingHook))
scream_and_die(EC_WinSock, ERR_BlockingHook);
main_window = new VT102Emulator(nCmdShow); // Create main window
main_init_all(_argc, _argv); // Initialize VT
ret_val = Global::MessageLoop(); // Go!
}
catch (xalloc &)
{
Global::PostOutOfMemoryMessage();
}
catch (...)
{
WSACleanup(); // At least take care of the sockets
throw;
};
delete main_window; // Free memory
WSACleanup (); // clean up Winsock stuff
return ret_val;
}
// ----------------------------------------------------------------------
// These are called by VaporTalk
//
extern "C" {
/* Returns non-null on error */
const char * NewSocket(SOCKET s, long evt)
{
if (main_window)
return main_window->NewSocket(s, evt);
return "Main program not initialized";
};
void WriteString(char * str, int len)
{
if (main_window)
main_window->Output(str, len);
}
}
// EOF //
@2.3log@Added code to specify startup file on command line, default to"C:/VT/MAIN.VTC".@text@d4 1a4 1// $Id: global.cpp 2.2 1995/10/27 20:06:46 tsurace Exp tsurace $d6 4d38 1d266 3d272 3a274 3 // To facilitate location of the startup file, pass the command line // to vt (assume it is a startup file), and as a fallback set the // environment variable "VTSTART" to point to "C:\VT\MAIN.VTC"d276 1a276 7 int n_cmd_line_params = 1; char * my_cmd_line[2]; my_cmd_line[0] = "VTW"; my_cmd_line[1] = lpszCmdLine; // Assume all the rest is a filename if (0 != strlen(lpszCmdLine)) // Are there command-line parameters? n_cmd_line_params = 2;a277 2 putenv("VTSTART=C:/VT/MAIN.VTC"); // Fallback defaulta287 1 Global::Init(hInstance, hPrevInstance); // Init globalsd289 1a289 1 main_init_all(n_cmd_line_params, my_cmd_line); // Initialize VT@2.2log@Added Getch function to allow retrieving single keystroke.Added accelerator loading/translation code.@text@d4 1a4 1// $Id: global.cpp 2.1 1995/10/24 15:52:51 tsurace Exp tsurace $d6 4a260 12 (void) lpszCmdLine; // silence 'not used' message /* Initialize the winsock interface */ WORD wVersionRequested; WSADATA wsaData; wVersionRequested = MAKEWORD (1, 1); if (WSAStartup(wVersionRequested, &wsaData) != 0) scream_and_die(EC_WinSock, ERR_WinSockMissing); if (NULL == WSASetBlockingHook(Global::BlockingHook)) scream_and_die(EC_WinSock, ERR_BlockingHook);d264 24d290 1a290 1 main_init_all(0, NULL); // Initialize VT@2.1log@Roll.@text@d4 4a7 4// $Id: global.cpp 1.5 1995/10/18 23:53:59 tsurace Beta tsurace $// $Log: global.cpp $// Revision 1.5 1995/10/18 23:53:59 tsurace// Added version stringd9 3d43 1d48 1a48 1"<insert name here> Version 1.0.0 $State: Beta $";d74 2a75 2// is to say we must not process keyboard input except for BREAK, or// any socket messages (DUH).a87 1 {a88 1 };d97 1a97 1 TranslateMessage(&msg);d106 38d150 2d227 1a227 1// Loops foreverd234 6a239 1 TranslateMessage(&msg);@1.5log@Added version string@text@d4 5a8 2// $Id: global.cpp 1.4 1995/10/18 22:46:59 tsurace Beta tsurace $// $Log: global.cpp $d44 1a44 1"<insert name here> Version 1.0.0 $State$";@1.4log@Added BlockingHook to handle blocking calls correctly (connect()).@text@d4 1a4 1// $Id: global.cpp 1.3 1995/10/11 21:02:31 tsurace Exp tsurace $d6 3d38 5d45 2a46 2"You seem to be out of memory, :( and it is possible\n\that this program will crash soon. :< On the bright side,\n\@1.3log@Added out-of-memory handling (xalloc).@text@d4 1a4 1// $Id: global.cpp 1.2 1995/10/08 23:28:47 tsurace Exp tsurace $d6 3d55 37d206 4a209 1 scream_and_die(EC_FatalError, ERR_WinSockMissing);@1.2log@Change the order of calls on exiting.@text@d4 6a9 3// $Id: global.cpp 1.1 1995/10/05 18:34:42 tsurace Exp tsurace $// $Log$// (end of logd15 3d29 2a30 3// Functions to get the Window pointer from a handle, which is stored// in the "extra" field as a longd32 10d46 1d52 3a54 3HINSTANCE Global::_hInstance = 0;HINSTANCE Global::_hPrevInstance = 0;d61 14a74 1// Main window procd81 1a81 10 // The pointer pWindow will have an invalid value if the WM_CREATE // message has not yet been processed. At a call to WM_CREATE, // of course, we set that value. // This code will break if windows fails to set extra bytes to // zero at some future rev. VT102Emulator *pWindow = GetPointer(hWnd); // Get window's "this" pointer if (pWindow == 0) // Pointer not set?d83 10a92 1 if (iMessage == WM_CREATE) // Create message is speciald94 9a102 4 // Retrieve the window's "this" pointer LPCREATESTRUCT lpcs = (LPCREATESTRUCT) lParam; pWindow = (VT102Emulator *) lpcs->lpCreateParams;d104 10a113 7 // Store the "This" pointer in the window's extra bytes SetPointer(hWnd, pWindow); // Now let the object perform whatever // initialization it needs for WM_CREATE in its own // WndProc. return_value = pWindow->WndProc( iMessage, wParam, lParam );d117 2a118 2 // Not our message, pass it on. return_value = DefWindowProc( hWnd, iMessage, wParam, lParam );d121 1a121 1 elsed123 2a124 2 // Call the window's proc return_value = pWindow->WndProc( iMessage, wParam, lParam );d131 5a135 1// _MessageLoop - main program loop of the emulator. Static functiona138 1 d144 1a144 1 return msg.wParam; // Probably the return value of the exit dialogd151 3d166 1a166 2 exit(EXIT_FAILURE); d168 19a186 9 Global::Init(hInstance, hPrevInstance); main_window = new VT102Emulator(nCmdShow); main_init_all(0, NULL); // Initialize vt int ret_val = Global::MessageLoop(); delete main_window; WSACleanup (); /* clean up Winsock stuff */d190 3a192 9// invalidate_func - called to invalidate an area of the main_windowvoid invalidate_func(Pos & pos, Size & size){ if (NULL == main_window) // No window? return; main_window->Invalidate(pos, size);}a193 5void NewSocket(SOCKET s, long evt){ if (main_window) main_window->NewSocket(s, evt);};d195 5d201 9a209 4void WriteString(char * str, int len){ if (main_window) main_window->Output(str, len);d212 1a212 1}@1.1log@Initial revision@text@d4 3a6 1// $Id$d133 1a134 1 delete main_window;@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -