예제 #1
0
/*
 * NewCursor - create a new cursor for a window
 */
void NewCursor( window_id wid, cursor_type ct )
{
    window      *w;
    int         height;
    int         width;

    if( BAD_ID( wid ) ) {
        return;
    }
    w = WINDOW_FROM_ID( wid );
    height = FontHeight( WIN_TEXT_FONT( w ) );
    width = FontAverageWidth( WIN_TEXT_FONT( w ) );
    height = (long) height * ct.height / 100L;
    width = (long) width * ct.width / 100L;
    MyHideCaret( wid );
    DestroyCaret();
    cursorHeight = height;
    cursorWidth = width;
    if( !haveOldBlinkTime ) {
        oldBlinkTime = GetCaretBlinkTime();
        haveOldBlinkTime = true;
    }
    CreateCaret( wid, (HBITMAP)NULLHANDLE, cursorWidth, cursorHeight );
    SetCursorBlinkRate( EditVars.CursorBlinkRate );
    MyShowCaret( wid );
    cursorType = ct;

} /* NewCursor */
예제 #2
0
/*
 * SetCursorOnLine - set cursor at specified column in single line text string
 */
void SetCursorOnLine( window_id wid, int col, char *str, type_style *style )
{
    window      *w;
    int         x, y;
    int         width, height;

    if( BAD_ID( wid ) ) {
        return;
    }
    w = WINDOW_FROM_ID( wid );
    // y = FontHeight( WIN_TEXT_FONT( w ) ) - cursorHeight;

    x = MyTextExtent( wid, style, str, col - 1 );
    width = MyTextExtent( wid, style, str, col ) - x;

    /* adjust so that Insert cursor is 0 width
     * Also make the overstrike cursor the height of the insert cursor.
     */
    width = (long)width * cursorType.width / 100L;
    height = EditVars.InsertCursorType.height;
    y = FontHeight( WIN_TEXT_FONT( w ) ) - height;

    MyHideCaret( wid );
    DestroyCaret();
    // CreateCaret( wid, (HBITMAP)NULLHANDLE, width, cursorHeight );
    CreateCaret( wid, (HBITMAP)NULLHANDLE, width, height );
    SetCaretPos( x, y );
    MyShowCaret( wid );

} /* SetCursorOnLine */
예제 #3
0
/*
 * setCursorOnScreen - set cursor at specified row and column in edit window
 */
static void setCursorOnScreen( int row, int col )
{
    window      *w;
    int         x, y;
    int         width;
    int         funny;

    if( BAD_ID( current_window_id ) ) {
        return;
    }

    if( EditFlags.Quiet || EditFlags.NoSetCursor ) {
        return;
    }

    funny = getCursorInfo( current_window_id, row, col, &x, &width );
    w = WINDOW_FROM_ID( current_window_id );
    y = row * FontHeight( WIN_TEXT_FONT( w ) ) - cursorHeight;
    width = (long) width * cursorType.width / 100L;
    if( cursorWidth != width ) {
        MyHideCaret( current_window_id );
        DestroyCaret();
        CreateCaret( current_window_id, (HBITMAP)NULLHANDLE, width, cursorHeight );
        cursorWidth = width;
    }
    // adjust position for italic sillyness
    SetCaretPos( x - funny, y );
    MyShowCaret( current_window_id );

} /* setCursorOnScreen */
예제 #4
0
/*
 * InvokeColSelHook - invoke column hook with specified data
 */
vi_rc InvokeColSelHook( int sc, int ec )
{
    int         j, i;
    char        wordbuff[MAX_STR];
    char        data[MAX_STR + 32];
    int         lne;
#ifndef __WIN__
    int         x1;
    int         has_bord;
#endif

#ifdef __WIN__
    if( LastEvent != VI_KEY( FAKEMOUSE ) ) {
        lne = (CurrentPos.line - LeftTopPos.line) * FontHeight( WIN_TEXT_FONT( &EditWindow ) );
    } else {
        lne = MouseY;
    }
#else
    has_bord = WindowAuxInfo( current_window_id, WIND_INFO_HAS_BORDER );
    x1 = WindowAuxInfo( current_window_id, WIND_INFO_X1 );
    if( LastEvent != VI_KEY( MOUSEEVENT ) ) {
        lne = WindowAuxInfo( current_window_id, WIND_INFO_Y1 ) + CurrentPos.line - LeftTopPos.line;
        if( has_bord ) {
            ++lne;
        }
    } else {
        lne = MouseRow;
    }
#endif

    j = 0;
    if( ec - sc >= MAX_STR ) {
        ec = sc + MAX_STR - 2;
    }
    for( i = sc - 1; i <= ec - 1; i++ ) {
        wordbuff[j++] = CurrentLine->data[i];
    }
    wordbuff[j] = '\0';
#ifdef __WIN__
    sc = MyTextExtent( current_window_id, WIN_TEXT_STYLE( &EditWindow ),
        &CurrentLine->data[0], sc );
    ec = MyTextExtent( current_window_id, WIN_TEXT_STYLE( &EditWindow ),
        &CurrentLine->data[0], ec );
#else
    sc = x1 + VirtualColumnOnCurrentLine( sc ) - LeftTopPos.column;
    ec = x1 + VirtualColumnOnCurrentLine( ec ) - LeftTopPos.column;
    if( !has_bord ) {
        sc--;
        ec--;
    }
#endif
    MySprintf( data, "\"%s\" %d %d %d %d", wordbuff, lne, sc, ec, ec - sc + 1 );
    return( SourceHookData( SRC_HOOK_MOUSE_CHARSEL, data ) );

} /* InvokeColSelHook */
예제 #5
0
static void msgString( int line_no, const char *str )
{
    int     height;
    RECT    rect;
    HDC     hdc;

    if( !AllowDisplay || BAD_ID( message_window_id ) ) {
        return;
    }
    GetClientRect( message_window_id, &rect );
    height = FontHeight( WIN_TEXT_FONT( &MessageBar ) );
    rect.top += (line_no - 1) * height;
    rect.bottom = rect.top + height;
    hdc = TextGetDC( message_window_id, WIN_TEXT_STYLE( &MessageBar ) );
    FillRect( hdc, &rect, ColorBrush( WIN_TEXT_BACKCOLOR( &MessageBar ) ) );
    TextReleaseDC( message_window_id, hdc );
    WriteString( message_window_id, 0, rect.top, WIN_TEXT_STYLE( &MessageBar ), str );
}
예제 #6
0
/*
 * drawRepeatString - draw the current repeat string
 */
static void drawRepeatString( void )
{
    int     height;
    RECT    rect;
    HDC     hdc;

    if( !AllowDisplay || BAD_ID( repeat_window_id ) ) {
        return;
    }
    GetClientRect( repeat_window_id, &rect );
    height = FontHeight( WIN_TEXT_FONT( &RepeatCountWindow ) );
    rect.bottom = rect.top + height;
    hdc = TextGetDC( repeat_window_id, WIN_TEXT_STYLE( &RepeatCountWindow ) );
    FillRect( hdc, &rect, ColorBrush( WIN_TEXT_BACKCOLOR( &RepeatCountWindow ) ) );
    TextReleaseDC( repeat_window_id, hdc );
    WriteString( repeat_window_id, 0, rect.top, WIN_TEXT_STYLE( &RepeatCountWindow ), repString );

} /* drawRepeatString */
예제 #7
0
/*
 * InvokeLineSelHook - invoke the mouse selection
 */
vi_rc InvokeLineSelHook( linenum s, linenum e )
{
    char        tmp[32];
    int         lne, col;
#ifndef __WIN__
    int         has_bord;
#endif

#ifdef __WIN__
    if( LastEvent != VI_KEY( FAKEMOUSE ) ) {
        /* assume we're not in insert mode *ouch* */
        col = PixelFromColumnOnCurrentLine( CurrentPos.column );
        lne = (CurrentPos.line - LeftTopPos.line) * FontHeight( WIN_TEXT_FONT( &EditWindow ) );
    } else {
        col = MouseX;
        lne = MouseY;
    }
#else
    if( LastEvent != VI_KEY( MOUSEEVENT ) ) {
        has_bord = WindowAuxInfo( current_window_id, WIND_INFO_HAS_BORDER );
        lne = WindowAuxInfo( current_window_id, WIND_INFO_Y1 ) + CurrentPos.line - LeftTopPos.line;
        col = WindowAuxInfo( current_window_id, WIND_INFO_X1 ) + VirtualColumnOnCurrentLine( CurrentPos.column ) - LeftTopPos.column - 1;
        if( has_bord ) {
            ++lne;
            ++col;
        }
        if( col < 0 ) {
            col = 0;
        }
    } else {
        col = MouseCol;
        lne = MouseRow;
    }
#endif
    MySprintf( tmp, "%d %d %l %l", lne, col, s, e );
    return( SourceHookData( SRC_HOOK_MOUSE_LINESEL, tmp ) );

} /* InvokeLineSelHook */
예제 #8
0
void DefaultWindows( RECT *world, RECT *workspace )
{
    RECT        *r, *last, tmp;
    window      *w;
    int         border;
    int         screeny;
    int         diff;
#ifdef __NT__
    int         statusHeight = GetStatusHeight();
#endif

    border = GetSystemMetrics( SM_CYBORDER );
    screeny = GetSystemMetrics( SM_CYSCREEN );

    if( EditFlags.StatusInfo ) {
        /* first we do the status bar */
        w = &StatusBar;
        r = &w->def_area;
        *r = *world;

        /*
         * the lovely '4' here comes from the face that we have a border of
         * two pixels and two pixels for drawing the box and I didn't feel
         * like adding yet another define.
         * This whole function reeks a little anyway :)
         */
#ifdef __NT__
        if( statusHeight != 0 ) {
            r->top = r->bottom - statusHeight;
        } else {
#endif
            r->top = r->bottom - (FontHeight( WIN_TEXT_FONT( w ) ) + 2 * border + 7);
#ifdef __NT__
        }
#endif
        last = r;
    } else {
        tmp = *world;
        tmp.top = tmp.bottom;
        last = &tmp;
    }

    /* next the message bar */
    w = &MessageBar;
    r = &w->def_area;
    // let these windows share a common border, except when Win32 common controls
    // are used
    *r = *last;
    r->bottom = last->top;
#ifdef __NT__
    if( statusHeight == 0 ) {
#endif
        r->bottom += border;
#ifdef __NT__
    }
#endif
    r->top = r->bottom - FontHeight( WIN_TEXT_FONT( w ) ) - 4 * border;
    last = r;

    /* the command window */
    #define BORDER  25
    w = &CommandWindow;
    r = &w->def_area;
    // put it right over top of the message bar
    *r = *world;
    r->bottom -= BORDER;
    r->left += BORDER;
    r->right -= BORDER;
    r->top = r->bottom - FontHeight( WIN_TEXT_FONT( w ) ) - 4 * border;

    /* the repeat count window */
    #undef BORDER
    #define BORDER  20
    w = &RepeatCountWindow;
    r = &w->def_area;
    // put it right over top of the message bar
    *r = *world;
    r->bottom -= BORDER;
    r->left += BORDER;
    r->right -= BORDER;
    r->top = r->bottom - FontHeight( WIN_TEXT_FONT( w ) ) - 4 * border;

    /* the file completion window */
    w = &FileCompleteWindow;
    r = &w->def_area;
    #undef BORDER
    #define BORDER  50
    *r = *world;
    r->bottom -= BORDER;
    r->left += BORDER;
    r->right -= BORDER;
    r->top += BORDER;
    if( (r->bottom - r->top) > screeny / 3 ) {
        diff = r->bottom - r->top - screeny / 3;
        r->top += diff;
    }

    *workspace = *world;
    workspace->bottom = last->top;
    NewToolBar( workspace );
}
예제 #9
0
int WindowAuxInfo( window_id wid, int type )
{
    window      *w;
    int         value, height;
    RECT        area;

    if( BAD_ID( wid ) || !IsWindow( wid ) ) {
        return( 0 );
    }
    w = WINDOW_FROM_ID( wid );
    GetClientRect( wid, &area );
    switch( type ) {
    case WIND_INFO_X1:
        value = area.left;
        break;
    case WIND_INFO_Y1:
        value = area.top;
        break;
    case WIND_INFO_X2:
        value = area.right;
        break;
    case WIND_INFO_Y2:
        value = area.bottom;
        break;
    case WIND_INFO_TEXT_LINES:
        height = FontHeight( WIN_TEXT_FONT( w ) );
        // the 4/5 is a rather arbitrary constant chosen so that we don't show
        // less than 20% of a line
        // value = area.bottom - area.top + (height / 5);
        value = area.bottom - area.top; // + height - 1;
        value /= height;
        break;
    case WIND_INFO_TEXT_COLS:
        value = area.right - area.left;
        value /= FontAverageWidth( WIN_TEXT_FONT( w ) );
        break;
    case WIND_INFO_HEIGHT:
        value = area.bottom - area.top;
        break;
    case WIND_INFO_WIDTH:
        value = area.right - area.left;
        break;
    case WIND_INFO_TEXT_COLOR:
        value = WIN_TEXT_COLOR( w );
        break;
    case WIND_INFO_BACKGROUND_COLOR:
        value = WIN_TEXT_BACKCOLOR( w );
        break;
    case WIND_INFO_HAS_SCROLL_GADGETS:
    case WIND_INFO_HAS_BORDER:
        value = false;
        break;
    case WIND_INFO_TEXT_FONT:
        value = WIN_TEXT_FONT( w );
        break;
    case WIND_INFO_BORDER_COLOR1:
    case WIND_INFO_BORDER_COLOR2:
        value = -1;
        break;
    default:
        value = 0;
        break;
    }
    return( value );
}