There are two extremes for the paradigm for the bidirectional word processor (BDWP):
You and your customer have to decide what kind of user your BDWP will support. Then you and your customer have to pick one paradigm that is appropriate for this user. Then, the BDWP you specify follows this and only this paradigm.
Here are more details on the two paradigms:
In EITHER case, the characters are in Unicode and the file operated on by the BDWP follows the Unicode standard. That is, if you view the file that your BDWP has produced through any other fully Unicode compliant application, that application's visual order view is the same as your BDWP's visual order view. This assumption means that whatever paradigm you choose, your BDWP makes Unicode compliant files.
Each character's direction is determined by the default direction of the alphabet of the keyboard through which the character is entered. That is, if the user is using a Hebrew keyboard, then typing a space results in an RTL space being put into the file. If the user is using an English keyboard, then typing a space results in an LTR space being put into the file. The same holds for all characters, e.g., digits and punctuation, which are classified as weak and neutral in Unicode; they are strong in this paradigm.
Any sequence of characters, selected with the pointer (mouse), can be made a subdocument with either direction, LTR or RTL. Thus, if the user is making a LTR document that contains a RTL address that contains LTR digits in the middle of which are LTR characters, then the user will have to make the RTL address an RTL subdocument in order to get the LTR letters inside the digits not to be moved to the wrong place (See the bidirectional text reading lesson.).
Any sequence of characters, selected with the pointer, can be given either direction, LTR or RTL. Thus, the user is able to specify a sequence of RTL characters to be LTR or a sequence of LTR characters to be RTL, e,g, in order to write a manual for a BDWP.
The tradeoff, FROM THE USER'S VIEWPOINT, are:
If you choose Paradigm 1, User in Full Control, then your BDWP will create the fiction that the user is under full control and that each character entered is strong, while, in fact, the file is stored according to the Unicode standard.
One possible way to achieve this fiction is for the BDWP to keep track of character directions and subdocuments and to drop control characters into the file in the correct places to cause the UBDA to interpret the file so that each character has the direction the user thinks it has and that the file's embeddings match the document--subdocument structure that the user thinks the file has.
If you choose Paradigm 2, the BDWP chooses character directions as specified by the UBDA. Even so, you have to choose a modus operandi from among a spectrum of modi operandi. The variation along this spectrum is according to the degree of well-formedness checking or enforcing that the BDWP does as the user enters control characters:
There is a command to enter each control character at the place the cursor points. For each such command, the BDWP checks nothing and simply inserts the specified character at the place in the file pointed to by the cursor. However, the resulting visual order view will be unpredictable if the file is ill-formed, e.g., an LRE, RLE, LRO, or RLO is not paired with a matching PDF.
There is a command to enter each control character at the place the cursor points. For each such command, the BDWP checks that the placement of the control characters follows the constraints for well-formedness, e.g., that embedding and overriding commands are paired properly with PDFs. You will have to decide how to treat the situation in which an embedding or overriding has been started, but its corresponding PDF has not been given yet.
There is a command to enter each of LRM and RLM at the place the cursor points. There is a command to enter each of a LRE-PDF, a RLE-PDF, a LRO-PDF, and a RLO-PDF pair at the beginning and end of the region selected by the current selection. With such commands, it is guaranteed that the entered control characters follow the constraints for well-formedness.
Your user's manual must describe somewhere in the beginning the chosen paradigm and the chosen modus operandi if it is relevant for your chosen paradigm.
The above has described the paradigms and modi operandi in terms of what the user DOES and can DO, but there is more. No matter what paradigm and modus operandi you choose, you need to provide commands that allow the user to VIEW what he has input and to see how the software has interpreted what is in the file. This ability to view is particularly important when the software is going to be making default assumptions that may differ from the user's intent. Even when the user is in full control, he can make mistakes (REALLY???), and therefore, the user needs to be able to see how the software has interpreted what he has entered.
So you will need commands to show:
Note that in a showing of a file in logical order,
Note that one could achieve these views by
Finally, no matter your paradigm and modus operandi don't forget to deal with:
The problem with a selection that crosses a direction change boundary, which does not have to be the beginning of an embedding or an overriding, is the cognitive dissonance caused by the fact that as the selection crosses the direction change boundary, the highlighted region starts to grow in the direction opposite that of the hand movement. So, the user is tempted to start moving the hand the other way. But, moving the other way should cause undoing of the selection, not growing of the selection.
There are at least two ways to deal with this cognitive dissonance: