• 回答数

    3

  • 浏览数

    152

胖墩er猫
首页 > 论文问答 > 简易文本编辑器c语言

3个回答 默认排序
  • 默认排序
  • 按时间排序

时间不等人了

已采纳
北京科技大学的吧。。。
168 评论

张小电1301

286 评论

橘子汽水2046

#include #include #include "h"#include "h"suct line{int charnum;char *base;};typedef suct line SequListElemType;#include "h"#define MAXLINES 1000int key;int cureditline=0;int curscrtopline=0;int cureditcol=0;int funckey;int editwinx=2;int editwiny=3;int editwinlines=20;int mainover=0;FILE *curfile;char filename[255]="xt";SequList *Document;char ascii(int k);prinoc(int startfileline,int startscrline);readdoc(FILE *fp);editline(int curline,int maxcolnum){char s[2000];setscrcolor(BLUE,YELLOW);scpy(s,Document->elem[curline]base);getsing(editwinx,editwiny curline-curscrtopline,s,maxcolnum);free(Document->elem[curline]base);Document->elem[curline]base=(char *)malloc(slen(s) 1);scpy(Document->elem[curline]base,s);}prinoc(int startfileline,int startscrline){int i;int j;cursor_hide();i=startscrline;j=startfileline;setscrcolor(BLUE,YELLOW);gotoxy(editwinx,editwiny startscrline);while(i<=editwinlines && ilength){clearscrline(editwinx,editwiny i,78);putsxy(editwinx,editwiny i ,Document->elem[j -1]base);}while(i<=editwinlines)clearscrline(editwinx,editwiny i ,78);cursor_show();}getline(FILE *fp,char *l){int i=0;while(!feof(fp))if((l[i ]=fgetc(fp))=='\n')break;l[i-1]='\0';}closedoc(FILE *fp){int i;fclose(fp);for(i=0;ilength;i )free(Document->elem[i]base);SequListDesoy(Document);}readdoc(FILE *fp){char *newline;char s[20000];int linenum=0;suct line curline;if(!fp) return;while(!feof(fp)){getline(fp,s);linenum ;newline=(char *)malloc(slen(s) 1);scpy(newline,s);base=newline;harnum=slen(newline);SequListInsert(Document,linenum,curline);}}char ascii(int k){char c;c=(k<<8)>>8;if(c>=32&&c<127)return c;elsereturn 0;}insertchar(char *s,char c,int pos){int i;for(i=slen(s) 1;i>pos;i--)s[i]=s[i-1];s[i]=c;}deletechar(char *s,int pos){int i;int j;j=slen(s);for(i=pos;i<=j;i )s[i]=s[i 1];}clearscrline(int x,int y,int num){int i;for(i=0;i0){cureditline--;gotoxy(editwinx,editwiny cureditline);editline(cureditline,78);}break;case KEYDown:if (cureditlinelength-1){cureditline ;gotoxy(editwinx,editwiny cureditline);editline(cureditline,78);}break;case KEYCl_y:deleteline(cureditline 1);if(Document->length==0)insertnewline(cureditline 1);if(cureditline>=Document->length)insertnewline(cureditline 1);prinoc(cureditline 1,cureditline-curscrtopline);gotoxy(editwinx,editwiny cureditline);editline(cureditline,78);break;case KEYLeft:case KEYRight:break;case KEYCl_s:break;case ESC:cursor_hide();dofunc(getmenuitem());break;case KEYAlt_x:mainover=1;break;default:gotoxy(editwinx,editwiny cureditline-curscrtopline);editline(cureditline,78);break;}}closedoc(curfile);setscrcolor(BLACK,WHITE);clrscr();cursor_show();}

174 评论

相关问答