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

📄 mined1.c

📁 MINED文本文件编缉器
💻 C
📖 第 1 页 / 共 4 页
字号:
	   if (get_l_err1 != NIL_PTR || get_l_err2 != NIL_PTR) {		ring_bell ();		error (get_l_err1, get_l_err2);		sleep (1);	   }	   fstatus ("Read", nr_of_chars);	}  }  else				/* Just install a "\n" */	line = line_insert (line, "\n", 1);  if (line == NIL_LINE) {	sleep (2) /* give time to read allocation error msg */;	viewonly = TRUE;  }  reset (header->next, 0);	/* Initialize pointers */  move_to (0, 0);  loading = FALSE;		/* Stop loading, reset flag */}voidload_file (file)  char * file;{  load_file_w_o_display (file);/* Print screen */  display (0, header->next, last_y, 0);  move_to (0, 0);/* fstatus ("Read", -1L); */}/*-------------------------------------------------------------------------*//* * Ask the user if he wants to save the file or not. */intask_save (){  register uchar c;  status_line (file_name [0] ? file_name : "[buffer]" ,			" has been modified. Save? (y/n)");	/* previously only basename (file_name) was printed */  c = promptyn ();  clear_status ();  if (c == 'y')	return wrt_text (TRUE);  else if (c == 'n')	return FINE;  else {	quit = FALSE;	/* abort character has been given */	return ERRORS;  }}/* * Ask user if named file should be overwritten. */FLAGcheckoverwrite (name)char * name;{  uchar c;  if (access (name, 0 /* F_OK */) < 0)	/* Cannot access file */	return TRUE;	/* thus no danger of unwanted damage */  status_line (name [0] ? name : "[buffer]" ,			": OK to overwrite? (y/n)");	/* previously only basename (name) was printed */  c = promptyn ();  clear_status ();  if (c == 'y')	return TRUE;  else if (c == 'n')	return FALSE;  else {/*	quit = FALSE;	abort character has been given */	return FALSE;  }}/* * Attach new file name to buffer */voidNN (){  char file [maxLINE_LEN];	/* Buffer for new file name */  if (get_file ("Enter new file name:", file) == ERRORS)	return;  overwriteOK = FALSE;  writable = TRUE;  modified = TRUE;	/* cf. CHDI command */  copy_string (file_name, file);	/* Save new file name */  clear_status ();}/* * Write file in core to disc. *//* Call graph for writing functions:	panic --\		 > QUED --\	ESC q --/	   > ask_save --\	ESC e ---> EDIT --/		 \	ESC v ---> VIEW -/		  \	ESC w -----------------------------> WT	ESC z -----------> SUSP ----------/	ESC ESC ---------> EXED ---------/*/long write_count;	/* number of chars written */voidwrite_file (fd)  int fd;{  register LINE * line;  write_count = 0L;  clear_buffer (); /* out_count = 0; */  for (line = header->next; line != tail; line = line->next) {	if (line->shift_count & DUMMY) {		if (line->next == tail && line->text [0] == '\n')			continue;	}	if (writestring (fd, line->text) == ERRORS) {		write_count = -1L;		break;	}	write_count += (long) length_of (line->text);  }  if (write_count > 0L && flush_buffer (fd) == ERRORS)	write_count = -1L;  (void) close (fd);}intwrt_text (conditional)  FLAG conditional;{  char file [maxLINE_LEN];	/* Buffer for new file name */  int fd;			/* Filedescriptor of file */  int ret;  if (wpipe) {    fd = STD_OUT;    status_line ("Writing ", "to standard output");    wpipe = FALSE; /* no further write to same stream possible */  }  else {    if (modified == FALSE && viewonly == FALSE && conditional == TRUE) {	status_msg ("Write not necessary.");	return FINE;    }    /* Check if file_name is valid and if file can be written */    if (file_name [0] == '\0' || writable == FALSE) {	overwriteOK = FALSE;	if ((ret = get_file ("Enter file name:", file)) != FINE)		return ret;	copy_string (file_name, file);		/* Save file name */    }    if (overwriteOK == FALSE) {	if (checkoverwrite (file_name) == TRUE)		overwriteOK = TRUE;	else {	if (quit == FALSE)			writable = FALSE;		return ERRORS;	}    }    if ((fd = creat (file_name, fprot)) < 0) {	/* Empty file */	error ("Cannot create or write: " /*, file_name */, serror ());	writable = FALSE;	return ERRORS;    }    else	writable = TRUE;    status_line ("Writing ", file_name);  }  write_file (fd);  if (write_count == -1L)	return ERRORS;  modified = FALSE;  rpipe = FALSE;	/* File name is now assigned *//* Display how many chars (and lines) were written *//*  fstatus ("Wrote", write_count); */  fstatus ("Wrote", -1L);  return FINE;}voidWT (){  (void) wrt_text (TRUE);}voidWTU (){  (void) wrt_text (FALSE);}intpanicwrite (){  int fd;  fd = creat (panic_file, fprot);  write_file (fd);  if (write_count == -1L)	return ERRORS;  else	return FINE;}/* * Edit/view another file. If the current file has been modified,  * ask whether the user wants to save it. * (We could allow to switch between edit and view mode without changing  * the file, but we would have to consider carefully the relationship  * between viewonly and modified.) */voidedit_file (prompt, vomode)  char * prompt;  FLAG vomode;{  char new_file [maxLINE_LEN];	/* Buffer to hold new file name */  if (modified == TRUE && viewonly == FALSE && ask_save () != FINE)	return;  viewonly = vomode;/* Get new file name */  if (get_file (prompt, new_file) == ERRORS)	return;/* Free old linked list, initialize global variables and load new file */  initialize ();  clear_screen ();  load_file (new_file [0] == '\0' ? NIL_PTR : new_file);}voidEDIT (){  edit_file ("Edit file:", FALSE);}voidVIEW (){  edit_file ("View file:", TRUE);}voidedit_nth_file (n)  int n;{  int number, index;  if (modified == TRUE && viewonly == FALSE && ask_save () != FINE)	return;  if (n == -1) {	index = get_number ("Edit which file (enter number) ...", '\0', & number);	if (index == ERRORS) return;	n = number - 1 + fnami_min;  }  if (n < fnami_min) n = fnami_min;  if (n > fnami_max) n = fnami_max;/* Free old linked list, initialize global variables and load new file */  initialize ();  clear_screen ();  fnami = n;  if (fnami < fnami_min) load_file (NIL_PTR);/*  else load_file ((* fnamv) [fnami]); */  else load_file (fnamv [fnami]);}voidNXTFILE (){  if (hop_flag > 0) edit_nth_file (fnami_max);  else edit_nth_file (fnami + 1);}voidPRVFILE (){  if (hop_flag > 0) edit_nth_file (fnami_min);  else edit_nth_file (fnami - 1);}voidNTHFILE (){  edit_nth_file (-1);}/* * Leave editor. If the file has changed, ask if the user wants to save it. */voidQUED (){  if (modified == TRUE && viewonly == FALSE && ask_save () != FINE)	return;  delete_yank_file ();  set_cursor (0, YMAX);  putchar ('\n');  raw_mode (OFF);  exit (0);}/* * Exit editing current file. If the file has changed, save it. * Edit next file if there is one. */voidEXFILE (){  if (modified == TRUE)	if (wrt_text (TRUE) != FINE) return;  if (fnami < fnami_max) NXTFILE ();  else {	delete_yank_file ();	set_cursor (0, YMAX);	putchar ('\n');	raw_mode (OFF);	exit (0);  }}/* * Exit editor. If the file has changed, save it. */voidEXMINED (){	if (modified == TRUE)		if (wrt_text (TRUE) != FINE) return;	delete_yank_file ();	set_cursor (0, YMAX);	putchar ('\n');	raw_mode (OFF);	exit (0);}/* * Exit editing current file. Exit editor if multiexit flag set. */voidEXED (){  if (multiexit == TRUE) EXFILE ();  else EXMINED ();}/* * Count_chars () count the number of chars that the line would occupy on the * screen. Counting starts at the real x-coordinate of the line. * Was only called by delete_text (). */#ifdef UNUSEDintcount_chars (line)  LINE * line;{  register int cnt = get_shift (line->shift_count) * - SHIFT_SIZE;  register char * textp = line->text;/* Find begin of line on screen */  while (cnt < 0) {	if (is_tab (* textp ++))		cnt = tab (cnt);	else		cnt ++;  }/* Count number of chars left */  cnt = 0;  while (* textp != '\n') {	if (is_tab (* textp ++))		 cnt = tab (cnt);	else		cnt ++;  }  return cnt;}#endif /* UNUSED *//*  ==================================================================	* *				Line wrap around			* *  ==================================================================	*//* * Advance pointer and counter to next character. * Handle tab characters and Chinese 2-byte characters correctly. */voidadvance_char (poipoi, colpoi)  char * * poipoi;  int * colpoi;{  if (is_tab (* * poipoi)) {	(* poipoi) ++;	* colpoi = tab (* colpoi);  }  else if (Chinese == TRUE && multichar (* * poipoi)) {	(* poipoi) ++;	(* poipoi) ++;	(* colpoi) ++;	(* colpoi) ++;  }  else {	(* poipoi) ++;	(* colpoi) ++;  }}/* * JUS justifies the current line according to the current margins */voidJUS (){  char * poi;  char * last_blank;  int column;  poi = cur_line->text;  column = 0;  while (column < left_margin && (poi < cur_text || white_space (* poi))) {	advance_char (& poi, & column);  }  if (column < left_margin) {	move_address (poi, y);	while (column < left_margin) {		if (tab (column) <= left_margin) {			S ('\t');			column = tab (column);		} else {			S (' ');			column ++;		}	}	poi = cur_line->text;	/* old text pointer may be invalid */	column = 0;		/* so start again */  }  last_blank = NIL_PTR;  while (column < right_margin && * poi != '\n') {	if (column >= left_margin &&	    (white_space (* poi) || * poi == '-')) last_blank = poi;	advance_char (& poi, & column);  }  if (* poi != '\n') {	if (last_blank != NIL_PTR) {		poi = last_blank;		poi ++;		move_address (poi, y);		SNL ();		JUS ();	}	else {	/* no wrapping point found */		while (! white_space (* poi) && * poi != '\n')			advance_char (& poi, & column);	/* to handle Chin. */		if (* poi == '\n') {			move_address (poi, y);			MRT ();		}		else {			poi ++;			move_address (poi, y);			if (* poi != '\n') SNL ();			else MRT ();			JUS ();		}	}  }  else if (poi - last_blank == 1) {	move_address (poi, y);	DCC ();	while (white_space (* cur_text)) DCC ();	if (* cur_text != '\n') JUS ();	else {		poi = cur_text;		poi --;		if (Chinese == TRUE && inmultichar (cur_line->text, poi))			poi --;		while (white_space (* poi)) {			DPC ();			poi = cur_text;			poi --;			if (Chinese == TRUE && inmultichar (cur_line->text, poi))				poi --;		}		MRT ();	}  }  else {	move_address (poi, y);	MRT ();  }}

⌨️ 快捷键说明

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