Siag

Scheme In A Grid

Copyright © 1996 Ulric Eriksson


Contents


Introduction to Siag

Siag is an X-based spreadsheet for Linux, the only one I know that looks even halfway decent and doesn't cost money. It uses Scheme (a Lisp dialect) both for expressions and as an extension language, which makes it easy to create new functions (for native Lispers, that is).

Siag stands for Scheme In A Grid. It is copyrighted by me, Ulric Eriksson, but is free for use by anybody without paying me any money. Read the file Copying for more information. The latest version is

How to...


Commands


File Menu

The File menu contains commands for opening and saving documents, as well as starting new instances of Siag and exiting running ones.

New

Opens a new empty Siag window.

Open

Asks for a file name and opens the file with that name as a Siag document.

Save

Saves the currently open document using the most recently used filename. If no name has been given to the document, the name "noname" is used.

Save As

Asks for a filename and saves the currently open document using that filename.

Print

Prints a single page using the lpr command.

Exit

Quits from Siag. If there are any changes that have not been saved, Siag asks if they should be saved.

Edit Menu

The Edit menu contains commands for deleting, cutting and pasting, as well as for inserting and removing lines and columns.

Delete

Delete the contents of the current cell.

Insert Line

Insert a line into the document, shifting the rest of the document down.

Label

Asks for a label to insert into the current cell.

Expression

Asks for an expression to insert into the current cell.

Block Menu

The block menu contains commands to manipulate the rectangular area of the document which is called the block.

Set Mark

Moves the mark to the current cell.

Set Block

Sets the block to be the rectangular area between the mark and the current cell.

Copy Block

Copies the contents of the block to the area to the right and below the current cell.

Delete Block

Deletes all the cells in the block.

Format Menu

The format menu contain commands that control the appearance of the cells, on the screen as well as on paper.

Column Width

Sets the width in pixels of the current column.

Row Height

Sets the height in pixels of the current row.

Cell Format

Displays a dialog which allows setting a number of options for the current cell.

Keys

Although some commands are available on the menu, it is faster in the long run to use the keyboard to control Siag. Here are the standard keybindings.

Home
Move to column 1 on the current line.
End
Move to the last used cell on the current line.
x
Moves the mark to the current cell.
Arrow Keys
The arrow keys work the way one would expect them to, moving the current cell one step in the indicated direction.
g
Ask for two numbers and jumps to those coordinates.
o
Asks for a file name and opens the file with that name as a Siag document.
s
Saves the currently open document using the most recently used filename. If no name has been given to the document, the name "noname" is used.
W
Asks for a filename and saves the currently open document using that filename.
q
Quits from Siag. If there are any changes that have not been saved, Siag asks if they should be saved.
v
Copies the contents of the block to the area to the right and below the current cell.
V
Copies the contents of the block in such a way that overlapping areas are handled properly.
X
Swaps point and mark.
Esc
Asks for the name of a command to execute. This is useful for commands that do not have keybindings or that take arguments.
"
Enter a label into the current cell.
=
Enter an expression into the current cell.
!
Recalculate all the cells in the document once. For documents that contain circular references, this may have to be repeated. Ideally, there should be an option to always automatically recalculate the cells, but that is yet to be implemented.
PgUp
Move the document up one windowful.
PgDown
Move the document down one windowful.
b
Move the document left one windowful.
f
Move the document right one windowful.
P
Move point to line one.
N
Move point to the last used line.
?
Prints information about the contents of the current cell.
Space
Moves mark to the current cell.
F1
Prints version information about Siag.

Concepts

label
A descriptive text in a cell that is not used for any calculations.
expression
A string in a cell which evaluates to a (floating point) numeric result. The simplest expression is a number; more complicated expressions can be entered in Scheme syntax.

The Scheme used in Siag has a few extensions to make it more useful in a spreadsheet. These new functions have been added:

  • (row) Returns the row number of the cell which is being computed.
  • (col) Returns the column number of the cell which is being computed.
  • (get-cell row col) Returns the contents of the cell with the given coordinates.
  • (sum start end) Returns the sum of all the cells in the rectangle between start and end.
mark
The "other" standard position in the document, which is used for commands which need two coordinates.
current cell
The cell where labels and expressions are entered. The current cell can be moved using arrow keys, the mouse and other methods.
block
The block is a rectangular area which is displayed in inverse. It is used for commands which operate on a whole range of cells.

Scheme

Siag uses Scheme for commands and expressions. This means that the program can be easily extended with new functions. When Load is chosen from the File menu, for instance, the Lisp function (load-buffer) is called. It is thus possible to make File - Load do something completely different by writing a new load-buffer function, perhaps adding the ability to read other file formats.

Functions available as commands

(backward-cell)
Move point one cell to the left.
(forward-cell)
Move point one cell to the right.
(next-line)
Move point one line down.
(previous-line)
Move point one line up.
(beginning-of-line)
Move point to column 1.
(end-of-line)
Move point to the last used cell in the current line.
(beginning-of-buffer)
Move point to column 1, line 1.
(end-of-buffer)
Move point to the last used cell in the last used line.
(top-of-buffer)
Move point to line 1 without changing the column.
(bottom-of-buffer)
Move point to the last used line without changing the column.
(scroll-up)
Move the window up one windowful.
(scroll-cell-up)
Move the window up one line.
(scroll-down)
Move the window down one windowful.
(scroll-cell-down)
Move the window down one line.
(scroll-left)
Move the window left one windowful.
(scroll-cell-left)
Move the window left one column.
(scroll-right)
Move the window right one windowful.
(scroll-cell-right)
Move the window right one column.
(what-cursor-position)
Prints information about the contents of the current cell on the status bar.
(delete-cell)
Delete the contents of the current cell.
(insert-line)
Insert an empty line, moving the rest of the document down.
(edit-label)
Create a label in the current cell.
(edit-expression)
Create an expression in the current cell.
(set-mark-command)
Move mark to the current cell.
(exchange-point-and-mark)
Swap point and mark.
(kill-region)
Should delete everything between point and mark for compatibility with Emacs, but currently does nothing. Block commands are available for that purpose.
(copy-block)
Copy the block to the rectangular area with its top left corner in the current cell. If the block overlaps the destination area, useful fill operations can be achieved.
(intelligent-copy-block)
Copies the block in such a way that overlapping areas are handled correctly.
(delete-block)
Deletes all the cells in block.
(print-block)
Dumps the block to a text file.
(set-block)
Sets the block to be the area between mark and point.
(save-block-file)
What does this do?
(new-siag)
Loads a new Siag window.
(load-buffer)
Loads a Siag document into a new buffer.
(save-buffer)
Saves the current buffer as a Siag document.
(save-buffer-as)
Saves the current buffer using a new file name.
(print-version)
Prints version information on the status bar.
(help-contents)
Starts the Siaghelp program with siag.hlp as argument.
(help-search)
Search for keyword. Currently not implemented.
(help-for-help)
Starts the Siaghelp program with siaghelp.hlp as argument.
(recenter)
Redraws the screen.
(recalc-matrix)
Recalculates all the cells once. If the are circular references, this may need to be repeated.
(execute-extended-command)
Read and execute a Scheme command.
(keyboard-quit)
Abort a multi-key command sequence.
(quit-siag)
Exit from Siag. If there are any unsaved changes, asks if they should be saved.
(no-op)
Does nothing. Sometimes useful for debugging.

Functions available for expressions

In addition to the ordinary Scheme syntax, these commands are available to make life in a spreadsheet easier:
(row)
Returns the row number of the cell which is being computed.
(col)
Returns the column number of the cell which is being computed.
(get-cell row col)
Returns the contents of the cell with the given coordinates.
(sum start end)
Returns the sum of all the cells in the rectangle between start and end.
There are also bindings to a number of standard floating-point functions. There are three ways to execute Scheme code:
  1. Enter it as an expression in a cell
  2. Pressing Esc and typing it in the input window
  3. Loading it from a file using (load "filename")
A special case is the file .siagrc which is always read from the user's home directory on startup, if it exists.

There is no difference between functions that are intended for commands and those that are intended for expressions. It is quite possible to enter the function (forward-cell) into a cell, making the point move forward every time the sheet is recalculated. It is also possible to make the program compute the sum (+ 1 2) every time a certain key is pressed. Not very useful (except for debugging), but possible.


Ulric Eriksson - January 1996 - ulric@asogy.stockholm.se