shithub: spread

ref: af8848cfc823ec9fb1590bb16a2804bc6e1a714d
dir: /README.md/

View raw version
Spreadsheet Editor

This program builds around hoc(1).


# Spreadsheet files

They are divided into two blocks, separated by a line containing three `%`:

1. hoc script. Loaded verbatim to hoc. Use this to add functionality.
2. cells and cell contents.

A sample file could look like this:

	func t(a) {
		print a
	}
	%%%
	A1=3
	A2;hello
	A3=5
	A4=A1()+A3()

The general syntax of cells should be quite obvious, but it's worth noting
that cells divided by an `=` sign will end up being calculation functions,
while cells divided by a `;` sign are string literals. Both will end up
being hoc functions.

# Usage

	spread [-di] file

- `file` will be loaded as a spreadsheet
- `-d` enables extra debug output
- `-i` opens spread in CLI mode (see below)

# Modes

## GUI mode

### Mouse control

- RMB click on a cell to edit it
- Math cells that refer to other empty math cells generate those
  cells automatically, with a default value of `0`. This will
  overwrite existing text cells!

### Keyboard control

- Use the arrow keys (←↑↓→) to scroll
- Use `q` or `DEL` to quit
- Every other key input [A-Za-z0-9] opens the command line

### Command line

- `w [file]` - save to file (without file: save to original file)
- `s addr` - open the edit dialog for cell addr (addr be like: B5)
- `gg` - go to A1
- `g addr` - go to addr. This scrolls so that addr is in the top left corner
- `m` - toggle math mode. Math mode displays non-math cells in a greyed out state

### Edit dialog

This is a simple text entry box for the specified cell.

- To enter a function, start the line with an `=` sign.
- To enter a string/text, don't start the line with an `=` sign.

Simple as that.

## CLI mode

For now, this opens a direct channel to hoc. All commands entered will
be forwarded to the hoc process unchanged.

Example session for previous example program:

	A4()
	→ 8
	A1()
	→ 3
	A1()*A3()
	→ 15
	A1()+2*A3()
	→ 13

# Open questions

## Hoc limitations

- Range support. Since hoc doesn't support something like `eval`,
  it is impossible to support ranges (`A3()..A5()`) out of the box.
  If we need ranges we need to find a good solution or at least a
  solid workaround, like building a list dynamically.
  At the moment, I'm thinking about implementing a preprocessor that
  transforms snippets like `[A1()+A5()]` to `A1()+A2()+A3()+A4()+A5()`.
  Same should work for `[A1()*A5()]` etc.

## Bugs

Sure, there are many. Known issues are:

- Cyclic dependencies are not allowed, I added come rudimentary check
  that could leak some memory.