emacs-devel
[Top][All Lists]
Advanced

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

Sv: Sticky tooltips


From: arthur miller
Subject: Sv: Sticky tooltips
Date: Thu, 1 Oct 2020 02:28:25 +0000

I can't sleep, so I thought it help to read some C code. I got just more awake.

Anyway, I have looked at x-show-tip, and yes it is pretty  much same as I described 🙂.

I am not sure how to get buffer out of x-show-tip, so I was thinking about different
strategv: modify x-show-tip to take as argument a buffer (or string-or-buffer) and modify it accordingly;
throw away most of "lispy" code that deals with setting up buffer and styling the string. The
buffer itself should be setup and styled on lisp side in tooltip.el. Just as illutstration:

(defcustom tooltip-enable-sticky nil
  "When enabled the tooltip frame will show a small checkbox widget
witch when enabled will make a tooltip not dissapear after timeout. To
  close a sticky tooltip untick the checkbox."
  :type 'boolean
  :group 'tooltip)

(defun tooltip-show (text &optional use-echo-area)
....
  (if use-echo-area
      (tooltip-show-help-non-mode text)
    (condition-case error
.....

 (with-current-buffer (get-buffer-create "some name")

     ;; do some other setup needed ...

     (insert (propertize text 'face 'tooltip))

     (when enable-sticky-tooltips
        ;; setup "widget" part to show
        ;; checkbox
     )
     
     ;; send in "ready-made" buffer
     
     (x-show-tip (current-buffer)
           (  ... )
.....


Amd x-show-tip would have signature like this

  (Lisp_Object buffer, Lisp_Object frame, Lisp_Object parms, 
  Lisp_Object timeout, Lisp_Object dx, Lisp_Object dy)

I don't know how the function would deal with Gtk tooltips; if they can also take a buffer
and display it, that is why I mean the function to take string-or-buffer.

Another thing is timer; if user is going to make an action to cancel timer (enable sticky)
then lisp code needs access to the timer, so it probably should be handled in lisp too.


Från: Eli Zaretskii <eliz@gnu.org>
Skickat: den 30 september 2020 16:50
Till: Arthur Miller <arthur.miller@live.com>
Kopia: emacs-devel@gnu.org <emacs-devel@gnu.org>
Ämne: Re: Sticky tooltips
 
> From: Arthur Miller <arthur.miller@live.com>
> Cc: emacs-devel@gnu.org
> Date: Tue, 29 Sep 2020 23:30:14 +0200
>
> Yeah, you are correct, what tooltip already does, as you say is
> logically what I described, but the implementation is different:
> tooltip.el seems to outsource all it's work to xfns.c, and the code for
> tooltip frame creation; I used just "a naked frame" and some Lisp to
> create an effect of a tooltip.

The C-level implementation notwithstanding, we still insert the
tooltip text into a buffer, so we could snatch it from there, right?
We could have a command that took that text and displayed it in *Help*
buffer, for example.

> By the way; "tooltip-show" (in tooltip.el) seems to take a string
> argument; rather than a buffer, and that widget library "widget.el",
> needs a buffer (for the minor mode, etc).

See above.

> Just as a side curious question: did tooltips really needed own c
> implementation? Isn't code in x-create-tip-frame and x-show-tip seems
> redundant to other frame creation routines/display? Couldn't tooltips be
> implemented using normal frames, with "tooltip-special" code written in
> lisp?

If you compare x-create-frame and x-create-tip-frame, you will see
that the tip frame is special, and some of the differences are in
fields of the frame object that are not exposed to Lisp.  To move this
to Lisp would mean we'd have to expose them to Lisp first, and I'm not
sure we want to do that.

> I dont' mean to ditch it away, just a reflection on complexity. Maybe I
> don't see all the complexity with tooltips; but it is still ~900+ lines
> of c code that need to be maintained for X11, and there are well w32 and
> ns implementations, so around 3k locs?

The code replication is a separate issue: we did make an effort lately
to extract some common code and have it only once.  Patches are
welcome to do that in x-create-frame and x-create-tip-frame as well.
It isn't entirely trivial, because the common code is interspersed
with window-system specific API calls.

reply via email to

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