add `xschem text_string` command, update displayed floaters if a text object is changed

This commit is contained in:
stefan schippers 2023-10-24 18:47:58 +02:00
parent 94b43d41ed
commit d83acf710d
3 changed files with 30 additions and 7 deletions

View File

@ -515,6 +515,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
@ -1280,6 +1282,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
0.0 0.0 1.8 0.3 0.0 0.0 1.8 0.3
0.1 0.0 1.5 0.6 0.1 0.0 1.5 0.6
... ... ... ...</pre> ... ... ... ...</pre>
<li><kbd> test</kbd></li><pre>
Testmode ... </pre>
<li><kbd> text x y rot flip text props size draw</kbd></li><pre> <li><kbd> text x y rot flip text props size draw</kbd></li><pre>
Create a text object Create a text object
x, y, rot, flip specify the position and orientation x, y, rot, flip specify the position and orientation
@ -1287,6 +1291,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
props is the attribute string props is the attribute string
size sets the size size sets the size
draw is a flag. If set to 1 will draw the created text </pre> draw is a flag. If set to 1 will draw the created text </pre>
<li><kbd> text_string n</kbd></li><pre>
get text string of text object 'n' </pre>
<li><kbd> toggle_colorscheme</kbd></li><pre> <li><kbd> toggle_colorscheme</kbd></li><pre>
Toggle dark/light colorscheme </pre> Toggle dark/light colorscheme </pre>
<li><kbd> toggle_ignore</kbd></li><pre> <li><kbd> toggle_ignore</kbd></li><pre>
@ -1382,8 +1388,6 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"

View File

@ -1184,6 +1184,7 @@ static int edit_text_property(int x)
char property[100];/* used for float 2 string conv (xscale and yscale) overflow safe */ char property[100];/* used for float 2 string conv (xscale and yscale) overflow safe */
/* const char *str; */ /* const char *str; */
char *oldprop = NULL; char *oldprop = NULL;
int floater = there_are_floaters();
if(x < 0 || x > 2) { if(x < 0 || x > 2) {
fprintf(errfp, "edit_text_property() : unknown parameter x=%d\n",x); fprintf(errfp, "edit_text_property() : unknown parameter x=%d\n",x);
@ -1230,7 +1231,8 @@ static int edit_text_property(int x)
modified = 1; modified = 1;
xctx->push_undo(); xctx->push_undo();
} }
bbox(START,0.0,0.0,0.0,0.0); if(!floater) bbox(START,0.0,0.0,0.0,0.0);
else set_modify(-2); /* clear text floater caches */
for(k=0;k<xctx->lastsel; ++k) for(k=0;k<xctx->lastsel; ++k)
{ {
if(xctx->sel_array[k].type!=xTEXT) continue; if(xctx->sel_array[k].type!=xTEXT) continue;
@ -1249,7 +1251,7 @@ static int edit_text_property(int x)
cairo_restore(xctx->cairo_ctx); cairo_restore(xctx->cairo_ctx);
} }
#endif #endif
bbox(ADD, xx1, yy1, xx2, yy2 ); if(!floater) bbox(ADD, xx1, yy1, xx2, yy2 );
/* dbg(1, "edit_property(): text props=%s text=%s\n", tclgetvar("props"), tclgetvar("retval")); */ /* dbg(1, "edit_property(): text props=%s text=%s\n", tclgetvar("props"), tclgetvar("retval")); */
if(text_changed) { if(text_changed) {
double cg; double cg;
@ -1323,11 +1325,11 @@ static int edit_text_property(int x)
} }
#endif #endif
bbox(ADD, xx1, yy1, xx2, yy2 ); if(!floater) bbox(ADD, xx1, yy1, xx2, yy2 );
} /* for(k=0;k<xctx->lastsel; ++k) */ } /* for(k=0;k<xctx->lastsel; ++k) */
bbox(SET,0.0,0.0,0.0,0.0); if(!floater) bbox(SET,0.0,0.0,0.0,0.0);
draw(); draw();
bbox(END,0.0,0.0,0.0,0.0); if(!floater) bbox(END,0.0,0.0,0.0,0.0);
} }
my_free(_ALLOC_ID_, &oldprop); my_free(_ALLOC_ID_, &oldprop);
return modified; return modified;

View File

@ -4590,6 +4590,23 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp); Tcl_ResetResult(interp);
} }
/* text_string n
* get text string of text object 'n' */
else if(!strcmp(argv[1], "text_string") )
{
int n;
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
if(argc < 3) {Tcl_SetResult(interp,
"xschem text_string requires 1 additional argument", TCL_STATIC); return TCL_ERROR;}
n = atoi(argv[2]);
if(n >= 0 && n < xctx->texts) {
Tcl_SetResult(interp, xctx->text[n].txt_ptr, TCL_VOLATILE);
} else {
Tcl_ResetResult(interp);
}
}
/* toggle_colorscheme /* toggle_colorscheme
* Toggle dark/light colorscheme */ * Toggle dark/light colorscheme */
else if(!strcmp(argv[1], "toggle_colorscheme")) else if(!strcmp(argv[1], "toggle_colorscheme"))