My command-line apps often output brief reports to the console. These reports contains TAB characters. If I later copy the output from the console to a text file, I find that the Windows console converted TAB into spaces.
Is there a setting (or an alternative console I can use in Windows) which actually keeps the TAB character in the console window (so I can copy it), but still displays it as if it corresponds to a certain number of spaces?
Related
I'm programming a script that outputs tab characters. The users of this script expect to be able to copy and paste the output of this script from Windows Terminal into a spreadsheet program, and have the tab characters interpreted as dividers between cells. However, this breaks, because the tab characters get converted to spaces. How can I fix my script to force Windows Terminal to output tab characters instead of spaces?
For example, if I have a Python script that outputs "one\ttwo\tthree", this is what gets output to Windows Terminal:
one two three
The tab characters (U+0009) get converted to space characters (U+0020) by Windows Terminal. If I copy and paste this line into a text editor or a spreadsheet program, it will see space characters, not tab characters, which is not what I want.
As you've confirmed via that Github issue, there's no way to have Windows Terminal itself maintain the tabs (at least not yet). As a programmatic workaround for your script, consider offering the user the ability to output the results directly to the clipboard (assuming the output is "focused"/small enough) using something like this answer (Python-based, since that's the MRE you provided).
The user can, of course, also redirect the output to the clipboard using Windows clip.exe. E.g.:
python3 -c 'print("one\\ttwo\\tthree")' | clip.exe
I confirmed that the tabs are maintained in this case.
Unfortunately, there isn't a way to configure Windows Terminal to preserve tab characters. And I don't think there is a way for a script to force Windows Terminal to preserve tab characters.
See this bug report.
Is it possible to read what's currently displayed on the windows terminal pragmatically using any available API?
For example, I've got an app that tail's some log files. I'd like to be able to hit a key and open a text editor at the line that is currently being viewed. The problem is the terminal also has scroll bars.
Not easy. Perhaps you could capture the screen and use OCR to identify its contents, or make a shortcut to some sort of macro that selects all the screen and copies the text. But there is no API available to perform the task you ask.
Of course, you can tee the command you're running in the console to a file, and open such file with an editor whenever you like, however it will show the full output of the command and not the visible part. If you like more information on that topic, it is answered in SO - Displaying Windows command prompt output and redirecting it to a file
.
I am using VS express 2012 to run a code that display content of many files. I found that first files content do not show and when I debug step by step I found that the content show on the console window and disappear when other results show, which means they get pushed out of the window. of course I scroll up and I find the latest files only not all. Is there any option control this feature? and how can I see all results?
To avoid this you should convert your console application to a Windows Forms one and put all the output on a TextBox. Just execute the command on the Form load and redirect all the output to the TextBox.
It's not much work IMHO.
This is the nature of a console application, no different than if you were to echo data to the Windows command prompt. If there is too much data then of course it will scroll off the visible screen.
When my application logs lots of lines to the Windows console, the first lines disappear and only the the latest lines are shown. Is it possible to get the first logs anywhere? Are they stored on the system anywhere?
Short answer: No.
However, depending on your access and need, you could:
Redirect the output of the application to a file:
myapp.exe 1>logfile.txt 2>&1
Pipe the output through more, to enable page-by-page viewing of the output:
myapp.exe | more
Increase the number of buffered (displayed) lines of your console window:
Open system menu of the command window (CTRL+SPACE) and select Properties and increase the Height of the Screen Buffer Size
Or programmatically: see this answer
What are the three options we see in the debug console in Xcode? Just curious to know why there are three options? What purpose each option serve?
Debugger output is stuff printed by the debugger itself, and target output is what is printed by your application (printf, NSLog, etc).
Perhaps a read through of the Xcode User's Guide would do us all a little good tonight:
The Console Pane
The console pane displays program output and lets you enter commands
to the debugger tool. You specify the type of output the console
displays with the pop-up menu in the top-left corner of the console
pane:
All Output displays target and debugger output.
Debugger Output
displays debugger output only.
Target Output displays target output
only.