diff --git a/src/callback.c b/src/callback.c index c4788b68..092284aa 100644 --- a/src/callback.c +++ b/src/callback.c @@ -1331,20 +1331,20 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int return 0; } -/* del == 0 : delete and draw - * del == 1 : delete - * del == 2 : draw */ -void draw_crosshair(int del) +/* what == 0 : delete and draw + * what == 1 : delete + * what == 2 : draw */ +void draw_crosshair(int what) { int sdw, sdp; - dbg(1, "draw_crosshair(): del=%d\n", del); + dbg(1, "draw_crosshair(): what=%d\n", what); sdw = xctx->draw_window; sdp = xctx->draw_pixmap; if(!xctx->mouse_inside) return; xctx->draw_pixmap = 0; xctx->draw_window = 1; - if(del != 2) { + if(what != 2) { if(fix_broken_tiled_fill || !_unix) { MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gc[0], 0, (int)Y_TO_SCREEN(xctx->prev_crossy) - 2 * INT_WIDTH(xctx->lw), @@ -1362,7 +1362,7 @@ void draw_crosshair(int del) xctx->prev_crossx, Y_TO_XSCHEM(xctx->areay2)); } } - if(del != 1) { + if(what != 1) { drawline(xctx->crosshair_layer, NOW,X_TO_XSCHEM( xctx->areax1), xctx->mousey_snap, X_TO_XSCHEM(xctx->areax2), xctx->mousey_snap, 3, NULL); drawline(xctx->crosshair_layer, NOW, xctx->mousex_snap, Y_TO_XSCHEM(xctx->areay1), diff --git a/src/token.c b/src/token.c index 145c8e63..8255bb67 100644 --- a/src/token.c +++ b/src/token.c @@ -4295,13 +4295,14 @@ const char *translate(int inst, const char* s) if(!error) { char *iprefix = modelparam == 0 ? "i(" : modelparam == 1 ? "" : "v("; char *ipostfix = modelparam == 1 ? "" : ")"; + int prefix; my_strdup2(_ALLOC_ID_, &dev, instname); strtolower(dev); + prefix=dev[0]; len = strlen(path) + strlen(dev) + 40; /* some extra chars for i(..) wrapper */ dbg(1, "token=%s, dev=%s param=%s\n", token, dev, param ? param : ""); fqdev = my_malloc(_ALLOC_ID_, len); if(!sim_is_xyce) { - int prefix=dev[0]; int vsource = (prefix == 'v') || (prefix == 'e'); if(path[0]) { if(vsource) { @@ -4340,6 +4341,21 @@ const char *translate(int inst, const char* s) if(idx >= 0) { val = xctx->raw->cursor_b_val[idx]; } + /* special handling for resistors that are converted to b sources: + * i(@r.x4.r1[i]) --> i(@b.x4.br1[i]) + */ + if(idx < 0 && !strncmp(fqdev, "i(@r", 4)) { + if(path[0]) { + my_snprintf(fqdev, len, "i(@b.%sb%s[i])", path, dev); + } else { + my_snprintf(fqdev, len, "i(@b%s[i])", dev); + } + dbg(1, "fqdev=%s\n", fqdev); + idx = get_raw_index(fqdev, NULL); + if(idx >= 0) { + val = xctx->raw->cursor_b_val[idx]; + } + } if(idx < 0) { valstr = "-"; xctx->tok_size = 1; diff --git a/src/xschem.h b/src/xschem.h index a51b4ee9..b79a8215 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1394,7 +1394,7 @@ extern int select_dangling_nets(void); extern void tclmainloop(void); extern int Tcl_AppInit(Tcl_Interp *interp); extern void abort_operation(void); -extern void draw_crosshair(int del); +extern void draw_crosshair(int what); extern void backannotate_at_cursor_b_pos(xRect *r, Graph_ctx *gr); extern int callback(const char *winpath, int event, int mx, int my, KeySym key, int button, int aux, int state);