Adds terminal resizing and a screen shot

This commit is contained in:
sloum 2021-03-29 20:34:13 -07:00
parent 722db53a9c
commit ffb90d269f
3 changed files with 20 additions and 0 deletions

View File

@ -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_.

BIN
tally.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File

@ -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()