文本编辑器源文件(java语言)(23) cus.cusory= cus.liney*cus.h; cus.paint(getGraphics()); } public void keycusor(int x,int y) { cus.linex+= x; cus.liney+= y; cus.cusorx+= x*cus.w; cus.cusory+= y*cus.h; int i=0; cus.index=0; for(;i<cus.liney+sc.offsety-1;i++) cus.index+= sc.length[i]; cus.index+=cus.linex-1+sc.offsetx; cus.paint(getGraphics()); } public void add(char ch) { if(totle==0) totle= 1; for(int i= totle;i>=cus.index;i--) text[i]= text[i-1]; text[cus.index]= ch; totle++; sc.length[cus.liney]+= 1; repaint(); if(ch=='\n') { cus.linex= 1; cus.liney+= 1; cus.cusorx= 3;