Exemplo n.º 1
0
/*------------------------------------------------------------------
 * This initializes the vars in pr_current.
 *------------------------------------------------------------------*/
void i_vars_set(TOPLEVEL * pr_current)
{
  i_vars_libgeda_set(pr_current);

  pr_current->paper_width = default_paper_width;
  pr_current->paper_height = default_paper_height;
}
Exemplo n.º 2
0
/*! \brief Initialise variables in the TOPLEVEL
 *
 * Initialize the variables in toplevel. In practice, this is only
 * the paper size for the sheet.
 * \param toplevel pointer to the TOPLEVEL to set paper size in.
 */
void i_vars_set (TOPLEVEL *toplevel)
{
  i_vars_libgeda_set (toplevel);

  toplevel->paper_width = default_paper_width;
  toplevel->paper_height = default_paper_height;
}
Exemplo n.º 3
0
void ruby_toplevel_init(void)
{
    VALUE argv0;
    argv0 = rb_gv_get("$0");

    toplevel = s_toplevel_new();

    g_rc_parse(toplevel, StringValueCStr(argv0), "grubyrc", NULL);
    i_vars_libgeda_set(toplevel);
}
Exemplo n.º 4
0
static void
cmd_export_impl (void *data, int argc, char **argv)
{
  int i;
  GError *err = NULL;
  gchar *tmp;
  const gchar *out_suffix;
  struct ExportFormat *exporter = NULL;
  GArray *render_color_map = NULL;
  gchar *original_cwd = g_get_current_dir ();

  gtk_init_check (&argc, &argv);
  scm_init_guile ();
  libgeda_init ();
  scm_dynwind_begin (0);
  toplevel = s_toplevel_new ();
  edascm_dynwind_toplevel (toplevel);

  /* Now load rc files, if necessary */
  if (getenv ("GAF_INHIBIT_RCFILES") == NULL) {
    g_rc_parse (toplevel, "gaf export", NULL, NULL);
  }
  i_vars_libgeda_set (toplevel); /* Ugh */

  /* Parse configuration files */
  export_config ();

  /* Parse command-line arguments */
  export_command_line (argc, argv);

  /* If no format was specified, try and guess from output
   * filename. */
  if (settings.format == NULL) {
    out_suffix = strrchr (settings.outfile, '.');
    if (out_suffix != NULL) {
      out_suffix++; /* Skip '.' */
    } else {
      fprintf (stderr,
               _("ERROR: Cannot infer output format from filename '%s'.\n"),
               settings.outfile);
      exit (1);
    }
  }

  /* Try and find an exporter function */
  tmp = g_utf8_strdown ((settings.format == NULL) ? out_suffix : settings.format, -1);
  for (i = 0; formats[i].name != NULL; i++) {
    if (strcmp (tmp, formats[i].alias) == 0) {
      exporter = &formats[i];
      break;
    }
  }
  if (exporter == NULL) {
    if (settings.format == NULL) {
      fprintf (stderr,
               _("ERROR: Cannot find supported format for filename '%s'.\n"),
               settings.outfile);
      exit (1);
    } else {
      fprintf (stderr,
               _("ERROR: Unsupported output format '%s'.\n"),
               settings.format);
      fprintf (stderr, see_help_msg);
      exit (1);
    }
  }
  g_free (tmp);

  /* If more than one schematic/symbol file was specified, check that
   * exporter supports multipage output. */
  if ((settings.infilec > 1) && !(exporter->flags & OUTPUT_MULTIPAGE)) {
    fprintf (stderr,
             _("ERROR: Selected output format does not support multipage output\n"));
    exit (1);
  }

  /* Load schematic files */
  while (optind < argc) {
    PAGE *page;
    tmp = argv[optind++];

    page = s_page_new (toplevel, tmp);
    if (!f_open (toplevel, page, tmp, &err)) {
      fprintf (stderr,
               _("ERROR: Failed to load '%s': %s\n"), tmp,
               err->message);
      exit (1);
    }
    if (g_chdir (original_cwd) != 0) {
      fprintf (stderr,
               _("ERROR: Failed to change directory to '%s': %s\n"),
               original_cwd, g_strerror (errno));
      exit (1);
    }
  }

  /* Create renderer */
  renderer = eda_renderer_new (NULL, NULL);
  if (settings.font != NULL) {
    g_object_set (renderer, "font-name", settings.font, NULL);
  }

  /* Make sure libgeda knows how to calculate the bounds of text
   * taking into account font etc. */
  o_text_set_rendered_bounds_func (toplevel,
                                   export_text_rendered_bounds,
                                   renderer);

  /* Create color map */
  render_color_map =
    g_array_sized_new (FALSE, FALSE, sizeof(GedaColor), MAX_COLORS);
  render_color_map =
    g_array_append_vals (render_color_map, print_colors, MAX_COLORS);
  if (!settings.color) {
    /* Create a black and white color map.  All non-background colors
     * are black. */
    GedaColor white = {~0, ~0, ~0, ~0, TRUE};
    GedaColor black = {0, 0, 0, ~0, TRUE};
    for (i = 0; i < MAX_COLORS; i++) {
      GedaColor *c = &g_array_index (render_color_map, GedaColor, i);
      if (!c->enabled) continue;

      if (c->a == 0) {
        c->enabled = FALSE;
        continue;
      }

      if (i == OUTPUT_BACKGROUND_COLOR) {
        *c = white;
      } else {
        *c = black;
      }
    }
  }
  eda_renderer_set_color_map (renderer, render_color_map);

  /* Render */
  exporter->func ();

  scm_dynwind_end ();
  exit (0);
}
Exemplo n.º 5
0
static void
shell_main (void *data, int argc, char **argv)
{
  SCM setup_lst = SCM_EOL; /* We reverse! this before using it. */
  SCM run_lst = SCM_EOL;   /* We reverse! this before using it. */
  int c;
  int interactive = 1;
  int inhibit_rc = 0;
  int status;
  TOPLEVEL *toplevel;

  #include "shell.x"

  /* Parse command-line arguments */
  opterr = 0;
  while ((c = getopt (argc, argv, GETOPT_OPTIONS)) != -1) {
    switch (c) {
    case 's':
      /* Construct an application of LOAD to the script name */
      run_lst = scm_cons (scm_list_2 (sym_load,
                                      scm_from_locale_string (optarg)),
                          run_lst);
      interactive = 0;
      goto endoptloop;
    case 'c':
      /* We need to evaluate an expression */
      run_lst = scm_cons (scm_list_2 (sym_eval_string,
                                  scm_from_locale_string (optarg)),
                          run_lst);
      interactive = 0;
      goto endoptloop;
    case 'L':
      /* Add argument to %load-path */
      setup_lst = scm_cons (scm_list_3 (sym_set_x,
                                        sym_load_path,
                                        scm_list_3 (sym_cons,
                                                    scm_from_locale_string (optarg),
                                                    sym_load_path)),
                            setup_lst);
      break;
    case 'l':
      /* Same as -s, pretty much */
      run_lst = scm_cons (scm_list_2 (sym_load,
                                      scm_from_locale_string (optarg)),
                          run_lst);
      break;
    case 'q':
      inhibit_rc = 1;
      break;
    case 'h':
      usage (0);
    case 'V':
      version();
    case '?':
      if ((optopt != ':') && (strchr (GETOPT_OPTIONS, optopt) != NULL)) {
        fprintf (stderr,
                 "ERROR: -%c option requires an argument.\n\n",
                 optopt);
        usage (1);
      } else if (isprint (optopt)) {
        fprintf (stderr, "ERROR: Unknown option -%c\n\n", optopt);
        usage (1);
      } else {
        fprintf (stderr,
                 "ERROR: Unknown option character `\\x%x'.\n\n",
                 optopt);
        usage (1);
      }
    default:
      g_assert_not_reached ();
    }
  }

 endoptloop:
  /* Set program arguments visible from Guile */
  scm_set_program_arguments (argc - optind, argv + optind, "geda-shell");

  /* If interactive mode, load readline and run top REPL. */
  if (interactive) {
    run_lst = scm_cons (scm_list_2 (sym_use_modules,
                                    scm_list_2 (sym_ice_9, sym_readline)),
                        run_lst);
    run_lst = scm_cons (scm_list_1 (sym_activate_readline), run_lst);
    run_lst = scm_cons (scm_list_1 (sym_top_repl), run_lst);

    /* Print GPL bumf if necessary */
    if (isatty (1) && isatty (0)) {

      printf (
"gEDA " PACKAGE_GIT_VERSION "\n"
"Copyright (C) 1998-2010 gEDA developers\n"
"This is free software, and you are welcome to redistribute it under\n"
"certain conditions. For details, see the file `COPYING', which is\n"
"included in the gEDA distribution.\n"
"There is NO WARRANTY, to the extent permitted by law.\n"
              );
    }

  } else {
    run_lst = scm_cons (scm_list_1 (sym_quit), run_lst);
  }

  /* Reverse lists */
  setup_lst = scm_reverse_x (setup_lst, SCM_UNDEFINED);
  run_lst = scm_reverse_x (run_lst, SCM_UNDEFINED);

  /* Initialise libgeda */
  libgeda_init ();
  scm_dynwind_begin (0);
  toplevel = s_toplevel_new ();
  edascm_dynwind_toplevel (toplevel);

  /* First run the setup list */
  if (setup_lst != SCM_EOL) {
    setup_lst = scm_cons (sym_begin, setup_lst);
    scm_eval_x (setup_lst, scm_current_module ());
  }

  /* Now load rc files, if necessary */
  if (!inhibit_rc)
    g_rc_parse (toplevel, argv[0], NULL, NULL);

  i_vars_libgeda_set (toplevel); /* Ugh */

  /* Finally evaluate run list */
  run_lst = scm_cons (sym_begin, run_lst);
  status = scm_exit_status (scm_eval_x (run_lst, scm_current_module ()));
  exit (status);

  scm_dynwind_end ();

  scm_remember_upto_here_2 (setup_lst, run_lst);
}
Exemplo n.º 6
0
void i_vars_set(TOPLEVEL * pr_current)
{ 
    i_vars_libgeda_set(pr_current);

    pr_current->force_boundingbox = default_force_boundingbox;
}
Exemplo n.º 7
0
/*! \brief Initialise variables in the TOPLEVEL
 *
 * Initialize the variables in toplevel.
 * \param toplevel pointer to the TOPLEVEL to set paper size in.
 */
void i_vars_set (TOPLEVEL *toplevel)
{
  i_vars_libgeda_set (toplevel);
}
Exemplo n.º 8
0
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
void i_vars_set(GSCHEM_TOPLEVEL *w_current)
{
    TOPLEVEL *toplevel = w_current->toplevel;
    i_vars_libgeda_set(toplevel);

    /* this will be false if logging cannot be enabled */
    if (do_logging != FALSE) {
        do_logging = default_do_logging;
    }

    logging_dest = default_logging_dest;

    w_current->text_size     = default_text_size;
    w_current->text_caps     = default_text_caps;

    toplevel->background_color = default_background_color;

    toplevel->net_style          = default_net_style;
    w_current->net_endpoint_mode  = default_net_endpoint_mode;
    w_current->net_midpoint_mode  = default_net_midpoint_mode;
    w_current->net_direction_mode = default_net_direction_mode;
    w_current->net_selection_mode = default_net_selection_mode;

    toplevel->override_net_color = default_override_net_color;

    toplevel->bus_style          = default_bus_style;
    toplevel->override_bus_color = default_override_bus_color;

    toplevel->pin_style          = default_pin_style;
    toplevel->override_pin_color = default_override_pin_color;

    toplevel->line_style         = default_line_style;

    w_current->zoom_with_pan           = default_zoom_with_pan;
    w_current->actionfeedback_mode     = default_actionfeedback_mode;
    w_current->text_display_zoomfactor = default_text_display_zoomfactor;
    w_current->text_feedback           = default_text_feedback;
    w_current->scrollbars_flag         = default_scrollbars_flag;

    toplevel->object_clipping = default_object_clipping;
    w_current->embed_complex   = default_embed_complex;
    w_current->include_complex = default_include_complex;
    w_current->snap_size       = default_snap_size;
    w_current->log_window      = default_log_window;
    w_current->log_window_type = default_log_window_type;

    INIT_STR(w_current, print_command, DEFAULT_PRINT_COMMAND);

    toplevel->print_output_type      = default_print_output_type;
    toplevel->print_output_capstyle  = default_print_output_capstyle;
    toplevel->print_orientation      = default_print_orientation;
    toplevel->print_color            = default_print_color;
    toplevel->print_color_background = default_print_color_background;
    toplevel->setpagedevice_orientation = default_setpagedevice_orientation;
    toplevel->setpagedevice_pagesize = default_setpagedevice_pagesize;

    toplevel->image_color        = default_image_color;
    w_current->image_width        = default_image_width;
    w_current->image_height       = default_image_height;
    w_current->third_button       = default_third_button;
    w_current->middle_button      = default_middle_button;
    w_current->scroll_wheel       = default_scroll_wheel;
    toplevel->net_consolidate    = default_net_consolidate;
    w_current->file_preview       = default_file_preview;
    w_current->enforce_hierarchy  = default_enforce_hierarchy;
    w_current->text_origin_marker = default_text_origin_marker;
    w_current->fast_mousepan      = default_fast_mousepan;
    w_current->raise_dialog_boxes = default_raise_dialog_boxes;
    w_current->continue_component_place = default_continue_component_place;
    w_current->component_select_attrlist = default_component_select_attrlist;
    w_current->undo_levels = default_undo_levels;
    w_current->undo_control = default_undo_control;
    w_current->undo_type = default_undo_type;
    w_current->undo_panzoom = default_undo_panzoom;

    w_current->draw_grips = default_draw_grips;
    w_current->netconn_rubberband = default_netconn_rubberband;
    w_current->magneticnet_mode = default_magnetic_net_mode;
    w_current->sort_component_library = default_sort_component_library;
    w_current->warp_cursor = default_warp_cursor;
    w_current->toolbars = default_toolbars;
    w_current->handleboxes = default_handleboxes;

    toplevel->paper_width  = default_paper_width;
    toplevel->paper_height = default_paper_height;

    w_current->bus_ripper_size  = default_bus_ripper_size;
    w_current->bus_ripper_type  = default_bus_ripper_type;
    w_current->bus_ripper_rotation  = default_bus_ripper_rotation;

    toplevel->force_boundingbox  = default_force_boundingbox;

    w_current->dots_grid_dot_size          = default_dots_grid_dot_size;
    w_current->dots_grid_mode              = default_dots_grid_mode;
    w_current->dots_grid_fixed_threshold   = default_dots_grid_fixed_threshold;
    w_current->mesh_grid_display_threshold = default_mesh_grid_display_threshold;

    w_current->add_attribute_offset  = default_add_attribute_offset;

    w_current->mousepan_gain = default_mousepan_gain;
    w_current->keyboardpan_gain = default_keyboardpan_gain;

    w_current->select_slack_pixels = default_select_slack_pixels;
    w_current->zoom_gain = default_zoom_gain;
    w_current->scrollpan_steps = default_scrollpan_steps;

    toplevel->auto_save_interval = default_auto_save_interval;
}