[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
149/197: gurses: Add new procedure "word-endings".
From: |
Danny Milosavljevic |
Subject: |
149/197: gurses: Add new procedure "word-endings". |
Date: |
Mon, 3 Jul 2017 20:37:16 -0400 (EDT) |
dannym pushed a commit to branch wip-installer-2
in repository guix.
commit 441aff6bceabe5798dbfac1669dc2d7bf635e0c5
Author: John Darrington <address@hidden>
Date: Fri Jan 27 22:04:55 2017 +0100
gurses: Add new procedure "word-endings".
* gurses/stexi.scm (word-endings): New procedure.
---
gurses/stexi.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/gurses/stexi.scm b/gurses/stexi.scm
index e85ed82..87a7572 100644
--- a/gurses/stexi.scm
+++ b/gurses/stexi.scm
@@ -158,6 +158,33 @@ cdr is the remainder"
(reverse (paragraph-format text line-length )))
+(define-public (word-endings str)
+ "Return a list of all the indicies of all the word endings in STR. The list
is sorted in order of prefered padding location."
+ (let loop ((in str)
+ (x 0)
+ (n '())
+ (prev-white #t)
+ (prev-char #f)
+ )
+ (match
+ in
+ (() (map-in-order
+ (lambda (x) (car x))
+ (sort n (lambda (x y)
+ (if (eqv? (cadr x) (cadr y))
+ (> (caddr x) (caddr y))
+ (> (cadr x) (cadr y)))))))
+ ((first . rest)
+ (let ((white (xchar-blank? first)))
+ (loop rest (1+ x) (if (and (not prev-white) white)
+ (cons (list x
+ (case (xchar->char prev-char)
+ ((#\.) 3)
+ ((#\,) 2)
+ (else 1))
+ (random 1.0)) n)
+ n) white first))))))
+
(define (pad-complex-string str len)
"Return a complex string based on STR but with interword padding to make the
string of length LEN"
- 152/197: installer: New file i18n.scm., (continued)
- 152/197: installer: New file i18n.scm., Danny Milosavljevic, 2017/07/03
- 110/197: installer: Add an explanatory text to the main page., Danny Milosavljevic, 2017/07/03
- 120/197: gurses: Mini refactor., Danny Milosavljevic, 2017/07/03
- 124/197: gurses: Populate dropdown boxes in forms using a menu., Danny Milosavljevic, 2017/07/03
- 131/197: gurses: Use inverse instead of underline for field value area., Danny Milosavljevic, 2017/07/03
- 133/197: installer: Change livery., Danny Milosavljevic, 2017/07/03
- 146/197: gurses: Use match instead of car/cdr in line-split., Danny Milosavljevic, 2017/07/03
- 147/197: gurses: In paragraph-format avoid use of car and cdr., Danny Milosavljevic, 2017/07/03
- 144/197: gurses: Avoid one more use of car and cdr., Danny Milosavljevic, 2017/07/03
- 143/197: gurses: Add predicate to test if a complex char is blank., Danny Milosavljevic, 2017/07/03
- 149/197: gurses: Add new procedure "word-endings".,
Danny Milosavljevic <=
- 155/197: installer: Use _ instead of M_ for host-name-refresh., Danny Milosavljevic, 2017/07/03
- 160/197: installer: New convenience procedures., Danny Milosavljevic, 2017/07/03
- 158/197: installer: Correct placement of gettext call., Danny Milosavljevic, 2017/07/03
- 163/197: gurses: Cache the windows of buttons., Danny Milosavljevic, 2017/07/03
- 172/197: gurses: Update the cursor position when posting the form., Danny Milosavljevic, 2017/07/03
- 165/197: installer: New procedure key-value-slurp., Danny Milosavljevic, 2017/07/03
- 175/197: gurses: Don't crash if asked for an item by an invalid index., Danny Milosavljevic, 2017/07/03
- 171/197: installer: New page to edit user accounts., Danny Milosavljevic, 2017/07/03
- 187/197: installer: Add procudure for starting a wireless interface., Danny Milosavljevic, 2017/07/03
- 192/197: installer: Only build if guile-ncurses is available., Danny Milosavljevic, 2017/07/03