/* A part of a mini text-editor Author : iri Web siteb : http://www.irizone.net Version : 1.0 Date : october 2012 License : WTF Public License (http://sam.zoy.org/wtfpl/) */ /* This is the 'main' part. - main is the entry-point function. In this, we create a new instance of our Text Editor (TextEd) "class" Next, we build the user interface Moreover, we add the needed callbacks : - _cbLoad called when the user clicks on the 'load' button - _cbSave called when the user clicks on the 'save' button - load : what does the program when a file must be loaded ? - save : what does the program when the text object content must be saved ? Finally, close is a function called when the user interface has been destroyed */ fun load (dialogbox, ed, fileread)= TE_setWindowTitle ed _PtoScol fileread; // change the window title TE_setTextContent ed _getpack fileread;; // set the content text object with a content file fun save (dialogbox, ed, filewrite)= _createpack TE_getTextContent ed filewrite;; // save the content text object in a file fun _cbLoad (button, ed)= // show a open dialog box _DLGrflopen _DLGOpenFile _channel TE_getWindow ed nil nil "text\0*.txt\0pkg\0*.pkg\0scol\0*.scol\0\0" @load ed; 0;; fun _cbSave (button, ed)= // show a save dialog box _DLGrflsave _DLGSaveFile _channel TE_getWindow ed nil nil "text\0*.txt\0pkg\0*.pkg\0scol\0*.scol\0\0" @save ed; 0;; fun close ()= _closemachine;; // quit the program and destroy the VM fun main()= let TE_new 500 400 "Mini text editor" @_cbLoad @_cbSave @close -> ed in TE_create ed; 0;;