How to create a widget that updates when refresh is sent?

When I define a widget like this:

(tm-widget (buffer-list-choice)
  (refreshable "wos-test-widget-kind"
    (resize "200px" "50px"
      (text (number->string (current-time)))
)))

I may show it using (show buffer-list-choice)
and I refresh the "wos-test-widget-kind" using the refresh-now function as in (refresh-now "wos-test-widget-kind") then the underlying widget gets updated, which I can check by running the show command again, but the first widget that was shown before the refresh, does not update. How do I make the visible widget update?

I looked a bit into it and I did not find any way. Perhaps there is no way, or perhaps someone else knows.

1 Like

It seems that text widgets do not support refreshing. texmacs-output works:

(tm-widget (bibwid-preview)
  (resize ("520px" "520px" "9999px") ("100px" "100px" "9999px")
    (scrollable 
      (refreshable "bibwid-preview"
        (texmacs-output
         (bibwid-output)
         '(style "generic"))))))

(from the sources)

1 Like

This widget definition gives me an error and I don’t know why. If I remove the quasi-quote, then it works fine. Any ideas?

(tm-widget (wos/test-widget)
  (refreshable "wos/test-widget-kind"
    (resize "200px" "50px"
      (let ((converted (number->string 32)))
       (texmacs-output
        `(document ,converted))
        '(style (tuple "generic"))
     )
    )
  )
)

parentheses :slight_smile:

(tm-widget (wos/test-widget)
  (refreshable "wos/test-widget-kind"
    (resize "200px" "50px"
      (let ((converted (number->string 32)))
       (texmacs-output
        `(document ,converted)
        '(style (tuple "generic"))
     )
    )
  )
))

Formatted in the following way the balancing is easier to see:

(tm-widget (wos/test-widget)
  (refreshable "wos/test-widget-kind"
    (resize "200px" "50px"
      (let ((converted (number->string 32)))
       (texmacs-output
        `(document ,converted)
        '(style (tuple "generic")))))))

Or an editor which highlights the pairing, or both formatting and highlighting.

1 Like

I might be retarded, but

(tm-widget (wos/test-widget)
  (refreshable "wos/test-widget-kind"
    (resize "200px" "50px"
      (let ((converted (number->string 32)))
        (texmacs-output
          `(document ,converted)
          '(style (tuple "generic")))))))

still gives me an error when I copy it into the (interactive footer-eval) repl in TeXmacs.scheme-error

It works without the quasi-quote. Maybe that is not supported?

It works for me in a Scheme session. Possibly when you copy the quasi-quote character ‘`’ could be not encoded correctly? try to first copy the snippet in an external ascii editor and the copy it back. Or use a session, it is more practical for testing.

Yeah, it was some copying issue, because when I copied it into a session, then instead of a double quote ", it inserted two single quotes ‘’ into strings. It works now, thanks.

When you copy in TeXmacs you have to choose “Paste from Verbatim” to have the correct encoding.

1 Like