Logo

» About

» Downloads

» GitHub

» GitLab

Mottek Blog

» Mottek

» Archive

2024 2023 2022 2020 2019 2018 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 2005 2004 2003

RSS

Developing Newton apps with Einstein, TextMate and tntk

Developing Newton apps with Einstein, TextMate and tntk

In this post I want to describe my setup for developing Newton apps on Mac OS X using Einstein , TextMate and tntk.

Einstein is working very well as a replacement for an actual Newton during development. An important enabler is the AppleScript interface, which allows “remote controlling” the emulator. TextMate is my editor of choice for other development projects already, and extending it to support NewtonScript and interfacing with Einstein is very easy. And finally, tntk is able to generate Newton packages of reasonable complexity if certain limitations are kept in mind.

Setup

Setting up Einstein is straightforward, and instructions on getting a ROM file are just an internet search away. I’m using the the same screen resolution on the emulator as on an MP2100, and I install a list of very useful packages:

Unfortunately, BugTrap is not able to save trapped errors to the Notepad, but it is possible to use ViewFrame’s intercept functionality to break on exceptions, which is a very good replacement.

tntk does not need much setup, it just has to be somewhere in the path on Mac OS X, e.g. copied to /usr/local/bin or /usr/bin. The usage of standard NewtonOS elements like protos and constants requires a platform file, which is part of the Newton Toolkit (found in the Platforms folder after installing the NTK on the Mac and named e.g. Newton 2.1).

I’ve created a NewtonScript bundle for TextMate (a current snapshot can be downloaded from the git repository on SourceForge, the unpacked folder has to be renamed to NewtonScript.tmbundle) to enable syntax highlighting and simplify package compilation and installation. Package installation is not very elegant yet, it requires a small AppleScript named Install.scpt in the same folder where the source files under development are located. I am using right now a package specific script, but it could possibly also be simplified (Package name, symbol and path need to obviously replaced with real values):

tell application "Einstein"
	do newton script "GetRoot().%<package symbol>%:Close()"
	do newton script "SafeRemovePackage(GetPkgRef(\"<package name>\", GetStores()[0
]))"
	install package "<path to package file>"
end tell

It closes the application running in Einstein, removes the package, and then installs the new package. The TextMate bundle is configured to run the script via the shortcut Command-Shift-B.

Usage

The development cycle using tntk and Einstein is slightly different from using the NTK. One major difference is the absence of the Inspector, but ViewFrame is a very good replacement, and in some areas even superior. One big advantage is the ability to use standard source code version control systems since tntk uses text files. It has always bothered me to not have good change control when developing Newton applications.

Converting existing Newton applications is not straightforward, but possible if the original NTK project is available. The NTK allows saving the project as a text file, which can be modified into a tntk compatible source file. In general, the original developer documentation by Apple is an excellent resource to get started, and ViewFrame is very useful in understanding the inner workings of applications.

Happy hacking!

2011-01-16