emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/boxy bda3f52 8/8: Merge branch 'next' into 'main'


From: ELPA Syncer
Subject: [elpa] externals/boxy bda3f52 8/8: Merge branch 'next' into 'main'
Date: Wed, 13 Oct 2021 15:57:10 -0400 (EDT)

branch: externals/boxy
commit bda3f524f68a962ba36265882df39eafc80b6dfd
Merge: f1aa854 535b186
Author: Tyler Grinn <tyler@tygr.info>
Commit: Tyler Grinn <tyler@tygr.info>

    Merge branch 'next' into 'main'
    
    v1.0.3
    
    Closes #1
    
    See merge request tygrdev/boxy!4
---
 boxy.el                    | 55 +++++++++++++++++-----------------------------
 tests/boxy-test-chinese.el | 51 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+), 35 deletions(-)

diff --git a/boxy.el b/boxy.el
index 896e3aa..7d0cdd2 100644
--- a/boxy.el
+++ b/boxy.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2021 Free Software Foundation, Inc.
 
 ;; Author: Tyler Grinn <tylergrinn@gmail.com>
-;; Version: 1.0.2
+;; Version: 1.0.3
 ;; File: boxy.el
 ;; Package-Requires: ((emacs "26.1"))
 ;; Keywords: tools
@@ -115,11 +115,12 @@
 (require 'easy-mmode)
 (require 'eieio)
 (require 'cl-lib)
+(require 'subr-x)
 
 ;;;; Options
 
 (defgroup boxy nil
-  "Customization options for boxy"
+  "Customization options for boxy."
   :group 'applications)
 
 (defcustom boxy-default-margin-x 2
@@ -163,39 +164,23 @@
 (defface boxy-default nil
   "Default face used in Boxy mode.")
 
-(defface boxy-primary nil
-  "Face for highlighting the name of a box.")
+(defface boxy-primary
+   '((((background dark)) (:foreground "turquoise"))
+     (t (:foreground "dark cyan")))
+   "Face for highlighting the name of a box.")
 
-(face-spec-set
- 'boxy-primary
- '((((background dark)) (:foreground "turquoise"))
-   (t (:foreground "dark cyan")))
- 'face-defface-spec)
-
-(defface boxy-selected nil
+(defface boxy-selected
+   '((t :foreground "light slate blue"))
   "Face for the current box border under cursor.")
 
-(face-spec-set
- 'boxy-selected
- '((t :foreground "light slate blue"))
- 'face-defface-spec)
-
-(defface boxy-rel nil
+(defface boxy-rel
+  '((t :foreground "hot pink"))
   "Face for the box which is related to the box under the cursor.")
 
-(face-spec-set
- 'boxy-rel
- '((t :foreground "hot pink"))
- 'face-defface-spec)
-
-(defface boxy-tooltip nil
-  "Face for tooltips in a boxy diagram.")
-
-(face-spec-set
- 'boxy-tooltip
+(defface boxy-tooltip
  '((((background dark)) (:background "gray30" :foreground "gray"))
    (t (:background "gainsboro" :foreground "dim gray")))
- 'face-defface-spec)
+ "Face for tooltips in a boxy diagram.")
 
 ;;;; Constants
 
@@ -428,10 +413,10 @@
 (define-derived-mode boxy-mode special-mode
   "Boxy"
   "Mode for viewing an boxy diagram."
-  (let ((inhibit-message t))     ;FIXME: Please report the message as an error.
-    (setq indent-tabs-mode nil)
-    (cursor-sensor-mode t)
-    (toggle-truncate-lines t)))
+  (visual-line-mode -1)
+  (setq indent-tabs-mode nil)
+  (cursor-sensor-mode t)
+  (setq truncate-lines t))
 
 (cl-defun boxy-pp (box
                    &key
@@ -931,7 +916,7 @@ Uses `boxy--offset' to determine row and column offsets."
                                   (let ((remaining-chars (- (save-excursion 
(end-of-line)
                                                                             
(current-column))
                                                             (current-column))))
-                                    (delete-char (min (length str) 
remaining-chars))))))
+                                    (delete-char (min (string-width str) 
remaining-chars))))))
             (draw (cons top left)
                   (concat (cond ((and double dashed) "┏")
                                 (double "╔")
@@ -999,7 +984,7 @@ Uses `boxy--offset' to determine row and column offsets."
                             (* 2 padding)))
              (width (+ base-width
                        (if (slot-boundp box :name)
-                           (with-slots (name) box (length name))
+                           (with-slots (name) box (string-width name))
                          0)))
              (children (boxy--get-children box)))
         (setq stored-width
@@ -1030,7 +1015,7 @@ Uses `boxy--offset' to determine row and column offsets."
                                                   (mapcar #'boxy--get-width 
row)
                                                   (* -1 margin)))
                                                rows))))
-                  (if (> width (+ (* 2 padding) children-width))
+                  (if (> width (+ 1 (* 2 padding) children-width))
                       width
                     (+ base-width children-width)))))))))
 
diff --git a/tests/boxy-test-chinese.el b/tests/boxy-test-chinese.el
new file mode 100644
index 0000000..0d9f30e
--- /dev/null
+++ b/tests/boxy-test-chinese.el
@@ -0,0 +1,51 @@
+;;; boxy-test-chinese.el --- Chinese test cases for boxy -*- lexical-binding: 
t -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; Author: Tyler Grinn <tylergrinn@gmail.com>
+
+;;; Code:
+
+;;;; Requirements
+
+(require 'boxy-test-setup)
+
+;;;; Tests
+
+(ert-deftest boxy-test-chinese-hello ()
+  (let* ((world (boxy-box))
+         (thing (boxy-box :name "thing" :margin-y 0))
+         (hello (boxy-box :name "你好" :rel "in")))
+    (boxy-add-next thing world)
+    (boxy-add-next hello thing)
+    (boxy-pp world)
+    (with-current-buffer (get-buffer "*Boxy*")
+      (should (string= (buffer-string)
+           "
+╭──────╮
+│thing │
+│╭────╮│
+││你好││
+│╰────╯│
+╰──────╯
+")))))
+
+(ert-deftest boxy-test-chinese-greeting ()
+  (let* ((world (boxy-box))
+         (greeting (boxy-box :name "我叫泰勒" :margin-y 0))
+         (hello (boxy-box :name "你好" :rel "in")))
+    (boxy-add-next greeting world)
+    (boxy-add-next hello greeting)
+    (boxy-pp world)
+    (with-current-buffer (get-buffer "*Boxy*")
+      (should (string= (buffer-string)
+           "
+╭────────╮
+│我叫泰勒│
+│╭────╮  │
+││你好│  │
+│╰────╯  │
+╰────────╯
+")))))
+
+



reply via email to

[Prev in Thread] Current Thread [Next in Thread]