Component index
Section index

Component FRAMEWORK


Search

	/*
	    This shows how a multi-document editor can resume operation
	    from one session to the other. The trick is to use setdocumentid
	    to record a meaningful info about the document and getdocumentids()
	    to learn about all active document at the end of the session.
	
	    We will show a simple multi document editor. Note it can't save
	    anything to disk.
	*/
	<mod>
	static void sample_docid(int argc, char *argv[])
	{
	    <obj FRAMEWORK frm>("restart documents");
	    <f area1>
	        SSTRING *name = (SSTRING*)info.data;
	        setdocumentid (name->get());
	        DIALOG dia;
	        info.msgs.waitfor (dia);
	        glocal SSTRING tmp;
	        <call loadfile>(name->get(),false);
	        <f oneline>
	            glocal.tmp.append (line);
	        </f>
	        </call>
	        dia.newf_textarea (NULL,glocal.tmp,60,20);
	        int nof = 0;
	        while (1){
	            MENU_STATUS code = dia.edit (name->get(),"",help_none,nof,0);
	            if (code == MENU_MESSAGE){
	                if (info.msgs.is_ending()){
	                    break;
	                }else if (info.msgs.is_mayend()){
	                    endok();
	                }
	            }
	        }
	        delete name;
	    </f>
	    </obj>
	    if (argc == 0){
	        // We reload all the documents
	        SSTRINGS tb;
	        linuxconf_getall ("document","list",tb,false);
	        for (int i=0; i<tb.getnb(); i++){
	            frm.newdocument (new SSTRING(tb.getitem(i)));
	        }
	    }else{
	        // we load the documents from the command line
	        for (int i=0; i<argc; i++){
	            frm.newdocument (new SSTRING(argv[i]));
	        }
	    }
	    frm.loop();
	    {
	        // We save the list for the next session
	        SSTRINGS tb;
	        frm.getdocumentids(tb);
	        linuxconf_replace ("document","list",tb);
	        linuxconf_save();
	    }
	}
	</mod>