Skip to main content

Posts

Showing posts from October, 2021

Converting a Pango Markup Span Tag to a List of Text Widget Tag Options

Its always been a trouble task sharing formatted text between the gnocl::text widget and other display widgets such as the gnocl::label, gnocl::tree and gnocl::list widgets. This diffculty arises from not being able to define text attributes as pango markup, this is understandable given that fact that there is not a smooth overlap between the widget and pango attributes. What was needed was a way of bridging the two requirments, being able to take a markup <span> tag and converting to an -opt val list. Parsing markup strings using the pango api is not terribly helpful, it is complex and only works on complete strings, "<span .... ...>" would simply through up a pango formatting error. The solution has been much simpler by using a series of string mapping operations in the source module with the resul being the creation of a new gnocl::pango subcommand "markup2options". For instance, if:  set markup "<span font='Serif italic bold 24' fore

String and Text Block Insertion Allowing for HTML/Pango String Markup

Tcl offers some really excelling string manipulation tools 'straight out of the box' although sometimes something extra might be needed. What if, for instance, the strings contain markup? Any markup is invisible on screen and so any string positioning needs to ignore the effects of that markup on the overall string length. This can be achieved by using a simple flag to keep track of where characters in a string are containtained within a markup substring or not. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 ## insert str1 into str2 at position pos, allow for pango/html markup # @param[in] str1 # @param[in] str2 # @param[in] pos # @param[in] opt # @return modified string proc string_insert { str1 str2 pos { opt "" } } { switch $opt { -markup { set flag 1 set i 0 set res "" foreach c [ split $str2 "&qu

Recent Changes October, 2021

Most significant change during September was the inclusion of the -spellcheck option for the gnocl::text widget.  2021-09: gnocl::text o new boolean option -spellcheck, cget also works,  gnocl::spellcheck o moved separate code back into the main module gnocl::labelEntry o added substitution strings %X %Y %W %H to -onIconPress/-onIconRelease callback scripts. o cget -variable now works gnocl::calendar o added substitution strings %D %M %Y to -onDoubleDaySelect callback script.