Index: trunk/src/select.c =================================================================== --- trunk/src/select.c (revision 15742) +++ trunk/src/select.c (revision 15743) @@ -539,191 +539,3 @@ return 1; return 0; } - -pcb_bool pcb_select_object_by_name(pcb_board_t *pcb, int Type, const char *name_pattern, pcb_bool Flag, pcb_search_method_t method) -{ - pcb_bool changed = pcb_false; - const char **pat = NULL; - char *pattern_copy = NULL; - re_sei_t *regex; - - if (method == PCB_SM_REGEX) { - /* compile the regular expression */ - regex = re_sei_comp(name_pattern); - if (re_sei_errno(regex) != 0) { - pcb_message(PCB_MSG_ERROR, _("regexp error: %s\n"), re_error_str(re_sei_errno(regex))); - re_sei_free(regex); - return pcb_false; - } - } - else { - char *s, *next; - int n, w; - - /* We're going to mess with the delimiters. Create a copy. */ - pattern_copy = pcb_strdup(name_pattern); - - /* count the number of patterns */ - for (s = pattern_copy, w = 0; *s != '\0'; s++) { - if (*s == '|') - w++; - } - - pat = malloc((w + 2) * sizeof(char *)); /* make room for the NULL too */ - for (s = pattern_copy, n = 0; s != NULL; s = next) { - char *end; -/*fprintf(stderr, "S: '%s'\n", s, next);*/ - while (isspace(*s)) - s++; - next = strchr(s, '|'); - if (next != NULL) { - *next = '\0'; - next++; - } - end = s + strlen(s) - 1; - while ((end >= s) && (isspace(*end))) { - *end = '\0'; - end--; - } - if (*s != '\0') { - pat[n] = s; - n++; - } - } - pat[n] = NULL; - } - - /* loop over all visible objects with names */ - if (Type & PCB_TYPE_TEXT) - PCB_TEXT_ALL_LOOP(pcb->Data); - { - if (!PCB_FLAG_TEST(PCB_FLAG_LOCK, text) - && pcb_text_is_visible(PCB, layer, text) - && text->TextString && REGEXEC(text->TextString) - && PCB_FLAG_TEST(PCB_FLAG_SELECTED, text) != Flag) { - pcb_undo_add_obj_to_flag(text); - PCB_FLAG_ASSIGN(PCB_FLAG_SELECTED, Flag, text); - pcb_text_invalidate_draw(layer, text); - changed = pcb_true; - } - } - PCB_ENDALL_LOOP; - -#warning subc TODO: rewrite -#if 0 - if (pcb_silk_on(pcb) && (Type & PCB_TYPE_ELEMENT)) - PCB_ELEMENT_LOOP(pcb->Data); - { - if (!PCB_FLAG_TEST(PCB_FLAG_LOCK, element) - && ((PCB_FLAG_TEST(PCB_FLAG_ONSOLDER, element) != 0) == PCB_SWAP_IDENT || pcb->InvisibleObjectsOn) - && PCB_FLAG_TEST(PCB_FLAG_SELECTED, element) != Flag) { - const char* name = PCB_ELEM_NAME_VISIBLE(PCB, element); - if (name && REGEXEC(name)) { - pcb_undo_add_obj_to_flag(element); - PCB_FLAG_ASSIGN(PCB_FLAG_SELECTED, Flag, element); - PCB_PIN_LOOP(element); - { - pcb_undo_add_obj_to_flag(pin); - PCB_FLAG_ASSIGN(PCB_FLAG_SELECTED, Flag, pin); - } - PCB_END_LOOP; - PCB_PAD_LOOP(element); - { - pcb_undo_add_obj_to_flag(pad); - PCB_FLAG_ASSIGN(PCB_FLAG_SELECTED, Flag, pad); - } - PCB_END_LOOP; - PCB_ELEMENT_PCB_TEXT_LOOP(element); - { - pcb_undo_add_obj_to_flag(text); - PCB_FLAG_ASSIGN(PCB_FLAG_SELECTED, Flag, text); - } - PCB_END_LOOP; - pcb_elem_name_invalidate_draw(element); - pcb_elem_invalidate_draw(element); - changed = pcb_true; - } - } - } - PCB_END_LOOP; -#endif - -#warning padstack TODO: rewrite -#if 0 - if (pcb->PinOn && (Type & PCB_TYPE_PIN)) - PCB_PIN_ALL_LOOP(pcb->Data); - { - if (!PCB_FLAG_TEST(PCB_FLAG_LOCK, element) - && pin->Name && REGEXEC(pin->Name) - && PCB_FLAG_TEST(PCB_FLAG_SELECTED, pin) != Flag) { - pcb_undo_add_obj_to_flag(pin); - PCB_FLAG_ASSIGN(PCB_FLAG_SELECTED, Flag, pin); - pcb_pin_invalidate_draw(pin); - changed = pcb_true; - } - } - PCB_ENDALL_LOOP; - if (pcb->PinOn && (Type & PCB_TYPE_PAD)) - PCB_PAD_ALL_LOOP(pcb->Data); - { - if (!PCB_FLAG_TEST(PCB_FLAG_LOCK, element) - && ((PCB_FLAG_TEST(PCB_FLAG_ONSOLDER, pad) != 0) == PCB_SWAP_IDENT || pcb->InvisibleObjectsOn) - && PCB_FLAG_TEST(PCB_FLAG_SELECTED, pad) != Flag) - if (pad->Name && REGEXEC(pad->Name)) { - pcb_undo_add_obj_to_flag(pad); - PCB_FLAG_ASSIGN(PCB_FLAG_SELECTED, Flag, pad); - pcb_pad_invalidate_draw(pad); - changed = pcb_true; - } - } - PCB_ENDALL_LOOP; - if (pcb->ViaOn && (Type & PCB_TYPE_VIA)) - PCB_VIA_LOOP(pcb->Data); - { - if (!PCB_FLAG_TEST(PCB_FLAG_LOCK, via) - && via->Name && REGEXEC(via->Name) && PCB_FLAG_TEST(PCB_FLAG_SELECTED, via) != Flag) { - pcb_undo_add_obj_to_flag(via); - PCB_FLAG_ASSIGN(PCB_FLAG_SELECTED, Flag, via); - pcb_via_invalidate_draw(via); - changed = pcb_true; - } - } - PCB_END_LOOP; -#endif - if (Type & PCB_TYPE_NET) { - pcb_conn_lookup_init(); - changed = pcb_reset_conns(pcb_true) || changed; - - PCB_MENU_LOOP(&(pcb->NetlistLib[PCB_NETLIST_EDITED])); - { - pcb_cardinal_t i; - pcb_lib_entry_t *entry; - pcb_connection_t conn; - - /* Name[0] and Name[1] are special purpose, not the actual name */ - if (menu->Name && menu->Name[0] != '\0' && menu->Name[1] != '\0' && REGEXEC(menu->Name + 2)) { - for (i = menu->EntryN, entry = menu->Entry; i; i--, entry++) - if (pcb_rat_seek_pad(entry, &conn, pcb_false)) - pcb_rat_find_hook(conn.obj, pcb_true, pcb_true); - } - } - PCB_END_LOOP; - - changed = pcb_select_connection(pcb, Flag) || changed; - changed = pcb_reset_conns(pcb_false) || changed; - pcb_conn_lookup_uninit(); - } - - if (method == PCB_SM_REGEX) - re_sei_free(regex); - - if (changed) { - pcb_undo_inc_serial(); - pcb_draw(); - } - if (pat != NULL) - free(pat); - if (pattern_copy != NULL) - free(pattern_copy); - return changed; -} Index: trunk/src/select.h =================================================================== --- trunk/src/select.h (revision 15742) +++ trunk/src/select.h (revision 15743) @@ -42,12 +42,4 @@ pcb_bool pcb_select_connection(pcb_board_t *pcb, pcb_bool); - -typedef enum { - PCB_SM_REGEX = 0, - PCB_SM_LIST = 1 -} pcb_search_method_t; - -pcb_bool pcb_select_object_by_name(pcb_board_t *pcb, int, const char *, pcb_bool, pcb_search_method_t); - #endif Index: trunk/src/select_act.c =================================================================== --- trunk/src/select_act.c (revision 15742) +++ trunk/src/select_act.c (revision 15743) @@ -50,41 +50,6 @@ #include "compat_misc.h" #include "compat_nls.h" -#warning subc TODO: move this to dialogs -/* --------------------------------------------------------------------------- */ -/* Ask the user for a search pattern */ -static char *gui_get_pat(pcb_search_method_t * method) -{ - const char *methods[] = { "regexp", "list of names", NULL }; - pcb_hid_attribute_t attrs[2]; -#define nattr sizeof(attrs)/sizeof(attrs[0]) - static pcb_hid_attr_val_t results[nattr] = { 0 }; - - memset(attrs, 0, sizeof(attrs)); - - attrs[0].name = "Pattern"; - attrs[0].help_text = "Name/refdes pattern"; - attrs[0].type = PCB_HATT_STRING; - attrs[0].default_val.str_value = results[0].str_value; - - attrs[1].name = "Method"; - attrs[1].help_text = "method of search: either regular expression or a list of full names separated by |"; - attrs[1].type = PCB_HATT_ENUM; - attrs[1].enumerations = methods; - attrs[1].default_val.int_value = results[1].int_value; - - pcb_gui->attribute_dialog(attrs, nattr, results, "Find subcircuit", "Find subcircuit by refdes", NULL); - - *method = results[1].int_value; - if (results[0].str_value == NULL) - return NULL; - return pcb_strdup(results[0].str_value); -#undef nattr -} - - -/* --------------------------------------------------------------------------- */ - static const char pcb_acts_Select[] = "Select(Object|ToggleObject)\n" "Select(All|Block|Connection)\n"