Customize Colors, Fonts and Keyboard

Colors and fonts

The editor contains a line number column, a narrow left fringe, text area, and a right fringe. You can customize the colors of each area and also the text font. The configuration is written in a file twinit.l, which should be put in the root directory.

Following is a sample of twinit.l:

;; The color values from left to right are:
;;        Red Green Blue Alpha
;; in [0.0, 1.0].
(set-background-color     0.0 0.0 0.0 1)
(set-foreground-color     0.8 0.8 0.8 1)
(set-keyword-color        1.0 0.0 1.0 1)
(set-string-color         1.0 0.0 0.0 1) ;; Inline formulas between $$
(set-comment-color        1.0 0.0 0.0 1)
(set-selection-color      1.0 1.0 1.0 1)
(set-line-number-color    0.5 0.5 0.5 1)
(set-line-number-bgcolor  0.3 0.3 0.3 1)
(set-fringe-color         0.2 0.2 0.2 1)
(set-caret-color          0.9 0.9 0.9 1)
;; For available font names, see
(set-font  "Optima-Regular" 20.0)

Restart TEX Writer for the configuration to take effect. Now it looks like:

Figure 1. Colors and Font


You probably have noticed that the keyboard in Figure 1 looks a little different from the default one. That's right, you can customize the assistant keyboard in twinit.l as well.

It can be as simple as this:

(set-keys-1 "$" "\\" "{" "}" "_" "^" "+" "-" "=" "`" "'")
(set-keys-2 "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "(" ")" "[" "]")

You can see that the two lines above exactly defines the default keyboard:

Figure 2. Default Keyboard

set-keys-1 defines the first row keys, but not all of them will be shown, because the keyboard width is different between landscape mode and portrait mode. If there is no enough space, some of the keys in the tail will be cut off. Likewise, set-keys-2 defines the second row keys. You may notice we can set more keys in second row because the first row contains two predefined functional keys that do not insert text.

You can also set a key to a string with more than one characters, like ``begin''.

For advanced users, you can even bind a key to a predefined command:

(set-keys-1 "\\" "{" "}" "_" "^" "+" "-" "=" "%")
(set-keys-2 "$:(inline-maths)" "$$:(display-maths)" "{}:(braces)"
  "[]:(brackets)" "():(parentheses)" ";" "&" "~" "``" "''" "`" "'")

The second line looks funnier. The part before colon is the displayed title, and the part after specifies the command to execute when the key is tapped.

A command looks like this:

;; Inline maths
(define (inline-maths)
  (insert "\\(\\)")
  (goto-char (- (point) 2))

A Sample twinit.l

View: twinit.l


If you're reading on iPad, you can download the zip file right now, and open it in TEX Writer. Then switch to TEX Writer app, find it from the file list, tap on it, a twinit.l will be unzipped to the root directory. Now restart TEX Writer and you should see the look as shown in Figure 1.

Note: Please make sure TEX Writer isn't working in a sub directory. A good way is to open the readme.tex to make sure TEX Writer is in root directory.

Trouble Shooting

Delete twinit.l if there is anything wrong. If you did something terribly wrong and TEX Writer fails to start, then you should delete it via iTunes file sharing.

© 2012-2018, Chaoji Li. All rights reserved.