From 6c390d3614d81acd644bdf6278f891bb23070896 Mon Sep 17 00:00:00 2001 From: dmcoles Date: Mon, 16 Dec 2024 17:32:31 +0000 Subject: [PATCH] - show line numbers in code preview window - add vertical spacing support to label gadget - add support for setting and retrieving the string and integer value for requesters - fix issues with code generation where strings contain quote marks that need to be escaped - add hooktype property to string gadget - fix corruption in requester strings - ensure requester ids are refreshed --- cSourceGen.e | 15 +++++++++++++++ codePreviewForm.e | 1 + eSourceGen.e | 19 ++++++++++++++++++- labelObject.e | 21 ++++++++++++++++++++- rebuild.e | 40 ++++++++++++++++++++++------------------ sourceGen.e | 18 +++++++++++++++--- stringObject.e | 25 ++++++++++++++++++++++++- stringlist.e | 6 ++++-- 8 files changed, 119 insertions(+), 26 deletions(-) diff --git a/cSourceGen.e b/cSourceGen.e index 0027a3c..36fca40 100644 --- a/cSourceGen.e +++ b/cSourceGen.e @@ -503,6 +503,14 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, re IF reqItem.bodyParam StrAdd(tempStr,',STRPTR bodyText') ENDIF + + SELECT reqItem.reqType + CASE 1 + StrAdd(tempStr,',ULONG *numberValue') + CASE 2 + StrAdd(tempStr,',STRPTR buffer') + ENDSELECT + StrAdd(tempStr,')') self.writeLine(tempStr) @@ -547,15 +555,22 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, re CASE 1 StringF(tempStr,' REQI_MaxChars, \d,',IF reqItem.maxChars>10 THEN 10 ELSE reqItem.maxChars) self.writeLine(tempStr) + StrCopy(tempStr,' REQI_Number, *numberValue,') + self.writeLine(tempStr) CASE 2 StringF(tempStr,' REQS_MaxChars, \d,',reqItem.maxChars) self.writeLine(tempStr) + StrCopy(tempStr,' REQS_Buffer, buffer,') + self.writeLine(tempStr) ENDSELECT self.writeLine(' TAG_DONE);') DisposeLink(bodyText) self.writeLine(' if (reqobj)') self.writeLine(' {') self.writeLine(' res=DoMethod(reqobj, RM_OPENREQ, NULL, win, NULL);') + IF reqItem.reqType=1 + self.writeLine(' GetAttr(REQI_Number, reqobj, numberValue);') + ENDIF self.writeLine(' DisposeObject(reqobj);') self.writeLine(' }') self.writeLine(' return res;') diff --git a/codePreviewForm.e b/codePreviewForm.e index 53d678c..14a1386 100644 --- a/codePreviewForm.e +++ b/codePreviewForm.e @@ -70,6 +70,7 @@ EXPORT PROC create() OF codePreviewForm GA_TEXTEDITOR_WRAPBORDER,-1, GA_TEXTEDITOR_FIXEDFONT,TRUE, GA_TEXTEDITOR_HORIZONTALSCROLL, TRUE, + GA_TEXTEDITOR_SHOWLINENUMBERS, TRUE, GA_RELVERIFY, TRUE, GA_TABCYCLE, TRUE, GA_READONLY, TRUE, diff --git a/eSourceGen.e b/eSourceGen.e index e88ed08..aeadcdf 100644 --- a/eSourceGen.e +++ b/eSourceGen.e @@ -633,6 +633,12 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, re IF reqItem.bodyParam StrAdd(tempStr,',bodyText') ENDIF + SELECT reqItem.reqType + CASE 1 + StrAdd(tempStr,',initialValue') + CASE 2 + StrAdd(tempStr,',buffer') + ENDSELECT StrAdd(tempStr,')') self.writeLine(tempStr) @@ -677,9 +683,13 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, re CASE 1 StringF(tempStr,' REQI_MAXCHARS, \d,',IF reqItem.maxChars>10 THEN 10 ELSE reqItem.maxChars) self.writeLine(tempStr) + StrCopy(tempStr,' REQI_NUMBER, initialValue,') + self.writeLine(tempStr) CASE 2 StringF(tempStr,' REQS_MAXCHARS, \d,',reqItem.maxChars) self.writeLine(tempStr) + StrCopy(tempStr,' REQS_BUFFER, buffer,') + self.writeLine(tempStr) ENDSELECT self.writeLine(' TAG_END]') @@ -688,11 +698,18 @@ PROC genHeader(screenObject:PTR TO screenObject,rexxObject:PTR TO rexxObject, re self.writeLine(' reqobj:=NewObjectA(Requester_GetClass(),0,[TAG_END])') self.writeLine(' IF reqobj') self.writeLine(' res:=DoMethodA(reqobj, reqmsg)') + IF reqItem.reqType=1 + self.writeLine(' initialValue:=Gets(reqobj, REQI_NUMBER)') + ENDIF self.writeLine(' DisposeObject(reqobj)') self.writeLine(' ENDIF') self.writeLine(' END reqmsg') self.writeLine(' ADD.L #$100,A7') - self.writeLine('ENDPROC res') + IF reqItem.reqType=1 + self.writeLine('ENDPROC res,initialValue') + ELSE + self.writeLine('ENDPROC res') + ENDIF self.writeLine('') ENDFOR ENDPROC diff --git a/labelObject.e b/labelObject.e index 8b57799..abc84f7 100644 --- a/labelObject.e +++ b/labelObject.e @@ -7,6 +7,7 @@ OPT MODULE, OSVERSION=37 'button','gadgets/button', 'images/bevel', 'string', + 'gadgets/integer','integer', 'gadgets/chooser','chooser', 'gadgets/checkbox','checkbox', 'images/label','label', @@ -19,7 +20,7 @@ OPT MODULE, OSVERSION=37 MODULE '*reactionObject','*reactionForm','*colourPicker','*sourceGen','*validator' EXPORT ENUM LBLGAD_IDENT, LBLGAD_LABEL, LBLGAD_NAME, LBLGAD_FGPEN, LBLGAD_BGPEN, LBLGAD_DISPOSE, LBLGAD_JUSTIFICATION, - LBLGAD_OK, LBLGAD_CHILD, LBLGAD_CANCEL + LBLGAD_VERTSPACING, LBLGAD_OK, LBLGAD_CHILD, LBLGAD_CANCEL CONST NUM_LBL_GADS=LBLGAD_CANCEL+1 @@ -28,6 +29,7 @@ EXPORT OBJECT labelObject OF reactionObject bgPen:INT dispose:CHAR justify:CHAR + vertSpacing:INT ENDOBJECT OBJECT labelSettingsForm OF reactionForm @@ -143,6 +145,19 @@ PROC create() OF labelSettingsForm CHILD_LABEL, LabelObject, LABEL_TEXT, 'Justification', LabelEnd, + + LAYOUT_ADDCHILD, self.gadgetList[ LBLGAD_VERTSPACING ]:=IntegerObject, + GA_ID, LBLGAD_VERTSPACING, + GA_RELVERIFY, TRUE, + GA_TABCYCLE, TRUE, + INTEGER_MAXCHARS, 5, + INTEGER_MINIMUM, 0, + INTEGER_MAXIMUM, 65535, + IntegerEnd, + CHILD_LABEL, LabelObject, + LABEL_TEXT, 'Vertical Spacing', + LabelEnd, + LayoutEnd, LAYOUT_ADDCHILD, LayoutObject, @@ -237,6 +252,7 @@ PROC editSettings(comp:PTR TO labelObject) OF labelSettingsForm SetGadgetAttrsA(self.gadgetList[ LBLGAD_NAME ],0,0,[STRINGA_TEXTVAL,comp.name,0]) SetGadgetAttrsA(self.gadgetList[ LBLGAD_DISPOSE ],0,0,[CHECKBOX_CHECKED,comp.dispose,0]) SetGadgetAttrsA(self.gadgetList[ LBLGAD_JUSTIFICATION ],0,0,[CHOOSER_SELECTED,comp.justify,0]) + SetGadgetAttrsA(self.gadgetList[ LBLGAD_VERTSPACING ],0,0,[INTEGER_NUMBER,comp.vertSpacing,0]) res:=self.showModal() IF res=MR_OK @@ -247,6 +263,7 @@ PROC editSettings(comp:PTR TO labelObject) OF labelSettingsForm comp.bgPen:=self.tempBgPen comp.dispose:=Gets(self.gadgetList[ LBLGAD_DISPOSE ],CHECKBOX_CHECKED) comp.justify:=Gets(self.gadgetList[ LBLGAD_JUSTIFICATION ],CHOOSER_SELECTED) + comp.vertSpacing:=Gets(self.gadgetList[ LBLGAD_VERTSPACING ],INTEGER_NUMBER) ENDIF ENDPROC res=MR_OK @@ -290,6 +307,7 @@ EXPORT PROC serialiseData() OF labelObject IS makeProp(fgPen,FIELDTYPE_INT), makeProp(bgPen,FIELDTYPE_INT), makeProp(dispose,FIELDTYPE_CHAR), + makeProp(vertSpacing,FIELDTYPE_INT), makeProp(justify,FIELDTYPE_CHAR) ] @@ -300,6 +318,7 @@ EXPORT PROC genCodeProperties(srcGen:PTR TO srcGen) OF labelObject IF self.bgPen<>0 THEN srcGen.componentPropertyInt('IA_BGPen',self.bgPen) IF self.dispose THEN srcGen.componentProperty('LABEL_DisposeImage','TRUE',FALSE) IF self.justify<>0 THEN srcGen.componentProperty('LABEL_Justification',ListItem(['LJ_LEFT','LJ_CENTER','LJ_RIGHT'],self.justify),FALSE) + IF self.vertSpacing<>0 THEN srcGen.componentPropertyInt('LABEL_VerticalSpacing ',self.vertSpacing) ENDPROC EXPORT PROC genCodeChildProperties(srcGen:PTR TO srcGen) OF labelObject diff --git a/rebuild.e b/rebuild.e index f553f03..aaa1ca6 100644 --- a/rebuild.e +++ b/rebuild.e @@ -54,8 +54,8 @@ OPT OSVERSION=37,LARGE '*virtualObject','*sketchboardObject','*tabsObject','*requesterObject', '*requesterItemObject','*codePreviewForm' -#define vernum '1.2.0' -#date verstring '$VER:Rebuild 1.2.0-%Y%m%d%h%n%s' +#define vernum '1.3.0-dev' +#date verstring '$VER:Rebuild 1.3.0-%Y%m%d%h%n%s' #ifndef EVO_3_7_0 FATAL 'Rebuild should only be compiled with E-VO Amiga E Compiler v3.7.0 or higher' @@ -2416,25 +2416,29 @@ PROC doEdit() updateUndo() IF selectedComp.editSettings() changes:=TRUE - idx:=findWindowIndex(selectedComp) - IF idx<>-1 - mainRootLayout:=objectList.item(ROOT_LAYOUT_ITEM+(idx*3)) - winObj:=objectList.item(ROOT_WINDOW_ITEM+(idx*3)) - removeMembers(mainRootLayout,winObj) - IF selectedComp.type=TYPE_WINDOW - RA_CloseWindow(selectedComp.previewObject) - selectedComp.createPreviewObject(win.wscreen) - RA_OpenWindow(selectedComp.previewObject) - ENDIF + IF selectedComp.type=TYPE_REQUESTER_ITEM makeList(selectedComp) - addMembers(mainRootLayout,winObj) + ELSE + idx:=findWindowIndex(selectedComp) + IF idx<>-1 + mainRootLayout:=objectList.item(ROOT_LAYOUT_ITEM+(idx*3)) + winObj:=objectList.item(ROOT_WINDOW_ITEM+(idx*3)) + removeMembers(mainRootLayout,winObj) + IF selectedComp.type=TYPE_WINDOW + RA_CloseWindow(selectedComp.previewObject) + selectedComp.createPreviewObject(win.wscreen) + RA_OpenWindow(selectedComp.previewObject) + ENDIF + makeList(selectedComp) + addMembers(mainRootLayout,winObj) - IF selectedComp.type=TYPE_MENU - pwin:=Gets(winObj.previewObject,WINDOW_WINDOW) - IF pwin THEN ClearMenuStrip(pwin) - selectedComp.createPreviewObject(win.wscreen) + IF selectedComp.type=TYPE_MENU + pwin:=Gets(winObj.previewObject,WINDOW_WINDOW) + IF pwin THEN ClearMenuStrip(pwin) + selectedComp.createPreviewObject(win.wscreen) + ENDIF + rethinkPreviews() ENDIF - rethinkPreviews() ENDIF addUndo() genCodePreview() diff --git a/sourceGen.e b/sourceGen.e index d88eaa9..0c5c442 100644 --- a/sourceGen.e +++ b/sourceGen.e @@ -76,13 +76,25 @@ PROC componentLibtypeCreate(libname:PTR TO CHAR) OF srcGen ENDPROC PROC componentProperty(propName:PTR TO CHAR, propValue:PTR TO CHAR, isString) OF srcGen - DEF str - str:=String(StrLen(propName)+StrLen(propValue)+5) + DEF str,count=0,i + FOR i:=0 TO StrLen(propValue)-1 DO IF propValue[i]=self.stringDelimiter THEN count++ + + str:=String(StrLen(propName)+StrLen(propValue)+5+count) StrCopy(str,propName) IF self.upperCaseProperties THEN UpperStr(str) StrAdd(str,', ') IF isString THEN StrAddChar(str,self.stringDelimiter) - StrAdd(str,propValue) + FOR i :=0 TO StrLen(propValue)-1 + IF (propValue[i]=self.stringDelimiter) AND isString + IF self.type=ESOURCE_GEN + StrAdd(str,'\\a') + ELSEIF self.type=CSOURCE_GEN + StrAdd(str,'\\"') + ENDIF + ELSE + StrAddChar(str,propValue[i]) + ENDIF + ENDFOR IF isString THEN StrAddChar(str,self.stringDelimiter) StrAdd(str,',') self.writeLine(str) diff --git a/stringObject.e b/stringObject.e index 0785fd1..fe2c713 100644 --- a/stringObject.e +++ b/stringObject.e @@ -20,7 +20,7 @@ OPT MODULE, OSVERSION=37 MODULE '*reactionObject','*reactionForm','*sourceGen','*validator' EXPORT ENUM STRGAD_IDENT, STRGAD_NAME, STRGAD_HINT, STRGAD_MAXCHARS, STRGAD_VALUE,STRGAD_MINVISIBLE, STRGAD_JUSTIFY, - STRGAD_DISABLED, STRGAD_READONLY, STRGAD_TABCYCLE, STRGAD_REPLACEMODE, + STRGAD_HOOKTYPE, STRGAD_DISABLED, STRGAD_READONLY, STRGAD_TABCYCLE, STRGAD_REPLACEMODE, STRGAD_OK, STRGAD_CHILD, STRGAD_CANCEL @@ -31,6 +31,7 @@ EXPORT OBJECT stringObject OF reactionObject value[80]:ARRAY OF CHAR minVisible:INT justify:CHAR + hooktype:CHAR disabled:CHAR readOnly:CHAR tabCycle:CHAR @@ -41,6 +42,7 @@ OBJECT stringSettingsForm OF reactionForm PRIVATE stringObject:PTR TO stringObject labels1:PTR TO LONG + labels2:PTR TO LONG ENDOBJECT PROC create() OF stringSettingsForm @@ -162,6 +164,20 @@ PROC create() OF stringSettingsForm LABEL_TEXT, 'Justification', LabelEnd, + LAYOUT_ADDCHILD, self.gadgetList[ STRGAD_HOOKTYPE ]:=ChooserObject, + GA_ID, STRGAD_HOOKTYPE, + GA_RELVERIFY, TRUE, + GA_TABCYCLE, TRUE, + CHOOSER_POPUP, TRUE, + CHOOSER_MAXLABELS, 12, + CHOOSER_ACTIVE, 0, + CHOOSER_WIDTH, -1, + CHOOSER_LABELS, self.labels2:=chooserLabelsA(['SHK_CUSTOM','SHK_PASSWORD','SHK_IPADDRESS','SHK_FLOAT','SHK_HEXIDECIMAL','SHK_TELEPHONE','SHK_POSTALCODE','SHK_AMOUNT','SHK_UPPERCASE','SHK_HOTKEY ',0]), + ChooserEnd, + CHILD_LABEL, LabelObject, + LABEL_TEXT, 'Hook Type', + LabelEnd, + LAYOUT_ADDCHILD, LayoutObject, LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ, @@ -240,6 +256,7 @@ ENDPROC PROC end() OF stringSettingsForm freeChooserLabels( self.labels1 ) + freeChooserLabels( self.labels2 ) END self.gadgetList[NUM_STR_GADS] END self.gadgetActions[NUM_STR_GADS] DisposeObject(self.windowObj) @@ -274,6 +291,7 @@ PROC editSettings(comp:PTR TO stringObject) OF stringSettingsForm SetGadgetAttrsA(self.gadgetList[ STRGAD_VALUE ],0,0,[STRINGA_TEXTVAL,comp.value,0]) SetGadgetAttrsA(self.gadgetList[ STRGAD_MINVISIBLE ],0,0,[INTEGER_NUMBER,comp.minVisible,0]) SetGadgetAttrsA(self.gadgetList[ STRGAD_JUSTIFY ],0,0,[CHOOSER_SELECTED,comp.justify,0]) + SetGadgetAttrsA(self.gadgetList[ STRGAD_HOOKTYPE ],0,0,[CHOOSER_SELECTED,comp.hooktype,0]) SetGadgetAttrsA(self.gadgetList[ STRGAD_DISABLED ],0,0,[CHECKBOX_CHECKED,comp.disabled,0]) SetGadgetAttrsA(self.gadgetList[ STRGAD_READONLY ],0,0,[CHECKBOX_CHECKED,comp.readOnly,0]) @@ -288,6 +306,7 @@ PROC editSettings(comp:PTR TO stringObject) OF stringSettingsForm AstrCopy(comp.value,Gets(self.gadgetList[ STRGAD_VALUE ],STRINGA_TEXTVAL)) comp.minVisible:=Gets(self.gadgetList[ STRGAD_MINVISIBLE ],INTEGER_NUMBER) comp.justify:=Gets(self.gadgetList[ STRGAD_JUSTIFY ],CHOOSER_SELECTED) + comp.hooktype:=Gets(self.gadgetList[ STRGAD_HOOKTYPE ],CHOOSER_SELECTED) comp.disabled:=Gets(self.gadgetList[ STRGAD_DISABLED ],CHECKBOX_CHECKED) comp.readOnly:=Gets(self.gadgetList[ STRGAD_READONLY ],CHECKBOX_CHECKED) comp.tabCycle:=Gets(self.gadgetList[ STRGAD_TABCYCLE ],CHECKBOX_CHECKED) @@ -307,6 +326,7 @@ EXPORT PROC createPreviewObject(scr) OF stringObject GA_READONLY, self.readOnly, STRINGA_REPLACEMODE, self.replaceMode, STRINGA_JUSTIFICATION, ListItem([GACT_STRINGLEFT,GACT_STRINGCENTER,GACT_STRINGRIGHT],self.justify), + STRINGA_HOOKTYPE, ListItem([SHK_CUSTOM,SHK_PASSWORD,SHK_IPADDRESS,SHK_FLOAT,SHK_HEXIDECIMAL,SHK_TELEPHONE,SHK_POSTALCODE,SHK_AMOUNT,SHK_UPPERCASE,SHK_HOTKEY],self.hooktype), StringEnd IF self.previewObject=0 THEN self.previewObject:=self.createErrorObject(scr) @@ -320,6 +340,7 @@ EXPORT PROC create(parent) OF stringObject AstrCopy(self.value,'') self.minVisible:=4 self.justify:=0 + self.hooktype:=0 self.disabled:=0 self.readOnly:=0 self.tabCycle:=TRUE @@ -345,6 +366,7 @@ EXPORT PROC serialiseData() OF stringObject IS makeProp(value,FIELDTYPE_STR), makeProp(minVisible,FIELDTYPE_INT), makeProp(justify,FIELDTYPE_CHAR), + makeProp(hooktype,FIELDTYPE_CHAR), makeProp(disabled,FIELDTYPE_CHAR), makeProp(readOnly,FIELDTYPE_CHAR), makeProp(tabCycle,FIELDTYPE_CHAR), @@ -365,6 +387,7 @@ EXPORT PROC genCodeProperties(srcGen:PTR TO srcGen) OF stringObject srcGen.componentPropertyInt('STRINGA_MaxChars',self.maxChars) IF self.minVisible<>4 THEN srcGen.componentPropertyInt('STRINGA_MinVisible',self.minVisible) IF self.justify THEN srcGen.componentProperty('STRINGA_Justification',ListItem(['GACT_STRINGLEFT','GACT_STRINGCENTER','GACT_STRINGRIGHT'],self.justify),FALSE) + IF self.hooktype THEN srcGen.componentProperty('STRINGA_HookType',ListItem(['SHK_CUSTOM','SHK_PASSWORD','SHK_IPADDRESS','SHK_FLOAT','SHK_HEXIDECIMAL','SHK_TELEPHONE','SHK_POSTALCODE','SHK_AMOUNT','SHK_UPPERCASE','SHK_HOTKEY'],self.hooktype),FALSE) IF self.replaceMode THEN srcGen.componentProperty('STRINGA_ReplaceMode', 'TRUE', FALSE) ENDPROC diff --git a/stringlist.e b/stringlist.e index e550a5a..a40ca10 100644 --- a/stringlist.e +++ b/stringlist.e @@ -133,12 +133,14 @@ EXPORT PROC setFromTextString(newText:PTR TO CHAR) OF stringlist self.clear() pos:=0 WHILE (n:=InStr(newText+pos,'\n'))>=0 - str:=AstrClone(newText+pos,n) + IF n THEN str:=AstrClone(newText+pos,n) ELSE str:=String(0) self.add(str) DisposeLink(str) pos:=pos+n+1 ENDWHILE - IF StrLen(newText+pos) THEN self.add(newText+pos) + IF StrLen(newText+pos) + self.add(newText+pos) + ENDIF ENDPROC EXPORT PROC count() OF stringlist IS ListLen(self.items)