Changeset 35193 in project


Ignore:
Timestamp:
02/23/18 21:30:20 (10 months ago)
Author:
kon
Message:

bump ver , rmv get-terminal-width/height , fix output-port-width/height , split size info into width/height

Location:
release/4/posix-utils/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/posix-utils/trunk/posix-utils.scm

    r35181 r35193  
    1111  ;
    1212  terminal-info
    13   get-terminal-size
    14   get-terminal-width get-terminal-height
     13  get-terminal-name get-terminal-size
    1514  output-port-width output-port-height
    1615  ;
     
    6160(define-type terminal-length fixnum)
    6261
     62(define-type terminal-port output-port)
     63
    6364(define-type terminal-size (list terminal-length terminal-length))
    6465
    6566;
    6667
     68(: natural-fixnum? (* -> boolean : fixnum))
     69;
    6770(define (natural-fixnum? obj)
    6871  (and (fixnum? obj) (not (fxnegative? obj))) )
    6972
     73(: terminal-size? (* -> boolean : (list fixnum fixnum)))
     74;
    7075(define (terminal-size? obj)
    7176  (and
     
    7782(define-check+error-type terminal-size)
    7883
    79 (define (check-terminal-port? loc obj)
     84(: check-terminal-port? (symbol * -> terminal-port))
     85;
     86(define (check-terminal-port? loc obj #!optional var)
    8087  (and
    81     (terminal-port? (check-output-port loc obj))
     88    (terminal-port? (check-output-port loc obj var))
    8289    obj) )
    8390
     
    94101  (if (not (check-terminal-port? 'terminal-info port))
    95102    '()
    96     `((name . ,(terminal-name port))
    97       (size . ,(receive rect (terminal-size port) rect))) ) )
     103    (let (
     104      (size (receive rect (terminal-size port) rect)) )
     105      `((name . ,(terminal-name port))
     106        (width . ,(second size))
     107        (height . ,(first size))) ) ) )
     108
     109(: get-terminal-name (#!optional output-port --> (or boolean string)))
     110;
     111(define (get-terminal-name #!optional (port (current-output-port)))
     112  (and-let* ((port (check-terminal-port? 'get-terminal-size port)))
     113    (terminal-name port) ) )
    98114
    99115(: get-terminal-size (#!optional output-port --> (or boolean terminal-size)))
     
    103119    (receive rect (terminal-size port) rect) ) )
    104120
    105 (: get-terminal-width (#!optional output-port --> (or boolean terminal-length)))
    106 ;
    107 (define (get-terminal-width #!optional (port (current-output-port)))
    108   (and-let* (((check-terminal-port? 'get-terminal-width port)))
    109     (*output-port-width port) ) )
    110 
    111 (: get-terminal-height (#!optional output-port --> (or boolean terminal-length)))
    112 ;
    113 (define (get-terminal-height #!optional (port (current-output-port)))
    114   (and-let* (((check-terminal-port? 'get-terminal-height port)))
    115     (*output-port-height port) ) )
    116 
    117121(: output-port-width ((or boolean output-port) #!optional terminal-length --> terminal-length))
    118122;
    119123(define (output-port-width port #!optional (def TERMINAL-WIDTH))
    120   (if (not port)
    121     def
    122     (*output-port-width (check-terminal-port? 'output-port-width port) def) ) )
     124  (if (check-terminal-port? 'output-port-width port)
     125    (*output-port-width port def)
     126    def ) )
    123127
    124128(: output-port-height ((or boolean output-port) #!optional terminal-length --> terminal-length))
    125129;
    126130(define (output-port-height port #!optional (def TERMINAL-HEIGHT))
    127   (if (not port)
    128     def
    129     (*output-port-height (check-terminal-port? 'output-port-height port) def) ) )
    130 
    131 (: *output-port-width ((or boolean output-port) #!optional  terminal-length --> terminal-length))
     131  (if (check-terminal-port? 'output-port-height port)
     132    (*output-port-height port def)
     133    def ) )
     134
     135(: *output-port-width ((or boolean output-port) #!optional terminal-length --> terminal-length))
    132136;
    133137(define (*output-port-width port #!optional (def TERMINAL-WIDTH))
  • release/4/posix-utils/trunk/posix-utils.setup

    r35170 r35193  
    55(verify-extension-name "posix-utils")
    66
    7 (setup-shared-extension-module 'posix-utils (extension-version "1.2.0")
     7(setup-shared-extension-module 'posix-utils (extension-version "1.2.1")
    88  #:compile-options '(
    99    -fixnum-arithmetic
Note: See TracChangeset for help on using the changeset viewer.