home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
me34exe.zip
/
mutt
/
contrib
/
accent.mut
next >
Wrap
Text File
|
1995-01-14
|
9KB
|
250 lines
;;
;; File:
;; accent.mut - typewriterlike accents
;;
;; Description:
;; Code to assit typing characters that have accents; first type the
;; accent, then type the character. It's almost like an old
;; typewriter.
;;
;; - Characters that have accents can be defined by calling
;; 'accent-define' from your own 'accent-hook'. 'accent-hook' can
;; be used to overwrite the defaults that are set for MS-DOS in the
;; function MAIN, or to add new definitions.
;;
;; - Example of 'accent-hook' for SUN-OS:
;; (defun
;; accent-hook
;; {
;; (accent-clear-all)
;; ;; " ` ' ^ ~ @
;; (accent-define 0x61 228 224 225 226 227 229 ) ;; a
;; (accent-define 0x41 196 192 193 194 195 197 ) ;; A
;; (accent-define 0x63 0x63 0x63 0x63 0x63 231 0x63) ;; c
;; (accent-define 0x43 0x43 0x43 0x43 0x43 199 0x43) ;; C
;; (accent-define 0x65 235 232 233 234 0x65 0x65) ;; e
;; (accent-define 0x45 203 200 201 202 0x45 0x45) ;; E
;; (accent-define 0x69 239 236 237 238 0x69 0x69) ;; i
;; (accent-define 0x49 207 204 205 206 0x49 0x49) ;; I
;; (accent-define 0x6E 0x6E 0x6E 0x6E 0x6E 241 0x6E) ;; n
;; (accent-define 0x4E 0x4E 0x4E 0x4E 0x4E 209 0x4E) ;; N
;; (accent-define 0x6F 246 242 243 244 245 0x6F) ;; o
;; (accent-define 0x4F 214 210 211 212 213 0x4F) ;; O
;; (accent-define 0x75 252 249 250 251 0x75 0x75) ;; u
;; (accent-define 0x55 220 217 218 219 0x55 0x55) ;; U
;; (accent-define 0x79 255 0x79 253 0x79 0x79 0x79) ;; y
;; (accent-define 0x59 0x59 0x59 221 0x59 0x59 0x59) ;; Y
;; }
;; )
;;
;; Bugs:
;; A fixed length array is used to store the accented characters.
;;
;; History:
;; 940111 M.J. van der Velden
;; - more like a typewriter (the cursor does not advance
;; after pressing an accent).
;; - documentation errors
;; Public Domain (Version 1.3)
;; 931014 M.J. van der Velden
;; - added 'accent-help'
;; - added 'accent-clear-all'
;; - added 'accent-bind-local-keys'
;; - documentation errors
;; Public Domain (Version 1.2)
;; 930208 M.J. van der Velden
;; - Renamed quote to accent.
;; - Renamed hat to caret (^).
;; - Renamed att to at (@).
;; - Added support for control characters.
;; Public Domain (Version 1.1)
;; 930129 M.J. van der Velden
;; Public Domain (Version 1.0)
;;
(include me.mh)
(const
ACCENT-NO-OF-ENTRIES 50 ;; There are 50 characters allowed to have accents.
ACCENT-NO-OF-ACCENTS 7 ;; " ` ' ^ ~ @ plus 1 for the character itself.
ACCENT-KEY-SPACE 0x20
ACCENT-KEY-DOUBLE 0x22
ACCENT-KEY-LEFT 0x60
ACCENT-KEY-RIGHT 0x27
ACCENT-KEY-CARET 0x5E
ACCENT-KEY-TILDE 0x7E
ACCENT-KEY-AT 0x40
ACCENT-HELP-BUFNAME "*accents*"
ACCENT-PROMPT "=> "
)
(array int
accentTable 350 ;; ACCENT-NO-OF-ACCENTS*ACCENT-NO-OF-ENTRIES
)
(int
accentNoOfEntries
accentHelpBufId
)
(defun
accent-define (int c double left right caret tilde at)
{
(int index)
(int entryCnt)
(if (== accentNoOfEntries ACCENT-NO-OF-ENTRIES) {
(msg "To many accents!")
(get-key)
(halt)
})
(for (entryCnt 0) (< entryCnt accentNoOfEntries) (+= entryCnt 1) {
(if (== c (accentTable (* ACCENT-NO-OF-ACCENTS entryCnt))) {
(break)
})
})
(index (* ACCENT-NO-OF-ACCENTS entryCnt))
(accentTable index c)
(accentTable (+ index 1) double)
(accentTable (+ index 2) left)
(accentTable (+ index 3) right)
(accentTable (+ index 4) caret)
(accentTable (+ index 5) tilde)
(accentTable (+ index 6) at)
(+= accentNoOfEntries 1)
}
accent-character
{
(int c)
(int newChIndex)
(int entryCnt)
(bool definitionFound)
(insert-text (convert-to CHARACTER (key-pressed)))
(previous-character)
(update)
(c (get-key))
(if (> c 0xFF) {
;; c is a control character
(exe-key c)
(done)
})
(if (== c ACCENT-KEY-SPACE) {
(next-character)
(done)
})
(definitionFound FALSE)
(for (entryCnt 0) (< entryCnt accentNoOfEntries) (+= entryCnt 1) {
(if (== c (accentTable (* ACCENT-NO-OF-ACCENTS entryCnt))) {
(definitionFound TRUE)
(break)
})
})
(delete-character)
(if definitionFound {
(newChIndex
(+ (* ACCENT-NO-OF-ACCENTS entryCnt)
(switch (key-pressed)
ACCENT-KEY-DOUBLE 1
ACCENT-KEY-LEFT 2
ACCENT-KEY-RIGHT 3
ACCENT-KEY-CARET 4
ACCENT-KEY-TILDE 5
ACCENT-KEY-AT 6
default 0
)
)
)
(insert-text (convert-to CHARACTER (accentTable newChIndex)))
}{
(insert-text (convert-to CHARACTER c))
})
}
accent-bind-local-keys HIDDEN
{
(bind-local-key "accent-character" '"')
(bind-local-key "accent-character" "'")
(bind-local-key "accent-character" "`")
(bind-local-key "accent-character" '^')
(bind-local-key "accent-character" '~')
(bind-local-key "accent-character" '@')
}
accent-help
{
(int entryCnt)
(int index)
(if (== -2 (accentHelpBufId (attached-buffer ACCENT-HELP-BUFNAME))) {
(accentHelpBufId (create-buffer ACCENT-HELP-BUFNAME (bit-or BFFoo BFHidden2)))
})
(current-buffer accentHelpBufId TRUE)
(clear-buffer)
(insert-text " \" ` ' \^ ~ @ ^J")
(for (entryCnt 0) (< entryCnt accentNoOfEntries) (+= entryCnt 1) {
(index (* ACCENT-NO-OF-ACCENTS entryCnt))
(insert-text
(convert-to CHARACTER (accentTable index )) ": "
(convert-to CHARACTER (accentTable (+ index 1))) " "
(convert-to CHARACTER (accentTable (+ index 2))) " "
(convert-to CHARACTER (accentTable (+ index 3))) " "
(convert-to CHARACTER (accentTable (+ index 4))) " "
(convert-to CHARACTER (accentTable (+ index 5))) " "
(convert-to CHARACTER (accentTable (+ index 6))) "^J"
)
})
(accent-bind-local-keys)
(insert-text "^JFirst type the accent, then the character: ^J")
(insert-text ACCENT-PROMPT)
}
accent-clear-all
{
(accentNoOfEntries 0)
}
MAIN
{
(accent-clear-all)
;;
;; These defaults are for MS-DOS. You can provide
;; your own values for other systems by creating an
;; 'accent-hook'.
;;
;; " ` ' ^ ~ @
(accent-define 0x61 132 133 160 131 134 229 ) ;; a
(accent-define 0x41 142 0x41 0x41 0x41 143 197 ) ;; A
(accent-define 0x63 0x63 0x63 0x63 0x63 135 0x63) ;; c
(accent-define 0x43 0x43 0x43 0x43 0x43 128 0x43) ;; C
(accent-define 0x65 137 138 130 136 0x65 0x65) ;; e
(accent-define 0x45 0x45 0x45 144 0x45 0x45 0x45) ;; E
(accent-define 0x69 139 141 161 140 0x69 0x69) ;; i
(accent-define 0x6E 0x6E 0x6E 0x6E 0x6E 164 0x6E) ;; n
(accent-define 0x4E 0x4E 0x4E 0x4E 0x4E 165 0x4E) ;; N
(accent-define 0x6F 148 149 162 147 0x6F 0x6F) ;; o
(accent-define 0x46 153 0x46 0x46 0x46 0x46 0x46) ;; O
(accent-define 0x75 129 151 163 150 0x75 0x75) ;; u
(accent-define 0x55 154 0x55 0x55 0x55 0x55 0x55) ;; U
(accent-bind-local-keys)
(if (pgm-exists "accent-hook") {
(floc "accent-hook" ())
})
}
)