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;
240 if(!vp)
242 ed->e_vi = vp = newof(0,Vi_t,1,0);
243 vp->lastline = (genchar*)malloc(MAXLINE*CHARSIZE);
244 vp->direction = -1;
245 vp->ed = ed;
251 ed_setup(vp->ed,fd, reedit);
263 ioctl(fd,FIORDCHK,&vp->typeahead);
278 vp->typeahead = ((newtime-oldtime) < NTICKS);
374 vp->first_wind = 0;
377 vp->last_wind = i;
378 vp->long_line = ' ';
379 vp->long_char = ' ';
380 vp->o_v_char = '\0';
381 vp->ocur_phys = 0;
382 vp->ocur_virt = MAXCHAR;
383 vp->ofirst_wind = 0;
385 vp->u_column = INVALID - 1;
386 vp->U_space = Ubuf;
387 vp->u_space = ubuf;
393 if( vp->last_cmd == '\0' )
397 vp->last_cmd = 'i';
398 vp->findchar = INVALID;
399 vp->lastmotion = '\0';
400 vp->lastrepeat = 1;
401 vp->repeat = 1;
456 last_phys = ed_virt_to_phys(vp->ed,virtual,physical,last_virt,0,0);
460 vp->last_wind = w_size - 1;
463 vp->last_wind = last_phys;
464 genncpy(window, virtual, vp->last_wind+1);
478 && (vp->typeahead || cntl_char) )
480 refresh(vp,TRANSLATE);
481 pr_string(vp,Prompt);
482 putstring(vp,0, last_phys+1);
484 ed_crlf(vp->ed);
493 ed_crlf(vp->ed);
496 vp->last_cmd = 'i';
497 save_last(vp);
530 pr_string(vp,"\b\b\b\b \b\b");
541 pr_string(vp,Prompt);
543 refresh(vp,CONTROL);
545 refresh(vp,INPUT);
550 refresh(vp,TRANSLATE);
559 if(vp->ed->e_multiline)
562 sync_cursor(vp);
582 vp->U_saved = 0;
585 cur_phys = vp->first_wind;
586 vp->ofirst_wind = INVALID;
587 refresh(vp,INPUT);
590 getline(vp,APPEND);
592 getline(vp,APPEND);
594 getline(vp,ESC);
595 if(vp->ed->e_multiline)
596 cursor(vp, last_phys);
605 if( vp->addnl )
608 ed_crlf(vp->ed);
613 if(vp->bigvi)
615 vp->bigvi = 0;
625 if(vp->ed->nhlist)
626 ed_histlist(vp->ed,0);
643 static void append(Vi_t *vp,int c, int mode)
668 static void backword(Vi_t *vp,int nwords, register int cmd)
712 static int cntlmode(Vi_t *vp)
721 if(!vp->U_saved)
725 gencpy(vp->U_space, virtual);
726 vp->U_saved = 1;
729 save_last(vp);
731 real_u_space = vp->u_space;
734 vp->repeat = 1;
738 sync_cursor(vp);
744 while( c=ed_getchar(vp->ed,-1) )
746 vp->repeat_set = 0;
752 sync_cursor(vp);
758 c = getcount(vp,c);
760 vp->lastrepeat = vp->repeat;
765 if(mvcursor(vp,c))
767 sync_cursor(vp);
768 vp->repeat = 1;
776 c = vp->last_cmd;
777 vp->repeat = vp->lastrepeat;
778 i = textmod(vp,c, c);
782 i = textmod(vp,c, 0);
795 vp->last_cmd = c;
796 vp->lastrepeat = vp->repeat;
798 vp->repeat = 1;
811 if(vp->nonewline==0 && !vp->ed->e_nocrnl)
813 vp->nonewline = 0;
814 pr_string(vp,Prompt);
816 cur_phys = vp->first_wind;
817 vp->ofirst_wind = INVALID;
818 vp->long_line = ' ';
824 save_v(vp);
825 del_line(vp,BAD);
827 append(vp,c,APPEND);
828 refresh(vp,CONTROL);
829 ed_getchar(vp->ed,-1);
830 restore_v(vp);
838 save_v(vp);
839 switch( search(vp,c) )
851 if( vp->u_column == INVALID )
852 del_line(vp,BAD);
854 restore_v(vp);
862 if(vp->ed->hlist)
864 if(vp->ed->hoff >= vp->ed->hmax)
866 vp->ed->hoff++;
870 curhline += vp->repeat;
878 vp->u_space = tmp_u_space;
879 vp->u_column = tmp_u_column;
880 restore_v(vp);
881 vp->u_space = real_u_space;
884 save_v(vp);
891 if(vp->ed->hlist)
893 if(vp->ed->hoff == 0)
895 vp->ed->hoff--;
897 ed_histlist(vp->ed,*vp->ed->hlist!=0);
898 vp->nonewline++;
899 ed_ungetchar(vp->ed,cntl('L'));
905 vp->u_space = tmp_u_space;
906 i = vp->u_column;
907 save_v(vp);
908 vp->u_space = real_u_space;
909 tmp_u_column = vp->u_column;
910 vp->u_column = i;
913 curhline -= vp->repeat;
916 curhline += vp->repeat;
919 save_v(vp);
926 strcpy((char*)virtual,(char*)vp->u_space);
928 ed_internal((char*)vp->u_space,vp->u_space);
937 if(vp->ed->hlist)
939 ed_histlist(vp->ed,0);
941 ed_ungetchar(vp->ed,c);
942 ed_ungetchar(vp->ed,cntl('L'));
943 vp->nonewline = 1;
951 restore_v(vp);
955 save_v(vp);
960 gencpy(virtual, vp->U_space);
961 last_virt = genlen(vp->U_space) - 1;
968 if(vp->repeat_set==0)
973 if(vp->repeat_set==0)
974 vp->repeat = histmin+1;
975 if( vp->repeat <= histmin || vp->repeat > histmax )
979 curhline = vp->repeat;
980 save_v(vp);
989 if(ed_fulledit(vp->ed)==GOOD)
1017 append(vp,'#', APPEND);
1027 refresh(vp,INPUT);
1032 if(!vp->ed->hlist)
1035 if(vp->ed->hlist)
1037 if(vp->repeat > vp->ed->nhlist-vp->ed->hoff)
1039 curhline = vp->ed->hlist[vp->repeat+vp->ed->hoff-1]->index;
1052 ed_ungetchar(vp->ed,x);
1056 ed_ungetchar(vp->ed,c=ed_getchar(vp->ed,1));
1059 vp->repeat = 1;
1066 vp->repeat = 1;
1070 refresh(vp,CONTROL);
1071 vp->repeat = 1;
1084 static void cursor(Vi_t *vp,register int x)
1090 cur_phys = ed_setcursor(vp->ed, physical, cur_phys,x,vp->first_wind);
1104 static void cdelete(Vi_t *vp,register int nchars, int mode)
1117 vp->o_v_char = cp[0];
1151 static void del_line(register Vi_t *vp, int mode)
1157 save_v(vp);
1161 cdelete(vp,last_virt+1, BAD);
1162 refresh(vp,CONTROL);
1166 vp->findchar = INVALID;
1169 vp->last_wind = INVALID;
1170 vp->first_wind = 0;
1171 vp->o_v_char = '\0';
1172 vp->ocur_phys = 0;
1173 vp->ocur_virt = MAXCHAR;
1174 vp->ofirst_wind = 0;
1191 static int delmotion(Vi_t *vp,int motion, int mode)
1199 save_v(vp);
1205 end = mvcursor(vp,motion);
1233 cdelete(vp,delta, mode);
1246 static void endword(Vi_t *vp, int nwords, register int cmd)
1283 static void forward(Vi_t *vp,register int nwords, int cmd)
1323 static int getcount(register Vi_t *vp,register int c)
1332 vp->repeat_set++;
1337 c = ed_getchar(vp->ed,-1);
1341 vp->repeat *= i;
1364 static void getline(register Vi_t* vp,register int mode)
1370 vp->addnl = 1;
1380 if( (c=ed_getchar(vp->ed,mode==SEARCH?1:-2)) == usreof )
1396 c = ed_getchar(vp->ed,2);
1397 append(vp,c, mode);
1398 refresh(vp,INPUT);
1407 append(vp,c, mode);
1426 refresh(vp,INPUT);
1430 tmp = cntlmode(vp);
1434 vp->bigvi = (tmp==BIGVI);
1456 cdelete(vp,cur_virt+1, BAD);
1465 cdelete(vp,1, BAD);
1466 append(vp,usrerase, mode);
1473 cdelete(vp,1, BAD);
1483 sync_cursor(vp);
1487 cdelete(vp,1, BAD);
1497 cdelete(vp,1, BAD);
1502 backword(vp,1, 'W');
1503 cdelete(vp,tmp - cur_virt + 1, BAD);
1510 cdelete(vp,1, BAD);
1511 append(vp,usrkill, mode);
1518 delmotion(vp, '$', BAD);
1524 cdelete(vp,tmp - cur_virt + 1, BAD);
1527 del_line(vp,GOOD);
1534 vp->addnl = 0;
1538 save_last(vp);
1539 refresh(vp,INPUT);
1544 if(mode!=SEARCH && last_virt>=0 && (vp->ed->e_tabcount|| !isblank(cur_virt)) && vp->ed->sh->nextprompt)
1546 if(vp->ed->e_tabcount==0)
1548 ed_ungetchar(vp->ed,'\\');
1549 vp->ed->e_tabcount=1;
1552 else if(vp->ed->e_tabcount==1)
1554 ed_ungetchar(vp->ed,'=');
1557 vp->ed->e_tabcount = 0;
1565 replace(vp,c, 1);
1570 cdelete(vp,1, BAD);
1574 append(vp,c, mode);
1577 refresh(vp,INPUT);
1591 static int mvcursor(register Vi_t* vp,register int motion)
1613 tcur_virt = vp->repeat-1;
1623 switch(motion=getcount(vp,ed_getchar(vp->ed,-1)))
1627 if(!vp->ed->hlist && cur_virt>=0 && cur_virt<(SEARCHSIZE-2) && cur_virt == last_virt)
1639 vp->direction = -2;
1640 ed_ungetchar(vp->ed,'n');
1642 else if(cur_virt==0 && vp->direction == -2)
1643 ed_ungetchar(vp->ed,'n');
1645 ed_ungetchar(vp->ed,'k');
1648 ed_ungetchar(vp->ed,'j');
1664 ed_ungetchar(vp->ed,motion);
1682 tcur_virt += vp->repeat*incr;
1693 backword(vp,vp->repeat, motion);
1702 endword(vp, vp->repeat, motion);
1709 switch(vp->last_find)
1741 vp->last_find = motion;
1742 if((vp->findchar=getrchar(vp))==ESC)
1746 count = vp->repeat;
1750 && virtual[tcur_virt] != vp->findchar );
1756 if( fold(vp->last_find) == 'T' )
1796 forward(vp,vp->repeat, motion);
1813 static void pr_string(register Vi_t *vp, register const char *sp)
1830 static void putstring(register Vi_t *vp,register int col, register int nchars)
1866 static void refresh(register Vi_t* vp, int mode)
1870 register int first_w = vp->first_wind;
1896 n = ed_histgen(vp->ed,(char*)virtual);
1900 if(vp->ed->hlist)
1902 ed_histlist(vp->ed,n);
1903 pr_string(vp,Prompt);
1904 vp->ocur_virt = INVALID;
1905 ed_setcursor(vp->ed,physical,0,cur_phys,0);
1910 else if(mode==INPUT && v<=1 && vp->ed->hlist)
1911 ed_histlist(vp->ed,0);
1913 if( v<vp->ocur_virt || vp->ocur_virt==INVALID
1914 || ( v==vp->ocur_virt
1915 && (!is_print(virtual[v]) || !is_print(vp->o_v_char))) )
1924 p = vp->ocur_phys;
1925 v = vp->ocur_virt;
1934 ncur_phys = ed_virt_to_phys(vp->ed,virtual,physical,cur_virt,v,p);
1950 cursor(vp,first_w);
1954 vp->first_wind = cur_phys = first_w;
1960 if( first_w==vp->ofirst_wind && ncur_phys>=vp->ocur_phys && opflag==1 )
1962 p = vp->ocur_phys;
1971 for(; (p<=last_phys && w<=vp->last_wind); ++p, ++w)
1978 if( (p>last_phys || p>=first_w+w_size) && w>vp->last_wind
1979 && cur_virt==vp->ocur_virt )
1996 while( w <= vp->last_wind )
1998 vp->last_wind = --w;
2004 cursor(vp,p);
2009 while( w <= vp->last_wind )
2013 vp->last_wind = --new_lw;
2018 vp->long_char = '>';
2020 vp->long_char = '<';
2022 vp->long_char = '*';
2025 vp->long_char = ' ';
2027 if( vp->long_line != vp->long_char )
2035 putchar(vp->long_char);
2037 vp->long_line = vp->long_char;
2040 if(vp->ed->e_multiline && vp->ofirst_wind==INVALID && !vp->ed->e_nocrnl)
2041 ed_setcursor(vp->ed, physical, last_phys+1, last_phys+1, -1);
2042 vp->ed->e_nocrnl = 0;
2043 vp->ocur_phys = ncur_phys;
2044 vp->ocur_virt = cur_virt;
2045 vp->ofirst_wind = first_w;
2050 cursor(vp,ncur_phys);
2051 ed_flush(vp->ed);
2065 static void replace(register Vi_t *vp, register int c, register int increment)
2075 cur_window = cur_phys - vp->first_wind;
2076 if( vp->ocur_virt == INVALID || !is_print(c)
2078 || !is_print(vp->o_v_char)
2080 || !iswascii(c) || mbwidth(vp->o_v_char)>1
2088 cdelete(vp,1, BAD);
2089 append(vp,c, APPEND);
2092 refresh(vp,CONTROL);
2109 vp->o_v_char = c;
2110 ed_flush(vp->ed);
2121 static void restore_v(register Vi_t *vp)
2126 if( vp->u_column == INVALID-1 )
2132 gencpy(tmpspace, vp->u_space);
2133 tmpcol = vp->u_column;
2134 save_v(vp);
2138 vp->ocur_virt = MAXCHAR; /** invalidate refresh optimization **/
2148 static void save_last(register Vi_t* vp)
2157 genncpy(vp->lastline, (&virtual[first_virt]), i);
2158 vp->lastline[i] = '\0';
2169 static void save_v(register Vi_t *vp)
2174 gencpy(vp->u_space, virtual);
2175 vp->u_column = cur_virt;
2194 static int curline_search(Vi_t *vp, const char *string)
2199 ed_external(vp->u_space,(char*)vp->u_space);
2201 for(dp=(char*)vp->u_space,dpmax=dp+strlen(dp)-len; dp<=dpmax; dp++)
2204 return(dp-(char*)vp->u_space);
2207 ed_internal((char*)vp->u_space,vp->u_space);
2212 static int search(register Vi_t* vp,register int mode)
2219 if( vp->direction == -2 && mode != 'n')
2220 vp->direction = -1;
2224 del_line(vp,BAD);
2225 append(vp,mode, APPEND);
2226 refresh(vp,INPUT);
2228 getline(vp,SEARCH);
2231 vp->direction = mode=='/' ? -1 : 1;
2243 del_line(vp,BAD);
2252 new_direction = -vp->direction;
2254 new_direction = vp->direction;
2263 if(mode=='?' && (i=curline_search(vp,((char*)virtual)+1))>=0)
2279 vp->ocur_virt = INVALID;
2296 static void sync_cursor(register Vi_t *vp)
2309 if(vp->first_wind==vp->ofirst_wind && cur_virt>vp->ocur_virt && vp->ocur_virt!=INVALID)
2312 p = vp->ocur_phys + 1;
2317 v = vp->ocur_virt + 1;
2357 if( new_phys < vp->first_wind || new_phys >= vp->first_wind + w_size )
2362 refresh(vp,CONTROL);
2366 cursor(vp,new_phys);
2367 ed_flush(vp->ed);
2368 vp->ocur_phys = cur_phys;
2369 vp->ocur_virt = cur_virt;
2370 vp->o_v_char = virtual[vp->ocur_virt];
2383 static int textmod(register Vi_t *vp,register int c, int mode)
2386 register genchar *p = vp->lastline;
2387 register int trepeat = vp->repeat;
2390 if(mode && (fold(vp->lastmotion)=='F' || fold(vp->lastmotion)=='T'))
2391 vp->lastmotion = ';';
2406 if(vp->ed->e_tabcount!=1)
2414 save_v(vp);
2419 if(ed_expand(vp->ed,(char*)virtual, &cur_virt, &last_virt, c, vp->repeat_set?vp->repeat:-1)<0)
2421 if(vp->ed->e_tabcount)
2423 vp->ed->e_tabcount=2;
2424 ed_ungetchar(vp->ed,'\t');
2431 else if(c == '=' && !vp->repeat_set)
2434 vp->nonewline++;
2435 ed_ungetchar(vp->ed,cntl('L'));
2442 vp->ocur_virt = MAXCHAR;
2444 vp->ed->e_tabcount = 0;
2451 c = vp->lastmacro;
2453 if((c=getrchar(vp))==ESC)
2456 vp->lastmacro = c;
2457 if(ed_macro(vp->ed,c))
2459 save_v(vp);
2468 save_v(vp);
2471 if(vp->repeat_set==0)
2472 vp->repeat = -1;
2473 p = (genchar*)hist_word((char*)tmpbuf,MAXLINE,vp->repeat);
2486 append(vp,i,APPEND);
2494 sync_cursor(vp);
2502 save_v(vp);
2506 cursor(vp,cur_phys + 1);
2507 ed_flush(vp->ed);
2513 sync_cursor(vp);
2521 save_v(vp);
2524 vp->o_v_char = virtual[cur_virt];
2535 c = vp->lastmotion;
2537 c = getcount(vp,ed_getchar(vp->ed,-1));
2539 vp->lastmotion = c;
2542 del_line(vp,GOOD);
2546 if(!delmotion(vp, c, 'c'))
2564 c = vp->lastmotion;
2566 c = getcount(vp,ed_getchar(vp->ed,-1));
2568 vp->lastmotion = c;
2571 del_line(vp,GOOD);
2574 if(!delmotion(vp, c, 'd'))
2587 vp->ocur_virt = INVALID;
2597 save_v(vp);
2601 ++vp->u_column;
2612 append(vp,c,mode);
2623 save_v(vp);
2632 if((c=getrchar(vp))==ESC)
2635 save_v(vp);
2637 replace(vp,c, trepeat!=0);
2645 save_v(vp);
2646 cdelete(vp,vp->repeat, BAD);
2662 c = vp->lastmotion;
2664 c = getcount(vp,ed_getchar(vp->ed,-1));
2666 vp->lastmotion = c;
2671 else if(!delmotion(vp, c, 'y'))
2688 save_v(vp);
2701 replace(vp,c, 1);
2711 refresh(vp,CONTROL);
2742 static int getrchar(register Vi_t *vp)
2745 if((c=ed_getchar(vp->ed,1))== usrlnext)
2746 c = ed_getchar(vp->ed,2);