[HN Gopher] Windows Terminal Source Code
___________________________________________________________________
Windows Terminal Source Code
Author : anderspitman
Score : 79 points
Date : 2022-05-11 17:53 UTC (5 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| nyolfen wrote:
| winterm looks very nice but it often screws up character
| alignment if you resize the window. it happens so frequently that
| i gave it up, because at least once a day i could no longer tell
| what i was typing or trying to copy. i'm a happy customer with
| alacritty windows builds, but i wish it had tabs.
| dpool wrote:
| You're probably already aware of this, but just in case you're
| not (or someone else reads this that's curious), running tmux
| (src: https://github.com/tmux/tmux/wiki) inside alacritty will
| give you tab functionality along with the ability to
| horizontally/vertically split and a host of other fun features.
| nyolfen wrote:
| yes, i'm still a tab clicker though :)
| Lammy wrote:
| Here are all the ways it spies on you:
|
| https://github.com/microsoft/terminal/search?q=Telemetry%3A%...
|
| https://github.com/microsoft/terminal/blob/main/src/host/tel...
| whywhywhywhy wrote:
| ok, what do those do?
| foolfoolz wrote:
| tell microsoft when you're using features. presumably because
| they have a culture of metrics and every feature is required
| to have data on its usage patterns
| nojito wrote:
| It's just used to drive improvement efforts rather than
| focusing on features + bugs no one cares about/uses.
| rolph wrote:
| i read the code , they take usage data points build a logfile
| and wait for a request to retrive.
| Lammy wrote:
| There are some pretty detailed comments on many of them if
| you click through to their call sites, and more can be
| inferred from the file names of the callers.
|
| Let's take a look at `windowio.cpp` for example. This most-
| generic event fires every time you type any input character
| on the keyboard: https://github.com/microsoft/terminal/blob/5
| 7c3953aca49f68ac...
|
| It also has more-specific events for several different ways
| of selecting, copying, and pasting text: https://github.com/m
| icrosoft/terminal/blob/57c3953aca49f68ac...
|
| In `find.cpp` we can see it log every time you find the next
| result in the "Find" dialog, as well as when the dialog is
| closed: https://github.com/microsoft/terminal/blob/57c3953aca
| 49f68ac...
|
| In `windowproc.cpp` we can see it log every time you resize a
| console window, close a console window, bring up the context
| (right-click) menu, drag-and-drop on to a console window:
|
| - https://github.com/microsoft/terminal/blob/57c3953aca49f68a
| c...
|
| - https://github.com/microsoft/terminal/blob/57c3953aca49f68a
| c...
|
| - https://github.com/microsoft/terminal/blob/57c3953aca49f68a
| c...
|
| - https://github.com/microsoft/terminal/blob/57c3953aca49f68a
| c...
|
| This even extends outside the "Terminal" application wrapper
| itself, with a generic "LogApiCall" used to track e.g. any
| time any other process spawns a console window:
|
| - https://github.com/microsoft/terminal/blob/57c3953aca49f68a
| c...
|
| - https://github.com/microsoft/terminal/blob/57c3953aca49f68a
| c...
|
| Click around a few of the search results and see what else
| you can find!
| Genbox wrote:
| What you are stating is incorrect.
|
| Each of the calls you link to sets a boolean here: https://
| github.com/microsoft/terminal/blob/57c3953aca49f68ac...
|
| It does not transmit what you copy, search for or when you
| clicked/resized/closed the window. It simply stores a
| true/false value saying "feature X was used". In some
| cases, like with find/replace, it also stores the average
| length of things you searched for. That is a common way for
| developers to get an idea if performance characteristics
| due to the longest common substring problem[1]
|
| You are trying to spread misinformation here to make
| Microsoft look like a bad guy. There is nothing sinister
| going on here, it is just ordinary metric collection.
|
| But don't take my word for it. Take for example the "we can
| see it log every time you resize a console window"
| statement. In the link it calls SetWindowSizeChanged()[2]
| which again calls SetUserInteractive()[3] and it just sets
| a boolean to true.
|
| So there is no "log every time it resize a console window".
| It simply sets a variable to true, which presumably the
| Windows Terminal dev team use to see how many users use the
| console with interactive sessions.
|
| [1] https://en.wikipedia.org/wiki/Longest_common_substring_
| probl...
|
| [2] https://github.com/microsoft/terminal/blob/57c3953aca49
| f68ac...
|
| [3] https://github.com/microsoft/terminal/blob/57c3953aca49
| f68ac...
| eecc wrote:
| I'm frankly shocked for the level of triviality of this
| code: and endless series of if/else while I've been
| stressing about reactive, typeclasses and whatnot for the
| past 5 years. And I frankly prefer the latter
| mftb wrote:
| Thanks for doing this. Looking over some of the actual call
| sites and there commentary was interesting.
|
| For all the folks who say it's all totally innocuous (or
| even beneficial). Even if it is, I can tell you, I have no
| interest in my computer doing this while I'm using it.
| donmcronald wrote:
| I've always wondered what the performance impact is.
| Windows 10 feels so slow compared to Windows 7 and
| earlier that I'm constantly wondering how much of my life
| is being allocated to telemetry.
| mftb wrote:
| Not sure but it's a reasonable question. I'm willing to
| give MS the benefit of the doubt and guess that they have
| generally implemented it in as light a way as possible,
| but that said sometimes it probably causes dire
| performance problems to outright breakage. For me it's
| largely academic at this point, but it's another reason
| to be happy I moved my main workstation off Windows.
| sirsinsalot wrote:
| You're willing to give MS the benefit of the doubt? I
| remember the bad old days and they no longer have this
| luxury from me.
| mftb wrote:
| Understood and when I was being forced to deal with it
| more often, I was not feeling so magnanimous either.
| assttoasstmgr wrote:
| Say what you will about Microsoft but they put a
| substantially more amount of comments in their code, as
| compared to say, GNOME Terminal.
| ossusermivami wrote:
| as a software dev you know that soft anonymous telemetry of how
| a user use what you do is very valuable to make decision on how
| to make things....
|
| I wish there was way everywhere to collect with privacy and
| being accepted by user as not something we want to spie people
| on... but as always there is (a lot ) of abuse in this area so
| this may never going to happen
| voidfunc wrote:
| The horror!
| kingcharles wrote:
| Compile it without those functions?
| [deleted]
| Melatonic wrote:
| While I am not a huge fan of the way Windows is going in
| general for the most part you can turn off most of the tracking
| that is currently enabled. Unfortunately I do not have direct
| experience with the telemetry tracking for windows terminal.
| stockerta wrote:
| Lammy wrote:
| It doesn't have to be a full keylogger to be a very bad
| thing:
| https://kieranhealy.org/blog/archives/2013/06/09/using-
| metad...
| skywal_l wrote:
| The overton window is moving fast...
|
| You should not need telemetry on a terminal. It's a fscksing
| terminal, a window in which you display characters, why would
| anyone need telemetry?
|
| I am sure it is not intended as a keylogger but could become
| one very quickly if they fscks it up. It's microsoft we are
| talking about...
| Guillaume86 wrote:
| Just glancing through them it looks like perfectly reasonable
| telemetry collection, not sure why you call that spying.
| Lammy wrote:
| spy (/spaI/) v.,
|
| 1 : [intransitive] to collect secret information about
| another country, organization or person
| meowkit wrote:
| Is your runtime data "secret"?
|
| I think some people will have a hard time with this
| concept, but the idea of data being "private" or "secret",
| _by default_ , is disappearing. And it won't be coming back
| if the world continues to digitize.
|
| If you want those attributes for your data, you'll have to
| take measures. That means reading user agreements,
| verifying open source, using encryption intentionally.
|
| Vacuuming up data is not spying. Especially if you
| essentially agree to it when you accept the Windows terms
| of service (ethical issues of this aside).
| Lammy wrote:
| > Especially if you essentially agree to it when you
| accept the Windows terms of service (ethical issues of
| this aside)
|
| "But the plans were on display..."
|
| "On display? I eventually had to go down to the cellar to
| find them."
|
| "That's the display department."
|
| "With a flashlight."
|
| "Ah, well, the lights had probably gone."
|
| "So had the stairs."
|
| "But look, you found the notice, didn't you?"
|
| "Yes," said Arthur, "yes I did. It was on display in the
| bottom of a locked filing cabinet stuck in a disused
| lavatory with a sign on the door saying 'Beware of the
| Leopard."
| DoctorOW wrote:
| "secret information" is quite a bit of a stretch...
| baisq wrote:
| What you do with your software in the privacy of your
| home seems like it should be "secret"
| Genbox wrote:
| That is not how telemetry works. It is not spying or a
| privacy issue. Categorizing it as such only dilute the
| meaning of both terms so the real issues won't be taken
| serious.
|
| If you feel like a bunch of developers getting info about
| how many times the world clicks on a button hurts you
| personally, then don't install it. Calling it a privacy
| issue it taking it too far.
| imwillofficial wrote:
| It is absolutely both a spying and privacy issue. What I
| decide is private, or what information constitutes spying
| is arbitrary.
|
| I love windows terminal, but it should collect nothing by
| default. Another subjective opinion.
| cryptonector wrote:
| Terminals should not be sending telemetry.
|
| Imagine if every .exe and every .dll did that! That's not OK!
| babypuncher wrote:
| We have a habit of diluting words to the point where they are
| meaningless, and I think it does more to hurt important
| causes than support them. By labeling all forms of telemetry
| as "spying", we just make it so people are less likely to
| take actual claims of spying seriously.
| disruptiveink wrote:
| That is what it once meant. "Spyware" was the term used for
| any process that called home regarding any information
| about you, your computer or your usage in the background.
| Calling home for anything other than "Check for updates"
| menu items or other actions where calling home was the
| explicit action the user wanted would get your name
| tarnished in the media and added to the signature list of
| software built for the sole purpose of finding and
| forcefully removing software like that.
|
| Practically any Android app these days would be considered
| "spyware" if we were still applying the "spyware"
| definition of the early 2000s. And we would be better off
| if we had never stopped.
| tjoff wrote:
| Just glancing through them it looks like it wouldn't produce
| much meaningful data, begs the question - why have it in the
| first place? Since everyone involved must have known the
| reactions to it.
| Genbox wrote:
| Note: This is not news of any kind. Windows Terminal has been
| open source since its first release 3 years ago.
| Bostonian wrote:
| Just wondering -- why would Microsoft release the source code for
| this component of Windows?
| aneutron wrote:
| There's an excellent blog post by the product manager I believe
| that explains the history of the CMD command, how terminal
| emulation works in Windows, and the work they were doing.
|
| The way I understand this project is essentially "an interface"
| to the new ConPTY they developed (which IIRC is closed source,
| naturally).
|
| That doesn't make it any lesser. I've used it since a build was
| available, 4 years ago or something. I love it.
|
| EDIT: Found it !
| https://devblogs.microsoft.com/commandline/windows-command-l...
| DHowett wrote:
| So, one of the cool things about this repository (Hi! I'm the
| engineering lead for the Terminal/Console/... team. I'm
| biased!) is that it _also_ contains the source for ConPTY and
| the rest of the Windows console host[1]. Every change made
| here flows back into Windows, and vice-versa.
|
| In this repo, you can find some of our terrible secrets and
| workarounds and debugging hooks and _perhaps_ even some
| explanation for why things work the way they do. Or don 't
| work the way they should.
|
| If you're looking for a good[2] way to spend a few minutes,
| search for "LOAD BEARING" :)
|
| [1]: If you build the "Host.EXE" project and copy the
| resulting OpenConsole.exe over %WINDIR%\System32\conhost.exe,
| it'll work just fine and you'll pick up a bunch of the
| console changes we've made in the past few years.
|
| [2] Goodness not guaranteed, void where prohibited, etc.
|
| EDIT: Oh, kaelinl mentioned this in a sibling comment to
| yours. Sorry about that! I've also reworded parts of the main
| comment body to flow better.
| runevault wrote:
| Not sure I'd really call this a component of the OS. It is a
| new app that works with various shells (including cmd,
| powershell, and WSL) to create a better experience using them
| including tabbed view so you can have multiple terminals from a
| single window.
| easton wrote:
| The core console emulator for Windows is a part of this too:
| https://github.com/microsoft/terminal/tree/main/src/host
| kaelinl wrote:
| There are multiple projects in this repo. Windows Terminal,
| which the other commenters focus on, is a relatively new
| standalone app and not (yet?) bundled with the OS. They opted
| to open source it from the start, more or less. The other part
| is conhost, which is the classical terminal that has existed in
| Windows for decades. Some of the layout and rendering logic was
| pulled out of conhost to be shared with Terminal, and the two
| projects are maintained by the same team, so they open-sourced
| both. As I understand it, they then ship conhost and its shared
| components in Windows releases.
| tmottabr wrote:
| AFAIK it is bundled since Windows 11.
| Melatonic wrote:
| Windows in general is moving more in this direction and trying
| to integrate more with linux
| kingcharles wrote:
| Probably the same reason they've opened sourced some other
| components lately: community feedback and updates.
|
| There are a bunch of bugs in Windows core that I can't even get
| anyone to look at (and I'm an MVP). With these little bits
| they've opened sourced you can actively participate in helping
| the team fix the bugs, and add features as needed.
|
| I know the team on Terminal had a whole muddle of problems to
| do with rendering recently that probably still needs some
| outside input. Even Microsoft's developers can't and don't know
| all the best ways to carry out tasks with their own APIs -
| there is just too much to learn.
| uuyi wrote:
| I think they are load testing their github acquisition...
| oaiey wrote:
| There is no trade secret in it and users who use it can often
| also help improving it.
|
| There are only positive outcomes here
| rbanffy wrote:
| Why not? It's not something that gives Windows a competitive
| edge and it's very unlikely it could be ported to another
| platform.
| tiernano wrote:
| the code has been open since the beginning of the project,
| IIRC... back when it was announced first, to get it to build,
| you needed to build it locally...
| tambourine_man wrote:
| Apple should follow MS's example and open source its Terminal.app
|
| It's a decent terminal emulator, but could use several
| enhancements and the community could help.
|
| For some reason I haven't changed to iTerm yet, even though it's
| been objectively better in every way for years. Even the minor
| gripe I had with font rendering is fixed.
|
| There's something about using default apps as much as possible
| that appeals to me. But Terminal.app is lagging compared to the
| competition.
| ossusermivami wrote:
| when i am using macOS I use kitty as on my (primary) Linux
| laptop, and it's works beautifully there,
|
| (iterm2 is great too)
| disruptiveink wrote:
| I was a Terminal.app user since Tiger, only recently had to
| switch to iTerm 2 as since Big Sur it forces anti-aliasing on
| non-HiDPI displays, even when turned off in the settings (I
| like non anti-aliased Monaco 10pt). It looks like a bug, but
| hasn't been fixed since.
| Maursault wrote:
| > Apple should follow MS's example and open source its
| Terminal.app
|
| This is bellyaching about nothing. Instead, Microsoft should
| follow Apple's example and open source _the operating system_.
| The only part of macOS that is not open source is the GUI, i.e.
| Quartz Compositor, and the gui applications. Microsoft,
| meanwhile, is an incredible slouch when it comes to open
| source, only very recently changing their hostile "embrace,
| extend, extinguish" stance towards OSS.
| melony wrote:
| Mac without the userland is mostly useless. At that point you
| might as well switch fully to FreeBSD.
| Maursault wrote:
| This is a straw man, and also not entirely accurate. Darwin
| is BSD, and in theory just as useful as BSD, or FreeBSD,
| NetBSD, and useful to developers, and to anyone that can
| figure out how to install it and use it. [1] Meanwhile,
| Windows without hardware less than 2 years old is
| absolutely worthless. Thus, Linux.
|
| [1] http://www.puredarwin.org/
| rbanffy wrote:
| > It's a decent terminal emulator, but could use several
| enhancements and the community could help.
|
| It's the only modern terminal that passes the VT torture test.
| It supports double width and double height characters (great
| for terminal error messages).
|
| It doesn't support overline (which is awesome for status lines
| at the bottom of the screen) and requires font support for line
| drawing and block graphics (Unicode 13 introduced 2x3 blocks
| and the next one will introduce 2x4s).
|
| > There's something about using default apps as much as
| possible that appeals to me
|
| For me it's one less thing to distract my distraction-prone
| brain.
| Komodai wrote:
| VT torture test?
| DHowett wrote:
| I think rbanffy is referring to vttest[1], but I'm not
| certain.
|
| [1]: https://www.invisible-island.net/vttest/
|
| EDIT to add: vttest is maintained by the current maintainer
| of xterm. It's the "torturiest" VT test I know of.
| wayne wrote:
| Had a really fun trailer/video when it launched:
| https://www.youtube.com/watch?v=8gw0rXPMMPE
| dundarious wrote:
| Worth watching Casey Muratori's series of videos on terminals,
| and how to implement them, where he often makes specific
| comparison to Windows Terminal. He has some specific criticisms
| that are easy to disagree with, but the vast majority are well
| warranted. His broader series of videos on the topic are even
| worthwhile from a purely "software engineering education"
| standpoint.
|
| https://youtu.be/hxM8QmyZXtg
|
| I feel a bit bad about posting comments about it relatively
| frequently on HN, but it's just so very very good, and snark
| aside, his perspective is extremely valuable.
| rolph wrote:
| this caught my eye:
|
| >>Installing and running Windows Terminal
| Note: Windows Terminal requires Windows 10 2004 (build 19041) or
| later
|
| Microsoft Store [Recommended]
|
| Install the Windows Terminal from the Microsoft Store. This
| allows you to always be on the latest version when we release new
| builds with automatic upgrades.
|
| This is our preferred method.
|
| Other install methods
|
| Via GitHub
|
| For users who are unable to install Windows Terminal from the
| Microsoft Store, released builds can be manually downloaded from
| this repository's Releases page.
|
| Download the Microsoft.WindowsTerminal_<versionNumber>.msixbundle
| file from the Assets section. To install the app, you can simply
| double-click on the .msixbundle file, and the app installer
| should automatically run. If that fails for any reason, you can
| try the following command at a PowerShell prompt:<<
| pooper wrote:
| I am glad to see scoop called out in the list of installation
| methods. I use scoop and like the idea behind scoop.
| Applications should install in my user_profile when possible
| and should only require sudo when it isn't possible.
|
| All new application in $current_year should install as
| $current_user_scope by default. I hate how applications
| (looking at you, Google Chrome) try to install a scheduled task
| to keep itself updated. All of this should be up to the package
| manager. If I want to update the client application, I will do
| so myself.
| legulere wrote:
| You can also just install it with winget
| easton wrote:
| And the winget version updates automatically with the
| Microsoft Store (not that that matters much if you are into
| using scoop/choco, since you know to just scoop upgrade)
___________________________________________________________________
(page generated 2022-05-11 23:00 UTC)