~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/TCLwidgets/tw_svalue.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2   tw_svalue.c
  3 */
  4 #include <stdio.h>
  5 #include <tina/sys.h>
  6 #include <tcl.h>
  7 #include "tclWt.h"
  8 #include "tclWtPro.h"
  9 
 10 
 11 static void svalue_call(Tw_callback *twc)
 12 {
 13 }
 14 
 15 
 16 static void svalue_cmnd(Tw_callback * twc, char *args)
 17 {
 18         void (*set) () = (void (*)()) twc->data2;
 19         char   string[256];
 20 
 21         (void) sscanf(args, "%*s %s", string);
 22         (*set) (string);
 23 }
 24 
 25 
 26 static void svalue_prnt(FILE * fp, Tw_callback * twc)
 27 {
 28         char    (*get) () = (char (*) ()) twc->data1;
 29 
 30         (void) fprintf(fp, "%s %s\n", twc->name, (*get) ());
 31 }
 32 
 33 
 34 static char *ttcl_writetrace_svalue(ClientData cdata, Tcl_Interp * interp,
 35                                                                                                                                                 char *name1, char *name2, int flags)
 36 {
 37         Tw_callback *twc = (Tw_callback *) cdata;
 38         void (*set) () = (void (*)()) twc->data2;
 39         char *tclvalue;
 40 
 41         tclvalue = Tcl_GetVar2(interp, name1, name2, flags);
 42 
 43         if (!tclvalue)
 44                 return ("variable update failed");
 45 
 46         (*set)(tclvalue);
 47 
 48         return (NULL);
 49 }
 50 
 51 
 52 static char *ttcl_readtrace_svalue(ClientData cdata, Tcl_Interp * interp,
 53                                                                                                                                          char *name1, char *name2, int flags)
 54 {
 55         Tw_callback *twc = (Tw_callback *) cdata;
 56         char *(*get) () = (char *(*)()) twc->data1;
 57 
 58         if (!Tcl_SetVar2(interp, name1, name2, (*get)(), flags))
 59                 return ("variable update failed");
 60         return (NULL);
 61 }
 62 
 63 
 64 Tw_callback *tw_svalue(char *name, char *(*get) ( /* ??? */ ),
 65                                                                                          void (*set) ( /* ??? */ ), int nchars)
 66 {
 67         Tcl_Interp *interp;
 68         Tw_callback *twc;
 69         char *fullname = tw_extend_fullname(tw_get_toolname(), name);
 70         char *tclname;
 71 
 72         if ((interp = ttcl_get_interp()) == NULL)
 73                 return;
 74 
 75         twc = tw_callback_make(fullname, NULL, svalue_call, svalue_cmnd,
 76                                                                                                  svalue_prnt, (void (*)()) get, (void (*)()) set,
 77                                                                                                  NULL);
 78 
 79         tclname = ttcl_mkshellname(fullname, TTCLSVALUE);
 80 
 81         Tcl_SetVar(interp, tclname, (*get)(), 0);
 82 
 83         Tcl_TraceVar(interp, tclname, TCL_TRACE_WRITES, ttcl_writetrace_svalue,
 84                                                          (ClientData) twc);
 85         Tcl_TraceVar(interp, tclname, TCL_TRACE_READS, ttcl_readtrace_svalue,
 86                                                          (ClientData) twc);
 87 
 88         rfree(tclname);
 89         return (twc);
 90 }
 91 
 92 
 93 void tw_svalue_reset(Tw_callback * twc)
 94 {
 95 }
 96 
 97 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.