Pad++ Programmer's Guide
setlanguage
and settoplevel
commands will apply to Scheme as well as Tcl. These commands control which language is to be used.
The setlanguage
command specifies what language is to be used to evaluate all callback scripts that are created in the future. The settoplevel
command specifies what language the toplevel interpreter should use. In addition, the padwish executable has a -language option that specifies what language the interpreter should start using. It defaults to Tcl. The following session trace shows how the two languages work together:
surf[164] padwish -language scheme Real-time image zooming supported. > (+ 2 2) 4 > (pad '.pad 'create 'line 0 0 50 50) 22 > (pad '.pad 'itemconfig 22 '-penwidth 5) > (pad '.pad 'bind 22 '<Enter> "(pad '.pad 'ic %O '-pen 'red)") > (pad '.pad 'bind 22 '<Leave> "(pad '.pad 'ic %O '-pen 'black)") > (settoplevel 'tcl) > % % puts [expr 2 + 2] 4 % .pad create line 0 0 0 50 23 % .pad settoplevel scheme scheme % > > > (exit) surf[165]Adding a new interpreted scripting language to Pad++ requires creating some C++ interface code, and modifying the Pad++ C++ substrate to access that code, and build a new padwish executable. To add a language, several callback procedures must be defined, and then a new instance of the Pad_Language class must be created in tkMain.C. The necessary callback procedures are:
Pad_CreateProc *create_proc;
Pad_CommandProc *command_proc;
Pad_CompleteProc *complete_proc;
Pad_PromptProc *prompt_proc;
Pad_EvalProc *eval_proc;There are several relevant C++ files that should be examined to see how Scheme is currently connected to Pad++. The files are all in the PADHOME/src directory. pad-scheme.C implements all of the callback routines that form the connection between C++ and scheme. script.h declares the Pad_Language and Pad_Script classes. script.C implements those classes. tkMain.C instantiates the Pad_Language class for each available scripting language.
Copyright Computer Science Department, The University of New Mexico