Skip to content

Commit

Permalink
add realtime code preview window
Browse files Browse the repository at this point in the history
separate code generation options and code generation
limit memory usage of undo buffer based on free memory
add tooltype options for code previews and code preview window position
save code preview and preview window positions to project file
set weighting height for ok and cancel buttons on edit hint page to 0
  • Loading branch information
dmcoles committed Jul 17, 2024
1 parent 2bcff60 commit 5f5a868
Show file tree
Hide file tree
Showing 6 changed files with 475 additions and 31 deletions.
2 changes: 1 addition & 1 deletion codeGenForm.e
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
151 changes: 151 additions & 0 deletions codePreviewForm.e
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions reactionObject.e
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ PROC create() OF hintEditForm
GA_TABCYCLE, TRUE,
ButtonEnd,
LayoutEnd,
CHILD_WEIGHTEDHEIGHT,0,
LayoutEnd,
WindowEnd

Expand Down
Loading

0 comments on commit 5f5a868

Please sign in to comment.