Skip to content

The new Windows 11 Notepad uses RichEdit and comes with several standard RichEdit editing enhancements such as Alt+x to enter Unicode characters

In the first major Windows update on February 15, Microsoft started delivering new experiences for Windows 11; users will be able to enjoy taskbar enhancements, redesigned versions of Media Player and Notepad, as well as an Amazon Appstore Preview for Android apps.

Notepad now includes multi-step undo, an improved search interface, and dark mode support.

Like the physical notepads around your home, the Notepad app is designed to be a simple companion for all your basic note-taking needs. The redesigned user interface is both fresh, with new design features from Windows 11, and familiar, with the simplicity and ease of use that Notepad is famous for. Along with design updates, we’ve added dark mode, so the app is more consistent with your Windows experience. If your default system theme is dark mode, Notepad will automatically adopt the dark theme, or you can also select the app theme manually from the new settings page. Menus have also been simplified to make it easier to find the actions you want to perform in the app, and we’ve added much-requested new features like multi-level undo, colorful emojis, and a modern find-and-replace experience. and efficient. To get the redesigned Media Player and Notepad apps, visit the Microsoft Store.

Microsoft has devoted a post to discuss the technical side of some improvements that come with this tool.

Murray Sargent, Principle Software Engineer, CXE (Office Shared) indicated:

The new Windows 11 Notepad uses RichEdit and runs on current Windows 11 installations. In addition to a Windows 11 look with rounded corners and a dark theme option, the new Notepad includes several standard RichEdit editing enhancements, such as Alt+x to enter Unicode characters, Ctrl+} to switch between matching brackets/parentheses, multi-level undo, drag and drop, color emoji, block selection and automatic URL detection. You might guess that using a plain text RichEdit control in Notepad would be a slam dunk. RichEdit has had plain text controls since Office 97 (last century!) and they have been used a myriad of times. But these plain text controls are small and usually exist in dialog boxes. Notepad is often used to view large files, so high performance is important and lines can be very long. And Classic Notepad has been improved in a variety of ways, such as better performance, end-of-line (CR, LF, CRLF) detection, and a “Show Unicode Control Characters” context menu option. As a result, it took considerable effort to use RichEdit as the editing engine for the new Notepad. This article describes some additions and implementation details.

RichEdit additions

Classic Notepad has two handy features not implemented in RichEdit: end-of-line (CR, LF, CRLF) detection and Show Unicode Control Characters mode.

Murray notes that For years, Notepad didn’t break Unix convention lines that ended with an LF (U+000A) instead of a CRLF (U+000D U+000A). I used to open Unicode character data files, which contain lines terminated with LF, with WordPad and save them to convert LF to CRLF so that Notepad displays them correctly.

To solve this problem, Notepad did one better: it checked which line ending came first, then made that line ending the default for the file. Thus, a file with lines terminated by LF remains terminated by LF and is displayed correctly. Internally, RichEdit follows Word and Mac’s example of ending paragraphs with a CR and converting LF and CRLF to CR when reading from a file or storing text via an API like WM_SETTEXT or ITextRange2:: SetText2.

This is always the case, but you can tell RichEdit to recognize the type of line ending in a file and use that choice to save/copy the file by sending the message EM_SETENDOFLINE with wparam=EC_ENDOFLINE_DETECTFROMCONTENT .

Show Unicode control character mode and emoji

Notepad has had a Show Unicode Control Characters option in its context menu for many years. This mode displays Bidi zero-width control characters using distinctive zero-width glyphs. This is very useful, for example, to reveal the Bidi RLO (U+202E) and LRO (U+202D) codes which override the usual character directions and are sometimes used to spoof files for nefarious purposes. It also displays the zero-width join (ZWJU+200D) with a zero-width vertical line with an x ​​above it. But inside ZWJ emoji sequences, such as family emojis, the mode does not separate the sequence at ZWJs and does not reveal ZWJs by the zero-width ZWJ glyph. And the classic notepad doesn’t show ZWJ footage and emoji in general in color.

In the new Show Unicode Control Characters notebook mode, ZWJ sequences are separated at ZWJs and ZWJs are displayed by the ZWJ zero-width glyph. You can navigate inside the ZWJ sequence using the ← and → and type Alt+x to see the codes of the characters composing the sequence ZWJ. This allows you to understand how a ZWJ sequence is constructed. For example, the new mode displays the emoji family sequence ZWJ👨❤️👩given by the codes U+1F468 ZWJ U+2764 U+FE0F ZWJ U+1F469 as

Find/Replace dialog drop-down list

Visual Studio Code has a nifty Find/Replace dialog that drops down to the top right corner of the text box. If the dialog box overlaps the original text, the user can drag the text just below the bottom of the dialog box. The new Notepad mimics this behavior.

It was a bit difficult to get RichEdit to provide the associated functionality. In rich text formatting, the Paragraph Space Before and Space After properties are used to add spacing between paragraphs. Since RichEdit is a rich text editor, it supports these properties, and it was only natural to implement drop-down space as “front document space”.

The leading space value is included in the ascent of the first line of the document. The tricks were removing or replacing the first line and scrolling the display correctly with a non-zero document space value.

Plain text UI improvements

We decided to match the Visual-Studio user interface for selecting and deselecting the EOP character at the end of a line. This differs from Word’s user interface, which tends to automatically select the EOP character if you navigate to it. Specifically, in plain text controls, we don’t let the mouse expand the selection to include the EOP on a line or let Shift+End select the EOP. This corresponds to what is deleted if you press the Delete key after selecting the text. You can still select the EOP character using Shift+→ and extending the selection to the next line. Also, if line wrapping is disabled, the insertion point caret now follows any spaces you enter instead of ignoring spaces.

Some implementation details

Notepad in Windows 11 uses a window for its editing canvas and windows typically use GDI to display text and images. GDI does not have functions to display color fonts in color, unlike DirectWrite. To be able to use DirectWrite for color emoji and other enhancements, the new Notepad therefore creates a window RichEDitD2DPT, which uses DirectWrite for text and GDI for OLE objects (Notepad does not insert OLE objects). ).

The RichEdit version used in Notepad comes from the same sources as the RichEdit version loaded with Microsoft 365 Apps such as Word, PowerPoint, Excel, and OneNote. It’s not the Windows RichEdit in msftedit.dll. As a result, Notepad has the latest RichEdit enhancements.

Microsoft has fixed bugs that didn’t appear for RichEdit plain text controls over the years, in part because before Notepad, plain text instances were small.

Notepad uses the classic RichEdit font binding instead of the IProvideFontInfo font binding used in XAML text controls and in RichEdit controls that appear in Microsoft 365 Apps. Notepad does not want to load the mso libraries used in the latter, because these libraries are quite large. Classic font binding has been improved, but needs to add support for more scripts.

Source: Microsoft

And you?

Have you tried the new Notepad on Windows 11? What do you think ?

Leave a Reply

Your email address will not be published.