Пример #1
0
/*
 * SetWindowCursorForReal - set cursor in current window, if cursorNeedsDisp
 */
void SetWindowCursorForReal( void )
{
    if( !cursorNeedsDisplay || EditFlags.DisplayHold ) {
        return;
    }
    if( CurrentFile == NULL ) {
        HideCursor();
        return;
    }
#ifndef __WIN__
    SetGenericWindowCursor( CurrentWindow, (int) (CurrentPos.line - LeftTopPos.line + 1),
                            VirtualColumnOnCurrentLine( CurrentPos.column ) - LeftTopPos.column );
#else
    // for windows assume tabs to be of lenght 1
    if( !EditFlags.RealTabs ){
        SetGenericWindowCursor( CurrentWindow, (int) (CurrentPos.line - LeftTopPos.line + 1),
                                VirtualColumnOnCurrentLine( CurrentPos.column ) - LeftTopPos.column );
    } else {

        SetGenericWindowCursor( CurrentWindow, (int) (CurrentPos.line - LeftTopPos.line + 1),
                                VirtualColumnOnCurrentLine( CurrentPos.column ) );
    }
#endif

    cursorNeedsDisplay = false;

} /* SetWindowCursorForReal */
Пример #2
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 */