Beispiel #1
0
/*
 * SetFont - process a set font command
 */
vi_rc SetFont( const char *data )
{
    LOGFONT     l;
    STUPIDNTINT index;

    if( !getInt( &index, &data ) ) {
        return( ERR_INVALID_FONT );
    }
    if( index >= MAX_FONTS || index < 0 ) {
        return( ERR_INVALID_FONT );
    }
    initFont( index, &l );
    /*
     * Either the user can specify 'setfont x' and choose a font
     * using the common dialog - or he/she can do the full
     * 'setfont x n n n n n n... ad nauseum to define a font.
     */
    while( isspace( *data ) ) {
        data++;
    }
    if( *data == 0 ) {
        if( !userPickFont( &l, root_window_id ) ) {
            return( ERR_NO_ERR );
        }
    } else {
        if( !getLogFont( &l, &data ) ) {
            return( ERR_INVALID_FONT );
        }
    }
    SetUpFont( &l, index );
    return( ERR_NO_ERR );

} /* SetFont */
Beispiel #2
0
/*
 * PickFont - pick a new font with the font dialog
 */
void PickFont( font_type index, HWND parent )
{
    LOGFONT     l;

    initFont( index, &l );
    if( !userPickFont( &l, parent ) ) {
        return;
    }
    SetUpFont( &l, index );

} /* PickFont */
Beispiel #3
0
static void sendNewFont( void )
{
    type_style  *mod_style;

    if( mod_hwnd == NULL ) {
        return;
    }

    mod_style = (&(WINDOW_FROM_ID( mod_hwnd )->info->text));

    if( mod_hwnd == CurrentWindow ) {
        sendNewFontCurrentWindow();
    } else if( mod_hwnd != GetToolbarWindow() ) {
        /* (toolbar has no font)
        */
        SetUpFont( &CurLogfont, mod_style->font );
    }
}
Beispiel #4
0
static void sendNewFontCurrentWindow( void )
{
    int             row, col;
    syntax_element  style;
    BOOL            totally;
    linenum         line_num;

    ScreenToClient( mod_hwnd, &m_pt );
    ClientToRowCol( mod_hwnd, m_pt.x, m_pt.y, &row, &col, DIVIDE_BETWEEN );

    /* someone is base 0, someone else isn't.  bummer.
     * Also row may not be valid if attemping to drop beyond bottom
     * of visible text, so check!
     */

    if( col < 1 ) {
        return;
    }
    col--;

    // SStyle expect real not virtual columns!
    // Hmmm.
    line_num = (linenum)(LeftTopPos.line + row - 1);
    col = RealCursorPositionOnLine( line_num, col );

    style = SSGetStyle( row, col );
    if( style != SE_UNPARSED ) {
        /*
         * ASSUMPTION: font #s in win.cfg match SE_XXX enum values!
         */
        totally = FALSE;
        if( CtrlDown() ) {
            totally = TRUE;
        }
        EnsureUniformFonts( 0, SE_NUMTYPES - 1, &CurLogfont, totally );
        SetUpFont( &CurLogfont, SEType[style].font );
    }
}