⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 text editor.c

📁 使用C语言结构编写的
💻 C
字号:
#include"stdio.h"
#include"conio.h"
#include"dos.h"
#include"dir.h"
#include"string.h"
#include"ctype.h"

char far *Vid_base=0xb8000000; /*VDU base memory address*/

int i,j;
char *menulist[]={"^File","^Edit","^Search","^Case","^Help"};
int xpos=1,ypos=1,ins=1,Exit_Forge=1,choice,save=1,tx,ty;
char ch,filename[15]="NAMELESS.TXT",*dbuff,cpline[78],cplen,fstring[40],ttime[15];
union REGS in; /*for interrupt functions*/

	struct data /*the struct definition for the linked list*/
	{
	char text[78];
	struct data *prev,*next;
	int length;
	};

typedef struct data LINE;
LINE *Cur_line,*start;
char *filemenu[]={"^New","^Open...","^Save","Save ^As...","^Change Dir","^Dos Shell","^Exit"},
*editmenu[]={"Cu^t Line","^Copy Line","^Paste Line","Insert ^Date"},*srchmenu[]={"^Find...","Find ^Next"},
*casemenu[]={"To ^Upper","To ^Lower","^Toggle Case"};
*helpmenu[]={"^Contents","^About"};
struct  time t;
void insert_date();
void main(int argc,char *argv[])
{
clrscr();
window(2,3,79,24); /*set the window area*/
Cur_line=(LINE*)malloc(sizeof(LINE));
start=Cur_line;
Cur_line->next=NULL; /*initialization of the first node*/
Cur_line->prev=NULL; Cur_line->length=0;
if(argc>2)
	{
	printf("\nInvalid Number of arguments\n");
	exit(0);
	}
else
if(argc==2)  /*if filename is given as the second argument, copy filename and open*/
      {
      if(strlen(argv[1])>12)
       {printf("File name Too long"); free(Cur_line);  exit(0); }
      else
	{
	strcpy(filename,argv[1]);
	openfile();
	}
      }
Display_screen();   /*display list of menus*/
Display_status();
gotoxy(1,1);
setkeyboard();
while(Exit_Forge) /* the master loop*/
  {
   Displaytime();

   ch=getch();

   if(ch==0)
   Special_key();  /* do the special key function like up arrow/downarrow/left arrow delete etc*/
   else
   Normal_key(); /* set the position with the entered key or bspace ,enter key*/

   Display_status();
  }
Free_memory();
}


Display_screen()
{
int k;
char *shortcuts=" ^F^1 Help  ^F^2 Save  ^F^3 Open  ^A^L^T^-^X Exit  ^F^5 Find Next";
for(i=1;i<160;i+=2) /*set the status bar background to green and menu bar background  to green*/
 {
 *(Vid_base+(24*160)+i)=15;/*status bar*/
 *(Vid_base+i)=2;/*menu bar*/
 if(*shortcuts)
 {
 if(*shortcuts=='^')
 {
 *(Vid_base+(24*160)+i)=12;
 shortcuts++;
 }
 *(Vid_base+(24*160)+i-1)=*(shortcuts++);
 }

 delay(100);
 }
for(i=161;i<3840;i+=2)/*set the editing screen attribute*/
*(Vid_base+i)=31;

for(i=160;i<3840;i+=160)/*draw vertial borders*/
  {
  *(Vid_base+i)='

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -