Beispiel #1
0
void GetMkBlock( ss_block *ss_new, char *start, int line )
{
    line = line;

    if( start[0] == '\0' ) {
        if( firstNonWS == start ) {
            // line is empty -
            // do not flag following line as having anything to do
            // with an unterminated macro
            flags.inMacro = false;
        }
        getBeyondText( ss_new );
        return;
    }

    // Preprocessor directives must start at beginning of line
    if( (start[0] == '!') && (firstChar == start) ) {
        getPreproc( ss_new, start );
        return;
    }

    if( flags.inMacro ) {
        getMacro( ss_new, start, 0 );
        return;
    }

    if( isspace( start[0] ) ) {
        getWhiteSpace( ss_new, start );
        return;
    }

    switch( start[0] ) {
    case '$':
        getMacro( ss_new, start, 1 );
        return;
    case '#':
        getComment( ss_new, start );
        return;
    case '.':
        getDirective( ss_new, start );
        return;
    }

    if( isalpha( start[0] ) ) {
        getText( ss_new, start );
    } else {
        getSymbol( ss_new );
    }
}
Beispiel #2
0
std::map<QString, Macro*> MacroManager::getAllMacros(int mkey, int gkey)
{
	std::map<QString, Macro*> macros;
	QString curId = *getCurActiveId();
	std::map<QString, std::map<int, Macro> >::iterator outerit;
	//For each program
	for(outerit = programs.begin(); outerit != programs.end(); outerit++)
	{
		setCurActiveId((QString*)&outerit->first);
		macros.insert(std::pair<QString, Macro*>(outerit->first, getMacro(mkey, gkey)));
	}
	setCurActiveId(&curId);
	return macros;
}
Beispiel #3
0
int caInclude::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = getMacro(); break;
        case 1: *reinterpret_cast< QString*>(_v) = getFileName(); break;
        case 2: *reinterpret_cast< Visibility*>(_v) = getVisibility(); break;
        case 3: *reinterpret_cast< QString*>(_v) = getVisibilityCalc(); break;
        case 4: *reinterpret_cast< QString*>(_v) = getChannelA(); break;
        case 5: *reinterpret_cast< QString*>(_v) = getChannelB(); break;
        case 6: *reinterpret_cast< QString*>(_v) = getChannelC(); break;
        case 7: *reinterpret_cast< QString*>(_v) = getChannelD(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setMacro(*reinterpret_cast< QString*>(_v)); break;
        case 1: setFileName(*reinterpret_cast< QString*>(_v)); break;
        case 2: setVisibility(*reinterpret_cast< Visibility*>(_v)); break;
        case 3: setVisibilityCalc(*reinterpret_cast< QString*>(_v)); break;
        case 4: setChannelA(*reinterpret_cast< QString*>(_v)); break;
        case 5: setChannelB(*reinterpret_cast< QString*>(_v)); break;
        case 6: setChannelC(*reinterpret_cast< QString*>(_v)); break;
        case 7: setChannelD(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Beispiel #4
0
meMacro *
userGetMacro(meUByte *buf, int len)
{
    register int idx ;
    
    if(meGetString((meUByte *)"Enter macro name ", MLCOMMAND,2,buf,len) > 0)
    {        
        if((idx = decode_fncname(buf,0)) < 0)
            mlwrite(MWABORT,(meUByte *)"%s not defined",buf) ;
        else if(idx < CK_MAX)
            mlwrite(MWABORT,(meUByte *)"%s is a command",buf) ;
        else
            return getMacro(idx) ;
    }
    return NULL ;
}
Beispiel #5
0
static int
findHelpItem(meUByte *item, int silent)
{
    meWindow *wp ;
    meBuffer *bp, *hbp ;
    meLine   *lp, *elp ;
    int     sectLen, itemLen, ii ;
    meUByte  *ss, cc, sect[5] ;
    
    itemLen = meStrlen(item) ;
    if((item[itemLen-1] == ')') &&
       ((item[(ii=itemLen-3)] == '(') ||
        (item[(ii=itemLen-4)] == '(') ))
    {
        sectLen = itemLen-ii-2 ;
        meStrcpy(sect,item+ii) ;
        itemLen = ii ;
        item[itemLen] = '\0' ;
    }
    else
    {
        sectLen = 0 ;
        sect[0] = '\0' ;
        sect[1] = '\0' ;
    }
	
    if((hbp=helpBufferFind()) == NULL)
        return meABORT ;
    elp = hbp->baseLine ;
try_again:
    lp = meLineGetNext(elp) ;
    while(lp != elp)
    {
        if((lp->text[0] == '!') &&
           (!sectLen || 
            ((sect[1] == lp->text[2]) &&
             (((sectLen == 1) && (lp->text[3] == ' ')) || 
              (sect[2] == lp->text[3])))))
        {
            if((cc=lp->text[1]) == ' ')
            {
                ii = meLineGetLength(lp) - 4 ;
                if(ii != itemLen)
                    ii = -1 ;
            }
            else
            {
                ii = cc - '0' ;
                if(ii > itemLen)
                    ii = -1 ;
            }
            if((ii > 0) && !meStrncmp(item,lp->text+4,ii))
                break ;
        }
        lp = meLineGetNext(lp) ;
    }
        
    if(lp == elp)
    {
        meMacro *mac ;
        if(!meModeTest(hbp->mode,MDLOCK))
        {
            if(helpBufferLoad(hbp) == meABORT)
                return meABORT ;
            goto try_again ;
        }
        if((getMacroTypeS(item) == TKCMD) &&
           ((ii = decode_fncname(item,1)) >= CK_MAX) &&
           ((mac = getMacro(ii)) != NULL) &&
           (mac->hlp->flag & meMACRO_FILE))
        {
            meModeClear(hbp->mode,MDVIEW) ;
            if(mac->fname != NULL)
                execFile(mac->fname,0,1) ;
            else
                execFile(mac->name,0,1) ;
            helpBufferReset(hbp) ;
            if(!(mac->hlp->flag & meMACRO_FILE))
                goto try_again ;
        }
        if(!silent)
            mlwrite(MWABORT,(meUByte *)"[Can't find help on %s%s]",item,sect);
        return meABORT ;
    }
    if((wp = meWindowPopup(BhelpN,BFND_CREAT|BFND_CLEAR|WPOP_USESTR,NULL)) == NULL)
        return false ;
    if((sectLen == 0) && (lp->text[2] != ' '))
    {
        ss = sect ;
        *ss++ = '(' ;
        *ss++ = lp->text[2] ;
        if(lp->text[3] != ' ')
            *ss++ = lp->text[3] ;
        *ss++ = ')' ;
        *ss = '\0' ;
    }
    
    bp = wp->buffer ;
    /* Add the header */
    {
        meUByte buff[meBUF_SIZE_MAX] ;
        sprintf((char *)buff,"\033cD%s%s\033cA",lp->text+4,sect) ;
        addLineToEob(bp,buff) ;
        addLineToEob(bp,(meUByte *)"\n\033lsMicroEmacs\033lm[Home]\033le \033lsCommand G\033lm[Commands]\033le \033lsVariable \033lm[Variables]\033le \033lsMacro Lan\033lm[Macro-Dev]\033le \033lsGlobal G\033lm[Glossary]\033le") ;
        memset(buff,boxChars[BCEW],78) ;
        buff[78] = '\n' ;
        buff[79] = '\0' ;
        addLineToEob(bp,buff) ;
    }
    while(((lp=meLineGetNext(lp)) != elp) && (lp->text[0] == '!'))
        ;
    while((lp != elp) && ((cc=lp->text[0]) != '!'))
    {
        if(cc == '|')
        {
            if(meStrcmp(item,lp->text+1))
                lp = meLineGetNext(lp) ;
        }
        else if(cc == '$')
        {
            if(lp->text[1] == 'a')
            {
                if(sect[1] == '5')
                {
                    meUByte line[meBUF_SIZE_MAX], *ss ;
                    if((ss = getval(item)) != NULL)
                    {
                        addLineToEob(bp,(meUByte *)"\n\n\033cEVALUE\033cA\n") ;
                        meStrcpy(line,"    \"") ;
                        meStrncpy(line+5,ss,meBUF_SIZE_MAX-13) ;
                        line[meBUF_SIZE_MAX-2] = '\0' ;
                        meStrcat(line,"\"") ;
                        addLineToEob(bp,line) ;
                    }
                }
                if(sect[1] == '2')
                {
                    if((ii = decode_fncname(item,1)) >= 0)
                    {
                        meBind *ktp ;
                        meUByte line[meBUF_SIZE_MAX], *ss ;
                        addLineToEob(bp,(meUByte *)"\n\n\033cEBINDINGS\033cA\n") ;
                        meStrcpy(line,"    ") ;
                        ss = line+4 ;
                        for(ktp = &keytab[0] ; ktp->code != ME_INVALID_KEY ; ktp++)
                        {
                            if(ktp->index == ii)
                            {
                                *ss++ = '"' ;
                                meGetStringFromKey(ktp->code,ss);
                                ss += meStrlen(ss) ;
                                *ss++ = '"' ;
                                *ss++ = ' ' ;
                            }
                        }
                        if(ss == line+4)
                            meStrcpy(ss,"none") ;
                        else
                            *ss = '\0' ;
                        addLineToEob(bp,line) ;
                    }
                }
            }
        }
        else
            addLineToEob(bp,lp->text) ;
        lp = meLineGetNext(lp) ;
    }
    /* Add the footer */
    {
        meUByte buff[meBUF_SIZE_MAX] ;
        buff[0] = '\n' ;
        memset(buff+1,boxChars[BCEW],78) ;
        sprintf((char *)buff+79,"\n\033lsCopyright\033lm%s\033le",meCopyright) ;
        addLineToEob(bp,buff) ;
    }
    bp->dotLine = meLineGetNext(bp->baseLine);
    bp->dotOffset = 0 ;
    bp->dotLineNo = 0 ;
    meModeClear(bp->mode,MDEDIT) ;    /* don't flag this as a change */
    meModeSet(bp->mode,MDVIEW) ;      /* put this buffer view mode */
    resetBufferWindows(bp) ;            /* Update the window */
    mlerase(MWCLEXEC);	                /* clear the mode line */
    return true ;
}
Beispiel #6
0
static meMacro *
createMacro(meUByte *name)
{
    meUByte buff[meBUF_SIZE_MAX] ;
    register meMacro *mac ;
    register meLine *hlp ;
    register int idx ;
    
    /* If the macro name has not been give then try and get one */
    if((name == NULL) && 
       (meGetString((meUByte *)"Macro name",MLCOMMAND|MLEXECNOUSER, 0, buff, meBUF_SIZE_MAX) > 0) && (buff[0] != '\0'))
        name = buff ;
    
    if((name == NULL) || ((hlp = meLineMalloc(0,0)) == NULL))
        return NULL ;
    
    /* if it already exists */
    if((idx = decode_fncname(name,1)) >= 0)
    {
        /* if function return error, else clear the buffer */ 
        if(idx < CK_MAX)
        {
            mlwrite(MWABORT|MWPAUSE,(meUByte *)"Error! can't re-define a base function") ;
            meFree(hlp) ;
            return NULL ;
        }
        mac = getMacro(idx) ;
        if(!(mac->hlp->flag & meMACRO_EXEC))
        {
#if MEOPT_EXTENDED
            if(mac->hlp->flag & meMACRO_FILE)
            {
                if(meNullFree(mac->fname))
                    mac->fname = NULL ;
            }
#endif
            meLineLoopFree(mac->hlp,1) ;
        }
    }
    else
    {
        meCommand **cmd ;
        if((cmdTableSize & 0x1f) == 0)
        {
            /* run out of room in the command table, malloc more */
            meCommand **nt ;
            if((nt = (meCommand **) meMalloc((cmdTableSize+0x20)*sizeof(meCommand *))) == NULL)
                return NULL ;
            memcpy(nt,cmdTable,cmdTableSize*sizeof(meCommand *)) ;
            if(cmdTable != __cmdTable)
                free(cmdTable) ;
            cmdTable = nt ;
        }
        if(((mac = (meMacro *) meMalloc(sizeof(meMacro))) == NULL) ||
           ((mac->name = meStrdup(name)) == NULL))
        {
            meFree(hlp) ;
            return NULL ;
        }
        mac->id = cmdTableSize ;
#if MEOPT_EXTENDED
        mac->varList.head = NULL ;
        mac->varList.count = 0 ;
        mac->fname = NULL ;
        mac->callback = -1 ;
#endif
        cmdTable[cmdTableSize++] = (meCommand *) mac ;
        /* insert macro into the alphabetic list */
        cmd = &(cmdHead) ;
        while((*cmd != NULL) && (meStrcmp((*cmd)->name,name) < 0))
            cmd = &((*cmd)->anext) ;
        mac->anext = *cmd ;
        *cmd = (meCommand *) mac ;
#if MEOPT_CMDHASH
        /* insert macro into the hash table */
        {
            meUInt key ;
            
            mac->hnext = NULL ;
            key = cmdHashFunc(name) ;
            cmd = &(cmdHash[key]) ;
            while(*cmd != NULL)
                cmd = &((*cmd)->hnext) ;
            *cmd = (meCommand *) mac ;
        }
#endif
    }
    mac->hlp = hlp ;
    hlp->next = hlp ;
    hlp->prev = hlp ;
    return mac ;
}