⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vt102em.cpp

📁 使用BorlandC++4.5编译的一个MUD客户端程序
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    // Special unix compatibility fix: translate CR into NL    if (the_char == '\r')        the_char = '\n';        if (use_this_char)    {        char c[2];        c[0] = the_char;        c[1] = '\0';        process_incoming(c); // Send keystroke to VaporTalk    };}// ------------------------------------------------------------------------d615 32d664 1a664 1      case MY_SOCKET_MSG:@1.8log@Changed title.@text@d3 5a7 2// $Id: vt102em.cpp 1.7 1995/10/18 22:58:01 tsurace Beta tsurace $// $Log: vt102em.cpp $d75 1a75 1static const char _TITLE[] = "VT-Win 1.0 $State$";@1.7log@Made MY_SOCKET_LONG message globally accessible.@text@d3 1a3 1// $Id: vt102em.cpp 1.6 1995/10/15 23:33:25 tsurace Exp tsurace $d5 3d71 2a72 1char VT102Emulator::_szClassName[] = "VaporTalk Emulator Window";d103 1a103 1                         _szClassName,@1.6log@Added one line comment.@text@d3 1a3 1// $Id: vt102em.cpp 1.5 1995/10/15 23:23:39 tsurace Exp tsurace $d5 3a67 1const long MY_SOCKET_MSG  = (WM_USER + 1);d622 1a622 1    };@1.5log@Fixed bug that caused all windows to resize on SIZE_MINIMIZE.@text@d3 1a3 1// $Id: vt102em.cpp 1.4 1995/10/11 21:40:43 tsurace Exp tsurace $d5 3d586 1@1.4log@Modified the "select event" handling code.Modified resize functionality.Reflects changes to the scream_and_die function.@text@d3 1a3 1// $Id: vt102em.cpp 1.3 1995/10/08 23:29:29 tsurace Exp tsurace $d5 5d546 11d559 20a578 9    (void) type; // silence 'not used' message        width /= _fontSize.Width();   // Truncated to smaller int!  How nice!    height /= _fontSize.Height();        if (width < 15)       // These size parameters are enforced by vt        width = 15;    if (height < 4)        height = 4;d580 8a587 7    _screen.Resize(width, height); // Resize screen buffer        // Tricky - pretend we sent a TIOCGWINSZ signal to VT.  The cool thing    // about this, is that we don't have to worry about accidentally    // resizing asynchronously, because we didn't catch a signal!        resize_screen(height, width); // Tell vt about it!@1.3log@Modified code to update more quickly when scrolling.  It kindof sucks if you have a slow display card right now.@text@d3 1a3 1// $Id: vt102em.cpp 1.2 1995/10/07 00:33:48 tsurace Exp tsurace $d5 4d27 3a30 1#include "esc_seq.hpp"d33 5a37 1    // Functions from VT -- be sure to check the type of these when updatingd41 3a43 3    extern int io_check(long sec, long usec); /* remote.c */    extern int io_cycle();                    /* main.c */    extern void process_incoming (char * str); // keyboard input routined45 1d57 2a58 2const long MY_SOCKET_MSG = (WM_USER + 1);char VT102Emulator::_szClassName[] = "VT102 Emulator Window";d102 1a102 1        scream_and_die(IDERR_CREATEWINDOW);d141 3a143 3    assert(bottom >= top); // Hey, this won't work!    assert(top >= 0);    assert(bottom < _screen.Height()); // Off screen?d187 6a192 1void VT102Emulator::NewSocket (SOCKET s, long events)d195 15a209 1    WSAAsyncSelect (s, Handle(), MY_SOCKET_MSG, events);d264 1a264 1    assert(_screen.Width() > 0); // Useless!d389 1a389 1    wndclass.hIcon         = LoadIcon(Global::Instance(), "whello");d397 1a397 1        scream_and_die(IDERR_REGISTER);d408 1a408 1        scream_and_die(IDERR_LOADFONT);d421 1a421 1        scream_and_die(IDERR_GETTEXTMETRIC); // Could not get font intod553 1a553 3    // First size the screen buffer...this is scary, probably invalidates    // all the memory.    _screen.Resize(width, height);d581 1a581 3        io_check(0,0);       // Poll sockets        while (0 == io_cycle()) // Process buffered input            ;       d591 15@1.2log@Added some cursor colors and the _Size function.  Scrollingoptimization.@text@d3 6a8 2// $Id$// $Log$d37 1a37 1#define TEXT_FORE RGB(200,200,200)a65 1  _backgroundBrush((HBRUSH)(GetStockObject(BLACK_BRUSH))),d68 1d147 2d192 3a194 1        if ((GetTickCount() - _lastPaintTickCount) > 200)d196 1d211 1d553 3a555 3        io_check(0,0);        while (0 == io_cycle())            ;          // Just keep looping@1.1log@Initial revision@text@d3 8a10 3// Derived from the cheesy borland Hello World program, I intend to// make this into a simple VT102 emulator library...oh yeah, for 32-bit// programs only, but supportive of win32sd23 8a30 4 // Functions from VT extern int io_check(long sec, long usec); /* remote.c */ extern int io_cycle();                    /* main.c */ extern void process_incoming (char * str); // keyboard input routined33 5d51 2a52 2          RGB(200,200,200), // Normal foreground          RGB(40,255,100),  // Bold foregroundd58 2a59 1  _cursorBrush(0),d61 1a61 1  _backgroundColor(RGB(0,0,0)),d63 3a65 1  _fontSize(8,16)d92 2a93 1    Update(); a97 1    DeleteObject(_cursorBrush); // from CreateBrushIndirectd133 2a134 2        area.top = (top + 1) * _fontSize.Height();        area.bottom = (bottom + 1) * _fontSize.Height();d136 1a136 1        area.right = _screen.Width() * _fontSize.Width();d138 5a142 16        HDC hdc = GetDC(Handle());        RECT uncovered_rect;        ScrollDC(hdc,                 0, // No scroll of x                 - (amount * _fontSize.Height()),                 &area,                 NULL,                 NULL,                 &uncovered_rect);                ReleaseDC(Handle(), hdc);        InvalidateRect(Handle(),&uncovered_rect,TRUE);        // Force a screen refresh NOW for immediate feedback!        // This assumes that the screen buffer is up-to-date.  <sigh>        Update(); d144 2a145 2    return 1; // Successful scrolld151 2a152 2                                        const Size & size,                                        void * this_ptr)d164 1a164 1d180 9a188 2    for (int i=0; i < len; i++)            _screen.Put(str[i]); // No parsing for nowd197 2d201 3a203 1    PAINTSTRUCT ps;              // Begin paint, get infod205 1a205 1d210 1a210 1d213 2a214 2    DeleteObject(clip_reg);     // Don't need this region any mored216 1a216 1    EndPaint(Handle(), &ps );   // Done, yay!d224 4a227 1    int j; // counterd229 7a235 2    // Copy characters one-at-a-time out of the buffer to the screen.    for (j = 0; j < _screen.Width(); j++)d237 21a257 7        int index = _screen.IndexOf(j,row);        SetTextColor(hdc, _screen.ForegroundElement(index));        TextOut(hdc,                j * _fontSize.Width(),                row * _fontSize.Height(),                &_screen.TextElement(index),                1);d274 1a274 1    if (firstRow < 0)                      // Off top of screen?d280 1a280 1    if (lastRow < 0)                        // Off top of screend282 1a282 1    else if (lastRow >= _screen.Height())   // Off bottom of screen?d288 1a288 1d294 2a295 2    SetBkMode(hdc, oldBkMode);  // Restore old drawing modesd308 12a319 12    // Put the cursor    HBRUSH oldBrush = (HBRUSH)SelectObject(hdc, _cursorBrush);    Pos topLeft(_screen.Cursor());    _TextToDevice(topLeft);    Pos bottomRight(topLeft);    bottomRight.X() += _fontSize.Width() - 1;    bottomRight.Y() += _fontSize.Height() - 1;    Rectangle(hdc,              topLeft.X(), topLeft.Y(),              bottomRight.X(), bottomRight.Y());d321 3a323 1    SelectObject(hdc, oldBrush); // Put back old brushd336 1a336 1    WNDCLASS wndclass;          // Structure used to register Windows class.d341 1a341 1d354 1a354 1a368 4    _cursorBrush = CreateSolidBrush(RGB(0,125,255));    if (NULL == _cursorBrush)        scream_and_die(IDERR_CREATEBRUSH);d371 1a371 1d374 2a375 2    HDC hdc = GetDC(Handle());     // Get a device context for a secondd379 1a379 1    TEXTMETRIC fontMetric;                   // Get font infod382 1a382 1d384 1a384 1d388 1a388 1d390 1a390 1d418 1a418 1      case WM_CREATE:   // Ignored422 1a422 1      case WM_PAINT:    // Paint yourself!d426 2a427 2      case WM_CHAR:                  // Regular char eventsd434 1a434 1d439 8d457 1a457 1    return ret_val;          // Handled the messaged485 1a485 1d489 1a489 1d499 24d535 1a535 1    (void)wParam;    // Silence 'not used' warningd545 1a545 1            ; // Just keep loopingd549 1a549 1    @

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -