Classic Computer Magazine Archive COMPUTE! ISSUE 78 / NOVEMBER 1986 / PAGE 8

Reversing SpeedScript

Until recently, many of COMPUTE!S foreign readers could not use SpeedScript because their languages use a different form of letters. That problem was solved by Charles Brannon's "SpeedScript Fontmaker" (COMPUTE!, January 1986), which allows you to create your own custom character set. I'm sure that this program has made it possible for a large number of foreign readers to use this superb word processor. There are, however, some readers who still can't use SpeedScript—those from Israel and the Arabic countries. In those languages, writing proceeds from right to left, so a word processor whose cursor moves left to right is of little use. Can you make another small step (at least, I think it's small) and add a subroutine which permits us to write either from right to left or left to right?

Dov Ratzman

You're correct in your suspicion that the problem isn't as simple as it first seems. The direction of writing is far from a mere cosmetic feature of SpeedScript: It's bound up with the fundamental structure of the program. To explain, at the heart of SpeedScript is a routine labeled Refresh, which redraws the entire screen display every time you press a key. In essence, Refresh scoops a screen-sized chunk of text from the text portion of memory and displays it in the computer's screen memory area.

SpeedScript's text memory begins immediately above the end of the program itself. As you type in more characters, the text grows upward into higher memory locations. Screen memory is also arranged sequentially, with lower memory locations at the upper left corner of the screen and higher locations toward the bottom. A higher location in text memory corresponds to a higher location in screen memory. To display a screenful of text, SpeedScript moves characters one by one from a section of text memory into screen memory, automatically wrapping words which overlap the right screen border, until the entire screen is full. Since the Refresh routine is called so often, it must also be very fast.

To write from right to left, you would need to begin by rewriting the Refresh routine to display words in right to left order. Such a change destroys the simple, lower-to-higher correspondence between text memory and screen memory. In itself, the modification isn't impossible. However, it would add significantly to the size and complexity of Refresh and slow the routine somewhat.

Once Refresh had been rewritten, you would also need to rewrite all the routines that move the cursor from one character, word, sentence, or paragraph to another. Under the present scheme, moving the cursor forward (right) moves you forward in the text, which corresponds to a higher location in both text memory and screen memory. In a right-to-left SpeedScript, moving the cursor forward (right) along a screen line would move you forward (higher) in text memory, but backward (lower) in screen memory. When you hit the end of the line, you would need to jump to a higher screen memory location, without changing your location in text memory, and begin working your way backward (down) to the next line. Word-wrap, in particular, becomes much more difficult to implement under such circumstances.

Of course, if text is displayed from right to left, you'll want to print it the same way. A surprisingly large portion of SpeedScript involves printed output—which includes printing to disk, tape, or the screen, as well as with a printer. Rewriting these routines creates the same type of difficulties outlined above.

In short, what seems like a small change adds up to a very ambitious programming project which would change the size and location of nearly every routine in the program. In the past few years, we've published a number of SpeedScript enhancement programs such as "SpeedView" (elsewhere in this issue) and "SpeedCheck," the spelling checker (COMPUTE!'s GAZETTE, December 1985). Those programs, and the various modifications which have appeared in this column, depend on the fact that you can find certain parts of SpeedScript at certain locations in memory. Modifying SpeedScript to display text from right to left would render most, if not all, of those programs and enhancements useless.