Math Selection

Selection of text in a math zone obeys some special rules concerning built-up math objects, such as fractions and integrals. First some background on how these objects are stored helps to clarify the rules.

In memory, math objects start with a special 16-bit character and end with a different 16-bit character. In RichEdit, the start character is U+FDD0 and the end character is U+FDEF. An argument of an object ends with a special separator character (U+FDEE for RichEdit) when followed by another argument and it ends with the end-of-object character if the argument is the last one of the object. This math object structure is also discussed in my post on math find/replace. The math object delimiter characters belong to the special Unicode range U+FDD0..U+FDEF, which is defined for internal use only. That is, these characters can be used in memory, but should not be used in files.

Selection of text in a math zone works the same way it does in normal text as long as one of these three math-object delimiter characters isn’t selected. As soon as one is selected, the whole object is automatically selected. For example, if you type Shift+→ at the end of the numerator of a fraction, you attempt to select the numerator’s delimiter. This causes the whole fraction to be selected. Similarly if you type Shift+→ at the start of a math object or Shift+← at the end of a math object, the whole object is selected. The math object is also selected if you type Delete at the start of the object or Backspace at the end the object. A second Delete or Backspace then deletes the object. This behavior exists so that you don’t delete things by mistake. If you do so anyway, you can always undo your deletion by typing Ctrl+z.

You can select from outside a math zone part way into a math zone unless the math zone consists of a single math object. So if normal text precedes E = mc2, you can select that text along with, for example, E. As such the math zone isn’t treated as a single math object. This is possible because math zones are identified by a character format effect like bold rather than by start and end delimiter characters.