about summary refs log blame commit diff stats
path: root/arc/edit.arc.t
blob: ff039602349701c8bebca5fa7cc2609755947d10 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                       
                          

            

       
                        

                             
                               
                                                                 
         

                                  














                                                                                                        

       

                                    
(selective-load "mu.arc" section-level)
(set allow-raw-addresses*)

(section 100

(reset)
(new-trace "new-screen")
(add-code:readfile "edit.mu")
(add-code
  '((function test-new-screen [
      (1:screen-address/global <- new-screen 5:literal 5:literal)
     ])))
;? (each stmt function*!new-screen
;?   (prn stmt))
(let routine make-routine!test-new-screen
  (let before rep.routine!alloc
;?     (= dump-trace* (obj blacklist '("sz" "m" "setm" "addr" "cvt0" "cvt1")))
    (run 'test-new-screen)
;?     (prn memory*)
;?     (prn memory*.2001)
    (when (~is (memory* memory*.1) 5)  ; number of rows
      (prn "F - newly-allocated screen doesn't have the right number of rows: @(memory* memory*!2001)"))
    (let row-pointers (let base (+ 1 memory*.1)
                        (range base (+ base 4)))
  ;?     (prn row-pointers)
      (when (some nil (map memory* row-pointers))
        (prn "F - newly-allocated screen didn't initialize all of its row pointers"))
      (when (~all 5 (map memory* (map memory* row-pointers)))
        (prn "F - newly-allocated screen didn't initialize all of its row lengths")))))

(reset)

)  ; section 100 for all editor code
pan class="w"> *result, index:offset *i <- copy 0 d:address:address:array:character <- get-address *result, data:offset *d <- next-ingredient reply result ] recipe rewind-stream [ local-scope in:address:stream <- next-ingredient x:address:number <- get-address *in, index:offset *x <- copy 0 reply in/same-as-arg:0 ] recipe read-line [ local-scope in:address:stream <- next-ingredient idx:address:number <- get-address *in, index:offset s:address:array:character <- get *in, data:offset next-idx:number <- find-next s, 10/newline, *idx result:address:array:character <- string-copy s, *idx, next-idx *idx <- add next-idx, 1 # skip newline reply result ] recipe end-of-stream? [ local-scope in:address:stream <- next-ingredient idx:address:number <- get *in, index:offset s:address:array:character <- get *in, data:offset len:number <- length *s result:boolean <- greater-or-equal idx, len reply result ]