文本编辑器源文件(java语言)(22) } //打开已存在的文件 public void setname(String fn,String fd) { filename= fn; filedir= fd; } public void open(String line) { //findtext= line; line.getChars(0,line.length()-1,text,totle); totle+= line.length(); // text[totle]= '\n'; // totle++; // sc.length[lcount]= line.length()+1; // lcount++; repaint(); } public String getText() { char[] ret= new char[totle]; for(int i=0;i<totle;i++) ret[i]= text[i]; return (new String(ret)); } public void movecusor(int x,int y) { cus.linex= (int)((x-3)/cus.w); cus.liney= (int)((y-3*fh)/cus.h)+1; 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.cusorx= (cus.linex-1)*cus.w+3;