diff --git a/README.md b/README.md index 60aad69..90e2829 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ This is a work in progress spreadsheet program with a semi-limited feature set. In general the use case for _tally_ is small spreadsheets, notes, shopping lists, bills, little bits of relational data. It is not meant to do what Excel, or Calc, or Lotus123 do. It is meant to be a small and simple alternative for small and simple use cases. +![screen shot of tally showing monthly expenses vs income](tally.png) + ## Building / Installing You will need a Go compiler. Testing on eary versions has not been done, but suffice to say you should likely not need the latest cutting edge Go version to compile _tally_. diff --git a/tally.png b/tally.png new file mode 100644 index 0000000..0624416 Binary files /dev/null and b/tally.png differ diff --git a/workbook.go b/workbook.go index a439a5e..8c86536 100644 --- a/workbook.go +++ b/workbook.go @@ -6,6 +6,7 @@ import ( "path/filepath" "strings" "tildegit.org/sloum/tally/termios" + "time" ) const ( @@ -43,6 +44,20 @@ type workbook struct { termCols int } +func (w *workbook) PollForTermSize() { + for { + var cols, rows = termios.GetWindowSize() + if rows != w.termRows || cols != w.termCols { + w.termRows = rows + w.termCols = cols + fmt.Print("\033[2J") + w.Draw() + } + + time.Sleep(500 * time.Millisecond) + } +} + func (w workbook) Draw() { fmt.Print("\033[0;0H") fmt.Printf("FILE: \033[1m%-*.*s\033[0m\n", w.termCols-6, w.termCols-6, w.path) @@ -56,6 +71,9 @@ func (w *workbook) Run() { defer termios.Restore() termios.SetCharMode() fmt.Print("\033[?25l\033[2J") + + go w.PollForTermSize() + var input rune for { w.Draw()