[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/eat 6a94082eff 3/8: Use hash table to convert from charset
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/eat 6a94082eff 3/8: Use hash table to convert from charset |
Date: |
Mon, 28 Nov 2022 11:58:51 -0500 (EST) |
branch: elpa/eat
commit 6a94082effd5d501bf6e3608f04552abc7a9e844
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>
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.
---
eat.el | 86 ++++++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 49 insertions(+), 37 deletions(-)
diff --git a/eat.el b/eat.el
index 476a33acbb..e07081b1b9 100644
--- a/eat.el
+++ b/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 . ?█)
+ (?\` . ?�)
+ (?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 . ?█)
- (?\` . ?�)
- (?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
- [nongnu] elpa/eat updated (499c9dd911 -> f3fed64957), ELPA Syncer, 2022/11/28
- [nongnu] elpa/eat 6271968c86 2/8: Use as less let-bindings as possible, ELPA Syncer, 2022/11/28
- [nongnu] elpa/eat 6a94082eff 3/8: Use hash table to convert from charset,
ELPA Syncer <=
- [nongnu] elpa/eat 64c537da78 1/8: Replace 'let*' with 'let' wherever possible, ELPA Syncer, 2022/11/28
- [nongnu] elpa/eat bc4bd45fa6 5/8: Avoid copying STR to the extent possible, ELPA Syncer, 2022/11/28
- [nongnu] elpa/eat f3fed64957 8/8: Prefer 'pcase-exhaustive' over 'pcase', ELPA Syncer, 2022/11/28
- [nongnu] elpa/eat b36f923919 7/8: * eat.el (eat--t-change-charset): Assert argument, ELPA Syncer, 2022/11/28
- [nongnu] elpa/eat 9d14bbeaa5 4/8: Support multi-column characters properly, ELPA Syncer, 2022/11/28
- [nongnu] elpa/eat 9a5bd15866 6/8: Combine multiple setq/setf/setq-local into one, ELPA Syncer, 2022/11/28