guix-commits
[Top][All Lists]
Advanced

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

03/04: gurses: forms: Minor refactor.


From: John Darrington
Subject: 03/04: gurses: forms: Minor refactor.
Date: Thu, 23 Feb 2017 11:05:01 -0500 (EST)

jmd pushed a commit to branch wip-installer
in repository guix.

commit e7a688428137068d21717a942e0f9dd2d1d3137b
Author: John Darrington <address@hidden>
Date:   Tue Feb 21 08:45:50 2017 +0100

    gurses: forms: Minor refactor.
    
    * gurses/form.scm (form-enter): Add some more local symbols and use
    them.
---
 gurses/form.scm | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/gurses/form.scm b/gurses/form.scm
index c4adb3b..55c583f 100644
--- a/gurses/form.scm
+++ b/gurses/form.scm
@@ -158,15 +158,14 @@ label eq? to N"
     (form-update-cursor form))
 
   (if (form-enabled? form)
-      (let* ((f (array-ref (form-items form) (form-current-item form)))
-            (left (substring (field-value f) 0 (field-cursor-position f)))
-            (centre (substring (field-value f) (field-cursor-position f)
-                               (min (1+ (field-cursor-position f))
-                                    (string-length (field-value f)))))
-            (right (substring (field-value f)
-                              (min (1+ (field-cursor-position f))
-                                   (string-length (field-value f)))
-                              (string-length (field-value f)))))
+      (let* ((f      (array-ref (form-items form) (form-current-item form)))
+             (value  (field-value f))
+             (len    (string-length value))
+             (pos    (field-cursor-position f))
+            (left   (substring value 0 pos))
+            (centre (substring value pos (min (1+ pos) len)))
+            (right  (substring value (min (1+ pos) len) len)))
+
        (cond ((and (char? ch)
                    (not (char-set-contains? char-set:iso-control ch)))
 
@@ -181,7 +180,7 @@ label eq? to N"
               (field-set-value! f (string-append left right))
               (redraw-current-field form f)
               (form-update-cursor form))
-       
+
              ((eq? ch KEY_BACKSPACE)
               (if (positive? (field-cursor-position f))
                   (begin



reply via email to

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