Exemplo n.º 1
0
Arquivo: frame.c Projeto: collects/me
/*
 * meFrameEnlargeVideo
 * Enlarge the video frames attached to the virtual video structures.
 * Usually follows an enlargement of the screen. */
int
meFrameEnlargeVideo(meFrame *frame, int rows)
{
    meVideo *vvptr;                      /* Pointer to the video blocks */
    meVideoLine  *vs;                         /* Video store line */

    for (vvptr = &frame->video; vvptr != NULL; vvptr = vvptr->next)
    {
        /* Try and allocate new video frame */
        if ((vs = (meVideoLine *) meMalloc (rows * sizeof (meVideoLine))) == NULL)
            return (false);

        /* Allocation successful. Reset the contents to zero and swap
           for the existing one */
        memset (vs, 0, rows * sizeof (meVideoLine));  /* Reset to zero */
        meFree (vvptr->lineArray);                    /* Dispose of old one */
        vvptr->lineArray = vs;                        /* Swap in new one */
    }

    return (true);
}
Exemplo n.º 2
0
Arquivo: macro.c Projeto: collects/me
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 ;
}
Exemplo n.º 3
0
int
meUndo(int f, int n)
{
    if(n < -1)
    {
#ifndef NDEBUG
        if(n == -4)
        {
            meUndoNode *nn ;
            FILE *undoFp=NULL ;
            if(undoFp == NULL)
                undoFp = fopen("undo.log","w+") ;
            fprintf(undoFp,"[Undo stack for %s]\n",frameCur->bufferCur->name) ;
            nn=frameCur->bufferCur->undoHead ;
            while(nn != NULL)
            {
                if(meUndoIsLineSort(nn))
                {
                    fprintf(undoFp,"Undo 0x%02x %p %ld %ld:",nn->type,nn->next,
                            nn->udata.lineSort[0],nn->count) ;
                    for(n=0 ; n<nn->count ; n++)
                        fprintf(undoFp," %ld",nn->udata.lineSort[n+1]) ;
                    fprintf(undoFp,"\n") ;
                }
#if MEOPT_NARROW
                else if(meUndoIsNarrow(nn))
                {
                    meUndoNarrow *nun = (meUndoNarrow *) nn ;
                    fprintf(undoFp,"Undo 0x%02x %p Nrrw %x %ld %ld %d [%s]\n",nun->type,nun->next,
                            nun->name,nun->count,nun->udata.dotp,nun->markupCmd,nun->str) ;
                }
#endif
                else
                {
                    fprintf(undoFp,"Undo 0x%02x %p %ld (%ld,%d) [%s]\n",nn->type,nn->next,nn->count,
                            nn->udata.dotp,nn->doto,nn->str) ;
                    if(meUndoIsReplace(nn))
                    {
                        for(n=0 ; n<nn->doto ; n++)
                            fprintf(undoFp,"(%d,%d) ",nn->udata.pos[n][0],nn->udata.pos[n][1]) ;
                        fprintf(undoFp,"\n") ;
                    }
                }
                nn = nn->next ;
            }
            fprintf(undoFp,"---------------\n") ;
            fflush(undoFp) ;
        }
        else
#endif
            undoContFlag++ ;
    }
    else if(!meModeTest(frameCur->bufferCur->mode,MDUNDO))
        return ctrlg(meFALSE,1) ;
    else if(n < 0)
        meUndoRemove(frameCur->bufferCur) ;
    else
    {
        static meUndoNode *cun ;
        static meInt  ccount ;
        static meUShort cdoto ;

        if((lastflag != meCFUNDO) && ((cun = frameCur->bufferCur->undoHead) != NULL))
        {
            cdoto = cun->doto ;
            ccount = cun->count ;
        }
        for(;;)
        {
            meInt count, cont ;
            if((cun == NULL) || ((n <= 0) && !meModeTest(frameCur->bufferCur->mode,MDEDIT)))
                break ;
            if(bufferSetEdit() <= 0)               /* Check we can change the buffer */
                return meABORT ;
            cont=0 ;
            if(cun->type & meUNDO_SPECIAL)
            {
                if(meUndoIsSetEdit(cun))
                {
                    if(!(cun->type & meUNDO_UNSET_EDIT))
                    {
                        autowriteremove(frameCur->bufferCur) ;
                        meModeClear(frameCur->bufferCur->mode,MDEDIT) ;
                        frameAddModeToWindows(WFMODE) ;  /* update ALL mode lines */
                    }
                }
                else if(meUndoIsLineSort(cun))
                {
                    meLine *ln, *eln, **list ;
                    meInt *lineSort, *undoInfo, dddd ;
                    lineSort = cun->udata.lineSort ;
                    windowGotoLine(meTRUE,(*lineSort++) + 1) ;
                    if((list = meMalloc(cun->count * sizeof(meLine *))) == NULL)
                        return meABORT ;
                    undoInfo = meUndoAddLineSort(cun->count) ;
                    eln = frameCur->windowCur->dotLine ;
                    ln = meLineGetPrev(eln) ;
                    for(count=0 ; count<cun->count ; eln=meLineGetNext(eln),count++)
                    {
                        list[*lineSort++] = eln ;
                        eln->prev = (meLine *) count ;
                    }
                    for(count=0 ; count<cun->count ; ln=meLineGetNext(ln),count++)
                    {
                        if(undoInfo != NULL)
                        {
                            dddd = (meInt) list[count]->prev ;
                            *undoInfo++ = dddd ;
                        }
                        ln->next = list[count] ;
                        list[count]->prev = ln ;
                    }
                    ln->next = eln ;
                    eln->prev = ln ;
                    frameCur->windowCur->dotLine = list[0] ;
                    meFree(list) ;
                }
#if MEOPT_NARROW
                else if(meUndoIsNarrow(cun))
                {
                    meUndoNarrow *nun = (meUndoNarrow *) cun ;
                    meInt name ;
                    name = nun->name ;
                    windowGotoLine(meTRUE,nun->udata.dotp+1) ;
                    if(nun->type & meUNDO_NARROW_ADD)
                    {
                        meNarrow *nrrw ;
                        nrrw = frameCur->bufferCur->narrow ;
                        while(nrrw->name != name)
                            nrrw = nrrw->next ;
                        frameCur->bufferCur->dotLine = frameCur->windowCur->dotLine ;
                        frameCur->bufferCur->dotLineNo = frameCur->windowCur->dotLineNo ;
                        frameCur->bufferCur->dotOffset = 0 ;
                        meBufferRemoveNarrow(frameCur->bufferCur,nrrw,
                                             (nun->markupCmd > 0) ? nun->str:NULL,1) ;
                    }
                    else
                    {
                        meLine *slp ;
                        slp = frameCur->windowCur->dotLine ;
                        windowGotoLine(meTRUE,ccount+1) ;
                        meBufferCreateNarrow(frameCur->bufferCur,slp,frameCur->windowCur->dotLine,
                                             nun->udata.dotp,ccount,name,nun->scheme,
                                             (nun->markupFlag) ? nun->str:NULL,nun->markupCmd,1) ;
                    }
                }
#endif
                if(cun->type & meUNDO_CONTINUE)
                    cont=1 ;
                goto meUndoNext ;
            }
            if(cun->type & meUNDO_REPLACE)
            {
                windowGotoLine(meTRUE,cun->udata.pos[cdoto-1][0]+1) ;
                count = cun->udata.pos[cdoto-1][1] ;
                if(count < 0)
                {
                    cont = 1 ;
                    count = -1 - count ;
                }
                frameCur->windowCur->dotOffset = (meUShort) count ;
            }
            else
            {
                if(cun->type & meUNDO_CONTINUE)
                    cont = 1 ;
                windowGotoLine(meTRUE,cun->udata.dotp+1) ;
                frameCur->windowCur->dotOffset = cdoto ;
            }
            if(cun->type & meUNDO_SINGLE)
            {
                ccount-- ;
                count = 1 ;
            }
            else
                count = ccount ;
            if(cun->type & meUNDO_INSERT)
            {
                meWindowBackwardChar(frameCur->windowCur,count) ;
                if((count == 1))
                    meUndoAddDelChar() ;
                else
                    meUndoAddDelChars(count) ;
                mldelete(count,NULL) ;
            }
            if(cun->type & meUNDO_DELETE)
            {
                /* When dealing with long lines this loop becomes infinitly
                 * long because of the number of times that the line is
                 * re-allocated - pre-allocate the line length first. In order
                 * to reduce the processing overhead then we find the longest
                 * strings and then add them back in in one go, this ensures
                 * that we only ever re-allocate the line once. 
                 * Jon - 99/12/12.
                 */
                meUByte *ss, cc ;
                ss = cun->str ;
                /* Deal with a single character undo */
                if(cun->type & meUNDO_SINGLE)
                {
                    ss += ccount ;
                    if((cc = *ss++) == meCHAR_NL)
                        lineInsertNewline(meBUFINSFLAG_UNDOCALL);
                    else if (cc != '\0')
                        lineInsertChar(1, cc);
                    meUndoAddInsChar() ;
                }
                else
                {
                    /* Deal with a multiple character undo. */
                    count = bufferInsertText(ss,meBUFINSFLAG_UNDOCALL) ;
                    if(count > 0)
                        meUndoAddInsChars(count) ;
                }
            }
            if((cun->type & meUNDO_SINGLE) && (ccount > 0))
            {
                if(cun->type & meUNDO_FORWARD)
                    cdoto++ ;
                else if(cun->type & meUNDO_INSERT)
                    cdoto-- ;
            }
            else if(cun->type & meUNDO_REPLACE)
            {
                cdoto-- ;
                if(!cdoto)
                    goto meUndoNext ;
            }
            else
            {
meUndoNext:
                if((cun = cun->next) != NULL)
                {
                    cdoto = cun->doto ;
                    ccount = cun->count ;
                }
            }
            if(!cont && (--n == 0))
                break ;
        }
        thisflag = meCFUNDO ;
    }
    return meTRUE ;
}
Exemplo n.º 4
0
void
meSetupPathsAndUser(char *progname)
{
    meUByte *ss, buff[meBUF_SIZE_MAX] ;
    int ii, ll, gotUserPath ;
    
    curdir = gwd(0) ;
    if(curdir == NULL)
        /* not yet initialised so mlwrite will exit */
        mlwrite(MWCURSOR|MWABORT|MWWAIT,(meUByte *)"Failed to get cwd\n") ;
    
    /* setup the $progname make it an absolute path. */
    if(executableLookup(progname,evalResult))
        meProgName = meStrdup(evalResult) ;
    else
    {
#ifdef _ME_FREE_ALL_MEMORY
        /* stops problems on exit */
        meProgName = meStrdup(progname) ;
#else
        meProgName = (meUByte *)progname ;
#endif
    }
    
#if MEOPT_BINFS
    /* Initialise the built-in file system. Note for speed we only check the
     * header. Scope the "exepath" locally so it is discarded once the
     * pathname is passed to the mount and we exit the braces. */
    bfsdev = bfs_mount (meProgName, BFS_CHECK_HEAD);
#endif
    
    if(meUserName == NULL)
    {
        if(((ss = meGetenv ("MENAME")) == NULL) || (ss[0] == '\0'))
            ss = "user" ;
        meUserName = meStrdup(ss) ;
    }
    
    /* get the users home directory, user path and search path */
    if(((ss = meGetenv("HOME")) == NULL) || (ss[0] == '\0'))
        ss = "c:/" ;
    fileNameSetHome(ss) ;

    if(((ss = meGetenv ("MEUSERPATH")) != NULL) && (ss[0] != '\0'))
        meUserPath = meStrdup(ss) ;
    
    if(((ss = meGetenv("MEPATH")) != NULL) && (ss[0] != '\0'))
    {
        /* explicit path set by the user, don't need to look at anything else */
        searchPath = meStrdup(ss) ;
        /* we just need to add the $user-path to the front */
        if(meUserPath != NULL)
        {
            /* check that the user path is first in the search path, if not add it */
            ll = meStrlen(meUserPath) ;
            if(meStrncmp(searchPath,meUserPath,ll) ||
               ((searchPath[ll] != '\0') && (searchPath[ll] != mePATH_CHAR)))
            {
                /* meMalloc will exit if it fails as ME has not finished initialising */
                ss = meMalloc(ll + meStrlen(searchPath) + 2) ;
                meStrcpy(ss,meUserPath) ;
                ss[ll] = mePATH_CHAR ;
                meStrcpy(ss+ll+1,searchPath) ;
                meFree(searchPath) ;
                searchPath = ss ;
            }
        }
    }
    else
    {
        /* construct the search-path */
        /* put the $user-path first */
        if((gotUserPath = (meUserPath != NULL)))
            meStrcpy(evalResult,meUserPath) ;
        else
            evalResult[0] = '\0' ;
        ll = meStrlen(evalResult) ;
        
        /* look for the ~/jasspa directory */
        if(homedir != NULL)
        {
            meStrcpy(buff,homedir) ;
            meStrcat(buff,"jasspa") ;
            if(((ll = mePathAddSearchPath(ll,evalResult,buff,&gotUserPath)) > 0) && !gotUserPath)
                /* as this is the user's area, use this directory unless we find
                 * a .../<$user-name>/ directory */
                gotUserPath = -1 ;
        }
        
        /* Get the system path of the installed macros. Use $MEINSTPATH as the
         * MicroEmacs standard macros */
        if(((ss = meGetenv ("MEINSTALLPATH")) != NULL) && (ss[0] != '\0'))
        {
            meStrcpy(buff,ss) ;
            ll = mePathAddSearchPath(ll,evalResult,buff,&gotUserPath) ;
        }
        
        /* also check for directories in the same location as the binary */
        if((meProgName != NULL) && ((ss=meStrrchr(meProgName,DIR_CHAR)) != NULL))
        {
            ii = (((size_t) ss) - ((size_t) meProgName)) ;
            meStrncpy(buff,meProgName,ii) ;
            buff[ii] = '\0' ;
            ll = mePathAddSearchPath(ll,evalResult,buff,&gotUserPath) ;
        }
        if(!gotUserPath && (homedir != NULL))
        {
            /* We have not found a user path so set ~/ as the user-path
             * as this is the best place for macros to write to etc. */
            meStrcpy(buff,homedir) ;
            if(ll)
            {
                ii = meStrlen(buff) ;
                buff[ii++] = mePATH_CHAR ;
                meStrcpy(buff+ii,evalResult) ;
            }
            searchPath = meStrdup(buff) ;
        }
        else if(ll > 0)
            searchPath = meStrdup(evalResult) ;
    }
    if(searchPath != NULL)
    {
        fileNameConvertDirChar(searchPath) ;
        if(meUserPath == NULL)
        {
            /* no user path yet, take the first path from the search-path, this
             * should be a sensible directory to use */
            if((ss = meStrchr(searchPath,mePATH_CHAR)) != NULL)
                *ss = '\0' ;
            meUserPath = meStrdup(searchPath) ;
            if(ss != NULL)
                *ss = mePATH_CHAR ;
        }
    }
    if(meUserPath != NULL)
    {
        fileNameConvertDirChar(meUserPath) ;
        ll = meStrlen(meUserPath) ;
        if(meUserPath[ll-1] != DIR_CHAR)
        {
            meUserPath = meRealloc(meUserPath,ll+2) ;
            meUserPath[ll++] = DIR_CHAR ;
            meUserPath[ll] = '\0' ;
        }
    }
}
Exemplo n.º 5
0
Arquivo: frame.c Projeto: collects/me
int
meFrameChangeWidth(meFrame *frame, int ww)
{
    /* ensure the value is in range */
    if(ww < 8)
        ww = 8 ;
    else if(ww > 400)
        ww = 400 ;

    /* Already this size ?? Nothing to do */
    if(frame->width == ww)
        return true;

    meFrameLoopBegin() ;

    /* only process frames which use the same screen window */
    meFrameLoopContinue(loopFrame->mainId != frame->mainId) ;

    /* Only process if the window size is different from the current
     * window size. If we got here that is true, */
    if(ww > loopFrame->widthMax)
    {
        /* Must extend the length of loopFrame->mlLine, loopFrame->mlLineStore, and all window
         * mode lines */
        meWindow *wp ;                /* Temporary window pointer */
        meFrameLine *flp;             /* Frame line pointer */
        meFrameLine fl;               /* Temporary frame line */
        int ii, jj;                   /* Local loop counters */
        meLine *ml ;
        meUByte *mls ;

        if(((ml = meLineMalloc(ww,0)) == NULL) ||
                ((mls = meMalloc(ww+1)) == NULL))
            return false ;

        /* Fix up the frame store by growing the lines. Do a safe
         * grow where by we can recover if a malloc fails. */
        for (flp = loopFrame->store, ii = 0; ii < loopFrame->depthMax; ii++, flp++)
        {
            if ((fl.scheme = meMalloc(ww*(sizeof(meUByte)+sizeof(meStyle)))) == NULL)
                return false ;
            fl.text = (meUByte *) (fl.scheme+ww) ;

            /* Data structures allocated. Copy accross the new screen
             * information and pad endings with valid data. Strictly we
             * do not need to do this for all platforms, however if it
             * is safer if we make sure the data is valid. Resize is an
             * infrequent operation and time is not critical here */
            memcpy(fl.text, flp->text, sizeof(meUByte) * loopFrame->widthMax);
            memcpy(fl.scheme, flp->scheme, sizeof(meScheme) * loopFrame->widthMax);
            jj = ww ;
            while(--jj >= loopFrame->widthMax)
            {
                fl.text[jj] = ' ' ;
                fl.scheme[jj] = globScheme ;
            }
            /* Free off old data and copy in new */
            meFree (flp->scheme);
            flp->text = fl.text;
            flp->scheme = fl.scheme;
        }
        /* Fix up the window structures */
        memcpy(ml,loopFrame->mlLine,meLINE_SIZE+loopFrame->mlLine->length) ;
        if(loopFrame->mlStatus & MLSTATUS_KEEP)
        {
            meStrcpy(mls,loopFrame->mlLine->text);
            loopFrame->mlColumnStore = loopFrame->mlColumn ;
            loopFrame->mlStatus = (loopFrame->mlStatus & ~MLSTATUS_KEEP) | MLSTATUS_RESTORE ;
        }
        else if(loopFrame->mlStatus & MLSTATUS_RESTORE)
            meStrcpy(mls,loopFrame->mlLineStore) ;

        free(loopFrame->mlLine) ;
        free(loopFrame->mlLineStore) ;
        loopFrame->video.lineArray[loopFrame->depth].line = (loopFrame->mlLine = ml) ;
        loopFrame->mlLineStore = mls ;

        wp = loopFrame->windowList ;
        while(wp != NULL)
        {
            if((ml = meLineMalloc(ww,0)) == NULL)
                return false ;
            memcpy(ml,wp->modeLine,meLINE_SIZE+wp->modeLine->length) ;
            free(wp->modeLine) ;
            wp->modeLine = ml ;
            wp = wp->next ;
        }
        loopFrame->widthMax = ww ;
    }

    loopFrame->width = ww ;

    /* Fix up the windows */
#if MEOPT_FRAME
    {
        meFrame *fc=frameCur ;
        frameCur = loopFrame ;
        meFrameResizeWindows(frameCur,meFRAMERESIZEWIN_WIDTH);
        frameCur = fc ;
    }
#else
    meFrameResizeWindows(frameCur,meFRAMERESIZEWIN_WIDTH);
#endif

    meFrameLoopEnd() ;
    return true ;
}
Exemplo n.º 6
0
Arquivo: frame.c Projeto: collects/me
void
meFrameFree(meFrame *frame)
{
    meFrame     *ff ;
    meFrameLine *flp ;
    meWindow    *wp ;
    meVideo    *vvptr;
    int        ii ;

    /* take frame out of the list */
    if(frame == frameList)
        frameList = frame->next ;
    else
    {
        ff = frameList ;
        while(ff->next != frame)
            ff = ff->next ;
        ff->next = frame->next ;
    }
#if MEOPT_MWFRAME
    if(frameFocus == frame)
        frameFocus = NULL ;
#endif

    /* try to find a sibling of this frame */
    ff = frameList ;
    while((ff != NULL) && (ff->mainId != frame->mainId))
        ff = ff->next ;

    meFrameTermFree(frame,ff) ;

    while (frame->windowList != NULL)
    {
        wp = frame->windowList ;
        frame->windowList = wp->next ;
        if(--wp->buffer->windowCount == 0)
        {
            storeWindBSet(wp->buffer,wp) ;
            wp->buffer->histNo = bufHistNo ;
        }
        meFree(wp->modeLine) ;
        meFree(wp->dotCharOffset) ;
        meFree(wp);
    }
    /* Destruct all virtual video blocks */
    for(vvptr=frame->video.next; vvptr != NULL; vvptr = frame->video.next)
    {
        frame->video.next = vvptr->next;
        meFree (vvptr->lineArray);
        meFree (vvptr);
    }
    meFree(frame->video.lineArray);
    for(flp=frame->store,ii=0; ii<frame->depthMax; ii++, flp++)
        meFree(flp->scheme) ;
    meFree(frame->mlLine) ;
    meFree(frame->mlLineStore) ;
    meFree(frame->store) ;
    meFree(frame) ;
}
Exemplo n.º 7
0
Arquivo: frame.c Projeto: collects/me
int
meFrameChangeDepth(meFrame *frame, int dd)
{
    /* ensure the value is in range */
    if(dd < 4)
        dd = 4 ;
    else if(dd > 400)
        dd = 400 ;

    /* Already this size ?? Nothing to do */
    if((frame->depth+1) == dd)
        return true;

    meFrameLoopBegin() ;

    /* only process frames which use the same screen window */
    meFrameLoopContinue(loopFrame->mainId != frame->mainId) ;

    /* Only process if the window size is different from the current
     * window size. If we got here that is true.
     * Go and get some more screen space */
    if (dd > loopFrame->depthMax)
    {
        meFrameLine *flp;             /* Temporary frame line */
        int ii, jj;                 /* Local loop counter */

        if (meFrameEnlargeVideo(loopFrame,dd) == false)
            return false ;

        /* Grow the Frame store depthwise do this safely so that
         * we do not cause a crash at the video end.
         *
         * Grow the frame store first. Reallocate and then
         * copy across the old information.
         */
        if ((flp = (meFrameLine *) meMalloc (sizeof (meFrameLine) * dd)) == NULL)
            return false ;

        memcpy (flp, loopFrame->store, sizeof (meFrameLine) * loopFrame->depthMax);
        meFree (loopFrame->store);        /* Free off old store */
        loopFrame->store = flp;           /* Re-assign */

        /* Allocate a new set of lines for the remainder of the space */
        for (flp += loopFrame->depthMax, ii = loopFrame->depthMax; ii < dd; ii++, flp++)
        {
            if ((flp->scheme = meMalloc(loopFrame->widthMax*(sizeof(meUByte)+sizeof(meScheme)))) == NULL)
                return false ;

            flp->text = (meUByte *) (flp->scheme+loopFrame->widthMax) ;
            /* Initialise the data to something valid */
            jj = loopFrame->widthMax ;
            while(--jj >= 0)
            {
                flp->text[jj] = ' ' ;
                flp->scheme[jj] = globScheme ;
            }
        }
        loopFrame->depthMax = dd ;
    }

    /* Fix up the message line by binding to the new video frame */
    loopFrame->video.lineArray[loopFrame->depth].flag = 0 ;    /* Decouple the old one */
    loopFrame->video.lineArray[loopFrame->depth].line = NULL ;
    loopFrame->video.lineArray[dd-1].flag = VFMESSL;    /* Bind in new message line */
    loopFrame->video.lineArray[dd-1].line = loopFrame->mlLine ;
    loopFrame->video.lineArray[dd-1].endp = loopFrame->width;
    loopFrame->depth = dd-1 ;                       /* Set up global number of rows */

#if MEOPT_OSD
    if (loopFrame->menuDepth > 0)
        loopFrame->video.lineArray[0].line = loopFrame->menuLine;
#endif

    /* Fix up the windows */
#if MEOPT_FRAME
    {
        meFrame *fc=frameCur ;
        frameCur = loopFrame ;
        meFrameResizeWindows(frameCur,meFRAMERESIZEWIN_DEPTH);
        frameCur = fc ;
    }
#else
    meFrameResizeWindows(frameCur,meFRAMERESIZEWIN_DEPTH);
#endif

    meFrameLoopEnd() ;

    return true ;
}
Exemplo n.º 8
0
/*
 * setRegistry
 * Assign a new value to the registry
 */
int
setRegistry (int f, int n)
{
    meUByte buf1[meBUF_SIZE_MAX], *name ;
    meUByte buf2[meBUF_SIZE_MAX] ;
    meRegNode *rnp, *pnp, *nnp ;

    /* Get the arguments */
    if(meGetString((meUByte *)"Registry Path", 0, 0, buf1, meBUF_SIZE_MAX) == meABORT)
        return meABORT;
    if(n & 0x02)
    {
        if(((rnp = regFind(&root,buf1)) == NULL) || (rnp == &root))
            return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot find node %s]",buf1);
        
        /* setting the name of the node, not the value */
        if(meGetString((meUByte *)"name", 0, 0, buf2, meBUF_SIZE_MAX) == meABORT)
            return meABORT;
        if(((name=meStrrchr(buf2,'/')) != NULL) && (name[1] == '\0'))
        {
            *name = '\0' ;
            name = meStrrchr(buf2,'/') ;
        }
        if(name != NULL)
        {
            *name++ = '\0' ;
            if((pnp = regFind(&root,buf2)) == NULL)
                return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot find node %s]",buf2) ;
            nnp = pnp ;
            do {
                if(nnp == rnp)
                    return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot move node to itself or one of its children]") ;
            } while((nnp=nnp->parent) != NULL) ;
        }
        else
        {
            name = buf2 ;
            pnp = rnp->parent ;
        }
        if((pnp != rnp->parent) || meStrcmp(name,rnp->name))
        {
            if((name[0] == '\0') || (regFind(pnp,name) != NULL))
                return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot set registry node]");
            if((nnp = rnodeNew(name)) == NULL)
                return meABORT;
            rnodeUnlink(rnp) ;
            nnp->value = rnp->value ;
            nnp->child = rnp->child ;
            nnp->mode = rnp->mode ;
            meFree(rnp) ;
            rnodeLink(pnp,nnp) ;
            rnp = nnp->child ;
            while(rnp != NULL)
            {
                rnp->parent = nnp ;
                rnp = rnp->next ;
            }
        }
    }
    else
    {
        if(meGetString((meUByte *)"Value", 0, 0, buf2, meBUF_SIZE_MAX) == meABORT)
            return meABORT;

        /* Assigns the new value */
        if(regSet(&root,buf1,buf2) == NULL)
            return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot set registry node]");
    }
    return meTRUE;
}