void _WriteBuf(char *Buffer, WORD Count)
{
    int L, R;

    __InitEasyWin();
    L = _Cursor.x;
    R = _Cursor.x;
    while (Count > 0)
        {
        if (Buffer[0] == -1)
            Buffer[0] = ' ';
        switch (Buffer[0])
            {
            case 13:
            NewLine(L, R);
                break;
            case 10:
                break;
            case  9:
                do
                    {
                    *(ScreenPtr(_Cursor.x, _Cursor.y)) = ' ';
                    ++_Cursor.x;
                    if (_Cursor.x > R)
                        R = _Cursor.x;
                    if (_Cursor.x == _ScreenSize.x)
                        {
                        NewLine(L, R);
                        break;
                        }
                    } while (_Cursor.x % 8);
                break;
            case  8:
            if (_Cursor.x > 0)
                {
                --_Cursor.x;
                *(ScreenPtr(_Cursor.x, _Cursor.y)) = ' ';
                if (_Cursor.x < L )
                        L = _Cursor.x;
                }
                break;
            case  7:
                MessageBeep(0);
                break;
            default:
                *(ScreenPtr(_Cursor.x, _Cursor.y)) = Buffer[0];
                ++_Cursor.x;
                if (_Cursor.x > R)
                    R = _Cursor.x;
                if (_Cursor.x == _ScreenSize.x)
                    NewLine(L, R);
            }

        ++Buffer;
        --Count;
        }
    ShowText(L, R);
    if (_AutoTracking)
        _TrackCursor();
}
예제 #2
0
ScreenPtr
ScreenManager::get_current_screen()
{
  if (screens.empty())
    return ScreenPtr();
  else
    return screens.back();
}
static void ShowText(int L, int R)
{
    if (L < R)
        {
        InitDeviceContext();
        TextOut(DC, (L - _Origin.x) * CharSize.x,
                    (_Cursor.y - _Origin.y) * CharSize.y,
                    ScreenPtr(L, _Cursor.y), R - L);
        DoneDeviceContext();
        }
}
static void NewLine(int& L, int& R)
{
    ShowText(L, R);
    L = 0;
    R = 0;
    _Cursor.x = 0;
    ++_Cursor.y;
    if (_Cursor.y == _ScreenSize.y)
        {
        --_Cursor.y;
        ++FirstLine;
        if (FirstLine == _ScreenSize.y)
            FirstLine = 0;
        memset(ScreenPtr(0, _Cursor.y), ' ', _ScreenSize.x);
        ScrollWindow(CrtWindow, 0, -CharSize.y, NULL, NULL);
        UpdateWindow(CrtWindow);
        }
}
static void WindowPaint(VOID)
{
    int X1, X2, Y1, Y2;

    Painting = TRUE;
    InitDeviceContext();
    X1 = Max(0, PS.rcPaint.left / CharSize.x + _Origin.x);
    X2 = Min(_ScreenSize.x,
             (PS.rcPaint.right + CharSize.x - 1) / CharSize.x + _Origin.x);
    Y1 = Max(0, PS.rcPaint.top / CharSize.y + _Origin.y);
    Y2 = Min(_ScreenSize.y,
             (PS.rcPaint.bottom + CharSize.y - 1) / CharSize.y + _Origin.y);
    while (Y1 < Y2)
        {
        TextOut(DC, (X1 - _Origin.x) * CharSize.x, (Y1 - _Origin.y) * CharSize.y,
                    ScreenPtr(X1, Y1), X2 - X1);
        ++Y1;
        }
    DoneDeviceContext();
    Painting = FALSE;
}
void clreol(void)
{
    __InitEasyWin();
    memset(ScreenPtr(_Cursor.x, _Cursor.y), ' ',_ScreenSize.x - _Cursor.x);
    ShowText(_Cursor.x, _ScreenSize.x);
}