How can I get colored output in VS Code output window? - visual-studio-code

This is really a two part question, but they are in the same vein, so I will ask in one post.
When I flip through various colors, I see that they also have the ability to change the color of the Output window. Which VS Code setting can I use to change the color of this output? To be specific, I am not asking about the terminal, I am inquiring about the output window that displays the output when using coderunner as an example. Please refer to the screenshot to see which window I am referring to.
Second question is I can see that the output does support multiple colors. I am trying to use the module cpprint from the python lib prettyprinter to print colored output to this window. When I run the script in a terminal, I am getting colors, but in the output window, I am not getting any colors. Will it be possible for me to get similar colored output in the output window as in the terminal? I am assuming the output window supports colors because the [Running]... and end are in colors.
The Python lib I was referring to
Thanks!

So, for long while now, we have had to resort to an IBM developed extension named Output Colorizer, however, this extension clashed with other extensions, and cuased an array of bugs/issues. I personally had to disable it because it was causing text to not print at all in my output window.
We now have a much more robust, built-in solution, and it doesn't require doing anything.
Visual Studio Code added syntax-highlighting support to the "Output Channel" as part of a Milestone that it had been working on, in its March 2022 Release.
The syntax highlighting is configured by a specified languages grammar.
The language grammar that is used will vary, depending on which output channel you use. The person who decided on the language syntax highlighting used for any given output-channel is the person who authored the extension that the output-channel belongs too.
Here is the link to the official release note
Because the output highlights syntax on a language basis, configuring what colors the new feature uses to color any given text, is done the same way you color syntax.
In Depth Explanation:
If numbers are set by your theme to render green (#00FF00), then, then numbers that are printed in the Output View Panel will also be green.
If the language defined constants true & false render as a pastel-red (#FF7799) when you are writing TypeScript, but when you have a Java file open, they render as a bright pastel-yellow-green (#BBEE88), then the way they render will be contingent on whether or not the output window was set to Java or TypeScript. Obviously an output window for an extension that's a tool for Java, will most likely highlight syntax as Java. A typescript-tool extension will likely highlight all syntax as if it were typescript.
Some People Might Prefer that the Feature be more Customizable
Some people might want a more customizable feature, but I think it would be a mistake, even if it were possible, to highlight the syntax in the output differently from the editor. In fact, thinking about it, it would be stupid to have done that. It makes perfect sense that it is the way it is.
Anyways, that is the end of the Color in the Output Channel, or at-least for now.

Related

Formatted text in the command window

I know of the cprintf Undocumented Matlab way of changing the color and other font properties in the command window but I also saw this symbols in plots. This shows that Matlab supports TeX markup in plots at least. I played with it for a while and found it very useful. So much so that I wanted to find a way to include this in the command window.
I first tried sprintf('\color{red} Something\n') and was rewarded with an error that \c is not a recognized escape sequence. Google was no help either.
This is a way to use the some of the other formatting options in the command window?
The command window doesn't support TeX. Sorry. The TeX support is part of the routines that generate the figures, not the code that displays the command window.
In essence, the command window is, by modern standards, a pretty boring terminal emulator. There's not much you can do with it.
If you're looking for something to do math in that generates fancy notebooks on the fly that combine the commands you type and their results in a nice-to-read, modern way, you might just want to avoid Matlab and have a look at Jupyter (formerly IPython) Notebooks, which of course support MathJax (and thus, LaTeX math syntax): https://try.jupyter.org/

Notepad++ and autocompletion

I'm using mainly Notepad++ for my C++ developing and recently i'm in need for some kind of basic autocompletion, nothing fuzzy, just want to type some letters and get my function declaration instead of having a manual opened all of the time..
The integrated autocompletion feature of my Notepad++ version (6.9.2) gives the declaration of basic C functionality like say fopen and parses my current file user defined functions, but without declaration.
I guess it's normal for a text editor to not give easily such information since it has nothing to parse i.e. other files where your declarations are (as it's not an IDE), but i don't want either to mess again with MSVC just for the sake of autocomplete.
Is there an easy, not so-hackish way to add some basic C++ and/or user defined autocomplete?
UPDATE
Adding declarations the "hard way" in some file cpp.xml is a no-no for me as i have a pretty big base of ever changing declarations. Is there a way to just input say some list of h/cpp files and get declarations? or this falls into custom plugin area ?
Edit the cpp.xml file and add all the keywords and function descriptions you'd like. Just make sure you add them in alphabetical order or they will not show up.
Another option is to select Function and word completion in the Auto-Completion area of the Settings-->Preferences dialog. NPP will suggest every "word" in the current file that starts with the first N letters you type (you choose a value for N in the Auto-Completion controls).

command line drawing unicode boxes for a graph

I don't know what the correct keywords are for what I am trying to achieve.
I have rainbarf for tmux which AFAIK is written in Perl.
I am wondering if there is some library, extension or functionality in node.js which would enable me to draw bars like the ones rainbarf draws, in order to write tmux monitors (wifi, GPU usage, etc).
Edit
I think that the correct term is unicode boxes as I have finally found a page that documents them.
They seem to be unicode geometric shapes So I am guessing that correctly printing them to screen (assuming the terminal supports them) should achieve the same result?
They appear to be small pixel-sized boxes constrained by the size of a font.
rainbarf is inspired on spark. There are several implementations of spark in JavaScript (and also other languages), check here: https://github.com/holman/spark/wiki/Alternative-Implementations
I found the answer to my question.
This is not related to Node.JS and is in fact simple unicode character printing.
The above picture simply prints a sequence of those characters in a sequence:
'\u2581','\u2582','\u2583','\u2584',
'\u2585','\u2586','\u2587','\u2588'
This in effect produces the "unicode" graph.
It is not language specific, but the colors are.

Using emacs in batch mode to dump a file with syntax highlighting?

I'd like to use emacs in some kind of batch mode to just render a file with syntax highlighting and exit. Specifically, I want to dump the fontified buffer with ANSI escape codes so that it shows up reasonably syntax-highlighted on my terminal. Is there any way to do this?
The ansi-lpr.el library seems to be kind of along the lines of what I want, but the output isn't colorified. I can't figure out how to get over that final hurdle — there are a lot of modules to digest ANSI escape codes into Emacs text properties (e.g. ansi-color.el) but I haven't found anything that does the reverse. If anyone can point me to something that does, I think I can piece together the rest.
Alternatively, I've seen some hacky approaches like this answer (using script and capturing the output) but in my experiments that approach has seemed unlikely to be fruitful — you get tons of undesirable control sequences mixed in with the highlighted text.
The overarching motivation here is to use emacs in a $LESSOPEN pipe to get syntax highlighting when I page files. In case you're going to say it, I've tried and "just page files in Emacs" is not acceptable for me.
I'm glad to announce a new package, e2ansi, that (hopefully) does what you asked for.
The package provides a command-line tool e2ansi-cat that starts Emacs in batch mode, opens files, syntax highlight them (using font-lock), and creates ANSI-colored versions of the syntax highlighted files.
You can integrate this into less by setting the following variables to, for example:
export "LESSOPEN=|emacs --batch -Q -l ~/.emacs -l bin/e2ansi-cat %s"
export "LESS=-R"
export MORE=$LESS
The end result looks like the following:
You can vary the colors and attributes like bold, underline, and
italics by using a suitable Emacs theme.
The e2ansi package is located at https://github.com/Lindydancer/e2ansi
Personal note
I would like to thank you for posting this question, it directly inspired me to write e2ansi.

Get current terminal color pair in Perl

I'm trying to learn about color text in a terminal window. (In case it matters I'm using Terminal.app on OS X.) I'd like to get the terminal's current foreground and background color pair. It looks like I should be able to get this info in a perl script using the Term::Cap library, but the solution eludes me.
In a perl script how would I query the terminal's current foreground and background color pair value?
The feature is outside the scope of terminfo and termcap, because it deals with terminal responses, while terminfo/termcap describe these capabilities:
how to tell the terminal to do some commonly-implemented feature (such as clearing the screen), or
what sequence of characters might some special key (such as Home) send from the keyboard.
While in principle, there is no limitation on what could be part of a terminal description, there was little commonality across terminals back in the 1980s for responses. A few terminals could report specific features, most of those were constant (e.g., version information). Most of the variable responses came after terminfo/termcap had more or less solidified in X/Open Curses. ncurses extends that, but again, most of the extensions are either features or special keys.
Terminal.app implements the most commonly-used features of xterm, but (like other imitators) omits most of the terminal responses. Among other things, xterm provides terminal responses which can tell an application what the window's colors are currently. There are a couple of command-line utilities (xtermset and xtermcontrol) which have been written to use this information (and again, they cover only a part of the repertoire). Using xtermcontrol demonstrates that Terminal.app is lacking in this area — see screenshot:
I don't think most terminals support reporting this -- and it doesn't look like termcap or terminfo have any entries for it. You're just expected to set the color pair as necessary, not to ask the terminal what it's set to right now. In the ECMA-48 standard (better known as "ANSI" after ANSI X3.64, where it used to live), the only command that makes reference to color is SGR "Set Graphic Rendition", which is purely write-only.
Dunno about perl or Terminal.app, but xterm etc will write foreground/background color control sequences to stdin if you output "\033]10;?\07" or "\033]11;?\07" respectively. Check out http://invisible-island.net/xterm/ctlseqs/ctlseqs.html, http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Controls in particular.