How can I add to the terminal's scrollback using ncurses? - ncurses

I'm writing an app using ncurses which displays the status of tests running on multiple machines. It displays several progress bars at the bottom of the screen, and a failure log above them. However, the log may easily be longer than the rest of the terminal.
I'd like to have excess log roll off the top in such a way that if the user scrolls their terminal up they'll see the rest of the log. This is what happens when you scroll through a file using less; it replaces the current view with the next page, but the text you've passed ends up in the terminal's scrollback.
How can I get ncurses to do that?

Turns out this is easy. I just put a window at the top of the screen, made it scrollable (scrollok), and addstr'd text to it until it scrolled. The text scrolled right off into the scrollback without trouble.

Related

vim x/y scrollbar hiding my commands and being really anoying

i'm a new vim user since 2 weeks and i've currently have my biggest trouble for the moment on vim.
i always have a x and y scrollbar on my vim and the x one is very anoying because it cover my commands.
here is a screenshot of the scrollbars that appears when i use terminal inside of vim using `:term` / `:!dir` or even when i save my vimrc or source it (`:so ~/.vimrc`)
if there is any solutions to it i will be really grateful, thanks for reading
This is an issue with your layout settings in Powershell and Ubuntu. Right click on the top bar of either program, go to Properties and then go to the Layout tab. You can check the Wrap text output on resize box and that should get rid of your horizontal scrollbar, thereby allowing you to use Vim as normal. Alternatively, in the same menu, you can decrease the width of the screen buffer size so that it is smaller than the width of the window size.

ST3: Find text results in panel instead of a buffer

I must have hit a setting in ST3 and caused my program to display results in a panel instead of in a buffer. How do I get it back so that find-text results go into their own tab? I've done some digging around but I can't find what I did.
In the Find in Files panel, there is a series of buttons to the left of the Find field, and the right most one of those is the one that controls whether the find results show up in a panel or in a buffer.
Note that the button may look different in your version as it appears that you're using a different theme (the image below shows the default theme). You can verify that you have the correct button based on the tool tip text.

How to center text if there isn't enough newlines to get text to the center in sublime?

While coding in Sublime Text 3 if I get to the bottom of the page and try to use the show_at_center command I won't get able to get the current line all the way up to the center of the page because there isn't enough new lines. So I have to manually hit enter a bunch of times to get the text to come back up. Is there a way around this? Like some sort of command that: moves the text to the center of the screen even if there is only blank space below and no newlines.
Open your user preferences (Preferences -> Settings-User) and add the following setting:
"scroll_past_end": true
This allows you to keep scrolling the view all the way down until the last line is at the very top of the window.

ncurses scroll text contents of window

I'm looking for definitive answers about scrolling methods in a window or pad using ncurses.
I would like to display a stdout stream which quickly fills the number of available lines on the screen and starts to overflow. Using stdio the terminal simply scrolls the contents. But with ncurses as far as I understand the output is only limited to the screen area. Is this entirely accurate?
Is the usual approach then to put the entire contents of stdout into a buffer and then read specific parts of the buffer into a ncurses window or pad? Which other methods are there to scroll text using ncurses?
You may have overlooked scrollok:
The scrollok option controls what happens when the cursor
of a window is moved off the edge of the window or
scrolling region, either as a result of a newline action
on the bottom line, or typing the last character of the
last line. If disabled, (bf is FALSE), the cursor is left
on the bottom line. If enabled, (bf is TRUE), the window
is scrolled up one line (Note that to get the physical
scrolling effect on the terminal, it is also necessary to
call idlok).
Using that, you can write to any window, and have it scroll up—just like stdio.
Further reading:
clearok, idlok, idcok, immedok, leaveok, setscrreg,
wsetscrreg, scrollok, nl, nonl - curses output options
scroll, scrl, wscrl - scroll a curses window
Use scrollok like:
scrollok(win, TRUE);

PyQt QTextEdit text selection without moving the cursor (like ubuntu terminal)

I've developed a shell (imitating the ubuntu terminal --> can only edit text after current prompt) by a PyQt QTextEdit.
The thing is when I select some text, the cursor moves as I'm selecting this text (so it disappers from the current command line) and I would like the cursor to stay where it is (only when I select text because I want it to move when I move it programmatically by textEdit.moveCursor(...)) at the same time I'm selecting the text.
Does anybody have any idea of how could I do that?
My solution for now, is to save the position at any change of it (except when it changes by a click), and when I copy some text en paste it, it'll be automatically pasted in the last position the cursor was before the click. That works perfectly but it's "ugly" for the user because, as I said, when he selects the text the cursor disappears of the current line and is where the user is selecting the text. Not like in ubuntu terminal.
Thanks in advance! And sorry for my english.
Adri
I don't see an easy solution to implement this with a text editor API. A terminal is a hack, basically. It mixes a read-only element (anything above the current prompt) with a text editor.
My approach would be to create two text editors, make one read only and display the results of all operations there. If you hide the borders of the two editors, then it will look like a single one. You may have to forward a bunch of events (like scrolling with the keyboard) to the read-only display.

Resources