Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 1364) +++ trunk/src/Makefile.dep (revision 1365) @@ -283,6 +283,15 @@ mymem.h hid/gtk/../hidint.h ../src_3rd/genht/hash.h \ ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ ../src_3rd/genht/ht_inlines.h +hid_nogui.o: hid_nogui.c ../config.h ../config.manual.h ../config.auto.h \ + global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ + global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ + list_line.h ../src_3rd/genlist/gentdlist_impl.h \ + ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ + list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ + vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ + ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ + list_element.h libpcb_fp.h hid_resource.o: hid_resource.c global.h ../config.h ../config.manual.h \ ../config.auto.h const.h ../globalconst.h ../config.h macro.h \ global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ @@ -745,19 +754,9 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hidnogui.h \ - hid/common/../hidint.h compat.h error.h misc.h global.h \ - ../src_3rd/genvector/gds_char.h mymem.h portability.h pcb-printf.h \ - plugins.h hid/common/hidlist.h -hidnogui.o: hid/common/hidnogui.c ../config.h ../config.manual.h \ - ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ - global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ - list_common.h list_line.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ - list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ - vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h + list_element.h libpcb_fp.h hid.h hid_nogui.h hid/common/../hidint.h \ + compat.h error.h misc.h global.h ../src_3rd/genvector/gds_char.h mymem.h \ + portability.h pcb-printf.h plugins.h hid/common/hidlist.h res_parse.o: res_parse.c ../config.h ../config.manual.h ../config.auto.h \ free_atexit.h global.h const.h ../globalconst.h ../config.h macro.h \ global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ @@ -918,8 +917,8 @@ ../src_3rd/genvector/gds_char.h mymem.h hid/gtk/ghid-coord-entry.h \ hid/gtk/ghid-main-menu.h hid/gtk/ghid-layer-selector.h \ hid/gtk/ghid-route-style-selector.h resource.h \ - hid/gtk/gui-pinout-preview.h hid/common/hidnogui.h hid_draw_helpers.h \ - pcb-printf.h dolists.h + hid/gtk/gui-pinout-preview.h hid_nogui.h hid_draw_helpers.h pcb-printf.h \ + dolists.h gui-command-window.o: hid/gtk/gui-command-window.c ../config.h \ ../config.manual.h ../config.auto.h hid/gtk/gui.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1195,7 +1194,7 @@ list_element.h libpcb_fp.h data.h global.h action_helper.h crosshair.h \ mymem.h misc.h ../src_3rd/genvector/gds_char.h mymem.h pcb-printf.h \ resource.h clip.h event.h error.h hid.h hid/lesstif/../hidint.h \ - hid/common/hidnogui.h hid_draw_helpers.h hid_resource.h resource.h \ + hid_nogui.h hid_draw_helpers.h hid_resource.h resource.h \ hid/lesstif/lesstif.h dolists.h menu.o: hid/lesstif/menu.c ../config.h ../config.manual.h \ ../config.auto.h hid/lesstif/xincludes.h global.h const.h \ @@ -1248,7 +1247,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h hid.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h hid/batch/../hidint.h \ - pcb-printf.h hid_draw_helpers.h hid/common/hidnogui.h actions.h \ + pcb-printf.h hid_draw_helpers.h hid_nogui.h actions.h \ hid/common/hidinit.h dolists.h ../src_plugins/autoplace/autoplace.o: \ ../src_plugins/autoplace/autoplace.c ../config.h ../config.manual.h \ @@ -1448,7 +1447,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h error.h draw.h pcb-printf.h \ - plugins.h layer_helper.h hid.h hid/hidint.h hid/common/hidnogui.h \ + plugins.h layer_helper.h hid.h hid/hidint.h hid_nogui.h \ hid_draw_helpers.h ../src_plugins/export_ps/ps.h print.h \ hid/common/hidinit.h dolists.h ../src_plugins/export_ps/eps.o: ../src_plugins/export_ps/eps.c \ @@ -1462,7 +1461,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h pcb-printf.h hid.h hid/hidint.h \ - hid/common/hidnogui.h hid_draw_helpers.h ../src_plugins/export_ps/ps.h \ + hid_nogui.h hid_draw_helpers.h ../src_plugins/export_ps/ps.h \ hid/common/hidinit.h ../src_plugins/export_lpr/lpr.o: ../src_plugins/export_lpr/lpr.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ @@ -1475,7 +1474,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h plugins.h hid.h hid/hidint.h \ - ../src_plugins/export_lpr/../export_ps/ps.h hid/common/hidnogui.h \ + ../src_plugins/export_lpr/../export_ps/ps.h hid_nogui.h \ hid/common/hidinit.h ../src_plugins/export_gcode/gcode.o: ../src_plugins/export_gcode/gcode.c \ ../config.h ../config.manual.h ../config.auto.h plugins.h global.h \ @@ -1488,7 +1487,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h error.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h rats.h layer_helper.h hid.h \ - hid/gtk/../hidint.h hid/common/hidnogui.h hid_draw_helpers.h \ + hid/gtk/../hidint.h hid_nogui.h hid_draw_helpers.h \ ../src_plugins/export_gcode/gcode.h ../src_plugins/export_gcode/bitmap.h \ ../src_plugins/export_gcode/potracelib.h \ ../src_plugins/export_gcode/curve.h \ @@ -1533,7 +1532,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h error.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h rats.h plugins.h layer_helper.h \ - hid.h hid/gtk/../hidint.h hid/common/hidnogui.h hid_draw_helpers.h \ + hid.h hid/gtk/../hidint.h hid_nogui.h hid_draw_helpers.h \ hid/common/hidinit.h dolists.h ../src_plugins/export_png/png.o: ../src_plugins/export_png/png.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ @@ -1546,7 +1545,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h global.h error.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h plugins.h hid.h \ - hid/gtk/../hidint.h hid/common/hidnogui.h hid_draw_helpers.h \ + hid/gtk/../hidint.h hid_nogui.h hid_draw_helpers.h \ ../src_plugins/export_png/png.h hid/common/hidinit.h dolists.h ../src_plugins/export_bom/bom.o: ../src_plugins/export_bom/bom.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ @@ -1559,7 +1558,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h global.h error.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h pcb-printf.h plugins.h hid.h \ - hid/common/hidnogui.h hid/gtk/../hidint.h + hid_nogui.h hid/gtk/../hidint.h ../src_plugins/toporouter/toporouter.o: \ ../src_plugins/toporouter/toporouter.c \ ../src_plugins/toporouter/toporouter.h data.h global.h ../config.h \ Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 1364) +++ trunk/src/Makefile.in (revision 1365) @@ -39,6 +39,7 @@ hid_draw_helpers.o hid_extents.o hid_flags.o + hid_nogui.o hid_resource.o insert.o intersect.o @@ -90,7 +91,6 @@ undo_act.o vtonpoint.o hid/common/hidinit.o - hid/common/hidnogui.o res_parse.o res_lex.o portability.o Index: trunk/src/hid/batch/batch.c =================================================================== --- trunk/src/hid/batch/batch.c (revision 1364) +++ trunk/src/hid/batch/batch.c (revision 1365) @@ -17,7 +17,7 @@ #include "pcb-printf.h" #include "hid_draw_helpers.h" -#include "hid/common/hidnogui.h" +#include "hid_nogui.h" #include "actions.h" #include "hid/common/hidinit.h" Index: trunk/src/hid/common/hidnogui.c =================================================================== --- trunk/src/hid/common/hidnogui.c (revision 1364) +++ trunk/src/hid/common/hidnogui.c (nonexistent) @@ -1,460 +0,0 @@ -/* $Id$ */ - -#include "config.h" - -#include -#include -#include -#include - -#include "global.h" -#include "hid.h" - - -RCSID("$Id$"); - -/* This is the "gui" that is installed at startup, and is used when - there is no other real GUI to use. For the most part, it just - stops the application from (1) crashing randomly, and (2) doing - gui-specific things when it shouldn't. */ - -#define CRASH fprintf(stderr, "HID error: pcb called GUI function %s without having a GUI available.\n", __FUNCTION__); abort() - -typedef struct hid_gc_struct { - int nothing_interesting_here; -} hid_gc_struct; - -static HID_Attribute *nogui_get_export_options(int *n_ret) -{ - CRASH; - return 0; -} - -static void nogui_do_export(HID_Attr_Val * options) -{ - CRASH; -} - -static void nogui_parse_arguments(int *argc, char ***argv) -{ - CRASH; -} - -static void nogui_invalidate_lr(int l, int r, int t, int b) -{ - CRASH; -} - -static void nogui_invalidate_all(void) -{ - CRASH; -} - -static int nogui_set_layer(const char *name, int idx, int empty) -{ - CRASH; - return 0; -} - -static void nogui_end_layer(void) -{ -} - -static hidGC nogui_make_gc(void) -{ - return 0; -} - -static void nogui_destroy_gc(hidGC gc) -{ -} - -static void nogui_use_mask(int use_it) -{ - CRASH; -} - -static void nogui_set_color(hidGC gc, const char *name) -{ - CRASH; -} - -static void nogui_set_line_cap(hidGC gc, EndCapStyle style) -{ - CRASH; -} - -static void nogui_set_line_width(hidGC gc, Coord width) -{ - CRASH; -} - -static void nogui_set_draw_xor(hidGC gc, int xor_) -{ - CRASH; -} - -static void nogui_set_draw_faded(hidGC gc, int faded) -{ -} - -static void nogui_draw_line(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) -{ - CRASH; -} - -static void nogui_draw_arc(hidGC gc, Coord cx, Coord cy, Coord width, Coord height, Angle start_angle, Angle end_angle) -{ - CRASH; -} - -static void nogui_draw_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) -{ - CRASH; -} - -static void nogui_fill_circle(hidGC gc, Coord cx, Coord cy, Coord radius) -{ - CRASH; -} - -static void nogui_fill_polygon(hidGC gc, int n_coords, Coord * x, Coord * y) -{ - CRASH; -} - -static void nogui_fill_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box) -{ - CRASH; -} - -static void nogui_fill_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) -{ - CRASH; -} - -static void nogui_thindraw_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) -{ - CRASH; -} - -static void nogui_fill_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pad, bool drawHole, bool mask) -{ - CRASH; -} - -static void nogui_thindraw_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pad, bool drawHole, bool mask) -{ - CRASH; -} - -static void nogui_fill_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) -{ - CRASH; -} - -static void nogui_calibrate(double xval, double yval) -{ - CRASH; -} - -static int nogui_shift_is_pressed(void) -{ - /* This is called from FitCrosshairIntoGrid() when the board is loaded. */ - return 0; -} - -static int nogui_control_is_pressed(void) -{ - CRASH; - return 0; -} - -static int nogui_mod1_is_pressed(void) -{ - CRASH; - return 0; -} - -static void nogui_get_coords(const char *msg, Coord * x, Coord * y) -{ - CRASH; -} - -static void nogui_set_crosshair(int x, int y, int action) -{ -} - -static hidval nogui_add_timer(void (*func) (hidval user_data), unsigned long milliseconds, hidval user_data) -{ - hidval rv; - CRASH; - rv.lval = 0; - return rv; -} - -static void nogui_stop_timer(hidval timer) -{ - CRASH; -} - -static hidval -nogui_watch_file(int fd, unsigned int condition, void (*func) (hidval watch, int fd, unsigned int condition, hidval user_data), - hidval user_data) -{ - hidval rv; - CRASH; - rv.lval = 0; - return rv; -} - -static void nogui_unwatch_file(hidval watch) -{ - CRASH; -} - -static hidval nogui_add_block_hook(void (*func) (hidval data), hidval data) -{ - hidval rv; - CRASH; - rv.ptr = NULL; - return rv; -} - -static void nogui_stop_block_hook(hidval block_hook) -{ - CRASH; -} - -static void nogui_log(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vprintf(fmt, ap); - va_end(ap); -} - -static void nogui_logv(const char *fmt, va_list ap) -{ - vprintf(fmt, ap); -} - -/* Return a line of user input text, stripped of any newline characters. - * Returns NULL if the user simply presses enter, or otherwise gives no input. - */ -#define MAX_LINE_LENGTH 1024 -static char *read_stdin_line(void) -{ - static char buf[MAX_LINE_LENGTH]; - char *s; - int i; - - s = fgets(buf, MAX_LINE_LENGTH, stdin); - if (s == NULL) { - printf("\n"); - return NULL; - } - - /* Strip any trailing newline characters */ - for (i = strlen(s) - 1; i >= 0; i--) - if (s[i] == '\r' || s[i] == '\n') - s[i] = '\0'; - - if (s[0] == '\0') - return NULL; - - return strdup(s); -} - -#undef MAX_LINE_LENGTH - -static int nogui_confirm_dialog(const char *msg, ...) -{ - char *answer; - int ret = 0; - bool valid_answer = false; - va_list args; - - do { - va_start(args, msg); - vprintf(msg, args); - va_end(args); - - printf(" ? 0=cancel 1 = ok : "); - - answer = read_stdin_line(); - - if (answer == NULL) - continue; - - if (answer[0] == '0' && answer[1] == '\0') { - ret = 0; - valid_answer = true; - } - - if (answer[0] == '1' && answer[1] == '\0') { - ret = 1; - valid_answer = true; - } - - free(answer); - } - while (!valid_answer); - return ret; -} - -static int nogui_close_confirm_dialog() -{ - return nogui_confirm_dialog(_("OK to lose data ?"), NULL); -} - -static void nogui_report_dialog(const char *title, const char *msg) -{ - printf("--- %s ---\n%s\n", title, msg); -} - -static char *nogui_prompt_for(const char *msg, const char *default_string) -{ - char *answer; - - if (default_string) - printf("%s [%s] : ", msg, default_string); - else - printf("%s : ", msg); - - answer = read_stdin_line(); - if (answer == NULL) - return strdup((default_string != NULL) ? default_string : ""); - else - return strdup(answer); -} - -/* FIXME - this could use some enhancement to actually use the other - args */ -static char *nogui_fileselect(const char *title, const char *descr, - char *default_file, char *default_ext, const char *history_tag, int flags) -{ - char *answer; - - if (default_file) - printf("%s [%s] : ", title, default_file); - else - printf("%s : ", title); - - answer = read_stdin_line(); - if (answer == NULL) - return (default_file != NULL) ? strdup(default_file) : NULL; - else - return strdup(answer); -} - -static int -nogui_attribute_dialog(HID_Attribute * attrs, int n_attrs, HID_Attr_Val * results, const char *title, const char *descr) -{ - CRASH; -} - -static void nogui_show_item(void *item) -{ - CRASH; -} - -static void nogui_beep(void) -{ - putchar(7); - fflush(stdout); -} - -static int nogui_progress(int so_far, int total, const char *message) -{ - return 0; -} - -static HID *nogui_request_debug_draw(void) -{ - return NULL; -} - -static void nogui_flush_debug_draw(void) -{ -} - -static void nogui_finish_debug_draw(void) -{ -} - -static void nogui_create_menu(const char *menu[], const char *action, const char *mnemonic, const char *accel, const char *tip) -{ -} - -void common_nogui_init(HID * hid) -{ - hid->get_export_options = nogui_get_export_options; - hid->do_export = nogui_do_export; - hid->parse_arguments = nogui_parse_arguments; - hid->invalidate_lr = nogui_invalidate_lr; - hid->invalidate_all = nogui_invalidate_all; - hid->set_layer = nogui_set_layer; - hid->end_layer = nogui_end_layer; - hid->make_gc = nogui_make_gc; - hid->destroy_gc = nogui_destroy_gc; - hid->use_mask = nogui_use_mask; - hid->set_color = nogui_set_color; - hid->set_line_cap = nogui_set_line_cap; - hid->set_line_width = nogui_set_line_width; - hid->set_draw_xor = nogui_set_draw_xor; - hid->set_draw_faded = nogui_set_draw_faded; - hid->draw_line = nogui_draw_line; - hid->draw_arc = nogui_draw_arc; - hid->draw_rect = nogui_draw_rect; - hid->fill_circle = nogui_fill_circle; - hid->fill_polygon = nogui_fill_polygon; - hid->fill_pcb_polygon = nogui_fill_pcb_polygon; - hid->fill_pcb_pad = nogui_fill_pcb_pad; - hid->thindraw_pcb_pad = nogui_thindraw_pcb_pad; - hid->fill_pcb_pv = nogui_fill_pcb_pv; - hid->thindraw_pcb_pv = nogui_thindraw_pcb_pv; - hid->fill_rect = nogui_fill_rect; - hid->calibrate = nogui_calibrate; - hid->shift_is_pressed = nogui_shift_is_pressed; - hid->control_is_pressed = nogui_control_is_pressed; - hid->mod1_is_pressed = nogui_mod1_is_pressed; - hid->get_coords = nogui_get_coords; - hid->set_crosshair = nogui_set_crosshair; - hid->add_timer = nogui_add_timer; - hid->stop_timer = nogui_stop_timer; - hid->watch_file = nogui_watch_file; - hid->unwatch_file = nogui_unwatch_file; - hid->add_block_hook = nogui_add_block_hook; - hid->stop_block_hook = nogui_stop_block_hook; - hid->log = nogui_log; - hid->logv = nogui_logv; - hid->confirm_dialog = nogui_confirm_dialog; - hid->close_confirm_dialog = nogui_close_confirm_dialog; - hid->report_dialog = nogui_report_dialog; - hid->prompt_for = nogui_prompt_for; - hid->fileselect = nogui_fileselect; - hid->attribute_dialog = nogui_attribute_dialog; - hid->show_item = nogui_show_item; - hid->beep = nogui_beep; - hid->progress = nogui_progress; - hid->request_debug_draw = nogui_request_debug_draw; - hid->flush_debug_draw = nogui_flush_debug_draw; - hid->finish_debug_draw = nogui_finish_debug_draw; - hid->create_menu = nogui_create_menu; -} - -static HID nogui_hid; - -HID *hid_nogui_get_hid(void) -{ - memset(&nogui_hid, 0, sizeof(HID)); - - nogui_hid.struct_size = sizeof(HID); - nogui_hid.name = "nogui"; - nogui_hid.description = "Default GUI when no other GUI is present. " "Does nothing."; - - common_nogui_init(&nogui_hid); - - return &nogui_hid; -} Index: trunk/src/hid/common/hidnogui.h =================================================================== --- trunk/src/hid/common/hidnogui.h (revision 1364) +++ trunk/src/hid/common/hidnogui.h (nonexistent) @@ -1,7 +0,0 @@ -#ifndef PCB_HID_COMMON_HIDNOGUI_H -#define PCB_HID_COMMON_HIDNOGUI_H - -void common_nogui_init(HID * hid); -HID *hid_nogui_get_hid(void); - -#endif Index: trunk/src/hid/common/hidinit.c =================================================================== --- trunk/src/hid/common/hidinit.c (revision 1364) +++ trunk/src/hid/common/hidinit.c (revision 1365) @@ -21,7 +21,7 @@ #include "global.h" #include "hid.h" -#include "hidnogui.h" +#include "hid_nogui.h" #include "../hidint.h" /* for dlopen() and friends on windows */ Index: trunk/src/hid/gtk/gtkhid-main.c =================================================================== --- trunk/src/hid/gtk/gtkhid-main.c (revision 1364) +++ trunk/src/hid/gtk/gtkhid-main.c (revision 1365) @@ -17,7 +17,7 @@ #include "error.h" #include "../hidint.h" #include "gui.h" -#include "hid/common/hidnogui.h" +#include "hid_nogui.h" #include "hid_draw_helpers.h" #include "pcb-printf.h" Index: trunk/src/hid/lesstif/main.c =================================================================== --- trunk/src/hid/lesstif/main.c (revision 1364) +++ trunk/src/hid/lesstif/main.c (revision 1365) @@ -29,7 +29,7 @@ #include "hid.h" #include "../hidint.h" -#include "hid/common/hidnogui.h" +#include "hid_nogui.h" #include "hid_draw_helpers.h" #include "hid_resource.h" #include "lesstif.h" Index: trunk/src/hid_nogui.c =================================================================== --- trunk/src/hid_nogui.c (nonexistent) +++ trunk/src/hid_nogui.c (revision 1365) @@ -0,0 +1,460 @@ +/* $Id$ */ + +#include "config.h" + +#include +#include +#include +#include + +#include "global.h" +#include "hid.h" + + +RCSID("$Id$"); + +/* This is the "gui" that is installed at startup, and is used when + there is no other real GUI to use. For the most part, it just + stops the application from (1) crashing randomly, and (2) doing + gui-specific things when it shouldn't. */ + +#define CRASH fprintf(stderr, "HID error: pcb called GUI function %s without having a GUI available.\n", __FUNCTION__); abort() + +typedef struct hid_gc_struct { + int nothing_interesting_here; +} hid_gc_struct; + +static HID_Attribute *nogui_get_export_options(int *n_ret) +{ + CRASH; + return 0; +} + +static void nogui_do_export(HID_Attr_Val * options) +{ + CRASH; +} + +static void nogui_parse_arguments(int *argc, char ***argv) +{ + CRASH; +} + +static void nogui_invalidate_lr(int l, int r, int t, int b) +{ + CRASH; +} + +static void nogui_invalidate_all(void) +{ + CRASH; +} + +static int nogui_set_layer(const char *name, int idx, int empty) +{ + CRASH; + return 0; +} + +static void nogui_end_layer(void) +{ +} + +static hidGC nogui_make_gc(void) +{ + return 0; +} + +static void nogui_destroy_gc(hidGC gc) +{ +} + +static void nogui_use_mask(int use_it) +{ + CRASH; +} + +static void nogui_set_color(hidGC gc, const char *name) +{ + CRASH; +} + +static void nogui_set_line_cap(hidGC gc, EndCapStyle style) +{ + CRASH; +} + +static void nogui_set_line_width(hidGC gc, Coord width) +{ + CRASH; +} + +static void nogui_set_draw_xor(hidGC gc, int xor_) +{ + CRASH; +} + +static void nogui_set_draw_faded(hidGC gc, int faded) +{ +} + +static void nogui_draw_line(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +{ + CRASH; +} + +static void nogui_draw_arc(hidGC gc, Coord cx, Coord cy, Coord width, Coord height, Angle start_angle, Angle end_angle) +{ + CRASH; +} + +static void nogui_draw_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +{ + CRASH; +} + +static void nogui_fill_circle(hidGC gc, Coord cx, Coord cy, Coord radius) +{ + CRASH; +} + +static void nogui_fill_polygon(hidGC gc, int n_coords, Coord * x, Coord * y) +{ + CRASH; +} + +static void nogui_fill_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box) +{ + CRASH; +} + +static void nogui_fill_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) +{ + CRASH; +} + +static void nogui_thindraw_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) +{ + CRASH; +} + +static void nogui_fill_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pad, bool drawHole, bool mask) +{ + CRASH; +} + +static void nogui_thindraw_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pad, bool drawHole, bool mask) +{ + CRASH; +} + +static void nogui_fill_rect(hidGC gc, Coord x1, Coord y1, Coord x2, Coord y2) +{ + CRASH; +} + +static void nogui_calibrate(double xval, double yval) +{ + CRASH; +} + +static int nogui_shift_is_pressed(void) +{ + /* This is called from FitCrosshairIntoGrid() when the board is loaded. */ + return 0; +} + +static int nogui_control_is_pressed(void) +{ + CRASH; + return 0; +} + +static int nogui_mod1_is_pressed(void) +{ + CRASH; + return 0; +} + +static void nogui_get_coords(const char *msg, Coord * x, Coord * y) +{ + CRASH; +} + +static void nogui_set_crosshair(int x, int y, int action) +{ +} + +static hidval nogui_add_timer(void (*func) (hidval user_data), unsigned long milliseconds, hidval user_data) +{ + hidval rv; + CRASH; + rv.lval = 0; + return rv; +} + +static void nogui_stop_timer(hidval timer) +{ + CRASH; +} + +static hidval +nogui_watch_file(int fd, unsigned int condition, void (*func) (hidval watch, int fd, unsigned int condition, hidval user_data), + hidval user_data) +{ + hidval rv; + CRASH; + rv.lval = 0; + return rv; +} + +static void nogui_unwatch_file(hidval watch) +{ + CRASH; +} + +static hidval nogui_add_block_hook(void (*func) (hidval data), hidval data) +{ + hidval rv; + CRASH; + rv.ptr = NULL; + return rv; +} + +static void nogui_stop_block_hook(hidval block_hook) +{ + CRASH; +} + +static void nogui_log(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); +} + +static void nogui_logv(const char *fmt, va_list ap) +{ + vprintf(fmt, ap); +} + +/* Return a line of user input text, stripped of any newline characters. + * Returns NULL if the user simply presses enter, or otherwise gives no input. + */ +#define MAX_LINE_LENGTH 1024 +static char *read_stdin_line(void) +{ + static char buf[MAX_LINE_LENGTH]; + char *s; + int i; + + s = fgets(buf, MAX_LINE_LENGTH, stdin); + if (s == NULL) { + printf("\n"); + return NULL; + } + + /* Strip any trailing newline characters */ + for (i = strlen(s) - 1; i >= 0; i--) + if (s[i] == '\r' || s[i] == '\n') + s[i] = '\0'; + + if (s[0] == '\0') + return NULL; + + return strdup(s); +} + +#undef MAX_LINE_LENGTH + +static int nogui_confirm_dialog(const char *msg, ...) +{ + char *answer; + int ret = 0; + bool valid_answer = false; + va_list args; + + do { + va_start(args, msg); + vprintf(msg, args); + va_end(args); + + printf(" ? 0=cancel 1 = ok : "); + + answer = read_stdin_line(); + + if (answer == NULL) + continue; + + if (answer[0] == '0' && answer[1] == '\0') { + ret = 0; + valid_answer = true; + } + + if (answer[0] == '1' && answer[1] == '\0') { + ret = 1; + valid_answer = true; + } + + free(answer); + } + while (!valid_answer); + return ret; +} + +static int nogui_close_confirm_dialog() +{ + return nogui_confirm_dialog(_("OK to lose data ?"), NULL); +} + +static void nogui_report_dialog(const char *title, const char *msg) +{ + printf("--- %s ---\n%s\n", title, msg); +} + +static char *nogui_prompt_for(const char *msg, const char *default_string) +{ + char *answer; + + if (default_string) + printf("%s [%s] : ", msg, default_string); + else + printf("%s : ", msg); + + answer = read_stdin_line(); + if (answer == NULL) + return strdup((default_string != NULL) ? default_string : ""); + else + return strdup(answer); +} + +/* FIXME - this could use some enhancement to actually use the other + args */ +static char *nogui_fileselect(const char *title, const char *descr, + char *default_file, char *default_ext, const char *history_tag, int flags) +{ + char *answer; + + if (default_file) + printf("%s [%s] : ", title, default_file); + else + printf("%s : ", title); + + answer = read_stdin_line(); + if (answer == NULL) + return (default_file != NULL) ? strdup(default_file) : NULL; + else + return strdup(answer); +} + +static int +nogui_attribute_dialog(HID_Attribute * attrs, int n_attrs, HID_Attr_Val * results, const char *title, const char *descr) +{ + CRASH; +} + +static void nogui_show_item(void *item) +{ + CRASH; +} + +static void nogui_beep(void) +{ + putchar(7); + fflush(stdout); +} + +static int nogui_progress(int so_far, int total, const char *message) +{ + return 0; +} + +static HID *nogui_request_debug_draw(void) +{ + return NULL; +} + +static void nogui_flush_debug_draw(void) +{ +} + +static void nogui_finish_debug_draw(void) +{ +} + +static void nogui_create_menu(const char *menu[], const char *action, const char *mnemonic, const char *accel, const char *tip) +{ +} + +void common_nogui_init(HID * hid) +{ + hid->get_export_options = nogui_get_export_options; + hid->do_export = nogui_do_export; + hid->parse_arguments = nogui_parse_arguments; + hid->invalidate_lr = nogui_invalidate_lr; + hid->invalidate_all = nogui_invalidate_all; + hid->set_layer = nogui_set_layer; + hid->end_layer = nogui_end_layer; + hid->make_gc = nogui_make_gc; + hid->destroy_gc = nogui_destroy_gc; + hid->use_mask = nogui_use_mask; + hid->set_color = nogui_set_color; + hid->set_line_cap = nogui_set_line_cap; + hid->set_line_width = nogui_set_line_width; + hid->set_draw_xor = nogui_set_draw_xor; + hid->set_draw_faded = nogui_set_draw_faded; + hid->draw_line = nogui_draw_line; + hid->draw_arc = nogui_draw_arc; + hid->draw_rect = nogui_draw_rect; + hid->fill_circle = nogui_fill_circle; + hid->fill_polygon = nogui_fill_polygon; + hid->fill_pcb_polygon = nogui_fill_pcb_polygon; + hid->fill_pcb_pad = nogui_fill_pcb_pad; + hid->thindraw_pcb_pad = nogui_thindraw_pcb_pad; + hid->fill_pcb_pv = nogui_fill_pcb_pv; + hid->thindraw_pcb_pv = nogui_thindraw_pcb_pv; + hid->fill_rect = nogui_fill_rect; + hid->calibrate = nogui_calibrate; + hid->shift_is_pressed = nogui_shift_is_pressed; + hid->control_is_pressed = nogui_control_is_pressed; + hid->mod1_is_pressed = nogui_mod1_is_pressed; + hid->get_coords = nogui_get_coords; + hid->set_crosshair = nogui_set_crosshair; + hid->add_timer = nogui_add_timer; + hid->stop_timer = nogui_stop_timer; + hid->watch_file = nogui_watch_file; + hid->unwatch_file = nogui_unwatch_file; + hid->add_block_hook = nogui_add_block_hook; + hid->stop_block_hook = nogui_stop_block_hook; + hid->log = nogui_log; + hid->logv = nogui_logv; + hid->confirm_dialog = nogui_confirm_dialog; + hid->close_confirm_dialog = nogui_close_confirm_dialog; + hid->report_dialog = nogui_report_dialog; + hid->prompt_for = nogui_prompt_for; + hid->fileselect = nogui_fileselect; + hid->attribute_dialog = nogui_attribute_dialog; + hid->show_item = nogui_show_item; + hid->beep = nogui_beep; + hid->progress = nogui_progress; + hid->request_debug_draw = nogui_request_debug_draw; + hid->flush_debug_draw = nogui_flush_debug_draw; + hid->finish_debug_draw = nogui_finish_debug_draw; + hid->create_menu = nogui_create_menu; +} + +static HID nogui_hid; + +HID *hid_nogui_get_hid(void) +{ + memset(&nogui_hid, 0, sizeof(HID)); + + nogui_hid.struct_size = sizeof(HID); + nogui_hid.name = "nogui"; + nogui_hid.description = "Default GUI when no other GUI is present. " "Does nothing."; + + common_nogui_init(&nogui_hid); + + return &nogui_hid; +} Index: trunk/src/hid_nogui.h =================================================================== --- trunk/src/hid_nogui.h (nonexistent) +++ trunk/src/hid_nogui.h (revision 1365) @@ -0,0 +1,7 @@ +#ifndef PCB_HID_COMMON_HIDNOGUI_H +#define PCB_HID_COMMON_HIDNOGUI_H + +void common_nogui_init(HID * hid); +HID *hid_nogui_get_hid(void); + +#endif Index: trunk/src_plugins/export_bom/bom.c =================================================================== --- trunk/src_plugins/export_bom/bom.c (revision 1364) +++ trunk/src_plugins/export_bom/bom.c (revision 1365) @@ -16,7 +16,7 @@ #include "plugins.h" #include "hid.h" -#include "hid/common/hidnogui.h" +#include "hid_nogui.h" #include "../hidint.h" Index: trunk/src_plugins/export_gcode/gcode.c =================================================================== --- trunk/src_plugins/export_gcode/gcode.c (revision 1364) +++ trunk/src_plugins/export_gcode/gcode.c (revision 1365) @@ -53,7 +53,7 @@ #include "hid.h" #include "../hidint.h" #include -#include "hid/common/hidnogui.h" +#include "hid_nogui.h" #include "hid_draw_helpers.h" #include "gcode.h" #include "bitmap.h" Index: trunk/src_plugins/export_gerber/gerber.c =================================================================== --- trunk/src_plugins/export_gerber/gerber.c (revision 1364) +++ trunk/src_plugins/export_gerber/gerber.c (revision 1365) @@ -30,7 +30,7 @@ #include "hid.h" #include "../hidint.h" -#include "hid/common/hidnogui.h" +#include "hid_nogui.h" #include "hid_draw_helpers.h" #include "hid/common/hidinit.h" Index: trunk/src_plugins/export_lpr/lpr.c =================================================================== --- trunk/src_plugins/export_lpr/lpr.c (revision 1364) +++ trunk/src_plugins/export_lpr/lpr.c (revision 1365) @@ -16,7 +16,7 @@ #include "hid.h" #include "hid/hidint.h" #include "../export_ps/ps.h" -#include "hid/common/hidnogui.h" +#include "hid_nogui.h" #include "hid/common/hidinit.h" Index: trunk/src_plugins/export_nelma/nelma.c =================================================================== --- trunk/src_plugins/export_nelma/nelma.c (revision 1364) +++ trunk/src_plugins/export_nelma/nelma.c (revision 1365) @@ -71,7 +71,7 @@ #include "hid.h" #include "../hidint.h" -#include "hid/common/hidnogui.h" +#include "hid_nogui.h" #include "hid_draw_helpers.h" #include Index: trunk/src_plugins/export_png/png.c =================================================================== --- trunk/src_plugins/export_png/png.c (revision 1364) +++ trunk/src_plugins/export_png/png.c (revision 1365) @@ -41,7 +41,7 @@ #include "hid.h" #include "../hidint.h" -#include "hid/common/hidnogui.h" +#include "hid_nogui.h" #include "hid_draw_helpers.h" #include "png.h" Index: trunk/src_plugins/export_ps/eps.c =================================================================== --- trunk/src_plugins/export_ps/eps.c (revision 1364) +++ trunk/src_plugins/export_ps/eps.c (revision 1365) @@ -15,7 +15,7 @@ #include "hid.h" #include "hid/hidint.h" -#include "hid/common/hidnogui.h" +#include "hid_nogui.h" #include "hid_draw_helpers.h" #include "ps.h" #include "hid/common/hidinit.h" Index: trunk/src_plugins/export_ps/ps.c =================================================================== --- trunk/src_plugins/export_ps/ps.c (revision 1364) +++ trunk/src_plugins/export_ps/ps.c (revision 1365) @@ -20,7 +20,7 @@ #include "hid.h" #include "hid/hidint.h" -#include "hid/common/hidnogui.h" +#include "hid_nogui.h" #include "hid_draw_helpers.h" #include "ps.h" #include "print.h" Index: trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/hid/hid.c =================================================================== --- trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/hid/hid.c (revision 1364) +++ trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/hid/hid.c (revision 1365) @@ -5,7 +5,7 @@ #include "src/global.h" #include "src/error.h" #include "src/hid.h" -#include "src/hid/common/hidnogui.h" +#include "src/hid_nogui.h" #include "src/hid/hidint.h" #include "src/pcb-printf.h" #define FROM_PKG