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

📄 macro.c

📁 功能强大的文本编辑器
💻 C
📖 第 1 页 / 共 5 页
字号:
                              help_int2 = set.margin[1];
                              help_int3 = set.margin[2];

                              num = sscanf (parse_ptr, "%d %c %d %c %d",
                                                        &help_int,
                                                        &komma,
                                                        &help_int2,
                                                        &komma,
                                                        &help_int3 );
                              if ((num < 1) ||
                                  (help_int3 <= help_int) ||
                                  (help_int3 <= help_int2))
                              {
                                 err_line = line_no;
                              }
                              else
                              {
                                               set.margin[0] = help_int;
                                 if (num >= 2) set.margin[1] = help_int2;
                                 if (num >= 3) set.margin[2] = help_int3;
                              } 
                              break;

                           case 'N':   /* No Tabs */
                              parse_ptr++;
                              set.notab = (toupper(*parse_ptr) == 'Y');
                              break;

                           case 'R':   /* Radix */
                              parse_ptr++;
                              switch (toupper(*parse_ptr))
                              {
                                 case 'A':
                                 case 'B':
                                 case 'D':
                                 case 'H':
                                 case 'O':
                                    set.radix = toupper(*parse_ptr);
                                    break;
         
                                 default:
                                    err_line = line_no;
                                    break;
                              }
                              break;

                           case 'S':   /* Show Find */
                              parse_ptr++;
                              set.showfind = (toupper(*parse_ptr) == 'Y');
                              break;

                           case 'T':   /* Tabs */
                              parse_ptr++;
                              if (sscanf (parse_ptr, "%d", &set.tabs) != 1)
                              {
                                 err_line = line_no;
                              }
                              set.tabs = max (1, min (COLUMNS, set.tabs));

							  /* bugfix 08.06.02 */
                              update_entire_window (fc->top_left);
                              check_dirty_cursor ();
                              break;

                           case 'V':   /* View Row */
                              parse_ptr++;
                              if (sscanf (parse_ptr, "%d", &set.viewrow) != 1)
                              {
                                 err_line = line_no;
                              }
                              set.viewrow -= LINE_OFFSET;
                              set.viewrow = max (0, min ((ROWS-1),
                                                  set.viewrow));
                              break;

                           case 'W':   /* Warning with beep */
                              parse_ptr++;
                              set.warning = (toupper(*parse_ptr) == 'Y');
                              set.warning = *parse_ptr - '0';
                              set.warning = max (0, min (2, set.warning));
                              break;

                           case '*':   /* Search with Wildcards */
                              parse_ptr++;
                              set.wildcards = (toupper(*parse_ptr) == 'Y');
                              break;

                           case '~':   /* Replace '~' with home directory */
                              parse_ptr++;
                              set.tilde_home = (toupper(*parse_ptr) == 'Y');
                              break;

#if (WITH_SYNTAX_HIGHLIGHTING)
                           case 'Y':   /* default sYntax */
                              parse_ptr++;
                              if (sscanf (parse_ptr, "%d", &set.syntax_global) != 1)
                              {
                                 err_line = line_no;
                              }
                              set.syntax_global &= 0x07;
                              fc->syntax_flag   &= set.syntax_global;
                              break;
#endif

                           default:
                              parse_ptr++;
                              break;
                        }
                     }
                     parse_ptr++;
                     break;

                  case '\\':   /* Comment */
                     key = string_2_key (&parse_ptr);
                     switch (key)
                     {
                        case COMM_STT:
                           save_stat = file_stat;
                           file_stat = COMMENT;
                           break;

                        default:
                           break;
                     }
                     break;

                  default:
                     parse_ptr++;
                     break;
               }
               break;
   
            case MACRO_NAME:
               name_ptr = macro_name;
               *name_ptr = '\0';
               help_ptr = parse_ptr;
               while (string_2_key (&help_ptr) != 0x1b)
               {                                  /* search end of name */
                  *name_ptr = *parse_ptr;
                  name_ptr++;
                  *name_ptr = '\0';
                  parse_ptr++;
                  help_ptr = parse_ptr;

               /* don't exceed max. name length */
                  if (name_ptr >= &macro_name[sizeof(macro_name)-1])
                  {
                     err_line = line_no;
                     break;
                  }

               /* for safety reasons ... */
                  if (parse_ptr >= max_ptr)
                  {
                     err_line = line_no;
                     break;
                  }
               }

               macro = init_macro (macro_name);
               if (macro == NULL)
               {
                  err_message (OUT_OF_MEMORY);
                  fclose (fp);
#if BIG_BUFFER
                  read_level--;
#endif
                  return -1;      /* error : abort --> */
               }

               parse_ptr += 3;   /* ignore "\BR" */

               file_stat = MACRO_SEQUENCE;
               break;
   
            case MACRO_SEQUENCE:
               if (macro->length >= (MACRO_SIZE-sizeof(int)))    /* reached max. size ? */
                  key = SEQU_MM;
               else
                  key = string_2_key (&parse_ptr);

               *macro->i_ptr = key;               /* add new key */
               macro->i_ptr++;
               macro->length += sizeof (int);

               if ((key == SEQU_MM) ||            /* end of sequence ? */
                   (key == SEQU_EM))
               {                                  /* yes : finish macro */
                  macro = chain_macro (macro, (key == SEQU_EM));
                  pop_macro_stack (macro, 0);
                  file_stat = NORMAL;
               }
               break;
   
            case COMMENT:
               switch (*parse_ptr)
               {
                  case '*':
                     parse_ptr++;
                     if (*parse_ptr == '\\')
                     {
                        file_stat = save_stat;
                     }
                     break;

                  default:
                     parse_ptr++;
                     break;
               }
               break;
         }  /* switch file_stat */
      }  /* for parse_ptr */

   }  /* while loop */

/* close datafile */
   fclose (fp);

#if BIG_BUFFER
   read_level--;
#endif

   if (err_line)
   {
      sprintf (err_text, " (line %d)", err_line);
      err_message_1 (INVALID_MACRO_ENTRY, err_text);
      return (- err_line);  /* error */
   }
   else
   {
      show_status_line_2 ("*** got macro file ***", 0, -2, 0);
      return 1;   /* o.k. */
   }
}  /* read_macro_file */

/* -FF-  */

int search_macro_file (void)
{
static char filename [BUF_256];
FILE *fp;

/* search sequence, without return between searches. */

/* 1.) search in PATH (not in ms/dos, only unix + os_9) */
/* 2.) search in mbedit path (path of exe-file = argv[0]) */
/* 3.) search in home directory */

#if (ACT_OP_SYSTEM == MS_DOS) /* || (ACT_OP_SYSTEM == WIN_32) */
#define SEARCH_IN_PATH 0
#else
#define SEARCH_IN_PATH 1
#endif

#if SEARCH_IN_PATH
static char path [BUF_256];
char *name_stt, *name_end;
#endif


#if SEARCH_IN_PATH

/* 1.) search in PATH */

/* get environment variable "PATH" */
   strncpy (path, getenv ("PATH"), sizeof (path));
   path [sizeof(path) - 1] = '\0';  /* forced end of string */

/* example: */
/* PATH=H:;D:\USR.PC\BIN;C:\SYSTEM;C:\PCLINK3;C:\BIN;D:\BIN;D:\BAT;D:\UTIL; */

/* parse environment variable */
   name_stt = path;
   name_end = path;
   while (*name_stt != 0)
   {
      while (*name_end != PATH_SEPARATOR)
      {
         if (*name_end == '\0')   /* missing last separator ? */
            break;                /* for safety reasons */
         name_end++;
      }
      *name_end = '\0';

   /* build macro filename */
      strncpy (filename, name_stt, sizeof(filename));
      strcat  (filename, FILE_SEPARATOR);
      strcat  (filename, MACRO_FILENAME);

#if MAC_TEST
      printf ("\015\012 filename = %s\015\012", filename);
#endif

   /* test, if file exists */
      if ((fp = fopen (filename, "r")) != NULL)
      {                                         /* found file in search path */
         fclose (fp);
         read_macro_file (filename, 1);  /* get it */
         break;
      }

   /* next pathname */
      name_end++;
      name_stt = name_end;
   }  /* while name_stt */

#endif

/* 2.) search in mbedit path */

/* build macro filename */
   strcpy (filename, get_exe_path ());
   strcat (filename, FILE_SEPARATOR);
   strcat (filename, MACRO_FILENAME);

#if MAC_TEST
   printf ("\015\012 filename = %s\015\012", filename);
#endif

/* test, if file exists */
   if ((fp = fopen (filename, "r")) != NULL)
   {                                         /* found file in search path */
      fclose (fp);
      read_macro_file (filename, 1);  /* get it */
   }

/* 3.) search in home directory */

/* build macro filename */
   strcpy (filename, HOME_DIR);
   strcat (filename, FILE_SEPARATOR);
   strcat (filename, MACRO_FILENAME);

#if MAC_TEST
   printf ("\015\012 filename = %s\015\012", filename);
#endif

/* test, if file exists */
   if ((fp = fopen (filename, "r")) != NULL)
   {                                         /* found file in search path */
      fclose (fp);
      return read_macro_file (filename, 1);  /* get it */
   }


   return -1;  /* nothing found */

}  /* search_macro_file */

/* -FF-  */

/* Modification History */
/* 30.12.92 - file erzeugt */
/* 01.01.93 - macro_stack */
/* 02.01.93 - list_macros () */
/* 03.01.93 - struct MACRO : int repeat */
/* 05.01.93 - more CTRL_keys (Home, End, PgUp, PgDn, Leftm Right) */
/* 17.06.93 - AFNV, AFRV */
/* 18.06.93 - set.warning */
/* 27.07.93 - set.warning: 0-2 */
/* 19.08.93 - put_macro_key ()  : force end of macro, if limits exceeded */
/* 24.08.93 - perform_insert_eol () */
/* 28.08.93 - STATIC */
/* 05.09.93 - Find mit Wildcard: '?' */
/* 10.09.93 - setvbuf (for speed) */
/* 12.09.93 - show_status_line_2 (..., ignore_batch) */
/* 29.09.93 - update_rest_of_window(), ...entire_window() */
/* 30.09.93 - key_tab: 0x0d0a */
/* 09.10.93 - Set Margin */
/* 11.10.93 - bugfix: \NL auch bei EOLN <= 0xff */
/* 20.10.93 - 'S'et 'M'argin: check bad values */
/* 29.11.93 - mb_ctype.h */
/* 29.11.93 - semigrafik abschaltbar */
/* 10.12.93 - MouSetMoveArea () */
/* 12.12.93 - MouSetMoveArea (..., 0) */
/* 13.12.93 - 'S','M': Aedit Format */
/* 07.01.94 - AS = 1: automatic shift of screen with cursor, set_auto_shift () */
/* 17.02.94 - read_macro_file (..., store_filename) */
/* 09.05.94 - AE=200, esc_waittime */
/* 10.05.94 - search_macro_file: modified search algorithm */
/* 11.05.94 - search_macro_file: return -1; --> break; */
/* 12.05.94 - MACRO_TUNING */
/* 13.05.94 - 0x0d --> "\\00D" (anstatt "\\0D") eindeutig: "\\0D1", usw... */
/* 15.05.94 - 0x0a --> "\\00A" (anstatt "\\0A") eindeutig: "\\0A0", usw... */
/* 17.05.94 - removed BIG_BUFFER fuer MS_DOS, HDS */
/* 19.05.94 - EOL --> EOLA */
/* 26.05.94 - list_macros: (w_bot[0] - STATUS_LINES) anstatt MAX_ROW */
/* 02.06.94 - INCLUDE macrofile */
/* 04.06.94 - INCLUDE macrofile: error message */
/* 05.06.94 - redisplay window, only if size changed */
/* 21.06.94 - key_tab []: 0x7f <--> "\RB" (Rubout) */
/* 29.06.94 - set.tilde_home */
/* 04.07.94 - WITH_E_DELIMIT */
/* 06.07.94 - 'S'et 'A'utonl */
/* 12.07.94 - Schreibfehler korrigiert */
/* 27.09.94 - type cast(s) wg. compiler warnings (microsoft c 6.0) */
/* 30.09.94 - start_index () global */
/* 02.10.94 - WITH_SYNTAX_HIGHLIGHTING */
/* 04.10.94 - <esc> sequences for vt100 */
/* 05.10.94 - vga: use hex code only, vt100: use string format only */
/* 06.10.94 - special case 0x7f = "\\XF" for SCO_UNIX */
/* 24.02.95 - QSORT_FUNC_ANSI */
/* 17.11.95 - syntax_global */
/* 25.11.95 - list of n macro files */
/* 27.11.95 - macro nesting level (display + limitation) */
/* 23.01.96 - printf ("\015\012") anstatt printf ("\r\n") */
/* 05.09.98 - key_tab: EOLN --> EOLN_INIT */
/* 07.09.98 - bugfixes: EOLN = special case in key_2_string + string_2_key */
/* 08.06.02 - bugfix: read_macro_file(): 'S'et 'T'abs: update_entire_window(), check_dirty_cursor() */
/* 29.03.03 - bugfix: init_sorted_tables(): start_index(... + 1) */
/* 01.04.03 - list_macros(): count additional rows of show_syntax_file() */
/* 23.04.03 - read_macro_file(): break reading line with 0x0a and 0x0d */
/* 30.04.03 - syntax highlighting for strings */
/* 11.02.04 - 'S'et 'H'ighbit 'A'uto */
/* 13.03.04 - disp_hnd.c: modifications for CSS (dashes in keywords) */

⌨️ 快捷键说明

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