Skip to Content.
Sympa Menu

texmacs-users - Re: read in TeXmacs's Guile

Subject: mailing-list for TeXmacs Users

List archive

Re: read in TeXmacs's Guile


Chronological Thread 
  • From: Massimiliano Gubinelli <address@hidden>
  • To: Wolfgang Lindner <address@hidden>
  • Cc: "address@hidden" <address@hidden>
  • Subject: Re: read in TeXmacs's Guile
  • Date: Mon, 12 Dec 2022 16:07:16 +0000

TeXmacs/Guile can interact with the user via popup windows in the UI. Please give a look at the files

$TEXMACS_PATH/progs/kernel/texmacs/tm-dialogue.scm

where you have functions like the following:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Questions with user interaction
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define-public (user-ask prompt cont)
  (tm-interactive cont
    (if (string? prompt)
        (list (build-interactive-arg prompt))
        (list prompt))))

(define-public (user-confirm prompt default cont)
  (let ((k (lambda (answ) (cont (yes? answ)))))
    (if default
        (user-ask (list prompt "question" (translate "yes") (translate "no")) k)
        (user-ask (list prompt "question" (translate "no") (translate "yes")) k))))

(define-public (user-url prompt type cont)
  (user-delayed (lambda () (choose-file cont prompt type))))

(define-public (user-delayed cont)
  (exec-delayed cont))


they work via continuations, so you will have to rewrite a bit your program.


Also you can create full-fedged widgets, look for example the file

$TEXMACS_PATH/progs/kernel/gui/tm-menu-test.scm


Best
Max




On 12 Dec 2022, at 15:11, Wolfgang Lindner <address@hidden> wrote:

Hi group,

Currently I work through the book of G Springer about Scheme using TeXmacs/Guile.
Until ch. 5 there were no problems and all programs run like a charm.

Now in Ch.6 about input/output I run into problems.
Here is a typical one.

;------------------------------------------------------------------
; - Program 6.6, pg. 174 -

(define read-demo
  (lambda ()
    (display "Enter data (enter done when finished): ")
    (let ((response (read)))
      (cond
        ((eq? response 'done) (display "Thank you. Good-bye."))
        (else (display "You entered: ")
              (write response)
              (newline)
              (read-demo))))))

; - End Program -
;------------------------------------------------------------------

Is it possible to use Texmacs-Guile interactive?
I know: use ‚format ..' instead of write/display ..

But what to do with (read) ??
How to work with user input and output?

Any hints or making the program about working are very welcome-

Best, Wolfgang


----
Dr. Wolfgang Lindner
Leichlingen, Germany
send from my iMac




Archive powered by MHonArc 2.6.24.

Top of Page