VSC Terminal - GNU Screen number of lines in the history - terminal

I use VSC and "screens" in the Terminal to watch the processes on the server (Node) (https://www.gnu.org/software/screen/manual/screen.html)
Earlier I was able to see many rows in the Terminal, also I was able to search in the console.log() history.
Beacause of an update on the server, the Screen in the Terminal shows only a few rows now (the number of rows that fit on the terminal height only) and the search doesn't work for the whole history.
I set the option "terminal.integrated.scrollback" to 10000, but this doesn't help, because the number of rows depends from the Screen settings.
Can you help me understand what setting should be changed on the server to get many rows of the history in the Screen-> terminal?
(Tried: defscrollback 10000 in the ~/screenrc - doesn't help!).
Thanks.

Related

How to keep terminal input always at bottom in Golang?

I am trying to create a program which will have live updates from some data source. And I also want to wait for user input just like a normal terminal. Right now, whenever there is update, I will print the content and print the prompt message for input again which create something like this:
Enter command >
This is a live update message
Enter command >
This is a multi-line li......
......ve update message
Enter command > quit
Bye bye!
The problem is that for every live message I received, I will print it and the "Enter command >" will be displayed again again and again, which is not desired. I want the live update to be update on the main part of the terminal, while the "Enter command >" always stay at the bottom
The closest package I can found on Github is https://github.com/gizak/termui but most of the examples inside is trying to display text, gauge and graphs. So I am not quite sure how to get started.
Is there any package or example of the termui package to achieve this? Thank you.
With github.com/gizak/termui you're heading in the correct direction.
To understand why you can't get that
I want the live update to be update on the main part of the terminal, while the "Enter command >" always stay at the bottom
part sorted out, a little excursion to the history of computing is due. ;-)
The thing is, the mode your teminal emulator¹ works by default originated
in how computers would communicate to the operator in the era which predated
alphanumeric displays — they would print their responses using a line printer. Now think of it: a line printer works like this: it prints whatever is sent to it on a roll of paper. What was output, was output.
The new output always appears physically below the older.
When alphanumeric displays (screens) came into existence they
naturally continued to support this mode:
the line text to be output was rendered at the bottom of the screen
with the text above it scrolled upwards.
That's what you see in your typical terminal emulator all the time when you're working in the command line of a shell (such as bash) running by the emulator window.
This, default, work mode of a terminal is called "canonical" or "cooked".
Then came more advanced displays, for which it was possible to change
individual positions on the screen — identified by their column and
row numbers.
This changed the paradigm of how the information was output: the concept
of a so-called "full-screen application" was born.
Typical examples of them are text editors such as Vim and Emacs.
To support full-screen text output, terminals (and terminal emulators)
were adapted by implementing certain extensions to their protocols.
A full-screen application first requests the terminal to switch into another
mode called "raw", in which the terminal sends most of what is input by the
user directly to the program running on the terminal.
The program handles this input and orders the terminal where and what
to draw.
You can read this good summary
of the distinction between the both modes.
As you are supposedly suspecting by now, to be able to keep some block
of information at a certain fixed place of the terminal's text screen,
you want your program to be a full-screen program and use the terminal's
raw mode and its special commands allowing you to directly modify
text at certain character cells.
Now the problem is that different terminals (and terminal emulators)
have different commands to do that, so there exist libraries to isolate
the programs from these gory details. They rely on the special "terminal
information databases" to figure out what capabilities a terminal has
and how to make it do what the program asks.
See man terminfo for more background.
The most widely known such library (written in C) is called ncurses,
and there exist native solutions for Go with supposedly the most visible
one being github.com/nsf/termbox-go.
The github.com/gizak/termui makes use of termbox-go but for you it might
suffice to use the latter directly.
¹ Chances are very high you're not sitting at
a real hardware terminal
connected to a UNIX® machine but are rather working in a GUI application
such as GNOME Terminal or xterm or Termial.app etc.
These are not "terminals" per se but are rather
terminal emulators —
that is, pieces of software emulating a hardware terminal.

How to keep same line on terminal top with long output?

Under Ubuntu 14.04, I'm writing a script that output a lot of text (several commands...), and I would like to keep one or more lines always on top of the terminal screen to display what's running title.
In other words, I try to reduce terminal vertical scroll zone and write in that non-scrolling zone.
How can I do that? I saw similar stuff using a loop catching output line by line, but I'm unable to find a way to tell the system to print from let's say line 2 or 3.
Thanks for your answers,
Nicolas
Nic, it appears this does quite nicely.
http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html

ANSI terminal - rewrite the output

i'm working on a new tool which rewrites multiple lines on the terminal BUT not using ncurses. so far it seemed to work great - until i discovered the problem i'm asking about here!
i don't find a way to remove the last 30 rows, if my terminal can only display 20 rows at a time, so the not seen last 10 rows can't be modified. as a result it will produce 10 more output lines on every redraw of my statusbar. if i then use the scrollback of konsole it looks like a mess.
the problem in detail
when i run ./demo2 on a terminal (konsole, xterm like) and everything fits into the viewable area (i got a pretty big screen and resolution on my xserver) everything works as expected, see the screenshots from below.
however, if i shrink konsole, parts of the dynamically rewritten area (it starts with --------------------) are not deleted anymore since the terminal seems unable to reach it for some unknown reason.
https://en.wikipedia.org/wiki/ANSI_terminal says:
CSI n A CUU – Cursor Up Moves the cursor n (default 1) cells
CSI n B CUD – Cursor Down
CSI n C CUF – Cursor Forward
CSI n D CUB – Cursor Back
If the cursor is already at the edge of the screen, this has no effect.
this is exactly what i noticed, it can't be done using these functions. do you have an idea what i could do to fix that?
i tried various other terminal escape sequences and none worked. all i want to do is to rewrite the buffer of what is currently displayed on the terminal.
please note: i know ncurses but i would like to have this functionality without using it.
ideally: the DOM terminal
it would be cool to edit the terminal output like it was a DOM tree. so that i could update single elements like a status-widget. i could then have IDs for single elements and update only these, without touching other elements before or after - ideally not loosing the user's selection (made with the mouse). maybe TMUX is what i want but after looking at that i didn't see how to make it work.
that would pretty much reimplement X-widget style rendering on a terminal!
ideas welcome! ;-)
see my project [demo2.cpp] at:
https://github.com/qknight/nix-build-hack
see the screenshots:
https://raw.github.com/qknight/nix-build-hack/master/screenshot1.jpeg
https://raw.github.com/qknight/nix-build-hack/master/screenshot2.jpeg

Resize terminal from command?

I'm using cygwin but, is it possible to resize the terminal window via a command rather than doing it myself every time I open it? Some scripts I want to be a certain size for my own benefit.
The 'CSI t' sequence can be used for that on xterm-compatible terminals. Search https://invisible-island.net/xterm/ctlseqs/ctlseqs.html for XTWINOPS for details.
For example, to resize to 50 rows and 80 columns.
echo -ne '\e[8;50;80t'
This works for me on bash.exe :
mode.com 80,50
to set 80 columns and 50 rows.
Note that mode and mode.com are not the same in this case.
You can't resize the default terminal, since it's just windows' native 'cmd'. Alternatively, I saw this new addition of late: http://georgik.sinusgear.com/2011/11/23/mintty-resizable-terminal-for-windows/. Not particularly sure whether you can resize that reminal from commandline though. It's still a windows console application.

Setting terminal to show latest output in another color

Is there a way to set the mac terminal to output its lastest output in a different color?
I am tired of wasting time looking for the last command when the terminal gets filled.
No, but you could arrange for your prompt to be in a different color. You could also split the pane; the bottom will scroll with the output while the top stays wherever it was.

Resources