예제 #1
0
extern  void    WndSelPopPiece( a_window *wnd, bool paint_immed )
{
    wnd_row             row;
    wnd_coord           *start;
    wnd_coord           *end;
    int                 piece;
    int                 buff_size;
    char                *ptr;
    int                 first;
    int                 len;
    wnd_line_piece      line;

    _Clr( wnd, WSW_SELECTING );
    _Clr( wnd, WSW_SELECTING_WITH_KEYBOARD );
    WndSelEnds( wnd, &start, &end );
    if( _Isnt( wnd, WSW_SUBWORD_SELECT ) ||
        ( start->row == end->row &&
          start->piece == end->piece && start->col == end->col ) ) {
        WndGetLine( wnd, start->row, start->piece, &line );
        GoBackward( wnd, start, &line );
        WndGetLine( wnd, end->row, end->piece, &line );
        GoForward( wnd, end, &line );
        if( end->row != start->row ) {
            GUIWndDirtyRow( wnd->gui, end->row );
            GUIWndDirtyRow( wnd->gui, start->row );
        } else if( paint_immed ) {
            GUIWndDirtyRow( wnd->gui, start->row );
        } else {
            WndDirtyScreenRange( wnd, start, end->col );
        }
    }
    buff_size = 0;
    for( row = start->row; row <= end->row; ++row ) {
        for( piece = 0; ; ++piece ) {
            if( !WndGetLine( wnd, row, piece, &line ) ) break;
            if( WndSelected( wnd, &line, row, piece, &first, &len ) ) {
                buff_size += len + 1;
            }
        }
    }
    WndFree( wnd->popitem );
    wnd->popitem = WndMustAlloc( buff_size+2 );
    ptr = wnd->popitem;
    for( row = start->row; row <= end->row; ++row ) {
        for( piece = 0; ; ++piece ) {
            if( !WndGetLine( wnd, row, piece, &line ) ) break;
            if( WndSelected( wnd, &line, row, piece, &first, &len ) ) {
                if( ptr != wnd->popitem ) *ptr++ = ' ';
                memcpy( ptr, line.text+first, len );
                ptr += len;
            }
        }
    }
    *ptr = '\0';
}
예제 #2
0
static void WndDrawSelect( a_window *wnd, wnd_line_piece *line,
                           wnd_row row, int piece )
{
    int                 first;
    int                 len;
    gui_ord             indent;

    if( _Is( wnd, WSW_NOT_TO_SCREEN ) ) return;
    if( WndSelected( wnd, line, row, piece, &first, &len ) ){
        indent = line->indent;
        if( first != 0 ) {
            indent += GUIGetExtentX( wnd->gui, line->text, first );
        }
        GUIDrawText( wnd->gui, line->text+first, len, row, indent, WndSelectedAttr );
    }
}