Lines Matching refs:vp
48 # define echoctl (vp->ed->e_echoctl)
140 #define editb (*vp->ed)
143 #define putchar(c) ed_putchar(vp->ed,c)
222 register Vi_t *vp = ed->e_vi; in ed_viread() local
240 if(!vp) in ed_viread()
242 ed->e_vi = vp = newof(0,Vi_t,1,0); in ed_viread()
243 vp->lastline = (genchar*)malloc(MAXLINE*CHARSIZE); in ed_viread()
244 vp->direction = -1; in ed_viread()
245 vp->ed = ed; in ed_viread()
251 ed_setup(vp->ed,fd, reedit); in ed_viread()
263 ioctl(fd,FIORDCHK,&vp->typeahead); in ed_viread()
278 vp->typeahead = ((newtime-oldtime) < NTICKS); in ed_viread()
374 vp->first_wind = 0; in ed_viread()
377 vp->last_wind = i; in ed_viread()
378 vp->long_line = ' '; in ed_viread()
379 vp->long_char = ' '; in ed_viread()
380 vp->o_v_char = '\0'; in ed_viread()
381 vp->ocur_phys = 0; in ed_viread()
382 vp->ocur_virt = MAXCHAR; in ed_viread()
383 vp->ofirst_wind = 0; in ed_viread()
385 vp->u_column = INVALID - 1; in ed_viread()
386 vp->U_space = Ubuf; in ed_viread()
387 vp->u_space = ubuf; in ed_viread()
393 if( vp->last_cmd == '\0' ) in ed_viread()
397 vp->last_cmd = 'i'; in ed_viread()
398 vp->findchar = INVALID; in ed_viread()
399 vp->lastmotion = '\0'; in ed_viread()
400 vp->lastrepeat = 1; in ed_viread()
401 vp->repeat = 1; in ed_viread()
456 last_phys = ed_virt_to_phys(vp->ed,virtual,physical,last_virt,0,0); in ed_viread()
460 vp->last_wind = w_size - 1; in ed_viread()
463 vp->last_wind = last_phys; in ed_viread()
464 genncpy(window, virtual, vp->last_wind+1); in ed_viread()
478 && (vp->typeahead || cntl_char) ) in ed_viread()
480 refresh(vp,TRANSLATE); in ed_viread()
481 pr_string(vp,Prompt); in ed_viread()
482 putstring(vp,0, last_phys+1); in ed_viread()
484 ed_crlf(vp->ed); in ed_viread()
493 ed_crlf(vp->ed); in ed_viread()
496 vp->last_cmd = 'i'; in ed_viread()
497 save_last(vp); in ed_viread()
530 pr_string(vp,"\b\b\b\b \b\b"); in ed_viread()
541 pr_string(vp,Prompt); in ed_viread()
543 refresh(vp,CONTROL); in ed_viread()
545 refresh(vp,INPUT); in ed_viread()
550 refresh(vp,TRANSLATE); in ed_viread()
559 if(vp->ed->e_multiline) in ed_viread()
562 sync_cursor(vp); in ed_viread()
582 vp->U_saved = 0; in ed_viread()
585 cur_phys = vp->first_wind; in ed_viread()
586 vp->ofirst_wind = INVALID; in ed_viread()
587 refresh(vp,INPUT); in ed_viread()
590 getline(vp,APPEND); in ed_viread()
592 getline(vp,APPEND); in ed_viread()
594 getline(vp,ESC); in ed_viread()
595 if(vp->ed->e_multiline) in ed_viread()
596 cursor(vp, last_phys); in ed_viread()
605 if( vp->addnl ) in ed_viread()
608 ed_crlf(vp->ed); in ed_viread()
613 if(vp->bigvi) in ed_viread()
615 vp->bigvi = 0; in ed_viread()
639 static void append(Vi_t *vp,int c, int mode) in append() argument
664 static void backword(Vi_t *vp,int nwords, register int cmd) in backword() argument
708 static int cntlmode(Vi_t *vp) in cntlmode() argument
717 if(!vp->U_saved) in cntlmode()
721 gencpy(vp->U_space, virtual); in cntlmode()
722 vp->U_saved = 1; in cntlmode()
725 save_last(vp); in cntlmode()
727 real_u_space = vp->u_space; in cntlmode()
730 vp->repeat = 1; in cntlmode()
734 sync_cursor(vp); in cntlmode()
740 while( c=ed_getchar(vp->ed,-1) ) in cntlmode()
742 vp->repeat_set = 0; in cntlmode()
748 sync_cursor(vp); in cntlmode()
754 c = getcount(vp,c); in cntlmode()
756 vp->lastrepeat = vp->repeat; in cntlmode()
761 if(mvcursor(vp,c)) in cntlmode()
763 sync_cursor(vp); in cntlmode()
764 vp->repeat = 1; in cntlmode()
772 c = vp->last_cmd; in cntlmode()
773 vp->repeat = vp->lastrepeat; in cntlmode()
774 i = textmod(vp,c, c); in cntlmode()
778 i = textmod(vp,c, 0); in cntlmode()
791 vp->last_cmd = c; in cntlmode()
792 vp->lastrepeat = vp->repeat; in cntlmode()
794 vp->repeat = 1; in cntlmode()
807 if(vp->nonewline==0 && !vp->ed->e_nocrnl) in cntlmode()
809 vp->nonewline = 0; in cntlmode()
810 pr_string(vp,Prompt); in cntlmode()
812 cur_phys = vp->first_wind; in cntlmode()
813 vp->ofirst_wind = INVALID; in cntlmode()
814 vp->long_line = ' '; in cntlmode()
820 save_v(vp); in cntlmode()
821 del_line(vp,BAD); in cntlmode()
823 append(vp,c,APPEND); in cntlmode()
824 refresh(vp,CONTROL); in cntlmode()
825 ed_getchar(vp->ed,-1); in cntlmode()
826 restore_v(vp); in cntlmode()
834 save_v(vp); in cntlmode()
835 switch( search(vp,c) ) in cntlmode()
847 if( vp->u_column == INVALID ) in cntlmode()
848 del_line(vp,BAD); in cntlmode()
850 restore_v(vp); in cntlmode()
857 curhline += vp->repeat; in cntlmode()
865 vp->u_space = tmp_u_space; in cntlmode()
866 vp->u_column = tmp_u_column; in cntlmode()
867 restore_v(vp); in cntlmode()
868 vp->u_space = real_u_space; in cntlmode()
871 save_v(vp); in cntlmode()
879 vp->u_space = tmp_u_space; in cntlmode()
880 i = vp->u_column; in cntlmode()
881 save_v(vp); in cntlmode()
882 vp->u_space = real_u_space; in cntlmode()
883 tmp_u_column = vp->u_column; in cntlmode()
884 vp->u_column = i; in cntlmode()
887 curhline -= vp->repeat; in cntlmode()
890 curhline += vp->repeat; in cntlmode()
893 save_v(vp); in cntlmode()
900 strcpy((char*)virtual,(char*)vp->u_space); in cntlmode()
902 ed_internal((char*)vp->u_space,vp->u_space); in cntlmode()
914 restore_v(vp); in cntlmode()
918 save_v(vp); in cntlmode()
923 gencpy(virtual, vp->U_space); in cntlmode()
924 last_virt = genlen(vp->U_space) - 1; in cntlmode()
931 if(vp->repeat_set==0) in cntlmode()
936 if(vp->repeat_set==0) in cntlmode()
937 vp->repeat = histmin+1; in cntlmode()
938 if( vp->repeat <= histmin || vp->repeat > histmax ) in cntlmode()
942 curhline = vp->repeat; in cntlmode()
943 save_v(vp); in cntlmode()
952 if(ed_fulledit(vp->ed)==GOOD) in cntlmode()
980 append(vp,'#', APPEND); in cntlmode()
990 refresh(vp,INPUT); in cntlmode()
1002 ed_ungetchar(vp->ed,x); in cntlmode()
1006 ed_ungetchar(vp->ed,c=ed_getchar(vp->ed,1)); in cntlmode()
1009 vp->repeat = 1; in cntlmode()
1016 vp->repeat = 1; in cntlmode()
1020 refresh(vp,CONTROL); in cntlmode()
1021 vp->repeat = 1; in cntlmode()
1034 static void cursor(Vi_t *vp,register int x) in cursor() argument
1040 cur_phys = ed_setcursor(vp->ed, physical, cur_phys,x,vp->first_wind); in cursor()
1054 static void cdelete(Vi_t *vp,register int nchars, int mode) in cdelete() argument
1067 vp->o_v_char = cp[0]; in cdelete()
1101 static void del_line(register Vi_t *vp, int mode) in del_line() argument
1107 save_v(vp); in del_line()
1111 cdelete(vp,last_virt+1, BAD); in del_line()
1112 refresh(vp,CONTROL); in del_line()
1116 vp->findchar = INVALID; in del_line()
1119 vp->last_wind = INVALID; in del_line()
1120 vp->first_wind = 0; in del_line()
1121 vp->o_v_char = '\0'; in del_line()
1122 vp->ocur_phys = 0; in del_line()
1123 vp->ocur_virt = MAXCHAR; in del_line()
1124 vp->ofirst_wind = 0; in del_line()
1141 static int delmotion(Vi_t *vp,int motion, int mode) in delmotion() argument
1149 save_v(vp); in delmotion()
1155 end = mvcursor(vp,motion); in delmotion()
1183 cdelete(vp,delta, mode); in delmotion()
1196 static void endword(Vi_t *vp, int nwords, register int cmd) in endword() argument
1233 static void forward(Vi_t *vp,register int nwords, int cmd) in forward() argument
1273 static int getcount(register Vi_t *vp,register int c) in getcount() argument
1282 vp->repeat_set++; in getcount()
1287 c = ed_getchar(vp->ed,-1); in getcount()
1291 vp->repeat *= i; in getcount()
1314 static void getline(register Vi_t* vp,register int mode) in getline() argument
1321 vp->addnl = 1; in getline()
1331 if( (c=ed_getchar(vp->ed,mode==SEARCH?1:-2)) == usreof ) in getline()
1345 c = ed_getchar(vp->ed,2); in getline()
1346 append(vp,c, mode); in getline()
1347 refresh(vp,INPUT); in getline()
1356 append(vp,c, mode); in getline()
1375 refresh(vp,INPUT); in getline()
1379 tmp = cntlmode(vp); in getline()
1383 vp->bigvi = (tmp==BIGVI); in getline()
1409 cdelete(vp,1, BAD); in getline()
1410 append(vp,usrerase, mode); in getline()
1417 cdelete(vp,1, BAD); in getline()
1427 sync_cursor(vp); in getline()
1431 cdelete(vp,1, BAD); in getline()
1441 cdelete(vp,1, BAD); in getline()
1446 backword(vp,1, 'W'); in getline()
1447 cdelete(vp,tmp - cur_virt + 1, BAD); in getline()
1454 cdelete(vp,1, BAD); in getline()
1455 append(vp,usrkill, mode); in getline()
1462 delmotion(vp, '$', BAD); in getline()
1468 cdelete(vp,tmp - cur_virt + 1, BAD); in getline()
1471 del_line(vp,GOOD); in getline()
1478 vp->addnl = 0; in getline()
1482 save_last(vp); in getline()
1483 refresh(vp,INPUT); in getline()
1488 …if(mode!=SEARCH && last_virt>=0 && (vp->ed->e_tabcount|| !isblank(cur_virt)) && vp->ed->sh->nextpr… in getline()
1490 if(vp->ed->e_tabcount==0) in getline()
1492 ed_ungetchar(vp->ed,'\\'); in getline()
1493 vp->ed->e_tabcount=1; in getline()
1496 else if(vp->ed->e_tabcount==1) in getline()
1498 ed_ungetchar(vp->ed,'='); in getline()
1501 vp->ed->e_tabcount = 0; in getline()
1509 replace(vp,c, 1); in getline()
1514 cdelete(vp,1, BAD); in getline()
1518 append(vp,c, mode); in getline()
1521 refresh(vp,INPUT); in getline()
1535 static int mvcursor(register Vi_t* vp,register int motion) in mvcursor() argument
1557 tcur_virt = vp->repeat-1; in mvcursor()
1567 switch(motion=getcount(vp,ed_getchar(vp->ed,-1))) in mvcursor()
1579 vp->direction = -2; in mvcursor()
1580 ed_ungetchar(vp->ed,'n'); in mvcursor()
1582 else if(cur_virt==0 && vp->direction == -2) in mvcursor()
1583 ed_ungetchar(vp->ed,'n'); in mvcursor()
1585 ed_ungetchar(vp->ed,'k'); in mvcursor()
1588 ed_ungetchar(vp->ed,'j'); in mvcursor()
1604 ed_ungetchar(vp->ed,motion); in mvcursor()
1622 tcur_virt += vp->repeat*incr; in mvcursor()
1633 backword(vp,vp->repeat, motion); in mvcursor()
1642 endword(vp, vp->repeat, motion); in mvcursor()
1649 switch(vp->last_find) in mvcursor()
1681 vp->last_find = motion; in mvcursor()
1682 if((vp->findchar=getrchar(vp))==ESC) in mvcursor()
1686 count = vp->repeat; in mvcursor()
1690 && virtual[tcur_virt] != vp->findchar ); in mvcursor()
1696 if( fold(vp->last_find) == 'T' ) in mvcursor()
1736 forward(vp,vp->repeat, motion); in mvcursor()
1753 static void pr_string(register Vi_t *vp, register const char *sp) in pr_string() argument
1770 static void putstring(register Vi_t *vp,register int col, register int nchars) in putstring() argument
1806 static void refresh(register Vi_t* vp, int mode) in refresh() argument
1810 register int first_w = vp->first_wind; in refresh()
1828 if( v<vp->ocur_virt || vp->ocur_virt==INVALID in refresh()
1829 || ( v==vp->ocur_virt in refresh()
1830 && (!is_print(virtual[v]) || !is_print(vp->o_v_char))) ) in refresh()
1839 p = vp->ocur_phys; in refresh()
1840 v = vp->ocur_virt; in refresh()
1849 ncur_phys = ed_virt_to_phys(vp->ed,virtual,physical,cur_virt,v,p); in refresh()
1865 cursor(vp,first_w); in refresh()
1869 vp->first_wind = cur_phys = first_w; in refresh()
1875 if( first_w==vp->ofirst_wind && ncur_phys>=vp->ocur_phys && opflag==1 ) in refresh()
1877 p = vp->ocur_phys; in refresh()
1886 for(; (p<=last_phys && w<=vp->last_wind); ++p, ++w) in refresh()
1893 if( (p>last_phys || p>=first_w+w_size) && w>vp->last_wind in refresh()
1894 && cur_virt==vp->ocur_virt ) in refresh()
1911 while( w <= vp->last_wind ) in refresh()
1913 vp->last_wind = --w; in refresh()
1919 cursor(vp,p); in refresh()
1924 while( w <= vp->last_wind ) in refresh()
1928 vp->last_wind = --new_lw; in refresh()
1933 vp->long_char = '>'; in refresh()
1935 vp->long_char = '<'; in refresh()
1937 vp->long_char = '*'; in refresh()
1940 vp->long_char = ' '; in refresh()
1942 if( vp->long_line != vp->long_char ) in refresh()
1950 putchar(vp->long_char); in refresh()
1952 vp->long_line = vp->long_char; in refresh()
1955 if(vp->ed->e_multiline && vp->ofirst_wind==INVALID && !vp->ed->e_nocrnl) in refresh()
1956 ed_setcursor(vp->ed, physical, last_phys+1, last_phys+1, -1); in refresh()
1957 vp->ed->e_nocrnl = 0; in refresh()
1958 vp->ocur_phys = ncur_phys; in refresh()
1959 vp->ocur_virt = cur_virt; in refresh()
1960 vp->ofirst_wind = first_w; in refresh()
1965 cursor(vp,ncur_phys); in refresh()
1966 ed_flush(vp->ed); in refresh()
1980 static void replace(register Vi_t *vp, register int c, register int increment) in replace() argument
1990 cur_window = cur_phys - vp->first_wind; in replace()
1991 if( vp->ocur_virt == INVALID || !is_print(c) in replace()
1993 || !is_print(vp->o_v_char) in replace()
1995 || !iswascii(c) || mbwidth(vp->o_v_char)>1 in replace()
2003 cdelete(vp,1, BAD); in replace()
2004 append(vp,c, APPEND); in replace()
2007 refresh(vp,CONTROL); in replace()
2024 vp->o_v_char = c; in replace()
2025 ed_flush(vp->ed); in replace()
2036 static void restore_v(register Vi_t *vp) in restore_v() argument
2041 if( vp->u_column == INVALID-1 ) in restore_v()
2047 gencpy(tmpspace, vp->u_space); in restore_v()
2048 tmpcol = vp->u_column; in restore_v()
2049 save_v(vp); in restore_v()
2053 vp->ocur_virt = MAXCHAR; /** invalidate refresh optimization **/ in restore_v()
2063 static void save_last(register Vi_t* vp) in save_last() argument
2072 genncpy(vp->lastline, (&virtual[first_virt]), i); in save_last()
2073 vp->lastline[i] = '\0'; in save_last()
2084 static void save_v(register Vi_t *vp) in save_v() argument
2089 gencpy(vp->u_space, virtual); in save_v()
2090 vp->u_column = cur_virt; in save_v()
2109 static int curline_search(Vi_t *vp, const char *string) in curline_search() argument
2114 ed_external(vp->u_space,(char*)vp->u_space); in curline_search()
2116 for(dp=(char*)vp->u_space,dpmax=dp+strlen(dp)-len; dp<=dpmax; dp++) in curline_search()
2119 return(dp-(char*)vp->u_space); in curline_search()
2122 ed_internal((char*)vp->u_space,vp->u_space); in curline_search()
2127 static int search(register Vi_t* vp,register int mode) in search() argument
2134 if( vp->direction == -2 && mode != 'n') in search()
2135 vp->direction = -1; in search()
2139 del_line(vp,BAD); in search()
2140 append(vp,mode, APPEND); in search()
2141 refresh(vp,INPUT); in search()
2143 getline(vp,SEARCH); in search()
2146 vp->direction = mode=='/' ? -1 : 1; in search()
2158 del_line(vp,BAD); in search()
2167 new_direction = -vp->direction; in search()
2169 new_direction = vp->direction; in search()
2178 if(mode=='?' && (i=curline_search(vp,((char*)virtual)+1))>=0) in search()
2194 vp->ocur_virt = INVALID; in search()
2211 static void sync_cursor(register Vi_t *vp) in sync_cursor() argument
2224 if(vp->first_wind==vp->ofirst_wind && cur_virt>vp->ocur_virt && vp->ocur_virt!=INVALID) in sync_cursor()
2227 p = vp->ocur_phys + 1; in sync_cursor()
2232 v = vp->ocur_virt + 1; in sync_cursor()
2272 if( new_phys < vp->first_wind || new_phys >= vp->first_wind + w_size ) in sync_cursor()
2277 refresh(vp,CONTROL); in sync_cursor()
2281 cursor(vp,new_phys); in sync_cursor()
2282 ed_flush(vp->ed); in sync_cursor()
2283 vp->ocur_phys = cur_phys; in sync_cursor()
2284 vp->ocur_virt = cur_virt; in sync_cursor()
2285 vp->o_v_char = virtual[vp->ocur_virt]; in sync_cursor()
2298 static int textmod(register Vi_t *vp,register int c, int mode) in textmod() argument
2301 register genchar *p = vp->lastline; in textmod()
2302 register int trepeat = vp->repeat; in textmod()
2305 if(mode && (fold(vp->lastmotion)=='F' || fold(vp->lastmotion)=='T')) in textmod()
2306 vp->lastmotion = ';'; in textmod()
2321 if(vp->ed->e_tabcount!=1) in textmod()
2329 save_v(vp); in textmod()
2334 if(ed_expand(vp->ed,(char*)virtual, &cur_virt, &last_virt, c, vp->repeat_set?vp->repeat:-1)<0) in textmod()
2336 if(vp->ed->e_tabcount) in textmod()
2338 vp->ed->e_tabcount=2; in textmod()
2339 ed_ungetchar(vp->ed,'\t'); in textmod()
2346 else if(c == '=' && !vp->repeat_set) in textmod()
2349 vp->nonewline++; in textmod()
2350 ed_ungetchar(vp->ed,cntl('L')); in textmod()
2357 vp->ocur_virt = MAXCHAR; in textmod()
2359 vp->ed->e_tabcount = 0; in textmod()
2366 c = vp->lastmacro; in textmod()
2368 if((c=getrchar(vp))==ESC) in textmod()
2371 vp->lastmacro = c; in textmod()
2372 if(ed_macro(vp->ed,c)) in textmod()
2374 save_v(vp); in textmod()
2383 save_v(vp); in textmod()
2386 if(vp->repeat_set==0) in textmod()
2387 vp->repeat = -1; in textmod()
2388 p = (genchar*)hist_word((char*)tmpbuf,MAXLINE,vp->repeat); in textmod()
2401 append(vp,i,APPEND); in textmod()
2409 sync_cursor(vp); in textmod()
2417 save_v(vp); in textmod()
2421 cursor(vp,cur_phys + 1); in textmod()
2422 ed_flush(vp->ed); in textmod()
2428 sync_cursor(vp); in textmod()
2436 save_v(vp); in textmod()
2439 vp->o_v_char = virtual[cur_virt]; in textmod()
2450 c = vp->lastmotion; in textmod()
2452 c = getcount(vp,ed_getchar(vp->ed,-1)); in textmod()
2454 vp->lastmotion = c; in textmod()
2457 del_line(vp,GOOD); in textmod()
2461 if(!delmotion(vp, c, 'c')) in textmod()
2479 c = vp->lastmotion; in textmod()
2481 c = getcount(vp,ed_getchar(vp->ed,-1)); in textmod()
2483 vp->lastmotion = c; in textmod()
2486 del_line(vp,GOOD); in textmod()
2489 if(!delmotion(vp, c, 'd')) in textmod()
2502 vp->ocur_virt = INVALID; in textmod()
2512 save_v(vp); in textmod()
2516 ++vp->u_column; in textmod()
2527 append(vp,c,mode); in textmod()
2538 save_v(vp); in textmod()
2547 if((c=getrchar(vp))==ESC) in textmod()
2550 save_v(vp); in textmod()
2552 replace(vp,c, trepeat!=0); in textmod()
2560 save_v(vp); in textmod()
2561 cdelete(vp,vp->repeat, BAD); in textmod()
2577 c = vp->lastmotion; in textmod()
2579 c = getcount(vp,ed_getchar(vp->ed,-1)); in textmod()
2581 vp->lastmotion = c; in textmod()
2586 else if(!delmotion(vp, c, 'y')) in textmod()
2603 save_v(vp); in textmod()
2616 replace(vp,c, 1); in textmod()
2626 refresh(vp,CONTROL); in textmod()
2657 static int getrchar(register Vi_t *vp) in getrchar() argument
2660 if((c=ed_getchar(vp->ed,1))== usrlnext) in getrchar()
2661 c = ed_getchar(vp->ed,2); in getrchar()