Skip to content

Commit

Permalink
Update frame's background
Browse files Browse the repository at this point in the history
  • Loading branch information
iris-garcia committed Jul 19, 2021
1 parent 156f65c commit 4672eb8
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions company-box.el
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

(require 'subr-x)
(require 'dash)
(require 'dash)
(require 'dash-functional)
(require 'company)
(require 'company-box-icons)
(require 'company-box-doc)
Expand Down Expand Up @@ -112,7 +112,7 @@ Only the 'background' color is used in this face."

(defface company-box-numbers
'((t :inherit company-box-candidate))
"Face used for numbers when `company-show-quick-access' is used."
"Face used for numbers when `company-show-numbers' is used."
:group 'company-box)

(defcustom company-box-color-icon t
Expand Down Expand Up @@ -290,7 +290,7 @@ Examples:
(dotimes (index 20)
(aset vec index
(concat
(string-trim (funcall company-quick-access-hint-function (mod index 10)))
(string-trim (funcall company-show-numbers-function (mod (1+ index) 10)))
(and (> index 10) " "))))
vec))

Expand All @@ -303,6 +303,10 @@ Examples:
'icons-in-terminal
(lambda (&rest _) " ")))

(defun company-box--update-frame-background (frame)
(with-selected-frame frame
(set-background-color (face-background 'company-tooltip nil t))))

(defun company-box--get-frame (&optional frame)
"Return the company-box child frame on FRAME."
(frame-local-getq company-box-frame frame))
Expand Down Expand Up @@ -386,7 +390,7 @@ It doesn't nothing if a font icon is used."
(defvar-local company-box--numbers-pos nil)

(defun company-box--remove-numbers (&optional side)
(let ((side (or side (if (eq company-show-quick-access 'left) 'left-margin 'right-margin)))
(let ((side (or side (if (eq company-show-numbers 'left) 'left-margin 'right-margin)))
(max (point-max)))
(--each company-box--numbers-pos
(and (< it max)
Expand All @@ -395,8 +399,8 @@ It doesn't nothing if a font icon is used."
(setq company-box--numbers-pos nil)))

(defun company-box--update-numbers (start)
(let ((side (if (eq company-show-quick-access 'left) 'left-margin 'right-margin))
(offset (if (eq company-show-quick-access 'left) 0 10))
(let ((side (if (eq company-show-numbers 'left) 'left-margin 'right-margin))
(offset (if (eq company-show-numbers 'left) 0 10))
(inhibit-redisplay t)
(inhibit-modification-hooks t))
(company-box--remove-numbers side)
Expand All @@ -411,7 +415,7 @@ It doesn't nothing if a font icon is used."
(put-text-property (1- it) it 'display `((margin ,side) ,(aref company-box--numbers (+ index offset))))))))

(defun company-box--maybe-move-number (start)
(when company-show-quick-access
(when company-show-numbers
(company-box--update-numbers start)))

(defvar-local company-box--last-scroll 0)
Expand Down Expand Up @@ -506,7 +510,7 @@ It doesn't nothing if a font icon is used."
(let ((buffer (current-buffer))
(inhibit-modification-hooks t)
(candidates-length company-candidates-length)
(show-numbers company-show-quick-access)
(show-numbers company-show-numbers)
(with-icons-p company-box--with-icons-p)
(window-configuration-change-hook nil)
(buffer-list-update-hook nil))
Expand All @@ -516,7 +520,7 @@ It doesn't nothing if a font icon is used."
(put-text-property (point-min) (point-max) 'company-box--rendered nil)
(setq company-box--first-render t
company-candidates-length candidates-length
company-show-quick-access show-numbers
company-show-numbers show-numbers
company-box--with-icons-p with-icons-p)
(unless on-update
(setq mode-line-format nil
Expand Down Expand Up @@ -583,7 +587,7 @@ It doesn't nothing if a font icon is used."
(char-height (frame-char-height frame))
(char-width (frame-char-width frame))
(height (* (min company-candidates-length company-tooltip-limit) char-height))
(space-numbers (if (eq company-show-quick-access 'left) char-width 0))
(space-numbers (if (eq company-show-numbers 'left) char-width 0))
(frame-resize-pixelwise t)
(mode-line-y (company-box--point-bottom))
((p-x . p-y) (company-box--prefix-pos))
Expand Down Expand Up @@ -638,6 +642,7 @@ It doesn't nothing if a font icon is used."
(unless (company-box--get-frame)
(company-box--set-frame (company-box--make-frame)))
(company-box--compute-frame-position (company-box--get-frame))
(company-box--update-frame-background (company-box--get-frame))
(company-box--move-selection t)
(company-box--update-frame-position (company-box--get-frame))
(unless (frame-visible-p (company-box--get-frame))
Expand Down Expand Up @@ -726,7 +731,7 @@ It doesn't nothing if a font icon is used."
string))

(defun company-box--make-number-prop nil
(let ((side (if (eq company-show-quick-access 'left) 'left-margin 'right-margin)))
(let ((side (if (eq company-show-numbers 'left) 'left-margin 'right-margin)))
(propertize " " 'company-box--number-pos t 'display `((margin ,side) " "))))

(defun company-box--make-line (candidate)
Expand All @@ -744,7 +749,7 @@ It doesn't nothing if a font icon is used."
(line (concat (unless (or (and (= space 2) icon-p) (= space 0))
(propertize " " 'display `(space :width ,(if (or (= space 1) (not icon-p)) 1 0.75))))
(company-box--apply-color icon-string i-color)
(when company-show-quick-access
(when company-show-numbers
(company-box--make-number-prop))
(company-box--apply-color candidate-string c-color)
align-string
Expand Down Expand Up @@ -818,7 +823,7 @@ It doesn't nothing if a font icon is used."
(when (> len max)
(setq max len)))
(forward-line))))
(* (+ max (if company-box--with-icons-p 6 2) (if company-show-quick-access 2 0))
(* (+ max (if company-box--with-icons-p 6 2) (if company-show-numbers 2 0))
char-width)))

(defun company-box--get-start-end-for-width (win win-start)
Expand Down Expand Up @@ -993,8 +998,8 @@ It doesn't nothing if a font icon is used."
(defun company-box--prevent-changes (&rest _)
(set-window-margins
nil
(if (eq company-show-quick-access 'left) 1 0)
(if (eq company-show-quick-access 't) 2 0)))
(if (eq company-show-numbers 'left) 1 0)
(if (eq company-show-numbers 't) 2 0)))

(defun company-box--handle-window-changes (&optional on-idle)
(-when-let* ((frame (company-box--get-frame)))
Expand Down

0 comments on commit 4672eb8

Please sign in to comment.