ComputerCraft

ComputerCraft

21M Downloads

Make Shell scrollable

JakobDev opened this issue ยท 6 comments

commented

It would be good, if you can scroll in the shell on a advanced Computer with the Mousewhell.

commented

That sounds like something easily programmable with moderate difficulty by user. In fact i believe there are some implementations of this already on computer craft forums. I do believe this does make a nice project for end user to make.

commented

So I implemented this for ClamShell:

The implementation isn't too hard: you can just have a "growable" framebuffer, which adds additional lines when term.scroll is used. However, there are a couple of things you've got to think about:

  • What to do about programs which clear or overwrite existing lines. For instance, edit leaves a lot of additional whitespace, and paint will delete previous history. One solution would be something like ncurses' private mode, where the program instructs the shell to draw the current program into a separate buffer, preserving the existing history. ClamShell tries to guess this "private mode", entering it if you call term.clear, but an explicit multishell.noScroll() or something would be better.

  • When do you allow people to scroll up/down? Obviously you don't want to do that all the time as that breaks programs like edit. But again, you should be able to do it within some programs - the Lua REPL would really benefit from scrollback. Clam Shell just overrides read to add scrolling support, but that is a rather ugly solution and doesn't work for some GUI applications which still use read for text input.

commented

I think, that term.clear should clean the history. That would solve the problems.

commented

That wouldn't solve problems, that would just cover them up. What happens with term.clearLine or term.setCursorPos?

commented

I think this was about normal shell not multi shell.
And about adding contents scroll.

commented

Good idea (and i'll merge your PR as soon as you make the small changes you requested)