Skip to main content

Posts

Recent posts

Remove Stray Repeated Spaces from a String

      #!/bin/sh # the next line restarts using tclsh \ exec tclsh "$0" "$@" package require -exact Gnocl 3.24 set str "\tAbc  def  ghi   klm    a. \tYes!   " ## reduce multiple spaces within a string but retain \t, trim all external spaces. # args: str        string to modify # returns:        updated string # proc removeSpaces { str } {     while 1 {         if { [string first "  " $str] == -1 } { break }         set str [string map [list "  " " "] $str]     }     return [string trim $str " "] } puts >[removeSpaces $str]<

Search for Named Icons

      # # return a sorted list of available icons with a name matching search pattern # proc findIcon {pattern} {          # load list of available icons     set contexts [gnocl::icon contexts]     foreach context $contexts {         lappend ICONS $context [lsort [gnocl::icon icons -context $context]]     }              foreach {k v} $ICONS {         foreach i  [lsearch -all -glob $v $pattern ] {             lappend res [lindex $v $i]             }       }     return [lsort $res] }

Simple Tcl/Gnocl based widget message bar.

The gtk api provides it own status bar widget which could be used for embedded widget feedback but this it aimed at being used as part of a application's toplevel window. A complex UI may have several component zone each of which giving its own feedback. This simpler messaging areas provided this capability by making feedback available by directly displaying the contents of global variables rather than pushing items onto a status message stack. if 0 { +-------------------------------------------------------------------------+ | msg0                                      |  msg1   |  msg2   |  msg3   |    +-------------------------------------------------------------------------+ } ## # Simple Tcl/Gnocl based message bar # ref = unique ref  (could be uapp or parent widget-id} # itesm = list of extra field to be displayed in var val tooltip # args = options to be passed to container proc gnocl::messageBar { {ref myapp} {values { {A a Z} {B b Y} {C c X} }} args} {     set bar [gnocl::

Using GnoclOption functions to Return Values for Customised Widget Options.

What to do... Make changes to the widgetFunc function to enable the GnoclOption function for that option to return a value by setting the ret to point ot a TclObj. /* this is a gnocl option handler ?? */ case GNOCL_CGET_NOTHANDLED: { /* cget for gnocl options handled in option function * the caveat here is that different widgets with the same option name may act differently, * if this is the case, then would it be more practical to create specific option functions? * (08/09/25) */ Tcl_Obj *ret = NULL; options[idx2].func ( interp, &options[idx2], G_OBJECT ( area ), &ret ); Tcl_SetObjResult (interp, ret); }

Dynamic Allocation of an Array of Strings in C.

   https://www.geeksforgeeks.org/how-to-create-a-dynamic-array-of-strings-in-c/ In C, dynamic arrays are essential for handling data structures whose size changes dynamically during the program’s runtime. Strings are arrays of characters terminated by the null character ‘\0’. A dynamic array of strings will ensure to change it’s size dynamically during the runtime of the program as per the user’s needs. In this article, we will learn how to create a dynamic array of strings in C. Create a Dynamic Array of Strings in C To create a dynamic array of strings in C, we can use the concept of double pointer and dynamic memory allocation. The double pointer is the pointer that stores the memory address of another pointer. We create an array of pointers to characters (i.e. strings) and then store the address of this array in the double-pointer to characters. Each of the pointer to the character is again allocated memory based on the size of the string it is storing. Approach In

Overhaul of widget cget functionality.

The current basis of the cget function for widgets is based upon code written over 20yrs ago and, whilst it works reasonably well for the simple setting of gtk widget properties, support for more complex custom options is hit and miss.   typedef struct GnoclOption_ {     const char *optName;       enum GnoclOptionType type;     const char *propName;     gnoclOptFunc *func;     const char *args;     const char *description;     const char *values;      enum GnoclOptionStatus status;     union {         gboolean b;         gint     i;         gdouble  d;           gchar    *str;           Tcl_Obj  *obj;           } val; } GnoclOption;   With the recent updating of the C sources which includes an expansion of the GnoclOption structure to accommodate documentation support, it well worth reviewing the way in which widget functions handle the return of options. Rather than treating the retrieval of properties set by a function as the final call, perhaps it should be prioritized.