diff --git a/codeGenForm.e b/codeGenForm.e index b3b154e..015f328 100644 --- a/codeGenForm.e +++ b/codeGenForm.e @@ -52,7 +52,7 @@ EXPORT PROC create() OF codeGenForm self.fullCodeOption:=chooserLabelsA(['Generate full code','Generate definitions only',0]) self.windowObj:=WindowObject, - WA_TITLE, 'Generate Code', + WA_TITLE, 'Code Options', WA_LEFT, 0, WA_TOP, 0, WA_HEIGHT, 80, diff --git a/codePreviewForm.e b/codePreviewForm.e new file mode 100644 index 0000000..079f2c3 --- /dev/null +++ b/codePreviewForm.e @@ -0,0 +1,151 @@ +OPT MODULE, OSVERSION=37 + + MODULE 'reaction/reaction_macros', + 'window','classes/window', + 'gadgets/layout','layout', + 'reaction/reaction_lib', + 'images/bevel', + 'gadgets/textEditor','texteditor', + 'gadgets/scroller','scroller', + 'images/label','label', + 'amigalib/boopsi', + 'intuition/intuition', + 'intuition/imageclass', + 'intuition/gadgetclass', + 'intuition/cghooks', + 'intuition/icclass' + + MODULE '*reactionForm','*stringStreamer' + +EXPORT DEF texteditorbase + +EXPORT ENUM PREVIEWGAD_TEXT, PREVIEWGAD_SCROLL +CONST NUM_PREVIEW_GADS=PREVIEWGAD_SCROLL+1 + +EXPORT OBJECT codePreviewForm OF reactionForm + left:INT + top:INT + width:INT + height:INT +ENDOBJECT + +EXPORT PROC create(left,top,width,height) OF codePreviewForm + DEF gads:PTR TO LONG + DEF tempbase,map + + NEW gads[NUM_PREVIEW_GADS] + self.gadgetList:=gads + NEW gads[NUM_PREVIEW_GADS] + + tempbase:=textfieldbase + textfieldbase:=texteditorbase + + self.left:=left + self.top:=top + self.width:=width + self.height:=height + + self.gadgetActions:=gads + self.windowObj:=WindowObject, + WA_TITLE, 'Code Preview', + WA_LEFT, self.left, + WA_TOP, self.top, + WA_HEIGHT, self.height, + WA_WIDTH, self.width, + WA_MINWIDTH, 150, + WA_MAXWIDTH, 8192, + WA_MINHEIGHT, 80, + WA_MAXHEIGHT, 8192, + WA_ACTIVATE, FALSE, + WA_PUBSCREEN, 0, + ->WA_CustomScreen, gScreen, + ->WINDOW_AppPort, gApp_port, + WA_CLOSEGADGET, TRUE, + WA_DEPTHGADGET, TRUE, + WA_SIZEGADGET, TRUE, + WA_DRAGBAR, TRUE, + WA_NOCAREREFRESH, TRUE, + WA_IDCMP,IDCMP_GADGETDOWN OR IDCMP_GADGETUP OR IDCMP_CLOSEWINDOW, + + WINDOW_PARENTGROUP, HLayoutObject, + LAYOUT_SPACEOUTER, TRUE, + LAYOUT_DEFERLAYOUT, TRUE, + + LAYOUT_ADDCHILD, self.gadgetList[ PREVIEWGAD_TEXT ]:=NewObjectA( TextEditor_GetClass(), NIL,[ + GA_ID, PREVIEWGAD_TEXT, + GA_TEXTEDITOR_WRAPBORDER,-1, + GA_TEXTEDITOR_FIXEDFONT,TRUE, + GA_TEXTEDITOR_HORIZONTALSCROLL, TRUE, + GA_RELVERIFY, TRUE, + GA_TABCYCLE, TRUE, + GA_READONLY, TRUE, + TAG_END]), + + LAYOUT_ADDCHILD, self.gadgetList[ PREVIEWGAD_SCROLL ]:=NewObjectA(Scroller_GetClass(),NIL,[ + GA_ID, PREVIEWGAD_SCROLL, + GA_RELVERIFY, TRUE, + GA_TABCYCLE, TRUE, + SCROLLER_ARROWS, TRUE, + SCROLLER_ORIENTATION, SORIENT_VERT, + TAG_END]), + + LayoutEnd, + WindowEnd + + map:=[GA_TEXTEDITOR_PROP_FIRST, SCROLLER_TOP, + GA_TEXTEDITOR_PROP_ENTRIES, SCROLLER_TOTAL, + GA_TEXTEDITOR_PROP_VISIBLE, SCROLLER_VISIBLE, + TAG_DONE] + + SetGadgetAttrsA(self.gadgetList[ PREVIEWGAD_TEXT ],0,0,[ICA_MAP,map,ICA_TARGET,self.gadgetList[ PREVIEWGAD_SCROLL ],0]) + + map:=[ + SCROLLER_TOP, GA_TEXTEDITOR_PROP_FIRST, + SCROLLER_TOTAL, GA_TEXTEDITOR_PROP_ENTRIES, + SCROLLER_VISIBLE, GA_TEXTEDITOR_PROP_VISIBLE, + TAG_DONE] + + SetGadgetAttrsA(self.gadgetList[ PREVIEWGAD_SCROLL ],0,0,[ICA_MAP,map,ICA_TARGET,self.gadgetList[ PREVIEWGAD_TEXT ],0]) + + textfieldbase:=tempbase + +ENDPROC + +PROC end() OF codePreviewForm + self.close() + END self.gadgetList[NUM_PREVIEW_GADS] + END self.gadgetActions[NUM_PREVIEW_GADS] +ENDPROC + +EXPORT PROC showCode(strStream:PTR TO stringStreamer) OF codePreviewForm + DEF str[201]:ARRAY OF CHAR + DEF win + strStream.reset() + win:=Gets(self.windowObj,WINDOW_WINDOW) + DoGadgetMethodA(self.gadgetList[ PREVIEWGAD_TEXT ],win,0,[GM_TEXTEDITOR_CLEARTEXT, 0]:gp_texteditor_cleartext) + SetGadgetAttrsA(self.gadgetList[ PREVIEWGAD_TEXT ],win,0,[GA_TEXTEDITOR_QUIET,1,TAG_END]) + WHILE strStream.readLine(str)<>-1 + str[StrLen(str)+1]:=0 + str[StrLen(str)]:="\n" + DoGadgetMethodA(self.gadgetList[ PREVIEWGAD_TEXT ],win,0,[GM_TEXTEDITOR_INSERTTEXT, 0, str, GV_TEXTEDITOR_INSERTTEXT_BOTTOM]:gp_texteditor_inserttext) + ENDWHILE + SetGadgetAttrsA(self.gadgetList[ PREVIEWGAD_TEXT ],win,0,[GA_TEXTEDITOR_QUIET,FALSE,TAG_END]) + SetGadgetAttrsA(self.gadgetList[ PREVIEWGAD_TEXT ],win,0,[GA_TEXTEDITOR_CURSORY,0,TAG_END]) + SetGadgetAttrsA(self.gadgetList[ PREVIEWGAD_SCROLL ],win,0,[SCROLLER_TOP,0,TAG_END]) + +ENDPROC + +EXPORT PROC close() OF codePreviewForm + RA_CloseWindow(self.windowObj) +ENDPROC + +EXPORT PROC show() OF codePreviewForm + SetAttrsA(self.windowObj,[ + WA_LEFT, self.left, + WA_TOP, self.top, + WA_HEIGHT, self.height, + WA_WIDTH, self.width, + TAG_DONE]) + + RA_OpenWindow(self.windowObj) +ENDPROC diff --git a/makefile b/makefile index cfd7979..d2c1392 100644 --- a/makefile +++ b/makefile @@ -15,7 +15,7 @@ all: rebuild release: options=$(releaseoptions) release: rebuild -rebuild: rebuild.e validator.m dialogs.m libraryVersions.m reactionLists.m tabsObject.m sketchboardObject.m virtualObject.m listViewObject.m ledObject.m textEditorObject.m tapeDeckObject.m gradSliderObject.m getColorObject.m dateBrowserObject.m colorWheelObject.m speedBarObject.m sliderObject.m bitmapObject.m penMapObject.m boingBallObject.m getScreenModeObject.m getFontObject.m getFileObject.m textFieldObject.m drawListObject.m fuelGaugeObject.m bevelObject.m listBrowserObject.m clickTabObject.m chooserObject.m radioObject.m menuObject.m rexxObject.m reactionListObject.m listManagerForm.m codeGenForm.m eSourceGen.m cSourceGen.m sourcegen.m fileStreamer.m stringStreamer.m baseStreamer.m reactionForm.m objectPicker.m windowObject.m screenObject.m paletteObject.m scrollerObject.m glyphObject.m spaceObject.m integerObject.m labelObject.m checkboxObject.m stringObject.m buttonObject.m layoutObject.m reactionObject.m stringlist.m requesterObject.m +rebuild: rebuild.e codePreviewForm.m validator.m dialogs.m libraryVersions.m reactionLists.m tabsObject.m sketchboardObject.m virtualObject.m listViewObject.m ledObject.m textEditorObject.m tapeDeckObject.m gradSliderObject.m getColorObject.m dateBrowserObject.m colorWheelObject.m speedBarObject.m sliderObject.m bitmapObject.m penMapObject.m boingBallObject.m getScreenModeObject.m getFontObject.m getFileObject.m textFieldObject.m drawListObject.m fuelGaugeObject.m bevelObject.m listBrowserObject.m clickTabObject.m chooserObject.m radioObject.m menuObject.m rexxObject.m reactionListObject.m listManagerForm.m codeGenForm.m eSourceGen.m cSourceGen.m sourcegen.m fileStreamer.m stringStreamer.m baseStreamer.m reactionForm.m objectPicker.m windowObject.m screenObject.m paletteObject.m scrollerObject.m glyphObject.m spaceObject.m integerObject.m labelObject.m checkboxObject.m stringObject.m buttonObject.m layoutObject.m reactionObject.m stringlist.m requesterObject.m $(compiler) rebuild $(options) reactionLists.m: reactionLists.e stringlist.m @@ -171,6 +171,9 @@ fileStreamer.m: fileStreamer.e baseStreamer.m stringStreamer.m: stringStreamer.e baseStreamer.m stringlist.m $(compiler) stringStreamer $(options) +codePreviewForm.m: codePreviewForm.e reactionForm.m stringStreamer.m + $(compiler) codePreviewForm $(options) + baseStreamer.m: baseStreamer.e $(compiler) baseStreamer $(options) @@ -202,4 +205,4 @@ validator.m: validator.e reactionObject.m reactionForm.m stringlist.m dialogs. $(compiler) validator $(options) clean: - delete validator.m bitmapObject.m dialogs.m libraryVersions.m tabsObject.m sketchboardObject.m virtualObject.m listViewObject.m ledObject.m textEditorObject.m tapeDeckObject.m gradSliderObject.m getColorObject.m dateBrowserObject.m colorWheelObject.m speedBarObject.m sliderObject.m penMapObject.m boingBallObject.m getScreenModeObject.m getFontObject.m getFileObject.m textFieldObject.m fuelGaugeObject.m drawListObject.m bevelObject.m listBrowserObject.m clickTabObject.m chooserObject.m radioObject.m menuObject.m rexxObject.m reactionListObject.m listPicker.m reactionForm.m listManagerForm.m codeGenForm.m cSourcegen.m eSourceGen.m sourceGen.m objectPicker.m colourPicker.m baseStreamer.m fileStreamer.m stringStreamer.m windowObject.m screenObject.m paletteObject.m scrollerObject.m glyphObject.m spaceObject.m integerObject.m labelObject.m checkboxObject.m stringObject.m buttonObject.m layoutObject.m reactionObject.m reactionLists.m stringlist.m requesterObject.m rebuild + delete codePreviewForm.m validator.m bitmapObject.m dialogs.m libraryVersions.m tabsObject.m sketchboardObject.m virtualObject.m listViewObject.m ledObject.m textEditorObject.m tapeDeckObject.m gradSliderObject.m getColorObject.m dateBrowserObject.m colorWheelObject.m speedBarObject.m sliderObject.m penMapObject.m boingBallObject.m getScreenModeObject.m getFontObject.m getFileObject.m textFieldObject.m fuelGaugeObject.m drawListObject.m bevelObject.m listBrowserObject.m clickTabObject.m chooserObject.m radioObject.m menuObject.m rexxObject.m reactionListObject.m listPicker.m reactionForm.m listManagerForm.m codeGenForm.m cSourcegen.m eSourceGen.m sourceGen.m objectPicker.m colourPicker.m baseStreamer.m fileStreamer.m stringStreamer.m windowObject.m screenObject.m paletteObject.m scrollerObject.m glyphObject.m spaceObject.m integerObject.m labelObject.m checkboxObject.m stringObject.m buttonObject.m layoutObject.m reactionObject.m reactionLists.m stringlist.m requesterObject.m rebuild diff --git a/reactionObject.e b/reactionObject.e index 50d24ae..cee6134 100644 --- a/reactionObject.e +++ b/reactionObject.e @@ -423,6 +423,7 @@ PROC create() OF hintEditForm GA_TABCYCLE, TRUE, ButtonEnd, LayoutEnd, + CHILD_WEIGHTEDHEIGHT,0, LayoutEnd, WindowEnd diff --git a/rebuild.e b/rebuild.e index 2f74b79..27f4354 100644 --- a/rebuild.e +++ b/rebuild.e @@ -40,7 +40,7 @@ OPT OSVERSION=37,LARGE 'workbench/workbench', 'amigalib/boopsi','exec/memory', 'listbrowser','gadgets/listbrowser', - 'intuition/intuition','intuition/imageclass','intuition/gadgetclass','intuition/classusr' + 'intuition/intuition','intuition/screens','intuition/imageclass','intuition/gadgetclass','intuition/classusr' MODULE '*fileStreamer','*stringStreamer','*baseStreamer','*objectPicker','*cSourceGen', '*eSourceGen', '*sourceGen','*codeGenForm','*listManagerForm','*reactionLists','*dialogs','*libraryVersions', @@ -51,7 +51,8 @@ OPT OSVERSION=37,LARGE '*stringObject','*integerObject','*stringlist','*reactionObject','*reactionForm','*boingBallObject', '*penMapObject','*sliderObject','*bitmapObject','*speedBarObject','*colorWheelObject','*dateBrowserObject', '*getColorObject','*gradSliderObject','*tapeDeckObject','*textEditorObject','*ledObject','*listViewObject', - '*virtualObject','*sketchboardObject','*tabsObject','*requesterObject' + '*virtualObject','*sketchboardObject','*tabsObject','*requesterObject', + '*codePreviewForm' #define vernum '1.2.0-dev' #date verstring '$VER:Rebuild 1.2.0-%Y%m%d%h%n%s' @@ -87,10 +88,11 @@ OPT OSVERSION=37,LARGE CONST MENU_PROJECT_SAVE=2 CONST MENU_PROJECT_SAVEAS=3 CONST MENU_PROJECT_REOPEN=4 - CONST MENU_PROJECT_GENCODE=6 - CONST MENU_PROJECT_SHOWLIBS=8 - CONST MENU_PROJECT_ABOUT=10 - CONST MENU_PROJECT_QUIT=12 + CONST MENU_PROJECT_CODEOPTIONS=6 + CONST MENU_PROJECT_SAVECODE=7 + CONST MENU_PROJECT_SHOWLIBS=9 + CONST MENU_PROJECT_ABOUT=11 + CONST MENU_PROJECT_QUIT=13 CONST MENU_EDIT_UNDO=0 CONST MENU_EDIT_REDO=1 @@ -108,7 +110,8 @@ OPT OSVERSION=37,LARGE CONST MENU_EDIT_SHOW_ADD_SETTINGS=17 CONST MENU_EDIT_WARN_ON_DEL=18 CONST MENU_EDIT_SAVE_ICONS=19 - CONST MENU_EDIT_PREVIEW=21 + CONST MENU_EDIT_PREVIEWCODE=20 + CONST MENU_EDIT_PREVIEW=22 CONST MENU_EDIT_MOVEUP=0 CONST MENU_EDIT_MOVEDOWN=1 @@ -127,6 +130,7 @@ OPT OSVERSION=37,LARGE showSettingsOnAdd:CHAR warnOnDelete:CHAR saveProjectIcons:CHAR + previewCode:CHAR windowTop:INT windowLeft:INT windowWidth:INT @@ -170,6 +174,8 @@ OPT OSVERSION=37,LARGE DEF recentFiles:PTR TO stringlist DEF undoData:PTR TO stdlist DEF undoPos=-1 + + DEF codePreviewForm:PTR TO codePreviewForm PROC openClasses() IF (requesterbase:=OpenLibrary('requester.class',0))=NIL THEN Throw("LIB","reqr") @@ -713,6 +719,10 @@ PROC loadIconPrefs() IF (MatchToolValue(s,'NO')) OR (MatchToolValue(s,'FALSE')) THEN systemOptions.saveProjectIcons:=FALSE ELSE systemOptions.saveProjectIcons:=TRUE ENDIF + IF(s:=FindToolType(dobj.tooltypes,'PREVIEWCODE')) + IF (MatchToolValue(s,'NO')) OR (MatchToolValue(s,'FALSE')) THEN systemOptions.previewCode:=FALSE ELSE systemOptions.previewCode:=TRUE + ENDIF + IF(s:=FindToolType(dobj.tooltypes,'SAVEPATH')) AstrCopy(systemOptions.savePath,s,256) ENDIF @@ -733,6 +743,22 @@ PROC loadIconPrefs() systemOptions.windowHeight:=Val(s) ENDIF + IF(s:=FindToolType(dobj.tooltypes,'CODEWINDOWLEFT')) + codePreviewForm.left:=Val(s) + ENDIF + + IF(s:=FindToolType(dobj.tooltypes,'CODEWINDOWTOP')) + codePreviewForm.top:=Val(s) + ENDIF + + IF(s:=FindToolType(dobj.tooltypes,'CODEWINDOWWIDTH')) + codePreviewForm.width:=Val(s) + ENDIF + + IF(s:=FindToolType(dobj.tooltypes,'CODEWINDOWHEIGHT')) + codePreviewForm.height:=Val(s) + ENDIF + FreeDiskObject(dobj) ENDIF ENDPROC @@ -982,6 +1008,7 @@ PROC doGenUp(parent:PTR TO reactionObject,child:PTR TO reactionObject) addMembers(mainRootLayout,window) rethinkPreviews() addUndo() + genCodePreview() ENDIF ENDPROC @@ -1003,6 +1030,7 @@ PROC doGenDown(parent:PTR TO reactionObject, child:PTR TO reactionObject) addMembers(mainRootLayout,window) rethinkPreviews() addUndo() + genCodePreview() ENDPROC PROC swapWindows(idx1,idx2) @@ -1060,6 +1088,7 @@ PROC moveUp(child:PTR TO reactionObject,count=1) addMembers(mainRootLayout,window) rethinkPreviews() addUndo() + genCodePreview() ENDIF ENDPROC @@ -1098,6 +1127,7 @@ PROC moveDown(child:PTR TO reactionObject,count=1) addMembers(mainRootLayout,window) rethinkPreviews() addUndo() + genCodePreview() ENDIF ENDPROC @@ -1122,6 +1152,7 @@ PROC movePrevLayout(comp:PTR TO reactionObject) addMembers(mainRootLayout,window) rethinkPreviews() addUndo() + genCodePreview() ENDPROC PROC moveNextLayout(comp:PTR TO reactionObject) @@ -1145,6 +1176,8 @@ PROC moveNextLayout(comp:PTR TO reactionObject) addMembers(mainRootLayout,window) rethinkPreviews() addUndo() + genCodePreview() + ENDPROC PROC moveIntoLayout(comp:PTR TO reactionObject,horiz) @@ -1172,6 +1205,7 @@ PROC moveIntoLayout(comp:PTR TO reactionObject,horiz) addMembers(mainRootLayout,window) rethinkPreviews() addUndo() + genCodePreview() ENDIF ENDPROC @@ -1287,11 +1321,8 @@ PROC showLibs() END libsForm ENDPROC -PROC genCode() - DEF fs:PTR TO fileStreamer - DEF tags - DEF fr:PTR TO filerequester - DEF fname[255]:STRING +PROC genCodePreview() + DEF fs:PTR TO stringStreamer DEF eSrcGen: PTR TO eSrcGen DEF cSrcGen: PTR TO cSrcGen DEF srcGen:PTR TO srcGen @@ -1312,14 +1343,132 @@ PROC genCode() DEF windowObj:PTR TO windowObject DEF tempStr[255]:STRING DEF sharedport=0 - DEF dupeName=0 + DEF win + + IF codePreviewForm=NIL THEN RETURN + win:=Gets(codePreviewForm.windowObj,WINDOW_WINDOW) + IF win=NIL THEN RETURN + + FOR i:=0 TO TYPE_MAX-1 DO libsused[i]:=0 + + i:=ROOT_LAYOUT_ITEM + NEW windowItems.stdlist(10) + NEW windowLayouts.stdlist(10) + WHILE i0 @@ -2129,6 +2323,7 @@ PROC doDelete() changes:=TRUE removeObject(selectedComp) addUndo() + genCodePreview() ENDIF ELSE IF (systemOptions.warnOnDelete=FALSE) ORELSE (warnRequest(mainWindow,'Warning','Are you sure you wish\nto delete this item?',TRUE)=1) @@ -2136,6 +2331,7 @@ PROC doDelete() changes:=TRUE removeObject(selectedComp) addUndo() + genCodePreview() ENDIF ENDIF ENDIF @@ -2206,6 +2402,7 @@ PROC doMoveToBuffer(comp:PTR TO reactionObject) copyToBuffer(comp,TRUE) removeObject(comp) addUndo() + genCodePreview() ENDPROC PROC copyFromBuffer(bufferComp:PTR TO reactionObject) @@ -2266,6 +2463,7 @@ PROC copyFromBuffer(bufferComp:PTR TO reactionObject) DeleteFile('t:tempcomp') changes:=TRUE addUndo() + genCodePreview() ENDPROC PROC moveFromBuffer(bufferComp:PTR TO reactionObject) @@ -2275,6 +2473,7 @@ PROC moveFromBuffer(bufferComp:PTR TO reactionObject) removeBufferItem(bufferComp) changes:=TRUE addUndo() + genCodePreview() ENDPROC PROC removeBufferItem(bufferComp:PTR TO reactionObject) @@ -2387,6 +2586,7 @@ PROC newProject() changes:=FALSE clearUndo() addUndo() + genCodePreview() ENDPROC PROC updateSettings() @@ -2411,6 +2611,11 @@ PROC updateSettings() IF a systemOptions.showBuffer:=IF (a.flags AND CHECKED) THEN TRUE ELSE FALSE ENDIF + + a:=ItemAddress(win.menustrip,menuCode(MENU_EDIT,MENU_EDIT_PREVIEWCODE,0)) + IF a + systemOptions.previewCode:=IF (a.flags AND CHECKED) THEN TRUE ELSE FALSE + ENDIF ENDIF ENDPROC @@ -2459,6 +2664,28 @@ PROC togglePreview(subitem) ENDIF ENDPROC +PROC handleCodePreviewInputs() + DEF result,tmp,code + DEF a:PTR TO menuitem + + WHILE ((result:=RA_HandleInput(codePreviewForm.windowObj,{code}+2)) <> WMHI_LASTMSG) + tmp:=(result AND WMHI_CLASSMASK) + SELECT tmp + CASE WMHI_CHANGEWINDOW + codePreviewForm.left:=Gets(codePreviewForm.windowObj,WA_LEFT) + codePreviewForm.top:=Gets(codePreviewForm.windowObj,WA_TOP) + codePreviewForm.width:=Gets(codePreviewForm.windowObj,WA_WIDTH) + codePreviewForm.height:=Gets(codePreviewForm.windowObj,WA_HEIGHT) + CASE WMHI_CLOSEWINDOW + a:=ItemAddress(win.menustrip,menuCode(MENU_EDIT,MENU_EDIT_PREVIEWCODE,0)) + a.flags:=a.flags AND Not(CHECKED) + systemOptions.previewCode:=FALSE + codePreviewForm.close() + ActivateWindow(win) + ENDSELECT + ENDWHILE +ENDPROC + PROC handlePreviewInputs() DEF pwin:PTR TO window,previewWin,i,code=0 DEF winObj:PTR TO windowObject @@ -2519,7 +2746,8 @@ PROC remakePreviewMenus() NM_SUB,IF recentFiles.count()>3 THEN recentFiles.item(3) ELSE 0,0,0,0, NM_SUB,IF recentFiles.count()>4 THEN recentFiles.item(4) ELSE 0,0,0,0, NM_ITEM,NM_BARLABEL,0,0,0, - NM_ITEM,'Generate Code',0,0,'C', + NM_ITEM,'Code Options',0,0,'C', + NM_ITEM,'Save Code',0,MIF_SHIFTCOMMSEQ,'C', NM_ITEM,NM_BARLABEL,0,0,0, NM_ITEM,'Show Libraries',0,0,0, NM_ITEM,NM_BARLABEL,0,0,0, @@ -2592,6 +2820,7 @@ PROC remakePreviewMenus() NM_ITEM,'Show Settings On Add',0,(CHECKIT OR (IF systemOptions.showSettingsOnAdd THEN CHECKED ELSE 0 ) OR MENUTOGGLE),0, NM_ITEM,'Warn On Delete',0,(CHECKIT OR (IF systemOptions.warnOnDelete THEN CHECKED ELSE 0 ) OR MENUTOGGLE),0, NM_ITEM,'Save Project Icons',0,(CHECKIT OR (IF systemOptions.saveProjectIcons THEN CHECKED ELSE 0 ) OR MENUTOGGLE),0, + NM_ITEM,'Code Preview Window',0,(CHECKIT OR (IF systemOptions.previewCode THEN CHECKED ELSE 0 ) OR MENUTOGGLE),0, NM_ITEM,NM_BARLABEL,0,0,0, NM_ITEM,'Preview Windows',0,0,0 ] @@ -2770,6 +2999,7 @@ PROC editLists() END listManagerForm clearBusy() addUndo() + genCodePreview() idx:=ROOT_WINDOW_ITEM WHILE idxMAX_UNDO_COUNT THEN undoData.remove(0) + WHILE (getUndoDatasize()>(Div(AvailMem(0),4)) AND (undoData.count()>5)) OR (undoData.count()>MAX_UNDO_COUNT) + strStream:=undoData.item(0) + END strStream + undoData.remove(0) + ENDWHILE NEW strStream.create() saveStream(strStream) @@ -2978,6 +3227,8 @@ PROC main() HANDLE DEF reactionList:PTR TO reactionListObject DEF i DEF item,type + DEF a:PTR TO menuitem + DEF scr:PTR TO screen DEF hintInfo:PTR TO hintinfo DEF strStream:stringStreamer @@ -2993,6 +3244,15 @@ PROC main() HANDLE NEW undoData.stdlist(MAX_UNDO_COUNT) + + scr:=LockPubScreen(0) + IF scr + tmp:=scr.width-350 + IF tmp<0 THEN tmp:=0 + ENDIF + UnlockPubScreen(0,scr) + NEW codePreviewForm.create(tmp,20,350,120) + hintInfo:=New(SIZEOF hintinfo*17) hintInfo[0].gadgetid:=GAD_ADD hintInfo[0].code:=-1 @@ -3084,6 +3344,7 @@ PROC main() HANDLE systemOptions.warnOnDelete:=TRUE systemOptions.showBuffer:=TRUE systemOptions.saveProjectIcons:=FALSE + systemOptions.previewCode:=TRUE systemOptions.windowLeft:=-1 systemOptions.windowTop:=-1 systemOptions.windowWidth:=-1 @@ -3092,6 +3353,8 @@ PROC main() HANDLE AstrCopy(systemOptions.savePath,'') loadIconPrefs() + IF systemOptions.previewCode THEN codePreviewForm.show() + createForm() Sets(mainWindow,WINDOW_HINTINFO,hintInfo) Sets(mainWindow,WINDOW_GADGETHELP, TRUE) @@ -3108,6 +3371,7 @@ PROC main() HANDLE WHILE running wsig:=getAllWindowSigs() sig:=Wait(wsig) + handleCodePreviewInputs() handlePreviewInputs() IF (sig AND (wsig)) WHILE ((result:=RA_HandleInput(mainWindow,{code}+2)) <> WMHI_LASTMSG) @@ -3130,7 +3394,9 @@ PROC main() HANDLE saveFileAs() CASE MENU_PROJECT_REOPEN ->Reopen file doLoad(recentFiles.item(subitem)) - CASE MENU_PROJECT_GENCODE ->Generate Code + CASE MENU_PROJECT_CODEOPTIONS ->Generate Code + editCodeOptions() + CASE MENU_PROJECT_SAVECODE -> genCode() CASE MENU_PROJECT_SHOWLIBS showLibs() @@ -3193,6 +3459,15 @@ PROC main() HANDLE CASE MENU_EDIT_BUFFER toggleBuffer() updateSettings() + CASE MENU_EDIT_PREVIEWCODE + updateSettings() + a:=ItemAddress(win.menustrip,menuCode(MENU_EDIT,MENU_EDIT_PREVIEWCODE,0)) + IF a.flags AND CHECKED + codePreviewForm.show() + genCodePreview() + ELSE + codePreviewForm.close() + ENDIF CASE MENU_EDIT_PREVIEW togglePreview(subitem) ENDSELECT @@ -3224,7 +3499,7 @@ PROC main() HANDLE CASE GAD_LISTS ->Lists editLists() CASE GAD_CODE ->Code - genCode() + editCodeOptions() CASE GAD_LOAD ->Load doLoad() CASE GAD_SAVE ->Save @@ -3355,7 +3630,7 @@ EXCEPT DO clearUndo() END undoData ENDIF - + IF codePreviewForm THEN END codePreviewForm IF objectList THEN END objectList IF bufferList disposeBufferObjects() diff --git a/stringStreamer.e b/stringStreamer.e index 871a280..22d9996 100644 --- a/stringStreamer.e +++ b/stringStreamer.e @@ -48,9 +48,13 @@ ENDPROC PROC readLine(outStr:PTR TO CHAR) OF stringStreamer DEF r,l IF self.data - AstrCopy(outStr,self.data.item(self.currpos),200) - r:=StrLen(outStr) - self.currpos:=self.currpos+1 + IF (self.currpos<(self.data.count())) + AstrCopy(outStr,self.data.item(self.currpos),200) + r:=StrLen(outStr) + self.currpos:=self.currpos+1 + ELSE + r:=-1 + ENDIF ENDIF ENDPROC r @@ -58,6 +62,16 @@ PROC reset() OF stringStreamer self.currpos:=0 ENDPROC +PROC getSize() OF stringStreamer + //very rough size estimation + DEF r=0,i + FOR i:=0 TO self.data.count()-1 + r:=r+EstrLen(self.data.item(i))+8 + ENDFOR + r:=r+32 +ENDPROC r + + PROC compareTo(otherStream:PTR TO stringStreamer) OF stringStreamer DEF i