vatlab / sos-notebook

Multi-language Jupyter Notebook
http://vatlab.github.io/SoS
BSD 3-Clause "New" or "Revised" License
176 stars 17 forks source link

Displaying only the last "screen" #6

Open BoPeng opened 7 years ago

BoPeng commented 7 years ago

Not at all sure if it can be done but one problem with the notebook interface is that the outputs are appended to the output cell and you have to constantly scroll to check the last few lines. Perhaps we can do something like auto-scroll, or show only the last 50 lines of results to give users a familiar "terminal" feeling.

BoPeng commented 7 years ago

There is an extension .. https://www.quora.com/Is-there-a-way-to-configure-Jupyter-notebook-to-auto-scroll-output-cells

BoPeng commented 7 years ago

The key code seems to be something like


        $(".output").on("resize", function () {
            if (!params.scrollDownIsEnabled) return;
            var output = $(this);
            setTimeout(function () {
                output.scrollTop(output.prop("scrollHeight"));
                console.log("height: " + output.prop("scrollHeight"));
            }, 0);
        });
BoPeng commented 7 years ago

The code was for Jupyter 4.x and I have adapted it for Jupyter 5.x.

BoPeng commented 7 years ago

Somehow does not work now.

BoPeng commented 6 years ago

Not sure why but scrolling sometimes work and sometimes not.

import time
for i in range(50):
   sh('ls')
   sh(f'echo {i}')
   time.sleep(0.3)