From d83acf710da9a09ef24e7dcaf0480631d067f715 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 24 Oct 2023 18:47:58 +0200 Subject: [PATCH] add `xschem text_string` command, update displayed floaters if a text object is changed --- doc/xschem_man/developer_info.html | 8 ++++++-- src/editprop.c | 12 +++++++----- src/scheduler.c | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index 25d47c05..0afa86ae 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -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.1 0.0 1.5 0.6 ... ... ... ... +
  • test
  • +   Testmode ... 
  • text x y rot flip text props size draw
  •     Create a text object
          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
          size sets the size
          draw is a flag. If set to 1 will draw the created text 
    +
  • text_string n
  • +   get text string of text object 'n' 
  • toggle_colorscheme
  •     Toggle dark/light colorscheme 
  • toggle_ignore
  • @@ -1382,8 +1388,6 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
     
     
     
    -
    -
     
     
     
    diff --git a/src/editprop.c b/src/editprop.c
    index 4cb95d8c..064b966a 100644
    --- a/src/editprop.c
    +++ b/src/editprop.c
    @@ -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 */
       /* const char *str; */
       char *oldprop = NULL;
    +  int floater = there_are_floaters();
     
       if(x < 0 || x > 2) {
         fprintf(errfp, "edit_text_property() : unknown parameter x=%d\n",x);
    @@ -1230,7 +1231,8 @@ static int edit_text_property(int x)
           modified = 1;
           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;klastsel; ++k)
         {
           if(xctx->sel_array[k].type!=xTEXT) continue;
    @@ -1249,7 +1251,7 @@ static int edit_text_property(int x)
             cairo_restore(xctx->cairo_ctx);
           }
           #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")); */
           if(text_changed) {
             double cg;
    @@ -1323,11 +1325,11 @@ static int edit_text_property(int x)
           }
           #endif
     
    -      bbox(ADD, xx1, yy1, xx2, yy2 );
    +      if(!floater) bbox(ADD, xx1, yy1, xx2, yy2 );
         } /* for(k=0;klastsel; ++k) */
    -    bbox(SET,0.0,0.0,0.0,0.0);
    +    if(!floater) bbox(SET,0.0,0.0,0.0,0.0);
         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);
       return modified;
    diff --git a/src/scheduler.c b/src/scheduler.c
    index e38a5e24..66dcad5a 100644
    --- a/src/scheduler.c
    +++ b/src/scheduler.c
    @@ -4590,6 +4590,23 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
           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 dark/light colorscheme */
         else if(!strcmp(argv[1], "toggle_colorscheme"))