Use hash table to convert from charset
* eat.el (eat--t-dec-line-drawing-chars): New constant containing the hash table. * eat.el (eat--t-write): Use hash-table instead alist while converting from DEC Line Drawing charset.
This commit is contained in:
parent
6271968c86
commit
6a94082eff
1 changed files with 49 additions and 37 deletions
86
eat.el
86
eat.el
|
@ -2362,6 +2362,53 @@ character or its the internal invisible spaces."
|
|||
(insert (propertize " " 'face face))
|
||||
(backward-char)))))
|
||||
|
||||
(defconst eat--t-dec-line-drawing-chars
|
||||
(eval-and-compile
|
||||
(let ((alist '((?+ . ?→)
|
||||
(?, . ?←)
|
||||
(?- . ?↑)
|
||||
(?. . ?↓)
|
||||
(?0 . ?█)
|
||||
(?\` . ?<3F>)
|
||||
(?a . ?▒)
|
||||
(?b . ?␉)
|
||||
(?c . ?␌)
|
||||
(?d . ?␍)
|
||||
(?e . ?␊)
|
||||
(?f . ?°)
|
||||
(?g . ?±)
|
||||
(?h . ?░)
|
||||
(?i . ?#)
|
||||
(?j . ?┘)
|
||||
(?k . ?┐)
|
||||
(?l . ?┌)
|
||||
(?m . ?└)
|
||||
(?n . ?┼)
|
||||
(?o . ?⎺)
|
||||
(?p . ?⎻)
|
||||
(?q . ?─)
|
||||
(?r . ?⎼)
|
||||
(?s . ?⎽)
|
||||
(?t . ?├)
|
||||
(?u . ?┤)
|
||||
(?v . ?┴)
|
||||
(?w . ?┬)
|
||||
(?x . ?│)
|
||||
(?y . ?≤)
|
||||
(?z . ?≥)
|
||||
(?{ . ?π)
|
||||
(?| . ?≠)
|
||||
(?} . ?£)
|
||||
(?~ . ?•)))
|
||||
(table (make-hash-table :purecopy t)))
|
||||
(dolist (pair alist)
|
||||
(puthash (car pair) (cdr pair) table))
|
||||
table))
|
||||
"Hash table for DEC Line Drawing charset.
|
||||
|
||||
The key is the output character from client, and value of the
|
||||
character to actually show.")
|
||||
|
||||
(defun eat--t-write (str)
|
||||
"Write STR on display."
|
||||
(let ((face (eat--t-face-face (eat--t-term-face eat--t-term)))
|
||||
|
@ -2387,43 +2434,8 @@ character or its the internal invisible spaces."
|
|||
;; `us-ascii'.
|
||||
('dec-line-drawing
|
||||
(dotimes (i (length str))
|
||||
(let ((replacement (alist-get (aref str i)
|
||||
'((?+ . ?→)
|
||||
(?, . ?←)
|
||||
(?- . ?↑)
|
||||
(?. . ?↓)
|
||||
(?0 . ?█)
|
||||
(?\` . ?<3F>)
|
||||
(?a . ?▒)
|
||||
(?b . ?␉)
|
||||
(?c . ?␌)
|
||||
(?d . ?␍)
|
||||
(?e . ?␊)
|
||||
(?f . ?°)
|
||||
(?g . ?±)
|
||||
(?h . ?░)
|
||||
(?i . ?#)
|
||||
(?j . ?┘)
|
||||
(?k . ?┐)
|
||||
(?l . ?┌)
|
||||
(?m . ?└)
|
||||
(?n . ?┼)
|
||||
(?o . ?⎺)
|
||||
(?p . ?⎻)
|
||||
(?q . ?─)
|
||||
(?r . ?⎼)
|
||||
(?s . ?⎽)
|
||||
(?t . ?├)
|
||||
(?u . ?┤)
|
||||
(?v . ?┴)
|
||||
(?w . ?┬)
|
||||
(?x . ?│)
|
||||
(?y . ?≤)
|
||||
(?z . ?≥)
|
||||
(?{ . ?π)
|
||||
(?| . ?≠)
|
||||
(?} . ?£)
|
||||
(?~ . ?•)))))
|
||||
(let ((replacement
|
||||
(gethash (aref str i) eat--t-dec-line-drawing-chars)))
|
||||
(when replacement
|
||||
(aset str i replacement))))))
|
||||
;; Find all the multi-column wide characters in STR, using a
|
||||
|
|
Loading…
Add table
Reference in a new issue