Diff for /gforth/utf-8.fs between versions 1.3 and 1.5

version 1.3, 2004/12/12 22:20:00 version 1.5, 2004/12/27 20:05:53
Line 20 Line 20
   
 \ short: u8 means utf-8 encoded address  \ short: u8 means utf-8 encoded address
   
 : u8len ( u -- n )  : u8len ( u8 -- n )
     dup      $80 u< IF  drop 1  EXIT  THEN \ special case ASCII      dup      $80 u< IF  drop 1  EXIT  THEN \ special case ASCII
     $800  2 >r      $800  2 >r
     BEGIN  2dup u>=  WHILE  5 lshift r> 1+ >r  REPEAT      BEGIN  2dup u>=  WHILE  5 lshift r> 1+ >r  REPEAT
Line 129 Line 129
 : u8tab-expand ( max span addr pos1 -- max span addr pos2 0 )  : u8tab-expand ( max span addr pos1 -- max span addr pos2 0 )
     key? IF  #tab (u8ins) 0  EXIT  THEN      key? IF  #tab (u8ins) 0  EXIT  THEN
     u8kill-expand 2dup extract-word dup 0= IF  nip EXIT  THEN      u8kill-expand 2dup extract-word dup 0= IF  nip EXIT  THEN
     search-prefix  tib-full?      search-prefix tib-full?
     IF    7 emit  2drop  0 0 prefix-found 2!      IF    7 emit  2drop  prefix-off
     ELSE  dup >r      ELSE  dup >r
         2>r >string r@ + 2r> 2swap insert          2>r >string r@ + 2r> 2swap insert
         r@ + rot r> + -rot          r@ + rot r> + -rot
     THEN      THEN
     prefix-found @ IF  bl (u8ins)  THEN  0 ;      prefix-found @ IF  bl (u8ins)  ELSE  .all .rest  THEN  0 ;
   
   : utf-8-io ( -- )
       ['] u8forw       ctrl F bindkey
       ['] u8back       ctrl B bindkey
       ['] ?u8del       ctrl H bindkey
       ['] u8eof        ctrl D bindkey
       ['] <u8del>      ctrl X bindkey
       ['] u8clear-tib  ctrl K bindkey
       ['] u8first-pos  ctrl A bindkey
       ['] u8end-pos    ctrl E bindkey
       ['] (u8enter)    #lf    bindkey
       ['] (u8enter)    #cr    bindkey
       ['] u8tab-expand #tab   bindkey
       ['] (u8ins)      IS insert-char
       ['] kill-prefix  IS everychar
       ['] save-cursor  IS everyline
       ['] u8key        IS key
       ['] u8emit       IS emit ;
   
 ' u8forw       ctrl F bindkey  
 ' u8back       ctrl B bindkey  
 ' ?u8del       ctrl H bindkey  
 ' u8eof        ctrl D bindkey  
 ' <u8del>      ctrl X bindkey  
 ' u8clear-tib  ctrl K bindkey  
 ' u8first-pos  ctrl A bindkey  
 ' u8end-pos    ctrl E bindkey  
 ' (u8enter)    #lf    bindkey  
 ' (u8enter)    #cr    bindkey  
 ' u8tab-expand #tab   bindkey  
 ' (u8ins) IS insert-char  
 ' save-cursor IS everyline  
 ' u8key IS key  
 ' u8emit IS emit  

Removed from v.1.3  
changed lines
  Added in v.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>