Skip to content

Commit

Permalink
- show line numbers in code preview window
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
dmcoles committed Dec 16, 2024
1 parent 2cd2c1b commit 6c390d3
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 26 deletions.
15 changes: 15 additions & 0 deletions cSourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;')
Expand Down
1 change: 1 addition & 0 deletions codePreviewForm.e
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 18 additions & 1 deletion eSourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]')
Expand All @@ -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
Expand Down
21 changes: 20 additions & 1 deletion labelObject.e
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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

Expand All @@ -28,6 +29,7 @@ EXPORT OBJECT labelObject OF reactionObject
bgPen:INT
dispose:CHAR
justify:CHAR
vertSpacing:INT
ENDOBJECT

OBJECT labelSettingsForm OF reactionForm
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
]

Expand All @@ -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
Expand Down
40 changes: 22 additions & 18 deletions rebuild.e
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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()
Expand Down
18 changes: 15 additions & 3 deletions sourceGen.e
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 24 additions & 1 deletion stringObject.e
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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])
Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -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
Expand All @@ -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),
Expand All @@ -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

Expand Down
6 changes: 4 additions & 2 deletions stringlist.e
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6c390d3

Please sign in to comment.