I am having problems with set-field-type! e.g. if I go into one of the example code fragments such as below and insert (set-field-type! (first field) TYPE_ALPHA 10)
I get the error message:
ERROR: Unbound variable: TYPE_ALPHA
Same with other types. The code works fine with that line commented out, so I am importing the correct modules and have things otherwise properly configured. I need to use TYPE_ENUM. Any suggestions?
In general I really like the guile-ncurses library.
;; Create a new form (define my-form (new-form field))
;; Calculate the area associated with the form
(define xy (scale-form my-form)) (define rows (car xy)) (define cols (cadr xy))
;; Create the window to be associated with the form (define my-form-win (newwin (+ 4 rows) (+ 4 cols)
4 4)) (keypad! my-form-win #t)
;; Set main window and subwindow (set-form-win! my-form my-form-win) (set-form-sub! my-form (derwin my-form-win rows cols 2 2))
;; Print a border around the main window and print a title (box my-form-win 0 0) (print-in-middle my-form-win 1 0 (+ cols 4) "My Form" (color-pair 1))
(post-form my-form)
(refresh my-form-win)
(addstr stdscr "Use UP, DOWN arrow keys to switch between fields" #:y (- (lines) 2) #:x 0) (refresh stdscr)
;; Loop through to get user requests
(let loop ((ch (getch my-form-win))) (if (not (eqv? ch (key-f 2))) (cond ((eqv? ch KEY_DOWN) (begin ;; Go to the end of the next field (form-driver my-form REQ_NEXT_FIELD)
(form-driver my-form REQ_END_LINE) (loop (getch my-form-win)))) ((eqv? ch KEY_UP) (begin ;; Go to the end of the previous field (form-driver my-form REQ_PREV_FIELD)
(form-driver my-form REQ_END_LINE) (loop (getch my-form-win)))) (else (begin ;; Print any normal character (form-driver my-form ch)
(loop (getch my-form-win)))))))