[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
16/26: gurses: Mini refactor.
From: |
John Darrington |
Subject: |
16/26: gurses: Mini refactor. |
Date: |
Sun, 22 Jan 2017 12:09:24 +0000 (UTC) |
jmd pushed a commit to branch wip-installer
in repository guix.
commit b264f4e04d88195281fda81c379d2947274e8166
Author: John Darrington <address@hidden>
Date: Wed Jan 18 17:46:19 2017 +0100
gurses: Mini refactor.
* gurses/form.scm: (draw-field-space): New procedure.
---
gurses/form.scm | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/gurses/form.scm b/gurses/form.scm
index b2161b6..bfa7620 100644
--- a/gurses/form.scm
+++ b/gurses/form.scm
@@ -34,6 +34,7 @@
#:use-module (ncurses curses)
#:use-module (ice-9 match)
+ #:use-module (srfi srfi-1)
#:use-module (srfi srfi-9))
(define-record-type <field>
@@ -62,12 +63,21 @@
(+ (field-cursor-position field)
(form-tabpos form)))))
+(define (draw-field-space win field y x)
+ "Draws the template for FIELD at Y, X"
+ (addchstr win
+ (make-list
+ (if (list? (field-size field))
+ (fold (lambda (x prev) (max prev (string-length x))) 0
+ (field-size field))
+ (field-size field))
+ (underline #\space))
+ #:y y
+ #:x x))
+
(define (redraw-field form field n)
"Redraw the FIELD in FORM"
- (addchstr (form-window form)
- (make-list (field-size field) (underline #\space))
- #:y n
- #:x (form-tabpos form))
+ (draw-field-space (form-window form) field n (form-tabpos form))
(addstr (form-window form) (field-value field)
#:y n
@@ -241,7 +251,7 @@ label eq? to N"
(pos 0))
(if (array-in-bounds? fields pos)
(let ((f (array-ref fields pos)))
- (addchstr win (make-list (field-size f) (underline #\space)) #:y
pos #:x xpos)
+ (draw-field-space win f pos xpos)
(loop fields (1+ pos)))))))
(define (get-current-field form)
- 15/26: gurses: Allow menu update to work for panel windows., (continued)
- 15/26: gurses: Allow menu update to work for panel windows., John Darrington, 2017/01/22
- 18/26: gurses: Populate the choices box in forms., John Darrington, 2017/01/22
- 06/26: installer: Add an explanatory text to the main page., John Darrington, 2017/01/22
- 22/26: installer: mount-points page: Enlarge the forms window., John Darrington, 2017/01/22
- 13/26: installer: Remove unnecessary "begin"., John Darrington, 2017/01/22
- 24/26: installer: Remove redundant list of file system types., John Darrington, 2017/01/22
- 20/26: gurses: Populate dropdown boxes in forms using a menu., John Darrington, 2017/01/22
- 12/26: installer: Fix bug in config generation., John Darrington, 2017/01/22
- 26/26: doc: Remove the text which mentions there is no graphical installer., John Darrington, 2017/01/22
- 19/26: installer: Add a popup window for forms which have multiple choice fields., John Darrington, 2017/01/22
- 16/26: gurses: Mini refactor.,
John Darrington <=
- 09/26: installer: Explicitly set the #:panel parameter for window creation procedures., John Darrington, 2017/01/22
- 11/26: installer: New procedure refresh*., John Darrington, 2017/01/22
- 23/26: gurses: Remove box from form popup window., John Darrington, 2017/01/22