Index: trunk/src/libcschem/extobj.c =================================================================== --- trunk/src/libcschem/extobj.c (revision 11154) +++ trunk/src/libcschem/extobj.c (revision 11155) @@ -30,11 +30,15 @@ #include #include #include +#include +#include #include "cnc_grp.h" #include "extobj.h" +static const char extobj_cookie[] = "extobj"; + /* persistent copy of impl; both key and value are allocated; on unregister a zombie impl is kept with all fields (including name) set to NULL */ htsp_t extobjs_impls; @@ -130,12 +134,77 @@ return gfx; } +static const char csch_acts_Extobj[] = "Extobj(Object|Selected, Update|Edit)"; +static const char csch_acth_Extobj[] = "Standard extended object operations on a single object (under the cursor) or selected objects."; +fgw_error_t csch_act_Extobj(fgw_arg_t *res, int argc, fgw_arg_t *argv) +{ + const char *scope, *cmd; + enum {SC_INVALID, SC_OBJ, SC_SEL} sc = SC_INVALID; + enum {OP_INVALID, OP_UPDATE, OP_EDIT} op = OP_INVALID; + int want_extobj = 1; /* search only for extended objects for objs.array[] */ + vtp0_t objs = {0}; + RND_ACT_IRES(1); + + /* we don't have funchash in libcschem, only in sch-rnd */ + RND_ACT_MAY_CONVARG(1, FGW_STR, Extobj, scope = argv[1].val.str); + RND_ACT_MAY_CONVARG(2, FGW_STR, Extobj, cmd = argv[2].val.str); + + switch(*scope) { + case 'o': case 'O': if (rnd_strcasecmp(scope, "object") == 0) sc = SC_OBJ; break; + case 's': case 'S': if (rnd_strcasecmp(scope, "selected") == 0) sc = SC_SEL; break; + } + + switch(*cmd) { + case 'u': case 'U': if (rnd_strcasecmp(scope, "update") == 0) op = OP_UPDATE; break; + case 'e': case 'E': if (rnd_strcasecmp(scope, "edit") == 0) op = OP_EDIT; break; + } + + switch(sc) { + case SC_OBJ: + break; + case SC_SEL: + break; + default: + rnd_message(RND_MSG_ERROR, "Extobj(): invalid scope '%s'\n", scope); + return 0; /* IRES is set to 1 */ + } + + if (objs.used == 0) { + rnd_message(RND_MSG_ERROR, "Extobj(): no suitable object found in scope '%s'\n", scope); + return 0; /* IRES is set to 1 */ + } + + switch(op) { + case OP_UPDATE: + RND_ACT_IRES(0); + return 0; + case OP_EDIT: + RND_ACT_IRES(0); + return 0; + default: + rnd_message(RND_MSG_ERROR, "Extobj(): invalid command '%s'\n", cmd); + break; + } + + return 0; /* IRES is set to 1 */ +} + +static rnd_action_t csch_extobj_act_list[] = { + {"Extobj", csch_act_Extobj, csch_acth_Extobj, csch_acts_Extobj} +}; + void csch_extobj_init(void) { htsp_init(&extobjs_impls, strhash, strkeyeq); + RND_REGISTER_ACTIONS(csch_extobj_act_list, extobj_cookie); } +void csch_extobj_act_uninit(void) +{ + rnd_remove_actions_by_cookie(extobj_cookie); +} + void csch_extobj_uninit(void) { htsp_entry_t *e; Index: trunk/src/libcschem/extobj.h =================================================================== --- trunk/src/libcschem/extobj.h (revision 11154) +++ trunk/src/libcschem/extobj.h (revision 11155) @@ -59,6 +59,7 @@ /*** internal, do not call ***/ void csch_extobj_init(void); +void csch_extobj_act_uninit(void); void csch_extobj_uninit(void); const csch_extobj_impl_t *csch_extobj_lookup(const char *name); Index: trunk/src/libcschem/libcschem.c =================================================================== --- trunk/src/libcschem/libcschem.c (revision 11154) +++ trunk/src/libcschem/libcschem.c (revision 11155) @@ -69,6 +69,7 @@ { csch_project_uninit(); csch_project_act_uninit(); + csch_extobj_act_uninit(); csch_integrity_act_uninit(); csch_drc_act_uninit(); csch_undo_act_uninit();