From cfaa19e09f34644dff9d6603a995f4ec81b25e3a Mon Sep 17 00:00:00 2001 From: "Henry M. Wu" Date: Mon, 11 May 1992 04:54:27 +0000 Subject: [PATCH] Fixed color modes. --- v7/src/edwin/ansi.scm | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/v7/src/edwin/ansi.scm b/v7/src/edwin/ansi.scm index c9fc96414..53fe39dab 100644 --- a/v7/src/edwin/ansi.scm +++ b/v7/src/edwin/ansi.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/ansi.scm,v 1.1 1992/04/22 21:20:37 mhwu Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/ansi.scm,v 1.2 1992/05/11 04:54:27 mhwu Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -39,6 +39,7 @@ MIT in each case. |# (define (make-ansi-terminal-description columns lines) (define (defined? sym) (not (lexical-unreferenceable? (the-environment) sym))) + (define (get-numstring scheme shell) (or (and (defined? scheme) (exact-nonnegative-integer? @@ -46,17 +47,44 @@ MIT in each case. |# (number->string (lexical-reference (the-environment) scheme))) (get-environment-variable shell))) + + (define (valid-mode? color-string) + (and (string? color-string) + (= (string-length color-string) 2) + (member (string-ref color-string 0) + '(#\3 #\4)) + (member (string-ref color-string 1) + '(#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7)))) + + (define (invert-mode color-string) + (make-mode (string (if (eqv? (string-ref color-string 0) #\3) + #\4 + #\3) + (string-ref color-string 1)))) + (define (make-mode color-string) - (or (and (string? color-string) - (string->number color-string) + (or (and (valid-mode? color-string) (string-append ";" color-string)) "")) + (let ((foregnd (get-numstring 'edwin:foreground-color "FOREGROUND")) (backgnd (get-numstring 'edwin:background-color "BACKGROUND"))) - (let ((standout - (string-append "\033[7" (make-mode foregnd) (make-mode backgnd) "m")) - (normal - (string-append "\033[0" (make-mode foregnd) (make-mode backgnd) "m"))) + (let ((normal + (string-append "\033[0" + (make-mode foregnd) + (make-mode backgnd) + "m")) + (standout + (if (or (not (valid-mode? foregnd)) (not (valid-mode? backgnd))) + (string-append "\033[7" + (make-mode foregnd) + (make-mode backgnd) + "m") + (string-append "\033[0" + (invert-mode backgnd) + (invert-mode foregnd) + "m")))) + (%make-termcap-description "ansi.sys" ; terminal-type-name false ; delete-is-insert-mode? -- 2.25.1