/[qemacs]/qemacs/qe.c
ViewVC logotype

Diff of /qemacs/qe.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19 by chqrlie, Mon May 9 06:21:49 2005 UTC revision 1.20 by chqrlie, Mon May 9 09:10:37 2005 UTC
# Line 65  static QEditScreen global_screen; Line 65  static QEditScreen global_screen;
65  static int screen_width = 0;  static int screen_width = 0;
66  static int screen_height = 0;  static int screen_height = 0;
67  EditBuffer *trace_buffer;  EditBuffer *trace_buffer;
68    int no_init_file;
69    const char *user_option;
70    
71  /* mode handling */  /* mode handling */
72    
# Line 1263  void text_write_char(EditState *s, int k Line 1265  void text_write_char(EditState *s, int k
1265  }  }
1266    
1267  /* XXX: may be better to move it into qe_key_process() */  /* XXX: may be better to move it into qe_key_process() */
1268  static void quote_grab_key(void *opaque, int key)  static void quote_key(void *opaque, int key)
1269  {  {
1270        /* CG: should pass s as opaque */
1271      QEmacsState *qs = &qe_state;      QEmacsState *qs = &qe_state;
1272      EditState *s;      EditState *s;
1273    
1274      s = qs->active_window;      s = qs->active_window;
1275      if (!s)      if (!s)
1276          return;          return;
1277    
1278        /* CG: why not insert special keys as well? */
1279      if (!KEY_SPECIAL(key) ||      if (!KEY_SPECIAL(key) ||
1280          (key >= 0 && key <= 31)) {          (key >= 0 && key <= 31)) {
1281          do_char(s, key);          do_char(s, key);
# Line 1282  static void quote_grab_key(void *opaque, Line 1287  static void quote_grab_key(void *opaque,
1287    
1288  void do_quote(EditState *s)  void do_quote(EditState *s)
1289  {  {
1290      qe_grab_keys(quote_grab_key, NULL);      qe_grab_keys(quote_key, NULL);
1291      put_status(s, "Quote: ");      put_status(s, "Quote: ");
1292  }  }
1293    
# Line 1326  void do_set_mark(EditState *s) Line 1331  void do_set_mark(EditState *s)
1331      put_status(s, "Mark set");      put_status(s, "Mark set");
1332  }  }
1333    
1334    void do_mark_whole_buffer(EditState *s)
1335    {
1336        s->b->mark = 0;
1337        s->offset = s->b->total_size;
1338    }
1339    
1340  EditBuffer *new_yank_buffer(void)  EditBuffer *new_yank_buffer(void)
1341  {  {
1342      QEmacsState *qs = &qe_state;      QEmacsState *qs = &qe_state;
# Line 1672  void do_goto_char(EditState *s, int pos) Line 1683  void do_goto_char(EditState *s, int pos)
1683      s->offset = eb_goto_char(s->b, pos);      s->offset = eb_goto_char(s->b, pos);
1684  }  }
1685    
1686    void do_count_lines(EditState *s)
1687    {
1688        int total_lines, line_num, mark_line, col_num;
1689    
1690        eb_get_pos(s->b, &total_lines, &col_num, s->b->total_size);
1691        eb_get_pos(s->b, &mark_line, &col_num, s->b->mark);
1692        eb_get_pos(s->b, &line_num, &col_num, s->offset);
1693        
1694        put_status(s, "%d lines, point on line %d, %d lines in block",
1695                   total_lines, line_num + 1, abs(line_num - mark_line));
1696    }
1697    
1698    void do_what_cursor_position(EditState *s)
1699    {
1700        char buf[128];
1701        int line_num, col_num;
1702        int c, pos, offset1;
1703    
1704        buf[0] = '\0';
1705        if (s->offset < s->b->total_size) {
1706            c = eb_nextc(s->b, s->offset, &offset1);
1707            pos = snprintf(buf, sizeof(buf), "char: ");
1708            if (c < 32 || c == 127) {
1709                pos += snprintf(buf + pos, sizeof(buf) - pos, "^%c ",
1710                                (c + '@') & 127);
1711            } else
1712            if (c < 127 || c >= 160) {
1713                buf[pos++] = '\'';
1714                pos = utf8_encode(buf + pos, c) - buf;
1715                buf[pos++] = '\'';
1716                buf[pos++] = ' ';
1717            }
1718            pos += snprintf(buf + pos, sizeof(buf) - pos, "(%#3o %d 0x%2x)  ",
1719                            c, c, c);
1720            /* CG: should display buffer bytes if non ascii */
1721        }    
1722        eb_get_pos(s->b, &line_num, &col_num, s->offset);
1723        put_status(s, "%spoint=%d column=%d mark=%d size=%d region=%d",
1724                   buf, s->offset, col_num, s->b->mark, s->b->total_size,
1725                   abs(s->offset - s->b->mark));
1726    }
1727    
1728  void do_set_tab_width(EditState *s, int tab_width)  void do_set_tab_width(EditState *s, int tab_width)
1729  {  {
1730      if (tab_width > 1)      if (tab_width > 1)
# Line 3175  static void free_cmd(ExecCmdState *es); Line 3228  static void free_cmd(ExecCmdState *es);
3228  void exec_command(EditState *s, CmdDef *d, int argval)  void exec_command(EditState *s, CmdDef *d, int argval)
3229  {  {
3230      ExecCmdState *es;      ExecCmdState *es;
3231        const char *argdesc;
3232    
3233        argdesc = d->name + strlen(d->name) + 1;
3234        if (*argdesc == '*') {
3235            argdesc++;
3236            if (s->b->flags & BF_READONLY) {
3237                put_status(s, "Buffer is read only");
3238                return;
3239            }
3240        }
3241            
3242      es = malloc(sizeof(ExecCmdState));      es = malloc(sizeof(ExecCmdState));
3243      if (!es)      if (!es)
# Line 3189  void exec_command(EditState *s, CmdDef * Line 3252  void exec_command(EditState *s, CmdDef *
3252      es->args[es->nb_args] = (void *)s;      es->args[es->nb_args] = (void *)s;
3253      es->args_type[es->nb_args] = CMD_ARG_WINDOW;      es->args_type[es->nb_args] = CMD_ARG_WINDOW;
3254      es->nb_args++;      es->nb_args++;
3255      es->ptype = d->name + strlen(d->name) + 1;      es->ptype = argdesc;
3256    
3257      parse_args(es);      parse_args(es);
3258  }  }
# Line 3293  static void parse_args(ExecCmdState *es) Line 3356  static void parse_args(ExecCmdState *es)
3356          qs->ec.function = d->name;          qs->ec.function = d->name;
3357          call_func(d->action.func, es->nb_args, es->args, es->args_type);          call_func(d->action.func, es->nb_args, es->args, es->args_type);
3358          /* CG: Should test for abort condition */          /* CG: Should test for abort condition */
3359            /* CG: Should follow qs->active_window ? */
3360      } while (--rep_count > 0);      } while (--rep_count > 0);
3361    
3362      qs->last_cmd_func = d->action.func;      qs->last_cmd_func = d->action.func;
# Line 3635  static void qe_key_process(int key) Line 3699  static void qe_key_process(int key)
3699          macro_add_key(key);          macro_add_key(key);
3700      }      }
3701            
3702    again:
3703      if (c->grab_key_cb) {      if (c->grab_key_cb) {
3704          c->grab_key_cb(c->grab_key_opaque, key);          c->grab_key_cb(c->grab_key_opaque, key);
3705          return;          /* allow key_grabber to quit and unget last key */
3706            if (c->grab_key_cb || qs->ungot_key == -1)
3707                return;
3708            key = qs->ungot_key;
3709            qs->ungot_key = -1;
3710      }      }
3711    
3712        /* safety check */
3713      if (c->nb_keys >= MAX_KEYS) {      if (c->nb_keys >= MAX_KEYS) {
3714          qe_key_init();          qe_key_init();
3715          c->describe_key = 0;          c->describe_key = 0;
3716          return;          return;
3717      }      }
3718    
3719      c->keys[c->nb_keys++] = key;      c->keys[c->nb_keys++] = key;
3720      s = qs->active_window;      s = qs->active_window;
3721      if (!s->minibuf) {      if (!s->minibuf) {
# Line 3700  static void qe_key_process(int key) Line 3771  static void qe_key_process(int key)
3771                      }                      }
3772                  }                  }
3773                  if (kd) {                  if (kd) {
3774                        /* horrible kludge to pass key as intrinsic argument */
3775                        /* CG: should have an argument type for key */
3776                      kd->cmd->val = (void *)key;                      kd->cmd->val = (void *)key;
3777                      goto exec_cmd;                      goto exec_cmd;
3778                  }                  }
# Line 3742  static void qe_key_process(int key) Line 3815  static void qe_key_process(int key)
3815              qe_key_init();              qe_key_init();
3816              edit_display(qs);              edit_display(qs);
3817              dpy_flush(&global_screen);              dpy_flush(&global_screen);
3818                /* CG: should move ungot key handling to generic event dispatch */
3819                if (qs->ungot_key != -1) {
3820                    key = qs->ungot_key;
3821                    qs->ungot_key = -1;
3822                    goto again;
3823                }
3824              return;              return;
3825          }          }
3826      }      }
# Line 4020  void file_completion(StringArray *cs, co Line 4099  void file_completion(StringArray *cs, co
4099      char path[MAX_FILENAME_SIZE];      char path[MAX_FILENAME_SIZE];
4100      char file[MAX_FILENAME_SIZE];      char file[MAX_FILENAME_SIZE];
4101      char filename[MAX_FILENAME_SIZE];      char filename[MAX_FILENAME_SIZE];
4102      char *base;      const char *base, *ext;
4103      int len;      int len;
4104            
4105      pstrcpy(path, sizeof(path), input);      splitpath(path, sizeof(path), file, sizeof(file), input);
     base = path + (basename(path) - path);  
     pstrcpy(file, sizeof(file), base);  
4106      pstrcat(file, sizeof(file), "*");      pstrcat(file, sizeof(file), "*");
4107      *base = '\0';  
4108      ffs = find_file_open(*path ? path : ".", file);      ffs = find_file_open(*path ? path : ".", file);
4109      while (find_file_next(ffs, filename, sizeof(filename)) == 0) {      while (find_file_next(ffs, filename, sizeof(filename)) == 0) {
4110          struct stat sb;          struct stat sb;
4111    
4112          base = filename + (basename(filename) - filename);          base = basename(filename);
4113          /* ignore . and .. to force direct match if          /* ignore . and .. to force direct match if
4114           * single entry in directory */           * single entry in directory */
4115          if (!strcmp(base, ".") || !strcmp(base, ".."))          if (!strcmp(base, ".") || !strcmp(base, ".."))
# Line 4042  void file_completion(StringArray *cs, co Line 4119  void file_completion(StringArray *cs, co
4119          if (!len || base[len - 1] == '~')          if (!len || base[len - 1] == '~')
4120              continue;              continue;
4121          /* ignore known output file extensions */          /* ignore known output file extensions */
4122          if (strfind(file_completion_ignore_extensions,          ext = extension(base);
4123                      extension(filename), 1)) {          if (*ext && strfind(file_completion_ignore_extensions, ext + 1, 1))
4124              continue;              continue;
4125          }  
         makepath(file, sizeof(file), path, base);  
4126          /* stat the file to find out if it's a directory.          /* stat the file to find out if it's a directory.
4127           * In that case add a slash to speed up typing long paths           * In that case add a slash to speed up typing long paths
4128           */           */
4129          stat(file, &sb);          if (!stat(filename, &sb) && S_ISDIR(sb.st_mode))
4130          if (S_ISDIR(sb.st_mode))              pstrcat(filename, sizeof(filename), "/");
4131              pstrcat(path, sizeof(path), "/");          add_string(cs, filename);
         add_string(cs, file);  
4132      }      }
4133    
4134      find_file_close(ffs);      find_file_close(ffs);
# Line 4581  void do_toggle_read_only(EditState *s) Line 4656  void do_toggle_read_only(EditState *s)
4656      s->b->flags ^= BF_READONLY;      s->b->flags ^= BF_READONLY;
4657  }  }
4658    
4659    void do_not_modified(EditState *s)
4660    {
4661        s->b->modified = 0;
4662    }
4663    
4664  static void kill_buffer_confirm_cb(void *opaque, char *reply);  static void kill_buffer_confirm_cb(void *opaque, char *reply);
4665  static void kill_buffer_noconfirm(EditBuffer *b);  static void kill_buffer_noconfirm(EditBuffer *b);
4666    
# Line 4695  static ModeDef *probe_mode(EditState *s, Line 4775  static ModeDef *probe_mode(EditState *s,
4775      return selected_mode;      return selected_mode;
4776  }  }
4777    
4778  static void do_load1(EditState *s, const char *filename1, int kill_buffer)  static void do_load1(EditState *s, const char *filename1,
4779                         int kill_buffer, int load_resource)
4780  {  {
4781      char buf[1025];      char buf[1025];
4782      char filename[MAX_FILENAME_SIZE];      char filename[MAX_FILENAME_SIZE];
# Line 4706  static void do_load1(EditState *s, const Line 4787  static void do_load1(EditState *s, const
4787      FILE *f;      FILE *f;
4788      struct stat st;      struct stat st;
4789    
4790        if (load_resource) {
4791            if (find_resource_file(filename, sizeof(filename), filename1))
4792                return;
4793        } else {
4794            /* compute full name */
4795            canonize_absolute_path(filename, sizeof(filename), filename1);
4796        }
4797    
4798      if (kill_buffer) {      if (kill_buffer) {
4799          /* CG: this behaviour is not correct */          /* CG: this behaviour is not correct */
4800          /* CG: should have a direct primitive */          /* CG: should have a direct primitive */
4801          do_kill_buffer(s, s->b->name);          do_kill_buffer(s, s->b->name);
4802      }      }
4803    
     /* compute full name */  
     canonize_absolute_path(filename, sizeof(filename), filename1);  
   
4804      /* see if file is already edited */      /* see if file is already edited */
4805      b = eb_find_file(filename);      b = eb_find_file(filename);
4806      if (b) {      if (b) {
# Line 4818  static void load_completion_cb(void *opa Line 4904  static void load_completion_cb(void *opa
4904    
4905  void do_load(EditState *s, const char *filename)  void do_load(EditState *s, const char *filename)
4906  {  {
4907      do_load1(s, filename, 0);      do_load1(s, filename, 0, 0);
4908  }  }
4909    
4910  void do_find_alternate_file(EditState *s, const char *filename)  void do_find_alternate_file(EditState *s, const char *filename)
4911  {  {
4912      do_load1(s, filename, 1);      do_load1(s, filename, 1, 0);
4913    }
4914    
4915    void do_load_file_from_path(EditState *s, const char *filename)
4916    {
4917        do_load1(s, filename, 0, 1);
4918  }  }
4919    
4920  void do_insert_file(EditState *s, const char *filename)  void do_insert_file(EditState *s, const char *filename)
# Line 6414  int parse_config_file(EditState *s, cons Line 6505  int parse_config_file(EditState *s, cons
6505          /* search for command */          /* search for command */
6506          d = qe_find_cmd(cmd);          d = qe_find_cmd(cmd);
6507          if (!d) {          if (!d) {
6508                /* CG: should handle variables */
6509              err = -1;              err = -1;
6510              put_status(s, "Unknown command '%s'", cmd);              put_status(s, "Unknown command '%s'", cmd);
6511              continue;              continue;
# Line 6425  int parse_config_file(EditState *s, cons Line 6517  int parse_config_file(EditState *s, cons
6517    
6518          /* construct argument type list */          /* construct argument type list */
6519          r = d->name + strlen(d->name) + 1;          r = d->name + strlen(d->name) + 1;
6520            if (*r == '*') {
6521                r++;
6522                if (s->b->flags & BF_READONLY) {
6523                    put_status(s, "Buffer is read only");
6524                    continue;
6525                }
6526            }
6527    
6528          for (;;) {          for (;;) {
6529              unsigned char arg_type;              unsigned char arg_type;
6530              int ret;              int ret;
# Line 6526  int parse_config_file(EditState *s, cons Line 6626  int parse_config_file(EditState *s, cons
6626    
6627          qs->ec.function = d->name;          qs->ec.function = d->name;
6628          call_func(d->action.func, nb_args, args, args_type);          call_func(d->action.func, nb_args, args, args_type);
6629            if (qs->active_window)
6630                s = qs->active_window;
6631          continue;          continue;
6632    
6633      fail:      fail:
# Line 6551  void parse_config(EditState *e, const ch Line 6653  void parse_config(EditState *e, const ch
6653      ffs = find_file_open(qs->res_path, "config");      ffs = find_file_open(qs->res_path, "config");
6654      if (!ffs)      if (!ffs)
6655          return;          return;
6656      for (;;) {      while (find_file_next(ffs, filename, sizeof(filename)) == 0) {
         if (find_file_next(ffs, filename, sizeof(filename)) != 0)  
             break;  
6657          parse_config_file(e, filename);          parse_config_file(e, filename);
6658      }      }
6659      find_file_close(ffs);      find_file_close(ffs);
# Line 6586  static CmdOptionDef *first_cmd_options; Line 6686  static CmdOptionDef *first_cmd_options;
6686  void qe_register_cmd_line_options(CmdOptionDef *table)  void qe_register_cmd_line_options(CmdOptionDef *table)
6687  {  {
6688      CmdOptionDef **pp, *p;      CmdOptionDef **pp, *p;
6689    
6690        /* link command line options table at end of list */
6691      pp = &first_cmd_options;      pp = &first_cmd_options;
6692      while (*pp != NULL) {      while (*pp != NULL) {
6693          p = *pp;          p = *pp;
# Line 6598  void qe_register_cmd_line_options(CmdOpt Line 6700  void qe_register_cmd_line_options(CmdOpt
6700    
6701  /******************************************************/  /******************************************************/
6702    
6703  static void show_help(void)  static void show_version(void)
6704    {
6705        printf("QEmacs version " QE_VERSION "\n"
6706               "Copyright (c) 2000-2003 Fabrice Bellard\n"
6707               "QEmacs comes with ABSOLUTELY NO WARRANTY.\n"
6708               "You may redistribute copies of QEmacs\n"
6709               "under the terms of the GNU Lesser General Public License.\n");
6710        exit(1);
6711    }
6712    
6713    static void show_usage(void)
6714  {  {
6715      CmdOptionDef *p;      CmdOptionDef *p;
6716      printf("QEmacs version " QE_VERSION ", Copyright (c) 2000-2003 Fabrice Bellard\n");      int pos;
6717    
6718        printf("Usage: qe [OPTIONS] [filename ...]\n"
6719               "\n"
6720               "Options:\n"
6721               "\n");
6722    
6723      /* generate usage */      /* print all registered command line options */
     printf("usage: qe");  
6724      p = first_cmd_options;      p = first_cmd_options;
6725      while (p != NULL) {      while (p != NULL) {
6726          while (p->name != NULL) {          while (p->name != NULL) {
6727              printf(" [-%s", p->name);              pos = printf("--%s", p->name);
6728                if (p->shortname)
6729                    pos += printf(", -%s", p->shortname);
6730              if (p->flags & CMD_OPT_ARG)              if (p->flags & CMD_OPT_ARG)
6731                  printf(" %s", p->argname);                  pos += printf(" %s", p->argname);
6732              printf("]");              if (pos < 24)
6733                    printf("%*s", pos - 24, "");
6734                printf("%s\n", p->help);
6735              p++;              p++;
6736          }          }
6737          p = p->u.next;          p = p->u.next;
6738      }      }
6739      printf(" [filename...]\n\n");      printf("\n"
6740               "Report bugs to bug@qemacs.org.  First, please see the Bugs\n"
6741               "section of the QEmacs manual or the file BUGS.\n");
6742        exit(1);
6743    }
6744    
6745      /* generate help */  int parse_command_line(int argc, char **argv)
6746      p = first_cmd_options;  {
6747      while (p != NULL) {      int optind;
6748          while (p->name != NULL) {  
6749              printf("-%s", p->name);      optind = 1;
6750              if (p->flags & CMD_OPT_ARG)      for (;;) {
6751                  printf(" %s", p->argname);          const char *r, *r1, *r2, *optarg;
6752              printf(": %s\n", p->help);          CmdOptionDef *p;
6753              p++;  
6754            if (optind >= argc)
6755                break;
6756            r = argv[optind];
6757            /* stop before first non option */
6758            if (r[0] != '-')
6759                break;
6760            optind++;
6761    
6762            r2 = r1 = r + 1;
6763            if (r2[0] == '-') {
6764                r2++;
6765                /* stop after `--' marker */
6766                if (r2[0] == '\0')
6767                    break;
6768          }          }
6769          p = p->u.next;  
6770            p = first_cmd_options;
6771            while (p != NULL) {
6772                while (p->name != NULL) {
6773                    if (!strcmp(p->name, r2) ||
6774                        (p->shortname && !strcmp(p->shortname, r1))) {
6775                        if (p->flags & CMD_OPT_ARG) {
6776                            if (optind >= argc) {
6777                                put_status(NULL,
6778                                           "cmdline argument expected -- %s", r);
6779                                goto next_cmd;
6780                            }
6781                            optarg = argv[optind++];
6782                        } else {
6783                            optarg = NULL;
6784                        }
6785                        if (p->flags & CMD_OPT_BOOL) {
6786                            *p->u.int_ptr = 1;
6787                        } else if (p->flags & CMD_OPT_STRING) {
6788                            *p->u.string_ptr = optarg;
6789                        } else if (p->flags & CMD_OPT_INT) {
6790                            *p->u.int_ptr = strtol(optarg, NULL, 0);
6791                        } else if (p->flags & CMD_OPT_ARG) {
6792                            p->u.func_arg(optarg);
6793                        } else {
6794                            p->u.func_noarg();
6795                        }
6796                        goto next_cmd;
6797                    }
6798                    p++;
6799                }
6800                p = p->u.next;
6801            }
6802            put_status(NULL, "unknown cmdline option '%s'", r);
6803        next_cmd: ;
6804        }
6805        return optind;
6806    }
6807    
6808    void set_user_option(const char *user)
6809    {
6810        QEmacsState *qs = &qe_state;
6811        char path[1024];
6812        const char *home_path;
6813    
6814        user_option = user;
6815        /* compute resources path */
6816        pstrcpy(qs->res_path, sizeof(qs->res_path),
6817               CONFIG_QE_PREFIX "/share/qe:" CONFIG_QE_PREFIX "/lib/qe:"
6818               "/usr/share/qe:/usr/lib/qe");
6819        if (user) {
6820            /* use ~USER/.qe instead of ~/.qe */
6821            /* CG: should get user homedir */
6822            snprintf(path, sizeof(path), "/home/%s", user);
6823            home_path = path;
6824        } else {
6825            home_path = getenv("HOME");
6826        }
6827        if (home_path) {
6828            pstrcat(qs->res_path, sizeof(qs->res_path), ":");
6829            pstrcat(qs->res_path, sizeof(qs->res_path), home_path);
6830            pstrcat(qs->res_path, sizeof(qs->res_path), "/.qe");
6831      }      }
     exit(1);  
6832  }  }
6833    
6834  static CmdOptionDef cmd_options[] = {  static CmdOptionDef cmd_options[] = {
6835      { "h", NULL, 0, "show help",      { "help", "h", NULL, 0, "display this help message and exit",
6836        {func_noarg: show_help}},        {func_noarg: show_usage}},
6837        { "no-init-file", "q", NULL, CMD_OPT_BOOL, "do not load config files",
6838          {int_ptr: &no_init_file}},
6839        { "user", "u", "USER", CMD_OPT_ARG, "load ~USER/.qe/config instead of your own",
6840          {func_arg: set_user_option}},
6841        { "version", "V", NULL, 0, "display version information and exit",
6842          {func_noarg: show_version}},
6843      { NULL },      { NULL },
6844  };  };
6845    
# Line 6801  static inline void init_all_modules(void Line 7005  static inline void init_all_modules(void
7005      module_hex_init(); /* hex.c(351) */      module_hex_init(); /* hex.c(351) */
7006      module_list_init(); /* list.c(102) */      module_list_init(); /* list.c(102) */
7007      module_tty_init(); /* tty.c(567) */      module_tty_init(); /* tty.c(567) */
7008    #ifndef CONFIG_TINY
7009      module_charset_more_init(); /* charsetmore.c(324) */      module_charset_more_init(); /* charsetmore.c(324) */
7010      module_unihex_init(); /* unihex.c(184) */      module_unihex_init(); /* unihex.c(184) */
7011      module_c_init(); /* clang.c(567) */      module_c_init(); /* clang.c(567) */
# Line 6809  static inline void init_all_modules(void Line 7014  static inline void init_all_modules(void
7014      module_bufed_init(); /* bufed.c(197) */      module_bufed_init(); /* bufed.c(197) */
7015      module_shell_init(); /* shell.c(922) */      module_shell_init(); /* shell.c(922) */
7016      module_dired_init(); /* dired.c(369) */      module_dired_init(); /* dired.c(369) */
7017    #endif
7018  #ifdef CONFIG_WIN32  #ifdef CONFIG_WIN32
7019      module_win32_init(); /* win32.c(504) */      module_win32_init(); /* win32.c(504) */
7020  #endif  #endif
7021  #ifdef CONFIG_X11  #ifdef CONFIG_X11
7022      module_x11_init(); /* x11.c(1704) */      module_x11_init(); /* x11.c(1704) */
7023  #endif  #endif
7024    #ifndef CONFIG_TINY
7025  #ifdef CONFIG_HTML  #ifdef CONFIG_HTML
7026      module_html_init(); /* html.c(894) */      module_html_init(); /* html.c(894) */
7027      module_docbook_init(); /* docbook.c(53) */      module_docbook_init(); /* docbook.c(53) */
7028  #endif  #endif
7029    #endif
7030  #ifdef CONFIG_FFMPEG  #ifdef CONFIG_FFMPEG
7031      module_video_init(); /* video.c(979) */      module_video_init(); /* video.c(979) */
7032      module_image_init(); /* image.c(844) */      module_image_init(); /* image.c(844) */
# Line 6885  void qe_init(void *opaque) Line 7093  void qe_init(void *opaque)
7093      EditBuffer *b;      EditBuffer *b;
7094      QEDisplay *dpy;      QEDisplay *dpy;
7095      int i, optind, is_player;      int i, optind, is_player;
     char *home_path;  
7096    
7097      /* compute resources path */      qs->ec.function = "qe-init";
     strcpy(qs->res_path,  
            CONFIG_QE_PREFIX "/share/qe:" CONFIG_QE_PREFIX "/lib/qe:"  
            "/usr/share/qe:/usr/lib/qe");  
     home_path = getenv("HOME");  
     if (home_path) {  
         pstrcat(qs->res_path, sizeof(qs->res_path), ":");  
         pstrcat(qs->res_path, sizeof(qs->res_path), home_path);  
         pstrcat(qs->res_path, sizeof(qs->res_path), "/.qe");  
     }  
7098      qs->macro_key_index = -1; /* no macro executing */      qs->macro_key_index = -1; /* no macro executing */
7099      qs->ungot_key = -1; /* no unget key */      qs->ungot_key = -1; /* no unget key */
     qs->ec.function = "qe-init";  
7100            
7101        /* setup resource path */
7102        set_user_option(NULL);
7103    
7104      eb_init();      eb_init();
7105      charset_init();      charset_init();
7106      init_input_methods();      init_input_methods();
# Line 6909  void qe_init(void *opaque) Line 7109  void qe_init(void *opaque)
7109      /* init basic modules */      /* init basic modules */
7110      qe_register_mode(&text_mode);      qe_register_mode(&text_mode);
7111      qe_register_cmd_table(basic_commands, NULL);      qe_register_cmd_table(basic_commands, NULL);
7112        qe_register_cmd_line_options(cmd_options);
7113    
7114      register_completion("command", command_completion);      register_completion("command", command_completion);
7115      register_completion("charset", charset_completion);      register_completion("charset", charset_completion);
# Line 6919  void qe_init(void *opaque) Line 7120  void qe_init(void *opaque)
7120            
7121      minibuffer_init();      minibuffer_init();
7122      less_mode_init();      less_mode_init();
       
     qe_register_cmd_line_options(cmd_options);  
7123    
7124      /* init all external modules in link order */      /* init all external modules in link order */
7125      init_all_modules();      init_all_modules();
# Line 6962  void qe_init(void *opaque) Line 7161  void qe_init(void *opaque)
7161      dummy_dpy.dpy_init(&global_screen, screen_width, screen_height);      dummy_dpy.dpy_init(&global_screen, screen_width, screen_height);
7162    
7163      /* handle options */      /* handle options */
7164      optind = 1;      optind = parse_command_line(argc, argv);
     for (;;) {  
         const char *r, *optarg;  
         CmdOptionDef *p;  
   
         if (optind >= argc)  
             break;  
         r = argv[optind];  
         if (r[0] != '-')  
             break;  
         optind++;  
   
         p = first_cmd_options;  
         while (p != NULL) {  
             while (p->name != NULL) {  
                 if (!strcmp(p->name, r + 1)) {  
                     if (p->flags & CMD_OPT_ARG) {  
                         if (optind >= argc) {  
                             put_status(NULL,  
                                        "cmdline argument expected -- %s", r);  
                             goto next_cmd;  
                         }  
                         optarg = argv[optind++];  
                     } else {  
                         optarg = NULL;  
                     }  
                     if (p->flags & CMD_OPT_BOOL) {  
                         *p->u.int_ptr = 1;  
                     } else if (p->flags & CMD_OPT_STRING) {  
                         *p->u.string_ptr = optarg;  
                     } else if (p->flags & CMD_OPT_INT) {  
                         *p->u.int_ptr = atoi(optarg);  
                     } else if (p->flags & CMD_OPT_ARG) {  
                         p->u.func_arg(optarg);  
                     } else {  
                         p->u.func_noarg();  
                     }  
                     goto next_cmd;  
                 }  
                 p++;  
             }  
             p = p->u.next;  
         }  
         put_status(NULL, "unknown cmdline option -- %s", r);  
     next_cmd: ;  
     }  
7165    
7166      parse_config(s, NULL);      /* load config file unless command line option given */
7167        if (!no_init_file)
7168            parse_config(s, NULL);
7169    
7170      qe_key_init();      qe_key_init();
7171    
# Line 7033  void qe_init(void *opaque) Line 7189  void qe_init(void *opaque)
7189      /* load file(s) */      /* load file(s) */
7190      for (i = optind; i < argc; i++) {      for (i = optind; i < argc; i++) {
7191          do_load(s, argv[i]);          do_load(s, argv[i]);
7192            /* CG: handle +linenumber */
7193      }      }
7194            
7195    #ifndef CONFIG_TINY
7196      if (is_player && optind >= argc) {      if (is_player && optind >= argc) {
7197          /* if player, go to directory mode by default if no file selected */          /* if player, go to directory mode by default if no file selected */
7198          do_dired(s);          do_dired(s);
7199      }      }
7200    #endif
7201    
7202      put_status(s, "QEmacs %s - Press F1 for help", QE_VERSION);      put_status(s, "QEmacs %s - Press F1 for help", QE_VERSION);
7203    

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26