Why is Microsoft WSL’s default terminal input experience better than other similar applications?

One developer (named Nick) posted a non-feedback issue in Windows Terminal’s GitHub repo — he was just curious about how the terminal had such smooth input.

Why is Microsoft WSL's default terminal input experience better than other similar applications?

Nick feels that this smoothness is something no other Windows app has, and even the lightest notepad.exe doesn’t offer this input experience. He also asked if this UI enhancement would be available for all Windows applications in the future.

Soon, the Windows development team member (@miniksa) who is responsible for the project answered Nick’s questions.

Miniksa says that keeping the WSL default terminal input faster than other apps is actually their only job! In addition, it may be because they must use the oldest and lowest level of Windows APIs to do this.

The default terminal for WSL does not involve many other layers or frames like a framework such as Electron, which has a not-so-specific bare window and does not have any add-ons. They process typing from window messages instead of some kind of event framework (WPF, WinForms, UWP, Electron) that is transmitted through the kernel. They then use GDI’s PolyTextOut to dump text directly into the window without extra decoration.

miniksa explains that notepad.exe is really lightweight, but it also has multiple controls in its window, and it is possible to use some kind of library, frame to determine its text layout in editing controls (or you may be using other libraries or frameworks for internationalization support…) ) , which makes their input slower than the WSL default terminal. Of course, WSL also needs to trade-offs, which do not provide complete international support as other applications.

Why would you do that? First, conhost.exe is very old. It must use the bare metal underlying of all content because it was created before most other frameworks were created. Second, it needs to maintain the lowest level possible, and it is written in C/C, and it needs to be as low-lying as possible to make it easier for third parties to use.

As for whether other Windows apps have a chance to use this smooth input effect, miniksa feels almost no chance. These apps can invoke a method and layout text in any language in a simple way, without having to manually calculate pixels or care what style their fonts should be in. And exactly how miniksa manually calculates pixels, sliding areas, and mathematical application areas is what makes WSL’s default terminal input faster.

Add a Comment

Your email address will not be published. Required fields are marked *