added a latex -> unicode keybinding cleaner-uper

svn: r7932
This commit is contained in:
Robby Findler 2007-12-09 23:31:19 +00:00
parent b7583984d8
commit d8c75d95d1

View File

@ -947,6 +947,34 @@
(send text lock #t) (send text lock #t)
#t)] #t)]
[TeX-compress
(let* ([shortcut-table
'(("lambda" "λ")
("forall" "\u2200")
("exists" "\u2203")
("in" "\u2208")
("Sigma" "\u2211")
("Pi" "\u220f")
("leq" "\u2264")
("geq" "\u2265")
("infty" "\u221e")
("leftarrow" "\u2190")
("rightarrow" "\u2192")
("Leftarrow" "\u21d0")
("Rightarrow" "\u21d2"))]
[biggest (apply max (map (λ (x) (string-length (car x))) shortcut-table))])
(λ (text event)
(let ([pos (send text get-start-position)])
(when (= pos (send text get-end-position))
(let ([slash (send text find-string "\\" 'backward pos (max 0 (- pos biggest 1)))])
(when slash
(let ([to-replace (assoc (send text get-text slash pos) shortcut-table)])
(when to-replace
(send text begin-edit-sequence)
(send text delete (- slash 1) pos)
(send text insert (cadr to-replace))
(send text end-edit-sequence)))))))))]
[greek-letters "αβγδεζηθι κλμνξοπρςστυφχψω"] [greek-letters "αβγδεζηθι κλμνξοπρςστυφχψω"]
[Greek-letters "ΑΒΓΔΕΖΗΘΙ ΚΛΜΝΞΟΠΡ ΣΤΥΦΧΨΩ"]) ;; don't have a capital ς, just comes out as \u03A2 (or junk) [Greek-letters "ΑΒΓΔΕΖΗΘΙ ΚΛΜΝΞΟΠΡ ΣΤΥΦΧΨΩ"]) ;; don't have a capital ς, just comes out as \u03A2 (or junk)
@ -969,6 +997,8 @@
(λ (txt evt) (send txt insert c))))) (λ (txt evt) (send txt insert c)))))
(string->list (string-append greek-letters Greek-letters))) (string->list (string-append greek-letters Greek-letters)))
(add "TeX compress" TeX-compress)
(add "down-into-embedded-editor" down-into-embedded-editor) (add "down-into-embedded-editor" down-into-embedded-editor)
(add "up-out-of-embedded-editor" up-out-of-embedded-editor) (add "up-out-of-embedded-editor" up-out-of-embedded-editor)
(add "forward-to-next-embedded-editor" forward-to-next-embedded-editor) (add "forward-to-next-embedded-editor" forward-to-next-embedded-editor)
@ -1062,6 +1092,8 @@
(setup-mappings greek-letters #f) (setup-mappings greek-letters #f)
(setup-mappings Greek-letters #t)) (setup-mappings Greek-letters #t))
(map "c:\\" "TeX compress")
(map-meta "c:down" "down-into-embedded-editor") (map-meta "c:down" "down-into-embedded-editor")
(map "a:c:down" "down-into-embedded-editor") (map "a:c:down" "down-into-embedded-editor")
(map-meta "c:up" "up-out-of-embedded-editor") (map-meta "c:up" "up-out-of-embedded-editor")