Пример #1
0
/*
 * DDECallback - callback routine for DDE
 */
WINEXPORT HDDEDATA CALLBACK DDECallback( UINT type, UINT fmt, HCONV hconv,
                             HSZ topicstrh, HSZ itemstrh, HDDEDATA hmem, DWORD data1,
                             DWORD data2 )
{
    char        tmp[64];
    vi_rc       rc;

    fmt = fmt;
    data1 = data1;
    data2 = data2;

    switch( type ) {
    case XTYP_CONNECT:
    case XTYP_CONNECT_CONFIRM:
    case XTYP_DISCONNECT:
    case XTYP_REQUEST:
    case XTYP_POKE:
        MySprintf( tmp, "%u %U %U %U %U", type, (DWORD) hconv,
                   (DWORD) topicstrh, (DWORD) itemstrh, (DWORD) hmem );
        DDERet = 0;
        rc = SourceHookData( SRC_HOOK_DDE, tmp );
        if( rc != ERR_NO_ERR ) {
            DDERet = (DWORD)DdeCreateDataHandle( (DWORD)DDEInstId, (LPBYTE)"err",
                                                 (DWORD)4, (DWORD)0, (HSZ)itemstrh,
                                                 (UINT)fmt, (UINT)0 );
        } else {
            DDERet = (DWORD)DdeCreateDataHandle( DDEInstId, (LPBYTE)"ok", 3, 0,
                                                 itemstrh, fmt, 0 );
        }
        return( (HDDEDATA) DDERet );
    }
    return( (HDDEDATA) NULL );

} /* DDECallback */
Пример #2
0
/*
 * InvokeMenuHook - invoke the menu hook
 */
vi_rc InvokeMenuHook( int menunum, int line )
{
    char        tmp[16];
    vi_rc       rc;

    MySprintf( tmp, "%d %d", menunum, line );
    rc = SourceHookData( SRC_HOOK_MENU, tmp );
    return( rc );

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

#ifndef __WIN__
    has_bord = WindowAuxInfo( CurrentWindow, WIND_INFO_HAS_BORDER );
    x1 = WindowAuxInfo( CurrentWindow, WIND_INFO_X1 );
    if( LastEvent != VI_KEY( MOUSEEVENT ) ) {
        lne = WindowAuxInfo( CurrentWindow, WIND_INFO_Y1 ) + CurrentPos.line - LeftTopPos.line;
        if( has_bord ) {
            ++lne;
        }
    } else {
        lne = MouseRow;
    }
#else
    if( LastEvent != VI_KEY( FAKEMOUSE ) ) {
        lne = (CurrentPos.line - LeftTopPos.line) * FontHeight( WIN_FONT( &EditWindow ) );
    } else {
        lne = MouseY;
    }
#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;
#ifndef __WIN__
    sc = x1 + VirtualColumnOnCurrentLine( sc ) - LeftTopPos.column;
    ec = x1 + VirtualColumnOnCurrentLine( ec ) - LeftTopPos.column;
    if( !has_bord ) {
        sc--;
        ec--;
    }
#else
    sc = MyTextExtent( CurrentWindow, WIN_STYLE( &EditWindow ),
        &CurrentLine->data[0], sc );
    ec = MyTextExtent( CurrentWindow, WIN_STYLE( &EditWindow ),
        &CurrentLine->data[0], ec );
#endif
    MySprintf( data, "\"%s\" %d %d %d %d", wordbuff, lne, sc, ec, ec - sc + 1 );
    return( SourceHookData( SRC_HOOK_MOUSE_CHARSEL, data ) );

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

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

} /* InvokeLineSelHook */