adjusting line size based on ouput screen in perl - string

I am outputing some text on the screen in perl
However, I want to make sure that only 1 line fits on each screen line thus if I change screen the program would automatically adjust its output line size.
Is there a way to automatically do it without having user-interaction?
Thanks

perl -MTerm::ReadKey -E '($cols,$rows) = GetTerminalSize(); say "This screen has $rows rows and $cols columns."'

On Unix/Linux you should be able to use the Term family of modules to get the current screen size. You can even hook SIGWINCH with it and respond to a terminal window resize event by adjusting your output.
http://search.cpan.org/modlist/User_Interfaces/Term

Related

Can the line spacing or line height be changed?

Is it possible to keep the font the same size and increase the space between lines of text?
I cannot find anything in the configuration settings or in the online handbook.
I'm getting old and have a hard time looking at the code without putting a blank line in between lines, but could get by if I could just increase the line spacing a bit.
If it matters, I'm using Manjaro and KDE.
Thank you.
As of Kate 22.12,1 this feature now exists! See Settings > Configure Kate > Appearance for the Line Height Multiplier setting.
This is an upper bound on the version in which the feature was introduced. It may have been added earlier, but I could not find mention of it in a cursory search of the Gitlab issue tracker.
AFAIK you can affect visible line spacing indirectly by choosing a font with different vertical arrangment. It's not a feature OP is looking for, but should be enough to "just increase the line spacing a bit".
I saved the text file in kate, opened it in LibreOffice, and then used the various "Format" options until the layout looked decent.

How to add some padding at the top?

My current vim setup sticks the first line all the way to the top, so that all the characters are touching the edge. Is there a way to to add a small amount of padding to the top so that the text doesn't touch the top?
Currently it looks as like:

How to make the input and output color different in Terminal?

In Pycharm-run, the input text color is always green and Italic while the output is always in plain text in white, which really helps me to distinguish the input from the output. How do I do that in Linux terminal or in VSCode?
I use Linux mint and i can easily change the color of font , color of palette, output color, size and all by opening the terminal -> Edit -> Preferences. It has all the options .I hope this helps.
open the bash terminal
go to .bashrc using vi or nano
at the end of the file add the PS1
PS1="\e[1;31m\u#\h \W$ \e[0;0m"
This code at the end of the rc file will make your prompt red and bold
There are many ways you can change by manipulating the characters in it.
Here is an useful link: https://phoenixnap.com/kb/change-bash-prompt-linux

Is there a way to set the default size of a plot window?

I would like to change the default size of an R plot window. Does anyone know if there is a configuration setting for this?
Your default size of a plotting window can be set using windows.options() or X11.options() with the width and height parameters. I think setting the defaults using windows.options() also sets them for X11 devices, at least on my windows machine. On Linux, X11 is used as a graphics device and thus you should be able to use X11.options() for your needs. If you want to save these defaults across R sessions, in the examples of http://stat.ethz.ch/R-manual/R-patched/library/grDevices/html/x11.html you can find a way this can be done.
If you want to set the size of the plot window to 600x600, say, add this line to ~/.Xresources:
R_x11*geometry: 600x600
and reload the file with
$ xrdb -merge ~/.Xresources

Win32 DrawText line height

I'm calling the Win32 DrawText function to output some text into a device context. The text is long and wraps nicely onto a second line. The problem is I need to decrease the space between lines a bit (I guess decrease the line height?). Any ideas on how to do this?
I would just call DrawText twice (one for each line) but then I have to do my own word wrap.
Is there any other way?
Thanks
It's been quite a while since I dealt with this on Win32, but I believe the font itself defines the "expected" spacing by defining empty space below the character. Drawtext uses this full "height to position the next line when wrapping. If you want to do something which is not in alignment with this sizing, I believe you will have to do your own wrapping calculations and multiple DrawText() calls.
One possibility is to put the text into a disabled Rich Edit Control. I think that gives you a lot of control over formatting.
If you do write your own word wrap, you probably want to use GetTextExtentExPoint() for measuring how much will fit in each line.

Resources