示例#1
0
/*
	FUNCTION: InitNewFont(LOGFONT, COLORREF)

	PURPOSE: Prepares a new font for use in the terminal screen

	PARAMETERS:
		LogFont		- New logical font for the screen
		rgbColour	- New colour for screen painting

*/
void InitNewFont(LOGFONT LogFont, COLORREF rgbColour) {
	TEXTMETRIC	tm;
	HDC			hDC;

	// If an old font exits, delete it
	if (HSCREENFONT(TermInfo)) {
		DeleteObject(HSCREENFONT(TermInfo));
	}

	LFSCREENFONT(TermInfo) = LogFont;
	HSCREENFONT(TermInfo) = CreateFontIndirect(&(LFSCREENFONT(TermInfo)));
	FGCOLOUR(TermInfo) = rgbColour;

	hDC = GetDC(ghWndMain);
	SelectObject(hDC, HSCREENFONT(TermInfo));
	GetTextMetrics(hDC, &tm);
	ReleaseDC(ghWndMain, hDC);

	// Character width and height
	XCHAR(TermInfo) = tm.tmAveCharWidth;
	YCHAR(TermInfo) = tm.tmHeight + tm.tmExternalLeading;

	// Set the terminal height and width based on the current font
	XSIZE(TermInfo) = tm.tmAveCharWidth * MAXCOLS;
	YSIZE(TermInfo) = (tm.tmHeight + tm.tmExternalLeading) * MAXROWS;

}
示例#2
0
/*-----------------------------------------------------------------------------*/
void InitFont() {
	TEXTMETRIC	tm;
	HDC			hdc;

	hdc = GetDC(ghwndMain);
	
	// set the font to be the default fixed-pitch font
	SelectObject(hdc, CreateFont(0, 0, 0, 0, 0, 0, 0, 0,
		DEFAULT_CHARSET, 0, 0, 0, FIXED_PITCH, NULL));

	GetTextMetrics(hdc, &tm);
	ReleaseDC(ghwndMain, hdc);

	// get text width & height
	XCHAR(TTYInfo) = tm.tmAveCharWidth;
	YCHAR(TTYInfo) = tm.tmHeight + tm.tmExternalLeading;
}
示例#3
0
/*-----------------------------------------------------------------------------

FUNCTION: OutputABufferToWindow(HWND, char *, DWORD)

PURPOSE: Updates TTY Buffer with characters just received.

PARAMETERS:
    hTTY     - handle to the TTY child window
    lpBuf    - address of data buffer
    dwBufLen - size of data buffer

HISTORY:   Date       Author      Comment
            5/ 8/91   BryanW      Wrote it
           10/27/95   AllenD      Modified for MTTTY Sample

-----------------------------------------------------------------------------*/
void OutputABufferToWindow(HWND hTTY, char * lpBuf, DWORD dwBufLen)
{
    RECT rect;

    /*
        update screen buffer with new buffer
        need to do a character by character check
        for special characters
    */
    int i;

    for ( i = 0 ; i < (int) dwBufLen; i++) {
        switch (lpBuf[ i ]) {
            case ASCII_BEL:                // BELL CHAR
                MessageBeep( 0 ) ;
                break ;

            case ASCII_BS:                 // Backspace CHAR
                if (COLUMN( TTYInfo ) > 0)
                   COLUMN( TTYInfo ) -- ;
                break ;

            case ASCII_CR:                 // Carriage Return
                COLUMN( TTYInfo ) = 0 ;
                if (!NEWLINE( TTYInfo ))
                    break;

                //
                // FALL THROUGH
                //

            case ASCII_LF:                 // Line Feed
                if (ROW( TTYInfo )++ == MAXROWS - 1)
                {
                    MoveMemory( (LPSTR) (SCREEN( TTYInfo )),
                                  (LPSTR) (SCREEN( TTYInfo ) + MAXCOLS),
                                  (MAXROWS - 1) * MAXCOLS ) ;
                    FillMemory((LPSTR) (SCREEN( TTYInfo ) + (MAXROWS - 1) * MAXCOLS),
                                  MAXCOLS,  ' ' ) ;
                    InvalidateRect( hTTY, NULL, FALSE ) ;
                    ROW( TTYInfo )-- ;
                }
                break ;

            default:                       // standard character
                SCREENCHAR(TTYInfo, COLUMN(TTYInfo), ROW(TTYInfo)) = lpBuf[ i ];

                rect.left = (COLUMN( TTYInfo ) * XCHAR( TTYInfo )) -
                            XOFFSET( TTYInfo ) ;
                rect.right = rect.left + XCHAR( TTYInfo ) ;
                rect.top = (ROW( TTYInfo ) * YCHAR( TTYInfo )) -
                           YOFFSET( TTYInfo ) ;
                rect.bottom = rect.top + YCHAR( TTYInfo ) ;
                InvalidateRect( hTTY, &rect, FALSE ) ;

                // 
                // Line wrap
                //
                if (COLUMN( TTYInfo ) < MAXCOLS-1 )
                    COLUMN( TTYInfo )++ ;
                else if (AUTOWRAP( TTYInfo ))
                    OutputABufferToWindow(hTTY, "\r\n", 2 ) ;
                
                break;
        }
    }

    MoveTTYCursor(hTTY);
    return;
}