microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95k stars 8.22k forks source link

Feature Request: Take screenshot of selection/viewport #1084

Open mcpiroman opened 5 years ago

mcpiroman commented 5 years ago

Summary of the new feature/enhancement

You can take a screenshot of whole window with Alt+Prt Scr, but it would be handy if one could do so only on selected text. With box selection this would contain selected area, whereas with regular selection it would contain every selected line.

In profile settings one could be able to choose whether the background of taken screenshot should be the actual displayed background or something else (probably solid color). This would ease making tutorials or reports, when one doesn't want to show what's behind the terminal. Other option could be additional marigin, as so the first pixel of text isn't the first pixel of image.

I'm not sure about appropriate shortcut, meaby some Func+Prt Scr?

Proposed technical implementation details (optional)

I can see this being solved either by taking regular screen shot or re-rendering selected text to buffer. Idk which option's better, but with custom background it seem's like the second one.

DHowett-MSFT commented 5 years ago

Thanks for the request! I think this is largely served by the windows snipping tool, Win+Shift+S, which does a way better job (it's got box selection, lasso selection, a timer, etc.) than we could at a significantly reduced engineering cost. :smile:

I realize that doesn't let you manipulate the background or change the padding, but I'm not certain that the Terminal is the right place to do this work.

I'll leave this open for another team member to comment on.

mcpiroman commented 5 years ago

I should have cleaned out what's the main purpose of this: I do a lot of screenshoting the console with such tools and the main problem is that you have to precisly match the text you want to select. Otherwise you can cut a few pixels of a bottom of a line, or include few pixels of the next line. This is even harder when text begins at first pixel of a terminal window (so 1 pixel to the left and you include sth outside window, 1 pixel to the right and you cut first letter).

With this feature one could easly tripple click whole line (when that's implemented), click some shortcut and he ends up with nice, pixel perfect screenshot.

If this could be done be the screenshot tool aligning to console text, I'd be fine.

miniksa commented 5 years ago

Is this perhaps just another format of data to be put onto the clipboard with Ctrl+C?

plain text, rtf text, html text... and a png?

mcpiroman commented 5 years ago

@miniksa Most probably, but I wouldn't go with Ctrl+C. Or meaby the screenshot (or some other data, like area coords) should be sent to snipping tool.

phuclv90 commented 5 years ago

In general texts should remain as texts. In Word, Excel... or any where you can just paste the text from the console and format as monospaced. That'll make it more readable and you can also zoom without loss of quality

mcpiroman commented 5 years ago

@phuclv90 Although ideally it's true that it's best to store terminal's state as text, it's not always applicable. You can usually just copy the text and style it to look like terminal but that's not so easy (custom font's, terminal's transparent background, emojis), and sometime's your required to provide the actual screenshot, as a prove of doing something (not that it couldn't be deceived). (btw. is/will be multi color text (foreground and backgound) copy supported? If so, is it ms office only format?) Thus I still consider the ability to quickly take a nicely text-aligned screenshot as valuable.

phuclv90 commented 5 years ago

@mcpiroman regarding formatted text some terminals do support copying that. Most often they'll have to put multiple formats in the clipboard (at least text + rtf + html) and the app where you paste will choose the format they want

For auditing it's still better to use some tools like the script command

zadjii-msft commented 5 years ago

I believe @carlos-zamora is already working on HTML & RTF copy/paste, so watch out for PR's in this area soon :)

mcpiroman commented 5 years ago

If accurately styled text copy was a thing, that would definitly cover most use cases of terminal recording, and in more robous way than screenshot. You could even produce html that looks like the terminal window itself, but that's maybe to much ;). One more thing to I'd like to ask is if wouldn't it be relatively easy to expose api which would return screen coordinates of charracters' bounds? That could be eventually consumed by screenshot programs (maybe windows snipping tool) to snap to the text grid. If so, even though text copy is the ideal case, I or others might still find that useful. Ofc that isn't anything critical, I'm just curious.

carlos-zamora commented 5 years ago

@cinnamon-msft and I were actually discussing the possibility of making a setting for triple-click to select "the entire row" vs "the entire viewport". Sounds like you want an actual keybinding though so that shouldn't be too much additional work.

mcpiroman commented 5 years ago

As a note, Markdown (and so GitHub or StackExchange) don't support colorful text (even in html). So for full styling, image is the only option here (AFAIK).

zadjii-msft commented 1 year ago

From #15147: if there's no selection, maybe the action should just export the entire viewport to the image file.

Also noted from discussion: This might be Hard to include all the XAML-y bits, like the background image & acrylic