示例#1
0
/*
 * srcHook - run a specified source hook
 */
static vi_rc srcHook( hooktype num, vi_rc lastrc )
{
    vars        *v;
    srcline     sline;
    vi_rc       rc;

    if( hookRun & num ) {
        return( lastrc );
    }

    /*
     * check script type
     */
    v = GetHookVar( num );
    /*
     * run script, if we have one
     */
    if( v != NULL ) {
        if( num == SRC_HOOK_COMMAND ) {
            VarAddGlobalStr( "Com", CommandBuffer );
        }
//        if( num == SRC_HOOK_MODIFIED ) {
//            lastrc = LastEvent;
//        }

        /*
         * set up for and run script
         */
        hookRun |= num;
        LastRetCode = lastrc;
        rc = Source( v->value, srcHookData, &sline );

        /*
         * if we had a command hook, look for replacement variable
         */
        if( num == SRC_HOOK_COMMAND ) {
            v = VarFind( "Com", NULL );
            if( v != NULL ) {
                strcpy( CommandBuffer, v->value );
            }
        }

        /*
         * we are done now, reset and go back
         */
        LastRetCode = ERR_NO_ERR;
        hookRun &= ~num;
        DCUpdateAll();
        return( rc );

    }
    return( lastrc );

} /* srcHook */
示例#2
0
/*
 * doHookAssign - do an assignment for a hook variable
 */
static void doHookAssign( FILE *fp, hooktype num )
{
    vars        *v;

    v = GetHookVar( num );
    if( v == NULL ) {
        return;
    }
    MyFprintf( fp, "assign %%(%s) = %s\n", v->name, v->value );
    MyFprintf( fp, "load %s\n", v->value );

} /* doHookAssign */