Question: ( @problem 1 ) ;; A * SIMPLE * one line text editor ;; ;; The screen looks like: ;; ;; ab | c ;;
@problem
;; A SIMPLE one line text editor
;;
;; The screen looks like:
;;
;; abc
;;
;; where is the cursor.
;;
;; Typing characters inserts them.
;; left and right arrow moves cursor
;; delete removes character before cursor
@htdw Editor
;;
;; Constants:
define WIDTH
define HEIGHT
define TEXTSIZE
define TEXTCOLOR "BLACK"
define CURSOR rectangle "solid" "red"
define MTS emptyscene WIDTH HEIGHT
;;
;; Data Definitions:
@htdd Editor
definestruct editor pre post
;; Editor is makeeditor String String
;; interp. makeeditor pre post is an editor
;; pre is text before cursor
;; post is text after cursor
define EDmakeeditor
define EDmakeeditor "abc" d
define EDmakeeditor "abcd"
define EDmakeeditor "abcd"
@ddtemplaterules compound ;; fields
define fnforeditor e
editorpre e
editorpost e
;;
;; Functions:
@htdf runeditor
@signature String Editor
;; run an editor, with pre as the initial text preceding the cursor
@templateorigin htdwmain
define runeditor pre
bigbang makeeditor pre
todraw render ; Editor Image
onkey handlekey ; Editor KeyEvent Editor
@htdf render
@signature Editor Image
;; place text with cursor at left, middle edge of MTS
checkexpect render makeeditor abc
overlayalign "left"
"middle"
beside text a TEXTSIZE TEXTCOLOR
CURSOR
text bc TEXTSIZE TEXTCOLOR
MTS
;define render e MTS ;stub
@templateorigin Editor
@template
define render e
editorpre e
editorpost e
Complete render
The starter contains an incomplete function design for render with an example and function template. Please comment out the stub and complete the function definition.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
