Index: trunk/doc-rnd/TODO =================================================================== --- trunk/doc-rnd/TODO (revision 1894) +++ trunk/doc-rnd/TODO (revision 1895) @@ -1,4 +1,5 @@ - replace settings with lihata (conf_*) + - chaneg ha:view to li:view in the conf -> segfault - menu lht updates: - fix lesstif menu lht for conf(toggle, editor/draw_grid, design) - pcb-menu-mkey.lht Index: trunk/src/conf.h =================================================================== --- trunk/src/conf.h (revision 1894) +++ trunk/src/conf.h (revision 1895) @@ -231,6 +231,9 @@ #define conf_toggle_editor(field) \ conf_set_editor(field, !conf_core.editor.field) +#define conf_toggle_editor_(sfield, field) \ + conf_set_editor(sfield, !conf_core.editor.field) + /* For temporary modification/restoration of variables (hack) */ #define conf_force_set_bool(var, val) *((CFT_BOOLEAN *)(&var)) = val Index: trunk/src/conf_act.c =================================================================== --- trunk/src/conf_act.c (revision 1894) +++ trunk/src/conf_act.c (revision 1895) @@ -23,9 +23,13 @@ * */ +#include "global.h" +#include "data.h" #include "config.h" #include "conf.h" +#include "conf_core.h" #include "error.h" +#include "misc.h" static const char conf_syntax[] = "conf(set, path, value, [role], [policy]) - change a config setting\n" @@ -145,10 +149,133 @@ return 0; } +/*------------ get/chk (check flag actions for menus) ------------------*/ +static const char GetStyle_syntax[] = "GetStyle()" ; +static const char GetStyle_help[] = "Return integer index (>=1) of the currently active style or 0 if no style is selected"; +static int ActionGetStyle(int argc, char **argv, Coord x, Coord y) +{ + STYLE_LOOP(PCB); + { + if (style->Thick == conf_core.design.line_thickness && + style->Diameter == conf_core.design.via_thickness && + style->Hole == conf_core.design.via_drilling_hole && style->Keepaway == conf_core.design.keepaway) + return n + 1; + } + END_LOOP; + return 0; +} +static const char ChkMode_syntax[] = "ChkMode(expected_mode)" ; +static const char ChkMode_help[] = "Return 1 if the currently selected mode is the expected_mode"; +static int ActionChkMode(int argc, char **argv, Coord x, Coord y) +{ +#warning TODO: convert this to a compile-time hash + struct { + char *name; + int mode; + } *m, modes[] = { + {"none", NO_MODE}, + {"arc", ARC_MODE}, + {"arrow", ARROW_MODE}, + {"copy", COPY_MODE}, + {"insertpoint", INSERTPOINT_MODE}, + {"line", LINE_MODE}, + {"lock", LOCK_MODE}, + {"move", MOVE_MODE}, + {"pastebuffer", PASTEBUFFER_MODE}, + {"polygon", POLYGON_MODE}, + {"polygonhole", POLYGONHOLE_MODE}, + {"rectangle", RECTANGLE_MODE}, + {"remove", REMOVE_MODE}, + {"rotate", ROTATE_MODE}, + {"rubberbandmove", RUBBERBANDMOVE_MODE}, + {"text", TEXT_MODE}, + {"thermal", THERMAL_MODE}, + {"via", VIA_MODE}, + {NULL, 0} + }; + assert(argc == 1); + for(m = modes; m->name != NULL; m++) { + if (strcmp(m->name, argv[0]) == 0) + return conf_core.editor.mode == m->mode; + } + Message("Unknown mode in ChkMode(): %s\n", argv[1]); + abort(); + return -1; +} + + +static const char ChkGridSize_syntax[] = + "ChkGridSize(expected_size)\n" + "ChkGridSize(none)\n" + ; +static const char ChkGridSize_help[] = "Return 1 if the currently selected grid matches the expected_size. If argument is \"none\" return 1 if there is no grid."; +static int ActionChkGridSize(int argc, char **argv, Coord x, Coord y) +{ + assert(argc == 1); + if (strcmp(argv[0], "none") == 0) + return PCB->Grid <= 300; + + return (PCB->Grid == GetValueEx(argv[0], NULL, NULL, NULL, NULL, NULL)); +} + +static const char ChkElementName_syntax[] = + "ChkElementName(1) - expect description\n" + "ChkElementName(2) - expect refdes\n" + "ChkElementName(3) - expect value\n" + ; +static const char ChkElementName_help[] = "Return 1 if currently shown element label (name) type matches the expected"; +static int ActionChkElementName(int argc, char **argv, Coord x, Coord y) +{ + int have, expected = argv[0][0] - '0'; + + assert(argc == 1); + if (conf_core.editor.description) have = 1; + else if (conf_core.editor.name_on_pcb) have = 2; + else have = 3; + + return expected == have; +} + +static const char ChkGridUnits_syntax[] = "ChkGridUnits(expected)"; +static const char ChkGridUnits_help[] = "Return 1 if currently selected grid unit matches the expected (normally mm or mil)"; +static int ActionChkGridUnits(int argc, char **argv, Coord x, Coord y) +{ + assert(argc == 1); + return strcmp(conf_core.editor.grid_unit->suffix, argv[0]) == 0; +} + +static const char ChkBuffer_syntax[] = "ChkBuffer(idx)"; +static const char ChkBuffer_help[] = "Return 1 if currently selected buffer's index matches idx"; +static int ActionChkBuffer(int argc, char **argv, Coord x, Coord y) +{ + int expected = argv[0][0] - '0'; + assert(argc == 1); +printf("Checkbuffer: %d == %d -> %d\n", (conf_core.editor.buffer_number + 1), expected, (conf_core.editor.buffer_number + 1) == expected ); + return (conf_core.editor.buffer_number + 1) == expected; +} + HID_Action conf_action_list[] = { {"conf", 0, ActionConf, conf_help, conf_syntax} + , + {"GetStyle", 0, ActionGetStyle, + GetStyle_help, GetStyle_syntax} + , + {"ChkMode", 0, ActionChkMode, + ChkMode_help, ChkMode_syntax} + , + {"ChkGridSize", 0, ActionChkGridSize, + ChkGridSize_help, ChkGridSize_syntax} + , + {"ChkElementName", 0, ActionChkElementName, + ChkElementName_help, ChkElementName_syntax} + , + {"ChkGridUnits", 0, ActionChkGridUnits, + ChkGridUnits_help, ChkGridUnits_syntax} + , + {"ChkBuffer", 0, ActionChkBuffer, + ChkBuffer_help, ChkBuffer_syntax} }; REGISTER_ACTIONS(conf_action_list, NULL) Index: trunk/src/conf_core.c =================================================================== --- trunk/src/conf_core.c (revision 1894) +++ trunk/src/conf_core.c (revision 1895) @@ -30,4 +30,10 @@ conf_clamp_to(CFT_COORD, conf_core.design.via_drilling_hole, 0, MAX_COORD, DEFAULT_DRILLINGHOLE * conf_core.design.via_thickness / 100); conf_clamp(CFT_COORD, conf_core.design.max_width, MIN_SIZE, MAX_COORD); conf_clamp(CFT_COORD, conf_core.design.max_height, MIN_SIZE, MAX_COORD); +#if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) + conf_force_set_bool(conf_core.rc.have_regex, 1); +#else + conf_force_set_bool(conf_core.rc.have_regex, 0); +#endif + } Index: trunk/src/conf_core.h =================================================================== --- trunk/src/conf_core.h (revision 1894) +++ trunk/src/conf_core.h (revision 1895) @@ -54,6 +54,11 @@ CFT_BOOLEAN description; /* display element description as element name, instead of value */ CFT_BOOLEAN name_on_pcb; /* display Reference Designator as element name, instead of value */ + struct view { + CFT_BOOLEAN flip_x; /* view: flip the board along the X (horizontal) axis */ + CFT_BOOLEAN flip_y; /* view: flip the board along the Y (vertical) axis */ + } view; + /* these two would need to be moved in the router plugin.... There are two reasons to keep them here: - the original pcb and pcb-rnd file formats already have named/numbered flags for these, so io_pcb needs these @@ -84,6 +89,8 @@ CFT_STRING rat_command; CFT_LIST preferred_gui; /* if set, try GUI HIDs in this order when no GUI is explicitly selected */ + + CFT_BOOLEAN have_regex; /* auto-set by postproc: whether we have regex compiled in */ } rc; const struct design { /* defaults of a new layout */ Index: trunk/src/dolists.h =================================================================== --- trunk/src/dolists.h (revision 1894) +++ trunk/src/dolists.h (revision 1895) @@ -2,8 +2,7 @@ #undef REGISTER_ACTIONS #undef REGISTER_ATTRIBUTES -#undef REGISTER_FLAGS #define REGISTER_ACTIONS(a, cookie) {extern void HIDCONCAT(register_,a)();HIDCONCAT(register_,a)();} #define REGISTER_ATTRIBUTES(a, cookie) {extern void HIDCONCAT(register_,a)();HIDCONCAT(register_,a)();} -#define REGISTER_FLAGS(a, cookie) {extern void HIDCONCAT(register_,a)();HIDCONCAT(register_,a)();} + Index: trunk/src/flags.c =================================================================== --- trunk/src/flags.c (revision 1894) +++ trunk/src/flags.c (revision 1895) @@ -36,199 +36,20 @@ #include "data.h" #include "hid_flags.h" +#warning TODO: these must be removed in favor of conf RCSID("$Id$"); -static int FlagCurrentStyle(int dummy) -{ - STYLE_LOOP(PCB); - { - if (style->Thick == conf_core.design.line_thickness && - style->Diameter == conf_core.design.via_thickness && - style->Hole == conf_core.design.via_drilling_hole && style->Keepaway == conf_core.design.keepaway) - return n + 1; - } - END_LOOP; - return 0; -} - -static int FlagGrid(int dummy) -{ - return PCB->Grid > 1; -} - -static int FlagGridSize(int dummy) -{ - return PCB->Grid; -} - -static int FlagUnitsMm(int dummy) -{ - return conf_set(CFR_DESIGN, "editor/grid_unit", -1, "mm", POL_OVERWRITE); -} - -static int FlagUnitsMil(int dummy) -{ - return conf_set(CFR_DESIGN, "editor/grid_unit", -1, "mil", POL_OVERWRITE); -} - -static int FlagBuffer(int dummy) -{ - return (int) (conf_core.editor.buffer_number + 1); -} - -static int FlagElementName(int dummy) -{ - if (conf_core.editor.name_on_pcb) - return 2; - if (conf_core.editor.description) - return 1; - return 3; -} - -static int FlagSETTINGS(int ofs) -{ - return *(bool *) ((char *) (&conf_core) + ofs); -} - -static int FlagMode(int x) -{ - if (x == -1) - return conf_core.editor.mode; - return conf_core.editor.mode == x; -} - -static int FlagHaveRegex(int x) -{ -#if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) - return 1; -#else - return 0; -#endif -} - -enum { - FL_SILK = -6, - FL_PINS, - FL_RATS, - FL_VIAS, - FL_BACK, - FL_MASK -}; - -static int FlagLayerShown(int n) -{ - switch (n) { - case FL_SILK: - return PCB->ElementOn; - case FL_PINS: - return PCB->PinOn; - case FL_RATS: - return PCB->RatOn; - case FL_VIAS: - return PCB->ViaOn; - case FL_BACK: - return PCB->InvisibleObjectsOn; - case FL_MASK: - return conf_core.editor.show_mask; - default: - if (n >= 0 && n < max_copper_layer) - return PCB->Data->Layer[n].On; - } - return 0; -} - -static int FlagLayerActive(int n) -{ - int current_layer; - if (PCB->RatDraw) - current_layer = FL_RATS; - else if (PCB->SilkActive) - current_layer = FL_SILK; - else - return 0; - - return current_layer == n; -} - /* The cast to (int) is ONLY valid because we know we are * taking offsets on structures where the offset will fit * in an integer variable. It silences compile warnings on * 64bit machines. */ +/* #define OffsetOf(a,b) (int)(size_t)(&(((a *)0)->b)) HID_Flag flags_flag_list[] = { - {"style", FlagCurrentStyle, 0} - , - {"grid", FlagGrid, 0} - , - {"gridsize", FlagGridSize, 0} - , - {"elementname", FlagElementName, 0} - , - {"have_regex", FlagHaveRegex, 0} - , - {"silk_shown", FlagLayerShown, FL_SILK} - , - {"pins_shown", FlagLayerShown, FL_PINS} - , - {"rats_shown", FlagLayerShown, FL_RATS} - , - {"vias_shown", FlagLayerShown, FL_VIAS} - , - {"back_shown", FlagLayerShown, FL_BACK} - , - {"mask_shown", FlagLayerShown, FL_MASK} - , - {"silk_active", FlagLayerActive, FL_SILK} - , - {"rats_active", FlagLayerActive, FL_RATS} - , - {"mode", FlagMode, -1} - , - {"nomode", FlagMode, NO_MODE} - , - {"arcmode", FlagMode, ARC_MODE} - , - {"arrowmode", FlagMode, ARROW_MODE} - , - {"copymode", FlagMode, COPY_MODE} - , - {"insertpointmode", FlagMode, INSERTPOINT_MODE} - , - {"linemode", FlagMode, LINE_MODE} - , - {"lockmode", FlagMode, LOCK_MODE} - , - {"movemode", FlagMode, MOVE_MODE} - , - {"pastebuffermode", FlagMode, PASTEBUFFER_MODE} - , - {"polygonmode", FlagMode, POLYGON_MODE} - , - {"polygonholemode", FlagMode, POLYGONHOLE_MODE} - , - {"rectanglemode", FlagMode, RECTANGLE_MODE} - , - {"removemode", FlagMode, REMOVE_MODE} - , - {"rotatemode", FlagMode, ROTATE_MODE} - , - {"rubberbandmovemode", FlagMode, RUBBERBANDMOVE_MODE} - , - {"textmode", FlagMode, TEXT_MODE} - , - {"thermalmode", FlagMode, THERMAL_MODE} - , - {"viamode", FlagMode, VIA_MODE} - , - {"grid_units_mm", FlagUnitsMm, -1} - , - {"grid_units_mil", FlagUnitsMil, -1} - , {"buffer", FlagBuffer, 0} , - }; -REGISTER_FLAGS(flags_flag_list, NULL) +*/ Index: trunk/src/hid_actions.c =================================================================== --- trunk/src/hid_actions.c (revision 1894) +++ trunk/src/hid_actions.c (revision 1895) @@ -220,30 +220,17 @@ return hid_actionv(name, argc, argv); } -int hid_actionv(const char *name, int argc, char **argv) +int hid_actionv_(const HID_Action *a, int argc, char **argv) { Coord x = 0, y = 0; int i, ret; - const HID_Action *a, *old_action; + const HID_Action *old_action; - if (!name) - return 1; - - a = hid_find_action(name); - if (!a) { - int i; - Message("no action %s(", name); - for (i = 0; i < argc; i++) - Message("%s%s", i ? ", " : "", argv[i]); - Message(")\n"); - return 1; - } - if (a->need_coord_msg) gui->get_coords(_(a->need_coord_msg), &x, &y); if (conf_core.rc.verbose) { - printf("Action: \033[34m%s(", name); + printf("Action: \033[34m%s(", a->name); for (i = 0; i < argc; i++) printf("%s%s", i ? "," : "", argv[i]); printf(")\033[0m\n"); @@ -257,6 +244,25 @@ return ret; } +int hid_actionv(const char *name, int argc, char **argv) +{ + const HID_Action *a; + + if (!name) + return 1; + + a = hid_find_action(name); + if (!a) { + int i; + Message("no action %s(", name); + for (i = 0; i < argc; i++) + Message("%s%s", i ? ", " : "", argv[i]); + Message(")\n"); + return 1; + } + return hid_actionv_(a, argc, argv); +} + static int hid_parse_actionstring(const char *rstr, char require_parens) { char **list = NULL; Index: trunk/src/hid_actions.h =================================================================== --- trunk/src/hid_actions.h (revision 1894) +++ trunk/src/hid_actions.h (revision 1895) @@ -18,6 +18,7 @@ int hid_action(const char *action_); int hid_actionl(const char *action_, ...); /* NULL terminated */ int hid_actionv(const char *action_, int argc_, char **argv_); +int hid_actionv_(const HID_Action *a, int argc, char **argv); /* Parse the given command string into action calls, and call hid_actionv for each action found. Accepts both "action(arg1, Index: trunk/src/hid_flags.c =================================================================== --- trunk/src/hid_flags.c (revision 1894) +++ trunk/src/hid_flags.c (revision 1895) @@ -19,103 +19,15 @@ RCSID("$Id$"); -typedef struct HID_FlagNode { - HID_Flag *flags; - int n; - const char *cookie; -} HID_FlagNode; - -static htsp_t *hid_flags = NULL; - -static int keyeq(char *a, char *b) -{ - return !strcmp(a, b); -} - -void hid_register_flags(HID_Flag * a, int numact, const char *cookie, int copy) -{ - HID_FlagNode *ha; - HID_Flag *f; - int n; - - if (hid_flags == NULL) - hid_flags = htsp_alloc(strhash, keyeq); - - for(f = a, n = 0; n < numact; n++, f++) { - if (htsp_get(hid_flags, f->name) != NULL) { - fprintf(stderr, "ERROR: can't register flag %s for cookie %s: name already in use\n", f->name, cookie); - return; - } - - /* printf("%d flag%s registered\n", n, n==1 ? "" : "s"); */ - ha = (HID_FlagNode *) malloc(sizeof(HID_FlagNode)); - ha->flags = f; - ha->n = n; - ha->cookie = cookie; - - htsp_set(hid_flags, f->name, ha); - } -} - -void hid_remove_flags_by_cookie(const char *cookie) -{ - htsp_entry_t *e; - HID_FlagNode *ha; - - if (hid_flags == NULL) - return; - - for(e = htsp_first(hid_flags); e; e = htsp_next(hid_flags, e)) { - ha = e->value; - if (ha->cookie == cookie) { - htsp_pop(hid_flags, e->key); - free(ha); - } - } -} - - -void hid_flags_uninit(void) -{ - if (hid_flags != NULL) { - htsp_entry_t *e; - for(e = htsp_first(hid_flags); e; e = htsp_next(hid_flags, e)) { - HID_FlagNode *ha; - ha = e->value; - if (ha->cookie != NULL) - fprintf(stderr, "Warning: uninitialized flag in hid_flags_uninit: %s by %s; check your plugins' uninit!\n", e->key, ha->cookie); - htsp_pop(hid_flags, e->key); - free(ha); - } - htsp_free(hid_flags); - hid_flags = NULL; - } -} - -HID_Flag *hid_find_flag(const char *name) -{ - HID_FlagNode *ha; - - if (hid_flags == NULL) - return NULL; - - ha = htsp_get(hid_flags, (char *)name); - if (ha == NULL) { - fprintf(stderr, "ERROR: hid_find_flag(): flag not found '%s'\n", name); - return NULL; - } - - return ha->flags; -} - -#warning TODO: return -1 on not found, prepare caller code to deal with this +#warning TODO: move this to conf +#warning TODO: return -1 on not found, prepare caller code to deal with this (e.g. disable menu) int hid_get_flag(const char *name) { static char *buf = 0; static int nbuf = 0; const char *cp; - HID_Flag *f; + cp = strchr(name, '/'); if (cp) { conf_native_t *n = conf_get_field(name); @@ -125,8 +37,49 @@ return 0; return n->val.boolean[0]; } + else { + char *end; + char *argv[2]; + cp = strchr(name, '('); + if (cp != NULL) { + const HID_Action *a; + char buff[256]; + int len; + len = cp - name; + if (len > sizeof(buff)-1) { + Message("hid_get_flag: action name too long: %s()\n", name); + return 0; /* -1 */ + } + memcpy(buff, name, len); + buff[len] = '\0'; + a = hid_find_action(buff); + if (!a) { + int i; + Message("hid_get_flag: no action %s\n", name); + return 0; /* -1 */ + } + cp++; + len = strlen(cp); + end = strchr(cp, ')'); + if ((len > sizeof(buff)-1) || (end == NULL)) { + Message("hid_get_flag: action arg too long or unterminated: %s\n", name); + return 0; /* -1 */ + } + len = end - cp; + memcpy(buff, cp, len); + buff[len] = '\0'; + argv[0] = buff; + argv[1] = NULL; + return hid_actionv_(a, len > 0, argv); + } + else { + fprintf(stderr, "ERROR: hid_get_flag(%s) - not a path or an action\n", name); +// abort(); + } + } - +#warning TODO: check this in practice +#if 0 cp = strchr(name, ','); if (cp) { int wv; @@ -149,6 +102,7 @@ if (!f) return 0; return f->function(f->parm); +#endif } Index: trunk/src/hid_flags.h =================================================================== --- trunk/src/hid_flags.h (revision 1894) +++ trunk/src/hid_flags.h (revision 1895) @@ -1,19 +1,6 @@ #ifndef PCB_HID_FLAGS_H #define PCB_HID_FLAGS_H -/* HID internal interfaces. These may ONLY be called from the HID - modules, not from the common PCB code. */ -typedef struct { - /* Name of the flag */ - char *name; - /* Function to call to get the value of the flag. */ - int (*function) (int); - /* Additional parameter to pass to that function. */ - int parm; -} HID_Flag; - -HID_Flag *hid_find_flag(const char *name); - /* Use this to temporarily enable all layers, so that they can be exported even if they're not currently visible. save_array must be MAX_LAYER+2 big. */ @@ -22,18 +9,8 @@ void hid_restore_layer_ons(int *save_array); -extern void hid_register_flags(HID_Flag *a, int n, const char *cookie, int copy); -#define REGISTER_FLAGS(a, cookie) HIDCONCAT(void register_,a) ()\ -{ hid_register_flags(a, sizeof(a)/sizeof(a[0]), cookie, 0); } - -/* Remove all flags matching a cookie */ -void hid_remove_flags_by_cookie(const char *cookie); - /* Looks up one of the flags registered above. If the flag is unknown, returns zero. */ int hid_get_flag(const char *name_); -/* Free all flags */ -void hid_flags_uninit(void); - #endif Index: trunk/src/hid_init.c =================================================================== --- trunk/src/hid_init.c (revision 1894) +++ trunk/src/hid_init.c (revision 1895) @@ -139,7 +139,6 @@ free(hid_list); hid_actions_uninit(); - hid_flags_uninit(); hid_attributes_uninit(); } Index: trunk/src/pcb-conf.lht =================================================================== --- trunk/src/pcb-conf.lht (revision 1894) +++ trunk/src/pcb-conf.lht (revision 1895) @@ -69,6 +69,10 @@ enable_stroke = 0 live_routing = 0 beep_when_finished = 0 + ha:view { + flip_x = 0 + flip_y = 0 + } } # editor ha:rc { Index: trunk/src/pcb-menu-gtk.lht =================================================================== --- trunk/src/pcb-menu-gtk.lht (revision 1894) +++ trunk/src/pcb-menu-gtk.lht (revision 1895) @@ -124,28 +124,28 @@ ha:Enable visible grid = { checked=editor/draw_grid; action=conf(toggle, editor/draw_grid, design) } ha:Grid units { li:submenu { - ha:mil = { checked=grid_units_mil,1; action=SetUnits(mil) } - ha:mm = { checked=grid_units_mm,1; action=SetUnits(mm) } + ha:mil = { checked=ChkGridUnits(mil); action=SetUnits(mil) } + ha:mm = { checked=ChkGridUnits(mm); action=SetUnits(mm) } } } ha:Grid size = { li:submenu { - ha:No Grid = { checked=grid,0; action=SetValue(Grid,1) } + ha:No Grid = { checked=ChkGridSize(none); action=SetValue(Grid,1) } - - ha:0.1 mil = { checked=gridsize,0.1mil; li:action={SetUnits(mil); SetValue(Grid,0.1mil)} } - ha:1 mil = { checked=gridsize,1mil; li:action={SetUnits(mil); SetValue(Grid,1mil)} } - ha:5 mil = { checked=gridsize,5mil; li:action={SetUnits(mil); SetValue(Grid,5mil)} } - ha:10 mil = { checked=gridsize,10mil; li:action={SetUnits(mil); SetValue(Grid,10mil)} } - ha:25 mil = { checked=gridsize,25mil; li:action={SetUnits(mil); SetValue(Grid,25mil)} } - ha:50 mil = { checked=gridsize,50mil; li:action={SetUnits(mil); SetValue(Grid,50mil)} } - ha:100 mil = { checked=gridsize,100mil; li:action={SetUnits(mil); SetValue(Grid,100mil)} } + ha:0.1 mil = { checked=ChkGridSize(0.1mil); li:action={SetUnits(mil); SetValue(Grid,0.1mil)} } + ha:1 mil = { checked=ChkGridSize(1mil); li:action={SetUnits(mil); SetValue(Grid,1mil)} } + ha:5 mil = { checked=ChkGridSize(5mil); li:action={SetUnits(mil); SetValue(Grid,5mil)} } + ha:10 mil = { checked=ChkGridSize(10mil); li:action={SetUnits(mil); SetValue(Grid,10mil)} } + ha:25 mil = { checked=ChkGridSize(25mil); li:action={SetUnits(mil); SetValue(Grid,25mil)} } + ha:50 mil = { checked=ChkGridSize(50mil); li:action={SetUnits(mil); SetValue(Grid,50mil)} } + ha:100 mil = { checked=ChkGridSize(100mil); li:action={SetUnits(mil); SetValue(Grid,100mil)} } - - ha:0.01 mm = { checked=gridsize,0.01mm; li:action={SetUnits(mm); SetValue(Grid,0.01mm)} } - ha:0.05 mm = { checked=gridsize,0.05mm; li:action={SetUnits(mm); SetValue(Grid,0.05mm)} } - ha:0.1 mm = { checked=gridsize,0.10mm; li:action={SetUnits(mm); SetValue(Grid,0.1mm)} } - ha:0.25 mm = { checked=gridsize,0.25mm; li:action={SetUnits(mm); SetValue(Grid,0.25mm)} } - ha:0.5 mm = { checked=gridsize,0.50mm; li:action={SetUnits(mm); SetValue(Grid,0.5mm)} } - ha:1 mm = { checked=gridsize,1mm; li:action={SetUnits(mm); SetValue(Grid,1mm)} } + ha:0.01 mm = { checked=ChkGridSize(0.01mm); li:action={SetUnits(mm); SetValue(Grid,0.01mm)} } + ha:0.05 mm = { checked=ChkGridSize(0.05mm); li:action={SetUnits(mm); SetValue(Grid,0.05mm)} } + ha:0.1 mm = { checked=ChkGridSize(0.10mm); li:action={SetUnits(mm); SetValue(Grid,0.1mm)} } + ha:0.25 mm = { checked=ChkGridSize(0.25mm); li:action={SetUnits(mm); SetValue(Grid,0.25mm)} } + ha:0.5 mm = { checked=ChkGridSize(0.50mm); li:action={SetUnits(mm); SetValue(Grid,0.5mm)} } + ha:1 mm = { checked=ChkGridSize(1mm); li:action={SetUnits(mm); SetValue(Grid,1mm)} } - ha:Grid -5mil = { a=Shiftg; action=SetValue(Grid,-5,mil) } ha:Grid +5mil = { a=g; action=SetValue(Grid,+5,mil) } @@ -157,9 +157,9 @@ - ha:Displayed element name { li:submenu { - ha:Description = { checked=elementname,1; action=Display(Description) } - ha:Reference Designator = { checked=elementname,2; action=Display(NameOnPCB) } - ha:Value = { checked=elementname,3; action=Display(Value) } + ha:Description = { checked=ChkElementName(1); action=Display(Description) } + ha:Reference Designator = { checked=ChkElementName(2); action=Display(NameOnPCB) } + ha:Value = { checked=ChkElementName(3); action=Display(Value) } } } ha:Enable Pinout shows number = { checked=editor/show_number; action=conf(toggle, editor/show_number, design) } @@ -260,12 +260,12 @@ - ha:Select by name { li:submenu { - ha:All objects = { active=have_regex; action=Select(ObjectByName) } - ha:Elements = { active=have_regex; action=Select(ElementByName) } - ha:Pads = { active=have_regex; action=Select(PadByName) } - ha:Pins = { active=have_regex; action=Select(PinByName) } - ha:Text = { active=have_regex; action=Select(TextByName) } - ha:Vias = { active=have_regex; action=Select(ViaByName) } + ha:All objects = { active=rc/have_regex; action=Select(ObjectByName) } + ha:Elements = { active=rc/have_regex; action=Select(ElementByName) } + ha:Pads = { active=rc/have_regex; action=Select(PadByName) } + ha:Pins = { active=rc/have_regex; action=Select(PinByName) } + ha:Text = { active=rc/have_regex; action=Select(TextByName) } + ha:Vias = { active=rc/have_regex; action=Select(ViaByName) } } } - @@ -333,11 +333,11 @@ ha:Break buffer elements to pieces = { action=PasteBuffer(Restore) } ha:Save buffer elements to file = { action=Save(PasteBuffer) } - - ha:Select Buffer \#1 = { checked=buffer,1; m=1; a=Shift1; action=PasteBuffer(1) } - ha:Select Buffer \#2 = { checked=buffer,2; m=2; a=Shift2; action=PasteBuffer(2) } - ha:Select Buffer \#3 = { checked=buffer,3; m=3; a=Shift3; action=PasteBuffer(3) } - ha:Select Buffer \#4 = { checked=buffer,4; m=4; a=Shift4; action=PasteBuffer(4) } - ha:Select Buffer \#5 = { checked=buffer,5; m=5; a=Shift5; action=PasteBuffer(5) } + ha:Select Buffer \#1 = { checked=ChkBuffer(1); m=1; a=Shift1; action=PasteBuffer(1) } + ha:Select Buffer \#2 = { checked=ChkBuffer(2); m=2; a=Shift2; action=PasteBuffer(2) } + ha:Select Buffer \#3 = { checked=ChkBuffer(3); m=3; a=Shift3; action=PasteBuffer(3) } + ha:Select Buffer \#4 = { checked=ChkBuffer(4); m=4; a=Shift4; action=PasteBuffer(4) } + ha:Select Buffer \#5 = { checked=ChkBuffer(5); m=5; a=Shift5; action=PasteBuffer(5) } } } # Buffer @@ -553,23 +553,23 @@ - ha:Tools { li:submenu { - ha:None = { checked=nomode,1; action=Mode(None) } - ha:Via = { checked=viamode,1; a=F1; action=Mode(Via) } - ha:Line = { checked=linemode,1; a=F2; action=Mode(Line) } - ha:Arc = { checked=arcmode,1; a=F3; action=Mode(Arc) } - ha:Text = { checked=textmode,1; a=F4; action=Mode(Text) } - ha:Rectangle = { checked=rectanglemode,1; a=F5; action=Mode(Rectangle) } - ha:Polygon = { checked=polygonmode,1; a=F6; action=Mode(Polygon) } - ha:Polygon Hole = { checked=polygonholemode,1; action=Mode(PolygonHole) } - ha:Buffer = { checked=pastebuffermode,1; a=F7; action=Mode(PasteBuffer) } - ha:Remove = { checked=removemode,1; a=F8; action=Mode(Remove) } - ha:Rotate = { checked=rotatemode,1; a=F9; action=Mode(Rotate) } - ha:Thermal = { checked=thermalmode,1; a=F10; action=Mode(Thermal) } - ha:Arrow = { checked=arrowmode,1; a=F11; action=Mode(Arrow) } - ha:Insert Point = { checked=insertpointmode,1; a=Insert; action=Mode(InsertPoint) } - ha:Move = { checked=movemode,1; action=Mode(Move) } - ha:Copy = { checked=copymode,1; action=Mode(Copy) } - ha:Lock = { checked=lockmode,1; a=F12; action=Mode(Lock) } + ha:None = { checked=ChkMode(none); action=Mode(None) } + ha:Via = { checked=ChkMode(via); a=F1; action=Mode(Via) } + ha:Line = { checked=ChkMode(line); a=F2; action=Mode(Line) } + ha:Arc = { checked=ChkMode(arc); a=F3; action=Mode(Arc) } + ha:Text = { checked=ChkMode(text); a=F4; action=Mode(Text) } + ha:Rectangle = { checked=ChkMode(rectangle); a=F5; action=Mode(Rectangle) } + ha:Polygon = { checked=ChkMode(polygon); a=F6; action=Mode(Polygon) } + ha:Polygon Hole = { checked=ChkMode(polygonhole); action=Mode(PolygonHole) } + ha:Buffer = { checked=ChkMode(pastebuffer); a=F7; action=Mode(PasteBuffer) } + ha:Remove = { checked=ChkMode(remove); a=F8; action=Mode(Remove) } + ha:Rotate = { checked=ChkMode(rotate); a=F9; action=Mode(Rotate) } + ha:Thermal = { checked=ChkMode(thermal); a=F10; action=Mode(Thermal) } + ha:Arrow = { checked=ChkMode(arrow); a=F11; action=Mode(Arrow) } + ha:Insert Point = { checked=ChkMode(insertpoint); a=Insert; action=Mode(InsertPoint) } + ha:Move = { checked=ChkMode(move); action=Mode(Move) } + ha:Copy = { checked=ChkMode(copy); action=Mode(Copy) } + ha:Lock = { checked=ChkMode(lock); a=F12; action=Mode(Lock) } ha:Cancel = { a=Escape; action=Mode(Escape) } } } Index: trunk/src/pcb-menu-lesstif.lht =================================================================== --- trunk/src/pcb-menu-lesstif.lht (revision 1894) +++ trunk/src/pcb-menu-lesstif.lht (revision 1895) @@ -252,12 +252,12 @@ ha:unselect all connected objects = { action=Unselect(Connection) } - ha:Select by name = { foreground=grey50; sensitive=false } - ha:All objects = { active=have_regex; action=Select(ObjectByName) } - ha:Elements = { active=have_regex; action=Select(ElementByName) } - ha:Pads = { active=have_regex; action=Select(PadByName) } - ha:Pins = { active=have_regex; action=Select(PinByName) } - ha:Text Objects = { active=have_regex; action=Select(TextByName) } - ha:Vias = { active=have_regex; action=Select(ViaByName) } + ha:All objects = { active=rc/have_regex; action=Select(ObjectByName) } + ha:Elements = { active=rc/have_regex; action=Select(ElementByName) } + ha:Pads = { active=rc/have_regex; action=Select(PadByName) } + ha:Pins = { active=rc/have_regex; action=Select(PinByName) } + ha:Text Objects = { active=rc/have_regex; action=Select(TextByName) } + ha:Vias = { active=rc/have_regex; action=Select(ViaByName) } - ha:Auto-place selected elements = { a=Ctrlp; action=AutoPlaceSelected() } ha:Disperse all elements = { action=DisperseElements(All) } Index: trunk/src/pcb-menu-mkey.lht =================================================================== --- trunk/src/pcb-menu-mkey.lht (revision 1894) +++ trunk/src/pcb-menu-mkey.lht (revision 1895) @@ -259,12 +259,12 @@ - ha:Select by name { li:submenu { - ha:All objects = { active=have_regex; action=Select(ObjectByName) } - ha:Elements = { active=have_regex; action=Select(ElementByName) } - ha:Pads = { active=have_regex; action=Select(PadByName) } - ha:Pins = { active=have_regex; action=Select(PinByName) } - ha:Text = { active=have_regex; action=Select(TextByName) } - ha:Vias = { active=have_regex; action=Select(ViaByName) } + ha:All objects = { active=rc/have_regex; action=Select(ObjectByName) } + ha:Elements = { active=rc/have_regex; action=Select(ElementByName) } + ha:Pads = { active=rc/have_regex; action=Select(PadByName) } + ha:Pins = { active=rc/have_regex; action=Select(PinByName) } + ha:Text = { active=rc/have_regex; action=Select(TextByName) } + ha:Vias = { active=rc/have_regex; action=Select(ViaByName) } } } - Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 1894) +++ trunk/src/plug_io.c (revision 1895) @@ -471,7 +471,7 @@ */ void set_some_route_style() { - if (hid_get_flag("style")) + if (hid_get_flag("GetStyle()")) return; SetLineSize(PCB->RouteStyle[0].Thick); SetViaSize(PCB->RouteStyle[0].Diameter, true); Index: trunk/src/select_act.c =================================================================== --- trunk/src/select_act.c (revision 1894) +++ trunk/src/select_act.c (revision 1895) @@ -236,16 +236,6 @@ return 0; } -/* FLAG(have_regex,FlagHaveRegex,0) */ -int FlagHaveRegex(int parm) -{ -#if defined(HAVE_REGCOMP) || defined(HAVE_RE_COMP) - return 1; -#else - return 0; -#endif -} - /* --------------------------------------------------------------------------- */ static const char unselect_syntax[] = Index: trunk/src_plugins/djopt/djopt.c =================================================================== --- trunk/src_plugins/djopt/djopt.c (revision 1894) +++ trunk/src_plugins/djopt/djopt.c (revision 1895) @@ -50,6 +50,8 @@ RCSID("$Id$"); +static const char *djopt_cookie = "djopt"; + #ifndef HAVE_RINT #define rint(x) (ceil((x) - 0.5)) #endif @@ -144,14 +146,6 @@ return autorouted_only; } -HID_Flag djopt_flag_list[] = { - {"optautoonly", djopt_get_auto_only, 0} -}; - -static const char *djopt_cookie = "djopt"; - -REGISTER_FLAGS(djopt_flag_list, djopt_cookie) - static char *element_name_for(corner_s * c) { ELEMENT_LOOP(PCB->Data); @@ -2725,13 +2719,11 @@ static void hid_djopt_uninit(void) { hid_remove_actions_by_cookie(djopt_cookie); - hid_remove_flags_by_cookie(djopt_cookie); } #include "dolists.h" pcb_uninit_t hid_djopt_init(void) { - REGISTER_FLAGS(djopt_flag_list, djopt_cookie) REGISTER_ACTIONS(djopt_action_list, djopt_cookie) return hid_djopt_uninit; } Index: trunk/src_plugins/hid_gtk/gtkhid-gdk.c =================================================================== --- trunk/src_plugins/hid_gtk/gtkhid-gdk.c (revision 1894) +++ trunk/src_plugins/hid_gtk/gtkhid-gdk.c (revision 1895) @@ -497,11 +497,11 @@ vrx = Vz(xradius); vry = Vz(yradius); - if (gport->view.flip_x) { + if (conf_core.editor.view.flip_x) { start_angle = 180 - start_angle; delta_angle = -delta_angle; } - if (gport->view.flip_y) { + if (conf_core.editor.view.flip_y) { start_angle = -start_angle; delta_angle = -delta_angle; } @@ -1081,9 +1081,9 @@ gport->height = height; gport->view.width = width * gport->view.coord_per_px; gport->view.height = height * gport->view.coord_per_px; - gport->view.x0 = gport->view.flip_x ? PCB->MaxWidth - cx : cx; + gport->view.x0 = conf_core.editor.view.flip_x ? PCB->MaxWidth - cx : cx; gport->view.x0 -= gport->view.height / 2; - gport->view.y0 = gport->view.flip_y ? PCB->MaxHeight - cy : cy; + gport->view.y0 = conf_core.editor.view.flip_y ? PCB->MaxHeight - cy : cy; gport->view.y0 -= gport->view.width / 2; /* clear background */ Index: trunk/src_plugins/hid_gtk/gtkhid-gl.c =================================================================== --- trunk/src_plugins/hid_gtk/gtkhid-gl.c (revision 1894) +++ trunk/src_plugins/hid_gtk/gtkhid-gl.c (revision 1895) @@ -813,11 +813,11 @@ glLoadIdentity(); glTranslatef(0.0f, 0.0f, -Z_NEAR); - glScalef((port->view.flip_x ? -1. : 1.) / port->view.coord_per_px, - (port->view.flip_y ? -1. : 1.) / port->view.coord_per_px, - ((port->view.flip_x == port->view.flip_y) ? 1. : -1.) / port->view.coord_per_px); - glTranslatef(port->view.flip_x ? port->view.x0 - PCB->MaxWidth : - -port->view.x0, port->view.flip_y ? port->view.y0 - PCB->MaxHeight : -port->view.y0, 0); + glScalef((conf_core.editor.view.flip_x ? -1. : 1.) / port->view.coord_per_px, + (conf_core.editor.view.flip_y ? -1. : 1.) / port->view.coord_per_px, + ((conf_core.editor.view.flip_x == conf_core.editor.view.flip_y) ? 1. : -1.) / port->view.coord_per_px); + glTranslatef(conf_core.editor.view.flip_x ? port->view.x0 - PCB->MaxWidth : + -port->view.x0, conf_core.editor.view.flip_y ? port->view.y0 - PCB->MaxHeight : -port->view.y0, 0); glEnable(GL_STENCIL_TEST); glClearColor(port->offlimits_color.red / 65535., @@ -957,10 +957,10 @@ hidgl_init_triangle_array(&buffer); ghid_invalidate_current_gc(); glPushMatrix(); - glScalef((gport->view.flip_x ? -1. : 1.) / gport->view.coord_per_px, - (gport->view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1); - glTranslatef(gport->view.flip_x ? gport->view.x0 - PCB->MaxWidth : - -gport->view.x0, gport->view.flip_y ? gport->view.y0 - PCB->MaxHeight : -gport->view.y0, 0); + glScalef((conf_core.editor.view.flip_x ? -1. : 1.) / gport->view.coord_per_px, + (conf_core.editor.view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1); + glTranslatef(conf_core.editor.view.flip_x ? gport->view.x0 - PCB->MaxWidth : + -gport->view.x0, conf_core.editor.view.flip_y ? gport->view.y0 - PCB->MaxHeight : -gport->view.y0, 0); hid_expose_callback(&ghid_hid, NULL, &pinout->element); hidgl_flush_triangles(&buffer); glPopMatrix(); @@ -1014,9 +1014,9 @@ gport->height = height; gport->view.width = width * gport->view.coord_per_px; gport->view.height = height * gport->view.coord_per_px; - gport->view.x0 = gport->view.flip_x ? PCB->MaxWidth - cx : cx; + gport->view.x0 = conf_core.editor.view.flip_x ? PCB->MaxWidth - cx : cx; gport->view.x0 -= gport->view.height / 2; - gport->view.y0 = gport->view.flip_y ? PCB->MaxHeight - cy : cy; + gport->view.y0 = conf_core.editor.view.flip_y ? PCB->MaxHeight - cy : cy; gport->view.y0 -= gport->view.width / 2; /* make GL-context "current" */ @@ -1050,8 +1050,8 @@ hidgl_init_triangle_array(&buffer); ghid_invalidate_current_gc(); glPushMatrix(); - glScalef((gport->view.flip_x ? -1. : 1.) / gport->view.coord_per_px, - (gport->view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1); + glScalef((conf_core.editor.view.flip_x ? -1. : 1.) / gport->view.coord_per_px, + (conf_core.editor.view.flip_y ? -1. : 1.) / gport->view.coord_per_px, 1); glTranslatef(gport->view.flip_x ? gport->view.x0 - PCB->MaxWidth : -gport->view.x0, gport->view.flip_y ? gport->view.y0 - PCB->MaxHeight : -gport->view.y0, 0); @@ -1113,10 +1113,10 @@ glDisable(GL_STENCIL_TEST); glPushMatrix(); - glScalef((port->view.flip_x ? -1. : 1.) / port->view.coord_per_px, - (port->view.flip_y ? -1. : 1.) / port->view.coord_per_px, (port->view.flip_x == port->view.flip_y) ? 1. : -1.); - glTranslatef(port->view.flip_x ? port->view.x0 - PCB->MaxWidth : - -port->view.x0, port->view.flip_y ? port->view.y0 - PCB->MaxHeight : -port->view.y0, 0); + glScalef((conf_core.editor.view.flip_x ? -1. : 1.) / port->view.coord_per_px, + (conf_core.editor.view.flip_y ? -1. : 1.) / port->view.coord_per_px, (port->view.flip_x == port->view.flip_y) ? 1. : -1.); + glTranslatef(conf_core.editor.view.flip_x ? port->view.x0 - PCB->MaxWidth : + -port->view.x0, conf_core.editor.view.flip_y ? port->view.y0 - PCB->MaxHeight : -port->view.y0, 0); return &ghid_hid; } Index: trunk/src_plugins/hid_gtk/gtkhid-main.c =================================================================== --- trunk/src_plugins/hid_gtk/gtkhid-main.c (revision 1894) +++ trunk/src_plugins/hid_gtk/gtkhid-main.c (revision 1895) @@ -135,8 +135,8 @@ /* Work out where on the screen the flip point is */ ghid_pcb_to_event_coords(center_x, center_y, &widget_x, &widget_y); - gport->view.flip_x = gport->view.flip_x != flip_x; - gport->view.flip_y = gport->view.flip_y != flip_y; + conf_set_design("editor/view/flip_x", "%d", conf_core.editor.view.flip_x != flip_x); + conf_SET_design("editor/view/flip_y", "%d", conf_core.editor.view.flip_y != flip_y); /* Pan the board so the center location remains in the same place */ ghid_pan_view_abs(center_x, center_y, widget_x, widget_y); @@ -1515,10 +1515,10 @@ AFAIL(cursor); dx = GetValueEx(argv[1], argv[3], NULL, extra_units_x, "", NULL); - if (gport->view.flip_x) + if (conf_core.editor.view.flip_x) dx = -dx; dy = GetValueEx(argv[2], argv[3], NULL, extra_units_y, "", NULL); - if (!gport->view.flip_y) + if (!conf_core.editor.view.flip_y) dy = -dy; EventMoveCrosshair(Crosshair.X + dx, Crosshair.Y + dy); @@ -1867,26 +1867,18 @@ REGISTER_ACTIONS(ghid_main_action_list, ghid_cookie) - - static int - flag_flipx(int x) +#warning are these still in use? also check lesstif +static int flag_flipx(int x) { - return gport->view.flip_x; + return conf_core.editor.view.flip_x; } static int flag_flipy(int x) { - return gport->view.flip_y; + return conf_core.editor.view.flip_y; } -HID_Flag ghid_main_flag_list[] = { - {"flip_x", flag_flipx, 0} - , - {"flip_y", flag_flipy, 0} -}; -REGISTER_FLAGS(ghid_main_flag_list, ghid_cookie) - #include "dolists.h" /* * We will need these for finding the windows installation @@ -2010,7 +2002,6 @@ void gtkhid_begin(void) { - REGISTER_FLAGS(ghid_main_flag_list, ghid_cookie) REGISTER_ACTIONS(ghid_main_action_list, ghid_cookie) REGISTER_ATTRIBUTES(ghid_attribute_list, ghid_cookie) REGISTER_ACTIONS(ghid_netlist_action_list, ghid_cookie) @@ -2023,6 +2014,5 @@ void gtkhid_end(void) { hid_remove_actions_by_cookie(ghid_cookie); - hid_remove_flags_by_cookie(ghid_cookie); hid_remove_attributes_by_cookie(ghid_cookie); } Index: trunk/src_plugins/hid_gtk/gui.h =================================================================== --- trunk/src_plugins/hid_gtk/gui.h (revision 1894) +++ trunk/src_plugins/hid_gtk/gui.h (revision 1895) @@ -40,8 +40,8 @@ #include "ghid-coord-entry.h" #include "ghid-main-menu.h" #include "gui-pinout-preview.h" +#include "conf_core.h" - /* Silk and rats lines are the two additional selectable to draw on. | gui code in gui-top-window.c and group code in misc.c must agree | on what layer is what! @@ -64,8 +64,8 @@ #define FROM_PCB_UNITS(v) coord_to_unit (conf_core.editor.grid_unit, v) #define TO_PCB_UNITS(v) unit_to_coord (conf_core.editor.grid_unit, v) -#define SIDE_X(x) ((gport->view.flip_x ? PCB->MaxWidth - (x) : (x))) -#define SIDE_Y(y) ((gport->view.flip_y ? PCB->MaxHeight - (y) : (y))) +#define SIDE_X(x) ((conf_core.editor.view.flip_x ? PCB->MaxWidth - (x) : (x))) +#define SIDE_Y(y) ((conf_core.editor.view.flip_y ? PCB->MaxHeight - (y) : (y))) #define DRAW_X(x) (gint)((SIDE_X(x) - gport->view.x0) / gport->view.coord_per_px) #define DRAW_Y(y) (gint)((SIDE_Y(y) - gport->view.y0) / gport->view.coord_per_px) @@ -139,9 +139,6 @@ Coord width; Coord height; - bool flip_x; - bool flip_y; - } view_data; /* The output viewport @@ -466,7 +463,7 @@ static inline int Vx(Coord x) { int rv; - if (gport->view.flip_x) + if (conf_core.editor.view.flip_x) rv = (PCB->MaxWidth - x - gport->view.x0) / gport->view.coord_per_px + 0.5; else rv = (x - gport->view.x0) / gport->view.coord_per_px + 0.5; @@ -476,7 +473,7 @@ static inline int Vy(Coord y) { int rv; - if (gport->view.flip_y) + if (conf_core.editor.view.flip_y) rv = (PCB->MaxHeight - y - gport->view.y0) / gport->view.coord_per_px + 0.5; else rv = (y - gport->view.y0) / gport->view.coord_per_px + 0.5; @@ -491,7 +488,7 @@ static inline Coord Px(int x) { Coord rv = x * gport->view.coord_per_px + gport->view.x0; - if (gport->view.flip_x) + if (conf_core.editor.view.flip_x) rv = PCB->MaxWidth - (x * gport->view.coord_per_px + gport->view.x0); return rv; } @@ -499,7 +496,7 @@ static inline Coord Py(int y) { Coord rv = y * gport->view.coord_per_px + gport->view.y0; - if (gport->view.flip_y) + if (conf_core.editor.view.flip_y) rv = PCB->MaxHeight - (y * gport->view.coord_per_px + gport->view.y0); return rv; } Index: trunk/src_plugins/hid_lesstif/main.c =================================================================== --- trunk/src_plugins/hid_lesstif/main.c (revision 1894) +++ trunk/src_plugins/hid_lesstif/main.c (revision 1895) @@ -148,7 +148,6 @@ out - the largest value means you are looking at the whole board. */ static double view_zoom = MIL_TO_COORD(10), prev_view_zoom = MIL_TO_COORD(10); -static bool flip_x = 0, flip_y = 0; static bool autofade = 0; static bool crosshair_on = true; @@ -171,24 +170,6 @@ notify_mark_change(true); } -static int flag_flipx(int x) -{ - return flip_x; -} - -static int flag_flipy(int x) -{ - return flip_y; -} - -HID_Flag lesstif_main_flag_list[] = { - {"flip_x", flag_flipx, 0} - , - {"flip_y", flag_flipy, 0} -}; - -REGISTER_FLAGS(lesstif_main_flag_list, lesstif_cookie) - /* This is the size of the current PCB work area. */ /* Use PCB->MaxWidth, PCB->MaxHeight. */ /* static int pcb_width, pcb_height; */ @@ -257,7 +238,7 @@ Vx(Coord x) { int rv = (x - view_left_x) / view_zoom + 0.5; - if (flip_x) + if (conf_core.editor.view.flip_x) rv = view_width - rv; return rv; } @@ -265,7 +246,7 @@ static inline int Vy(Coord y) { int rv = (y - view_top_y) / view_zoom + 0.5; - if (flip_y) + if (conf_core.editor.view.flip_y) rv = view_height - rv; return rv; } @@ -277,7 +258,7 @@ static inline Coord Px(int x) { - if (flip_x) + if (conf_core.editor.view.flip_x) x = view_width - x; return x * view_zoom + view_left_x; } @@ -284,7 +265,7 @@ static inline Coord Py(int y) { - if (flip_y) + if (conf_core.editor.view.flip_y) y = view_height - y; return y * view_zoom + view_top_y; } @@ -594,26 +575,26 @@ switch (argv[0][0]) { case 'h': case 'H': - flip_x = !flip_x; + conf_toggle_editor_("view/flip_x", view.flip_x); break; case 'v': case 'V': - flip_y = !flip_y; + conf_toggle_editor_("view/flip_y", view.flip_y); break; case 'r': case 'R': - flip_x = !flip_x; - flip_y = !flip_y; + conf_toggle_editor_("view/flip_x", view.flip_x); + conf_toggle_editor_("view/flip_y", view.flip_y); break; default: return 1; } /* SwapSides will swap this */ - conf_set_editor(show_solder_side, (flip_x == flip_y)); + conf_set_editor(show_solder_side, (conf_core.editor.view.flip_x == conf_core.editor.view.flip_y)); } stdarg_n = 0; - if (flip_x) + if (conf_core.editor.view.flip_x) stdarg(XmNprocessingDirection, XmMAX_ON_LEFT); else stdarg(XmNprocessingDirection, XmMAX_ON_RIGHT); @@ -620,7 +601,7 @@ XtSetValues(hscroll, stdarg_args, stdarg_n); stdarg_n = 0; - if (flip_y) + if (conf_core.editor.view.flip_y) stdarg(XmNprocessingDirection, XmMAX_ON_TOP); else stdarg(XmNprocessingDirection, XmMAX_ON_BOTTOM); @@ -867,10 +848,10 @@ AFAIL(cursor); dx = GetValueEx(argv[1], argv[3], NULL, extra_units_x, "mil", NULL); - if (flip_x) + if (conf_core.editor.view.flip_x) dx = -dx; dy = GetValueEx(argv[2], argv[3], NULL, extra_units_y, "mil", NULL); - if (!flip_y) + if (!conf_core.editor.view.flip_y) dy = -dy; EventMoveCrosshair(Crosshair.X + dx, Crosshair.Y + dy); @@ -1148,9 +1129,9 @@ xfrac = (double) x / (double) view_width; yfrac = (double) y / (double) view_height; - if (flip_x) + if (conf_core.editor.view.flip_x) xfrac = 1 - xfrac; - if (flip_y) + if (conf_core.editor.view.flip_y) yfrac = 1 - yfrac; max_zoom = PCB->MaxWidth / view_width; @@ -1209,9 +1190,9 @@ if (pan_thumb_mode) { opx = x * PCB->MaxWidth / view_width; opy = y * PCB->MaxHeight / view_height; - if (flip_x) + if (conf_core.editor.view.flip_x) opx = PCB->MaxWidth - opx; - if (flip_y) + if (conf_core.editor.view.flip_y) opy = PCB->MaxHeight - opy; view_left_x = opx - view_width / 2 * view_zoom; view_top_y = opy - view_height / 2 * view_zoom; @@ -1228,11 +1209,11 @@ /* continued drag, we calculate how far we've moved the cursor and set the position accordingly. */ else { - if (flip_x) + if (conf_core.editor.view.flip_x) view_left_x = opx + (x - ox) * view_zoom; else view_left_x = opx - (x - ox) * view_zoom; - if (flip_y) + if (conf_core.editor.view.flip_y) view_top_y = opy + (y - oy) * view_zoom; else view_top_y = opy - (y - oy) * view_zoom; @@ -2198,7 +2179,7 @@ XSetFunction(display, grid_gc, GXxor); XSetForeground(display, grid_gc, grid_color); } - if (flip_x) { + if (conf_core.editor.view.flip_x) { x2 = GridFit(Px(0), PCB->Grid, PCB->GridOffsetX); x1 = GridFit(Px(view_width), PCB->Grid, PCB->GridOffsetX); if (Vx(x2) < 0) @@ -2214,7 +2195,7 @@ if (Vx(x2) >= view_width) x2 -= PCB->Grid; } - if (flip_y) { + if (conf_core.editor.view.flip_y) { y2 = GridFit(Py(0), PCB->Grid, PCB->GridOffsetY); y1 = GridFit(Py(view_height), PCB->Grid, PCB->GridOffsetY); if (Vy(y2) < 0) @@ -2383,12 +2364,12 @@ region.Y1 = Py(0); region.X2 = Px(view_width); region.Y2 = Py(view_height); - if (flip_x) { + if (conf_core.editor.view.flip_x) { Coord tmp = region.X1; region.X1 = region.X2; region.X2 = tmp; } - if (flip_y) { + if (conf_core.editor.view.flip_y) { Coord tmp = region.Y1; region.Y1 = region.Y2; region.Y2 = tmp; @@ -3109,11 +3090,11 @@ height = Vz(height); cx = Vx(cx) - width; cy = Vy(cy) - height; - if (flip_x) { + if (conf_core.editor.view.flip_x) { start_angle = 180 - start_angle; delta_angle = -delta_angle; } - if (flip_y) { + if (conf_core.editor.view.flip_y) { start_angle = -start_angle; delta_angle = -delta_angle; } @@ -3307,11 +3288,11 @@ unsigned int keys_buttons; int pos_x, pos_y, root_x, root_y; XQueryPointer(display, window, &root, &child, &root_x, &root_y, &pos_x, &pos_y, &keys_buttons); - if (flip_x) + if (conf_core.editor.view.flip_x) view_left_x = x - (view_width - pos_x) * view_zoom; else view_left_x = x - pos_x * view_zoom; - if (flip_y) + if (conf_core.editor.view.flip_y) view_top_y = y - (view_height - pos_y) * view_zoom; else view_top_y = y - pos_y * view_zoom; @@ -3513,8 +3494,8 @@ save_vz = view_zoom; save_vw = view_width; save_vh = view_height; - save_fx = flip_x; - save_fy = flip_y; + save_fx = conf_core.editor.view.flip_x; + save_fy = conf_core.editor.view.flip_y; save_px = pixmap; pinout = pd; pixmap = pd->window; @@ -3524,8 +3505,8 @@ view_width = pd->v_width; view_height = pd->v_height; use_mask = 0; - flip_x = flip_y = 0; - + conf_force_set_bool(conf_core.editor.view.flip_x, 0); + conf_force_set_bool(conf_core.editor.view.flip_y, 0); region.X1 = 0; region.Y1 = 0; region.X2 = PCB->MaxWidth; @@ -3541,8 +3522,8 @@ view_width = save_vw; view_height = save_vh; pixmap = save_px; - flip_x = save_fx; - flip_y = save_fy; + conf_force_set_bool(conf_core.editor.view.flip_x, save_fx); + conf_force_set_bool(conf_core.editor.view.flip_y, save_fy); } static void pinout_unmap(Widget w, PinoutData * pd, void *v) @@ -3854,7 +3835,6 @@ static void lesstif_begin(void) { REGISTER_ACTIONS(lesstif_library_action_list, lesstif_cookie) - REGISTER_FLAGS(lesstif_main_flag_list, lesstif_cookie) REGISTER_ATTRIBUTES(lesstif_attribute_list, lesstif_cookie) REGISTER_ACTIONS(lesstif_main_action_list, lesstif_cookie) REGISTER_ACTIONS(lesstif_dialog_action_list, lesstif_cookie) @@ -3866,6 +3846,5 @@ static void lesstif_end(void) { hid_remove_actions_by_cookie(lesstif_cookie); - hid_remove_flags_by_cookie(lesstif_cookie); hid_remove_attributes_by_cookie(lesstif_cookie); } Index: trunk/src_plugins/hid_lesstif/styles.c =================================================================== --- trunk/src_plugins/hid_lesstif/styles.c (revision 1894) +++ trunk/src_plugins/hid_lesstif/styles.c (revision 1895) @@ -120,7 +120,7 @@ static void update_style_buttons() { - int i = hid_get_flag("style"); + int i = hid_get_flag("GetStyle()"); int j, n; for (n = 0; n < num_style_buttons; n++) { Index: trunk/src_plugins/vendordrill/vendor.c =================================================================== --- trunk/src_plugins/vendordrill/vendor.c (revision 1894) +++ trunk/src_plugins/vendordrill/vendor.c (revision 1895) @@ -807,13 +807,6 @@ return vendorMapEnable; } -#warning TODO: make this a normal config item in plugins/ -HID_Flag vendor_flag_list[] = { - {"VendorMapOn", vendor_get_enabled, 0} -}; - -REGISTER_FLAGS(vendor_flag_list, vendor_cookie) - static char **vendor_free_vect(char **lst, int *len) { if (lst != NULL) { @@ -843,7 +836,6 @@ static void hid_vendordrill_uninit(void) { hid_remove_actions_by_cookie(vendor_cookie); - hid_remove_flags_by_cookie(vendor_cookie); vendor_free_all(); } @@ -854,6 +846,5 @@ stub_vendorIsElementMappable = vendorIsElementMappable; REGISTER_ACTIONS(vendor_action_list, vendor_cookie) - REGISTER_FLAGS(vendor_flag_list, vendor_cookie) return hid_vendordrill_uninit; }