Skip to content

Commit

Permalink
Be less instrusive as requested (#57)
Browse files Browse the repository at this point in the history
Add customization variables for tooltip colors
  • Loading branch information
marciosmiderle authored and expez committed Jan 19, 2017
1 parent 41014e9 commit f5c4ee3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ it to the popup help buffer provided by

If you hit `M-x customize-group <RET> company-quickhelp <RET>` you'll
find a few variables you can diddle.
For instance, you can change the help popup text background and foreground colors.

You might also want to put this in your `init.el`:

Expand Down
20 changes: 17 additions & 3 deletions company-quickhelp.el
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ be triggered manually using `company-quickhelp-show'."
(const :tag "Don't limit the number of lines shown" nil))
:group 'company-quickhelp)

(defcustom company-quickhelp-color-foreground nil
"Popup text foreground color."
:type '(choice (color)
(const :tag "Default" nil))
:group 'company-quickhelp)

(defcustom company-quickhelp-color-background nil
"Popup text background color."
:type '(choice (color)
(const :tag "Default" nil))
:group 'company-quickhelp)

(defvar company-quickhelp--timer nil
"Quickhelp idle timer.")

Expand Down Expand Up @@ -159,7 +171,9 @@ currently active `company' completion candidate."
(let* ((frame (window-frame (selected-window)))
(max-width (pos-tip-x-display-width frame))
(max-height (pos-tip-x-display-height frame))
(w-h (pos-tip-string-width-height doc)))
(w-h (pos-tip-string-width-height doc))
(fg-bg `(,company-quickhelp-color-foreground
. ,company-quickhelp-color-background)))
(cond
((> (car w-h) width)
(setq doc (pos-tip-fill-string doc width nil 'none nil max-height)
Expand All @@ -168,11 +182,11 @@ currently active `company' completion candidate."
(> (cdr w-h) max-height))
(setq doc (pos-tip-truncate-string doc max-width max-height)
w-h (pos-tip-string-width-height doc))))
(pos-tip-show-no-propertize doc nil (overlay-start ovl) nil timeout
(pos-tip-show-no-propertize doc fg-bg (overlay-start ovl) nil timeout
(pos-tip-tooltip-width (car w-h) (frame-char-width frame))
(pos-tip-tooltip-height (cdr w-h) (frame-char-height frame) frame)
nil (+ overlay-width overlay-position) 1))
(pos-tip-show doc nil (overlay-start ovl) nil timeout width nil
(pos-tip-show doc fg-bg (overlay-start ovl) nil timeout width nil
(+ overlay-width overlay-position) 1))))))

(defun company-quickhelp--set-timer ()
Expand Down

0 comments on commit f5c4ee3

Please sign in to comment.