nsf / termbox-go

Pure Go termbox implementation
http://godoc.org/github.com/nsf/termbox-go
MIT License
4.67k stars 373 forks source link

Save current history/screen in plain text #239

Closed pedroalbanese closed 3 years ago

pedroalbanese commented 3 years ago

Greetings!

I have a problem with a program that uses this library, https://github.com/howeyc/sc. I actually discovered that it was discontinued. I need the command W (save in flat text) that was not implemented and the author does not intend to implement.

I would like to know if it is possible to save the contents of the terminal in flat text (I can not print with the open program). I need to only implement this function.

How to print the terminal content without use of mouse, with open application?

Thanks.

scrouthtv commented 3 years ago

Do you only want to export what is currently visible on screen?

Recently, I added GetCell, which allows for reading a single cell from the screen. The easiest way for API users would be something like this:

w, h := termbox.Size()

for x := 0; x < w; x++ {
  for y := 0; y < h; y++ {
    file.Write(termbox.GetCell(x, y).Ch)
  }
  file.Write('\n')
}

If you're familiar with Go, you could simply clone sc and implement the functionality yourself. If you're not, let me know and I'll do it

scrouthtv commented 3 years ago

Try cloning https://github.com/scrouthtv/sc, checking out feature/save and running it. If you press W, it exports the current screen to /tmp/hello.

Is this kind of what you want?

pedroalbanese commented 3 years ago

Hi, I greatly appreciate the speed in replying. Briefly, in the original SC there is a function that prints only the calculated table in plain text (https://www.linuxjournal.com/article/10699). The sc tool in golang is great, but it prevents us from exporting calculations. The author does not intend to implement..

I need more precisely the W command from the original SC program, to save the precomputed table. I'm not a Linux user and I'm new to Go, I needed this to run on Android and Windows which I can't cross-compile the C version for because of libncurses..

Thanks!

scrouthtv commented 3 years ago

You want to export the entire spreadsheet / table that is currently opened - including content that is currently off-screen?

So basically you want sc's P command, but the exported file should contain the calculated values and not their formulas.

This repository is about termbox, a Go alternative to ncurses. Your issue is more of an issue with sc, let's move over there.