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

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

[elpa] externals/boxy 7a04171 07/10: Added more tooltip test cases


From: ELPA Syncer
Subject: [elpa] externals/boxy 7a04171 07/10: Added more tooltip test cases
Date: Fri, 15 Oct 2021 10:57:11 -0400 (EDT)

branch: externals/boxy
commit 7a04171296ecb5cfabbf5a86839189f6314abb2e
Author: Tyler Grinn <tylergrinn@gmail.com>
Commit: Tyler Grinn <tylergrinn@gmail.com>

    Added more tooltip test cases
---
 boxy.el                   | 10 ++++++----
 tests/boxy-test-visual.el | 22 +++++++++++++++++-----
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/boxy.el b/boxy.el
index 1e7ed1c..cdc66b3 100644
--- a/boxy.el
+++ b/boxy.el
@@ -1555,6 +1555,7 @@ characters if possible."
          overlays)
     (dolist (str rows)
       (let ((left-margin 0)
+            (right-margin 0)
             start end cur-column)
         (save-excursion
           (let ((inhibit-read-only t))
@@ -1564,12 +1565,12 @@ characters if possible."
             (if (= cur-column left)
                 (setq start (point))
               (setq left-margin (- cur-column left))
-              (setq start (- (point) (- cur-column left))))
+              (setq start (- (point) left-margin)))
             (move-to-column (+ left width) t)
+            (setq end (point))
             (setq cur-column (current-column))
-            (if (= cur-column (+ left width))
-                (setq end (point))
-              (setq end (- (point) (- cur-column left))))))
+            (if (not (= cur-column (+ left width)))
+                (setq right-margin (- cur-column (+ left width))))))
         (setq str (format
                    (concat " %-" (number-to-string (- width 2)) "s ")
                    (truncate-string-to-width str boxy--tooltip-max-width nil 
nil t)))
@@ -1577,6 +1578,7 @@ characters if possible."
           (overlay-put overlay 'face boxy--tooltip-face)
           (overlay-put overlay 'display `((margin nil) ,str))
           (overlay-put overlay 'before-string (make-string left-margin ?\s))
+          (overlay-put overlay 'after-string (make-string right-margin ?\s))
           (push overlay overlays))
         (setq top (+ top 1))))
     (save-excursion (boxy-mode-recalculate-box-ring))
diff --git a/tests/boxy-test-visual.el b/tests/boxy-test-visual.el
index fb1a523..4da1d1b 100644
--- a/tests/boxy-test-visual.el
+++ b/tests/boxy-test-visual.el
@@ -1,4 +1,4 @@
-;;; boxy-test-chinese.Eli --- Visual tests for boxy -*- lexical-binding: t -*-
+;;; boxy-test-visual.el --- Visual tests for boxy -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2021 Free Software Foundation, Inc.
 
@@ -19,14 +19,26 @@
        (hello (boxy-box :name "你好" :rel "in" :tooltip "你好\n我叫泰勒")))
   (boxy-add-next greeting world)
   (boxy-add-next hello greeting)
-  (boxy-pp world))
+  (boxy-pp world :display-buffer-fn 'display-buffer-same-window))
 
 ;; Check that the tooltip for 你好 shows correctly
 (let* ((world (boxy-box))
        (greeting (boxy-box :name "我叫泰勒" :margin-y 0))
-       (hello (boxy-box :name "你好" :rel "in" :tooltip "你好\n我叫泰勒"))
-       (right (boxy-box :name "右边 " :rel "to the right of")))
+       (hello (boxy-box :name "你好" :rel "in" :tooltip "你好\n我叫泰勒我叫泰勒"))
+       (right (boxy-box :name "右边右边右边右边" :rel "to the right of")))
   (boxy-add-next greeting world)
   (boxy-add-next hello greeting)
   (boxy-add-next right greeting)
-  (boxy-pp world))
+  (boxy-pp world :display-buffer-fn 'display-buffer-same-window))
+
+
+;; Check that the tooltip for 你好 is truncated
+(let* ((boxy-tooltip-max-width 15)
+       (world (boxy-box))
+       (greeting (boxy-box :name "我叫泰勒" :margin-y 0))
+       (hello (boxy-box :name "你好" :rel "in" :tooltip "你好\n我叫泰勒我叫泰勒"))
+       (right (boxy-box :name "右边右边右边右边" :rel "to the right of")))
+  (boxy-add-next greeting world)
+  (boxy-add-next hello greeting)
+  (boxy-add-next right greeting)
+  (boxy-pp world :display-buffer-fn 'display-buffer-same-window))



reply via email to

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