2005-09-27 12:18:04 -04:00
|
|
|
(define (display-to-string val)
|
|
|
|
(let ((exp-port (open-output-string)))
|
2005-09-27 12:31:46 -04:00
|
|
|
(display val exp-port)
|
2005-09-27 12:18:04 -04:00
|
|
|
(get-output-string exp-port)))
|
|
|
|
|
|
|
|
;;expression as string
|
2005-09-27 12:31:46 -04:00
|
|
|
(define (write-to-string val)
|
2005-09-27 12:18:04 -04:00
|
|
|
(let ((exp-port (open-output-string)))
|
2005-09-27 12:31:46 -04:00
|
|
|
(write val exp-port)
|
2005-09-27 12:18:04 -04:00
|
|
|
(get-output-string exp-port)))
|
|
|
|
|
|
|
|
(define (on/off-option-processor name)
|
|
|
|
(lambda (option arg-name arg ops)
|
|
|
|
(cons (cons name #t) ops)))
|
|
|
|
|
2005-09-27 12:32:46 -04:00
|
|
|
|
|
|
|
(define (paste-selection vals marks? for-scheme-mode? to-scheme to-command)
|
|
|
|
(if marks?
|
|
|
|
(if for-scheme-mode?
|
|
|
|
(format #f "'(~a)" (string-join (map to-scheme vals)))
|
|
|
|
(string-join (map to-command vals)))
|
|
|
|
(if (null? vals)
|
|
|
|
""
|
|
|
|
(if for-scheme-mode?
|
|
|
|
(to-scheme (car vals))
|
2005-10-11 11:43:19 -04:00
|
|
|
(to-command (car vals))))))
|
|
|
|
|
|
|
|
(define *redisplay-everything* #t)
|
|
|
|
|
|
|
|
(define (set-redisplay-everything)
|
|
|
|
(set! *redisplay-everything* #t))
|
|
|
|
|
|
|
|
(define (unset-redisplay-everything)
|
|
|
|
(set! *redisplay-everything* #f))
|
|
|
|
|
|
|
|
(define (redisplay-everything?)
|
|
|
|
*redisplay-everything*)
|
2005-10-11 11:55:48 -04:00
|
|
|
|
2006-04-05 06:09:24 -04:00
|
|
|
(define (identity-function x) x)
|
|
|
|
|
|
|
|
(define replace-in-string
|
|
|
|
(lambda (str ch1 ch2)
|
|
|
|
(string-map (lambda (ch)
|
|
|
|
(if (char=? ch ch1)
|
|
|
|
ch2
|
|
|
|
ch))
|
|
|
|
str)))
|
|
|
|
|
|
|
|
(define fill-string
|
|
|
|
(lambda (str ch len)
|
|
|
|
(let ((missing-len (- len (string-length str))))
|
|
|
|
(if (zero? missing-len)
|
|
|
|
str
|
|
|
|
(string-append str
|
|
|
|
(make-string missing-len ch))))))
|
|
|
|
|
|
|
|
(define split-to-string-list
|
|
|
|
(lambda (str len)
|
|
|
|
(let ((str-len (string-length str)))
|
|
|
|
(let loop ((lst '())
|
|
|
|
(start 0))
|
|
|
|
(if (<= (- str-len start) len)
|
|
|
|
(reverse (cons (substring str start str-len) lst))
|
|
|
|
(loop (cons (substring str start (+ start len)) lst)
|
|
|
|
(+ start len)))))))
|
|
|
|
|
|
|
|
(define split-string-at-newline
|
|
|
|
(lambda (str)
|
|
|
|
(string-tokenize str (char-set-complement (char-set #\newline)))))
|