Wednesday, September 8, 2010

Visual REPL

Many of the recently successful programming languages have a REPL ("read-eval-print-loop") for experimenting or iterative programming. Mostly these seem to be for dynamic languages, although there is even a C REPL! Almost invariably, these are text-based (with notable exceptions for math systems like Mathematica).

I thought it would be fun to highlight some of the visual aspects of Factor's REPL (called the "listener"). For the examples below, it would be helpful to use these vocabularies first:

( scratchpad ) USING: colors http.client images.http io.styles ;

Styled Text

Print styled text directly to the listener's output. You can change font sizes, foreground and background colors, font family, font style, and other aspects of the text:

Tab Completion

You can get word completion as you write code (by pressing TAB) in the listener:

Word Definitions

You can print the definition of any word using see. In addition, you can click on most parts of the output to link to vocabulary pages, word definitions, etc.:

Helpful Search

Use apropos to search for words, vocabularies, and help articles. It uses some fuzzy completion algorithms to be more helpful for typos or approximations.

Viewing Images

Use the handy images.viewer vocabulary (written by Doug Coleman) to load and display images directly in the listener:


Anonymous said...

For people who are nostalgic for a CLI/text-only Factor REPL, you can start one up typing:

./factor -run=listener

meteore said...

Hi Jon. Thanks for your posts, I enjoy them very much. Do you know how to change the listener´s font?

mrjbq7 said...

@meteore: Thanks! The "default styles" have not been factored out in such a nice way -- for example, see here for code to change the colors to "white-on-black".

If you'd like to try, you can start by looking in To get the input area to be sans-serif, add "sans-serif-font >>font" to the "<interactor>". You can change the completion widget in ui.gadgets.completion by changing the "monospace-font" in "<completion-table>". And, so on... I think you would need to keep exploring and updating the gadgets that you want to change.

It would be great to take the colors patch, and make a similar fonts patch, and contribute it upstream. It's on my list unless someone else gets to it first.