"xschem getprop text xxx ...": allow "xxx" to be the name attribute in addition of the text index number

This commit is contained in:
stefan schippers 2026-01-28 12:34:09 +01:00
parent 5365da9239
commit 6d86b73c81
2 changed files with 31 additions and 9 deletions

View File

@ -853,7 +853,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
return result of get_cell_w_ext function </pre>
<li><kbd> get_fqdevice instname param modelparam</kbd></li><pre>
get the full pathname of "instname" device
modelparam:
modelparam:
0: current, 1: modelparam, 2: modelvoltage
param: device parameter, like ib, gm, vth
set param to {} (empty str) for just branch current of 2 terminal device
@ -899,8 +899,9 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
Get attribute 'attr' of rectangle number 'num' on layer 'layer'
getprop text num attr
Get attribute 'attr' of text number 'num'
if attribute is 'txt_ptr' return the text
Get attribute 'attr' of text number 'num', 'num' can also be the name attribute
of the text object
if 'attr' is 'txt_ptr' return the text string
getprop wire num attr
Get attribute 'attr' of wire number 'num'
@ -947,7 +948,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
Highlight instance 'inst'
if '-fast' is specified do not redraw
'inst' can be an instance name or number </pre>
<li><kbd> hilight_netname [-fast] net </kbd></li><pre>
<li><kbd> hilight_netname [-fast] net</kbd></li><pre>
Highlight net name 'net'
if '-fast' is given do not redraw hilights after operation </pre>
<li><kbd> image [invert|white_transp|black_transp|transp_white|transp_black|write_back|</kbd></li><pre>
@ -1140,7 +1141,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
will create the netlist in different places.
netlisting directory is reset to previous setting after completing this command
If -messages is given return the ERC messages instead of just a fail (1)
or no fail (0) code.
or no fail (0) code.
If -erc is given it means netlister is called from gui, enable show infowindow
If -nohier is given netlist only current level
If -keep_symbols is given no not purge symbols encountered traversing the
@ -1695,7 +1696,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> unselect_all [draw]</kbd></li><pre>
Unselect everything. If draw is given and set to '0' no drawing is done </pre>
<li><kbd> unselect_attached_floaters</kbd></li><pre>
Unselect objects (not symbol instances) attached to some instance with a
Unselect objects (not symbol instances) attached to some instance with a
non empty name=... attribute </pre>
<li><kbd> update_all_sym_bboxes</kbd></li><pre>
Update all symbol bounding boxes </pre>

View File

@ -51,6 +51,22 @@ void statusmsg(char str[],int n)
}
}
static int get_text(const char *s)
{
int i, found=0;
if(isonlydigit(s)) {
i=atoi(s);
found = 1;
} else for(i=0;i<xctx->texts; ++i) {
if(!strcmp(get_tok_value(xctx->text[i].prop_ptr, "name", 0), s)) {
found=1;
break;
}
}
if(!found || i < 0 || i >= xctx->texts) return -1;
return i;
}
static int get_symbol(const char *s)
{
int i, found=0;
@ -1952,8 +1968,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
* Get attribute 'attr' of rectangle number 'num' on layer 'layer'
*
* getprop text num attr
* Get attribute 'attr' of text number 'num'
* if attribute is 'txt_ptr' return the text
* Get attribute 'attr' of text number 'num', 'num' can also be the name attribute
* of the text object
* if 'attr' is 'txt_ptr' return the text string
*
* getprop wire num attr
* Get attribute 'attr' of wire number 'num'
@ -2073,7 +2090,11 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_SetResult(interp, "xschem getprop text needs <n> <token>", TCL_STATIC);
return TCL_ERROR;
} else {
int n = atoi(argv[3]);
int n = get_text(argv[3]);
if(n < 0) {
Tcl_AppendResult(interp, "xschem getprop: text object not found:", argv[3], NULL);
return TCL_ERROR;
}
if(!strcmp(argv[4], "txt_ptr"))
Tcl_SetResult(interp, xctx->text[n].txt_ptr, TCL_VOLATILE);
else