[Skip top navbar]

Andrew Gregory's Web Pages

Beach at Lancelin, Approx 31°1'5"S 115°19'49"E

-

An Editor Application Example


Description

The Editor Application module provides the framework for a complete application based around the central functionality of a text editor.

My Resource IDE program is built using it.


A Complete Example

Following is a complete application (all 67 lines of it!) that implements a simple Notepad application. The source code is available in notepad.zip (1.0K).

APP Notepad TYPE $1003 PATH "\TXT" EXT "TXT" ENDA PROC main: GLOBAL edwin%, edsig%, ewls% GLOBAL ebFind$( 80 ), ebFindD%, ebFindC% :REM Find settings GLOBAL ebSrch$( 80 ), ebRplc$( 80 ), ebRplcD%, ebRplcC% :REM Replace settings GLOBAL lpFmt& mpStart%:( "init", "eaDone" ) ENDP #include "\opl\lib\amsync.opl" #include "\opl\lib\editapp.opl" #include "\opl\lib\editbox.opl" #include "\opl\lib\iomngr.opl" #include "\opl\lib\lnkpaste.opl" #include "\opl\lib\rsmsg.opl" #include "\opl\lib\ui.opl" PROC init%: EvtFunc$( 1 ) = "eaKey" EvtFunc$( 5 ) = "eaBackG" EvtFunc$( 17 ) = "eaCmd" RETURN eaInit%:( $A000 ) :REM 40K buffer ENDP PROC eaMsg$:( msgid% ) VECTOR msgid% m01, m02, m03, m04, m05, m06, m07, m08, m09, m10 m11, m12, m13, m14, m15, m16, m17, m18, m19 ENDV RETURN "" m01:: RETURN "noasvmicbLefgrkj/zZy*pXx" m02:: RETURN "File" m03:: RETURN "Create new file" m04:: RETURN "Open file" m05:: RETURN "Save as" m06:: RETURN "Use new file" m07:: RETURN "Revert to saved?" m08:: RETURN "Merge in" m09:: RETURN "Find" m10:: RETURN "Search for" m11:: RETURN "Direction" m12:: RETURN "Forwards,Backwards" m13:: RETURN "Case sensitive" m14:: RETURN "Replace" m15:: RETURN "Replace with" m16:: RETURN "(E)End (R)Replace (S)Skip (A)All" m17:: RETURN "%u found, %u replaced" m18:: RETURN " lines" m19:: RETURN " words" ENDP REM Remember that you can add, chop and change these menus as you see fit REM Watch the hotkey->function mapping string above, though! PROC eaMenu:( id% ) IF id% = 1 mCARD "File", "New file", %n, "Open file", %o, "Save as", %a, "Save", %s, "Revert", %v, "Merge in", %m mCARD "Edit", "Insert text", %i, "Copy text", %c, "Bring text", %b, "Highlight all text", %L, "Evaluate", %e mCARD "Search", "Find text", %f, "Find again", %g, "Replace", %r, "Count", %k ENDIF IF id% = 3 mCARD "Special", "Zoom in", %z, "Zoom out", -%Z, "Exit, lose changes", %X, "Exit", %x ENDIF ENDP


-