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

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

[elpa] externals/company 1fdba51490 1/7: Make scrollbar narrower; move i


From: ELPA Syncer
Subject: [elpa] externals/company 1fdba51490 1/7: Make scrollbar narrower; move into the right margin
Date: Thu, 9 Nov 2023 21:57:31 -0500 (EST)

branch: externals/company
commit 1fdba51490438f65a002bf6917680d21826ae2ff
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>

    Make scrollbar narrower; move into the right margin
    
    Building on the pixelwise popup display.
---
 NEWS.md    |  1 +
 company.el | 31 ++++++++++++++++++++++++++-----
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index 42d05f8446..df68be1513 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,7 @@
 
 # Next
 
+* New user option `company-tooltip-scrollbar-width` with default 0.4.
 * The tooltip uses a more complex rendering approach, supporting double
   width/CJK characters, as well as buffer text of different sizes
   ([#1394](https://github.com/company-mode/company-mode/pull/1394)).
diff --git a/company.el b/company.el
index 391f183c66..3e29e6c981 100644
--- a/company.el
+++ b/company.el
@@ -299,6 +299,10 @@ This doesn't include the margins and the scroll bar."
   :type '(choice (const :tag "Scrollbar" scrollbar)
                  (const :tag "Two lines" lines)))
 
+(defcustom company-tooltip-scrollbar-width 0.4
+  "Width of the scrollbar thumb, in columns."
+  :type 'number)
+
 (defcustom company-tooltip-align-annotations nil
   "When non-nil, align annotations to the right tooltip border."
   :type 'boolean
@@ -3665,7 +3669,7 @@ but adjust the expected values appropriately."
                (str (car item))
                (annotation (cadr item))
                (left (nth 2 item))
-               (right (company-space-string company-tooltip-margin))
+               (right (company--right-margin))
                (width width)
                (selected (equal selection i)))
           (when company-show-quick-access
@@ -3701,10 +3705,27 @@ but adjust the expected values appropriately."
       (cons lower upper))))
 
 (defun company--scrollbar (i bounds)
-  (propertize " " 'face
-              (if (and (>= i (car bounds)) (<= i (cdr bounds)))
-                  'company-tooltip-scrollbar-thumb
-                'company-tooltip-scrollbar-track)))
+  (let* ((scroll-width (ceiling (* (default-font-width)
+                                   company-tooltip-scrollbar-width))))
+    (propertize " "
+                'display `(space . (:width (,scroll-width)))
+                'face
+                (if (and (>= i (car bounds)) (<= i (cdr bounds)))
+                    'company-tooltip-scrollbar-thumb
+                  'company-tooltip-scrollbar-track))))
+
+(defun company--right-margin ()
+  (if (or (not (eq company-tooltip-offset-display 'scrollbar))
+          (not (display-graphic-p))
+          (= company-tooltip-scrollbar-width 1))
+      (company-space-string company-tooltip-margin)
+    (let* ((scroll-width (ceiling (* (default-font-width)
+                                     company-tooltip-scrollbar-width)))
+           (rest-width (- (* (default-font-width) company-tooltip-margin)
+                          scroll-width)))
+      (propertize
+       (company-space-string company-tooltip-margin)
+       'display `(space . (:width (,rest-width)))))))
 
 (defun company--scrollpos-line (text width fancy-margin-width)
   (propertize (concat (company-space-string company-tooltip-margin)



reply via email to

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