syntax highlighting August 4, 2006
Posted by pharaoh in Uncategorized.add a comment
the next thing on the agenda is syntax highlighting, and i have spent a lot of time trying to design a good highlighting system. the goals are,
- simplicity. shell syntax is not going to be very complex, and consequently the highlighting code should be simple (esp on the shell side).
- configurability. no assumptions of shell syntax need be made.
i happened to see the source code of SpeedCrunch and the documentation of the QString::split() function, and a design struck me. it is as follows,
- the shell as well as anthias will parse the current command string into tokens. the string will be split into tokens that match a regular expression. the reg-exp will be specified by the shell to anthias.
- whenever the current command string is modified by the user, anthias will send the raw string to the shell, and also parse it locally into tokens.
- when the shell receives the current command string, it will also parse it into tokens (using the same reg-exp), and specify the syntax-id for each token. the syntax-id will be nothing but a number that will be mapped to some text-formatting style. the shell will also send the entire command string back to anthias, to keep the two in sync.