示例#1
0
/*
 * SetCursorOnLine - set cursor at specified column in single line text string
 */
void SetCursorOnLine( window_id id, int col, char *str, type_style *style )
{
    window      *w;
    int         x, y;
    int         width, height;

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

    x = MyTextExtent( id, style, str, col - 1 );
    width = MyTextExtent( id, 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_FONT( w ) ) - height;

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

} /* SetCursorOnLine */
示例#2
0
/*
 * NewCursor - create a new cursor for a window
 */
void NewCursor( window_id id, cursor_type ct )
{
    window      *w;
    int         height;
    int         width;

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

} /* NewCursor */
示例#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( CurrentWindow ) ) {
        return;
    }

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

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

} /* setCursorOnScreen */
示例#4
0
void MyRaiseCaret( window_id id )
{
    if( caretKilled ) {
        ShowCaret( id );
        caretKilled = FALSE;
        MyShowCaret( id );
    }
}
示例#5
0
void MyRaiseCaret( window_id wid )
{
    if( caretKilled ) {
        ShowCaret( wid );
        caretKilled = false;
        MyShowCaret( wid );
    }
}
示例#6
0
static void displayLine( input_buffer *input )
{
    char            display[MAX_STR];
    char            *buffer, *dest;
    int             length;
    int             cursor_pos;

    if( EditFlags.NoInputWindow ) {
        return;
    }
    assert( strlen( input->prompt ) < MAX_STR );
    strcpy( display, input->prompt );
    length = strlen( display );
    dest = &display[length];
    buffer = input->buffer + input->left_column;
    while( *buffer != '\0' && length < input->window.width ) {
        *dest++ = *buffer++;
        length += 1;
    }
    *dest = '\0';
    cursor_pos = input->curr_pos - input->left_column + 1;
    cursor_pos += strlen( input->prompt );
#ifdef __WIN__
    {
        RECT        rect;
        char        *ptr, *c;
        int         len, x;
        window_id   wid;

        wid = input->window.id;
        MyHideCaret( wid );
        GetClientRect( wid, &rect );
        // BlankRectIndirect( input->window.id, input->window.style.background, &rect );
        c = input->cache;
        for( len = 0, ptr = input->buffer; *ptr; ptr++, len++ ) {
            if( *c != *ptr ) {
                break;
            }
            c++;
        }
        x = MyTextExtent( wid, &input->window.style, input->cache, len );
        WriteString( wid, x, 0, &input->window.style, display + len );
        rect.left = MyTextExtent( wid, &input->window.style, display, strlen( display ) );
        BlankRectIndirect( wid, input->window.style.background, &rect );
        MyShowCaret( wid );
        SetCursorOnLine( input->window.id, cursor_pos, display, &input->window.style );
    }
#else
    DisplayLineInWindowWithColor( input->window.id, input->window.line,
        display, &input->window.style, 0 );
    SetGenericWindowCursor( input->window.id, input->window.line, cursor_pos );
#endif

} /* displayLine */
示例#7
0
vi_rc DCUpdate( void )
{
    vi_rc           rc;
    int             i, nlines;
    fcb             *fcb;
    line            *line;
    dc              dc;
    bool            firstLine, firstTilde;
    linenum         line_no;
    int             displayOffset;
    char            *displayText;
#ifdef __WIN__
    HDC             hdc_wnd;
#ifdef BITBLT_BUFFER_DISPLAY
    HDC             hdc_mem;
    HBITMAP         hbitmap;
    type_style      *ws;
#endif
#else
    bool            hasMouse;
    unsigned int    hdc_wnd = 0;
#endif

    if( EditFlags.Quiet || CurrentInfo == NULL ) {
        return( ERR_NO_ERR );
    }

#ifdef __WIN__
    MyHideCaret( CurrentWindow );
    hdc_wnd = GetDC( CurrentWindow );
#ifdef BITBLT_BUFFER_DISPLAY
    hdc_mem = CreateCompatibleDC( hdc_wnd );
    ws = &(SEType[SE_WHITESPACE]);
    hbitmap = CreateCompatibleBitmap( hdc_wnd,
                    WindowAuxInfo( CurrentWindow, WIND_INFO_WIDTH ),
                    FontHeight( ws->font ) );
    SelectObject( hdc_mem, hbitmap );
    SelectObject( hdc_mem, ColorBrush( ws->background ) );
#endif
#else
    hasMouse = DisplayMouse( false );
#endif

    rc = CGimmeLinePtr( LeftTopPos.line, &fcb, &line );
    if( rc != ERR_NO_ERR ) {
        return( rc );
    }

    nlines = CurrentInfo->dc_size;
    dc = CurrentInfo->dc;
    firstLine = true;
    firstTilde = true;
    for( i = 0, line_no = LeftTopPos.line; i < nlines; i++, line_no++ ) {
        if( dc->display ) {
            if( line ) {
                if( firstLine ) {
                    if( dc->valid ) {
                         // major speedup
                         SSInitLanguageFlagsGivenValues( &(dc->flags) );
                    } else {
                        SSInitLanguageFlags( line_no );
                    }
                    firstLine = false;
                }

                displayText = line->data;
                if( line->u.ld.nolinedata ) {
                    if( WorkLine->len >= 0 ) {
                        displayText = WorkLine->data;
                    } else {
                        displayText = "*** ERR NULL DATA ***";
                    }
                }
                displayOffset = VirtualLineLen( displayText );
                if( displayOffset > LeftTopPos.column ) {
                    displayOffset = LeftTopPos.column;
                }
            } else {
                if( EditFlags.DrawTildes ) {
                    displayText = "~";
                } else {
                    displayText = "";
                    if( firstTilde ) {
                        displayText = EditVars.FileEndString;
                        firstTilde = false;
                    }
                }
                displayOffset = 0;
            }
#ifdef BITBLT_BUFFER_DISPLAY
            DisplayLineInWindowWithSyntaxStyle( CurrentWindow, i + 1,
                                line, line_no, displayText, displayOffset,
                                hdc_wnd,
                                hdc_mem );
#else
            DisplayLineInWindowWithSyntaxStyle( CurrentWindow, i + 1,
                                line, line_no, displayText, displayOffset,
                                hdc_wnd );
#endif
            dc->display = false;
        } else {
            // just in case displaying 2+ blocks in one update
            firstLine = true;
        }
        if( line ) {
            rc = CGimmeNextLinePtr( &fcb, &line );
        }
        if( rc != ERR_NO_ERR && rc != ERR_NO_MORE_LINES ) {
            return( rc );
        }
        dc++;
    }
#ifdef __WIN__
#ifdef BITBLT_BUFFER_DISPLAY
    DeleteDC( hdc_mem );
    DeleteObject( hbitmap );
#endif
    ReleaseDC( CurrentWindow, hdc_wnd );
    MyShowCaret( CurrentWindow );
#else
    DisplayMouse( hasMouse );
#endif
    return( ERR_NO_ERR );
}