Monday, February 28, 2022

Switching between IBUS input methods....

Its great having the input method controller embedded into the Gnome taskbar so that input methods can be changed when moving between input windows using a keyboard command sequence. It would be useful too, if its was possible to keep tabs on what language is supposed to be used in a text widget and have the Tcl script switch input methods automatically. Here's how to do it...




# !/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require Gnocl

set chn [gnocl::text]
set skt [gnocl::text]
set vb [gnocl::vBox]

$vb add $chn -fill 1 -expand 1
$vb add $skt -fill 1 -expand 1

gnocl::window -child $vb -setSize 0.4

$chn configure \
-onFocusIn  { eval exec "ibus engine pinyin"} \
-onFocusOut { eval exec "ibus engine xkb:gb:extd:eng" }

$skt configure \
-onFocusIn  { eval exec "ibus engine m17n:sa:IAST" } \
-onFocusOut { eval exec "ibus engine xkb:gb:extd:eng" }



Friday, February 25, 2022

Using Tcl to trace changes to array variables

 
The Tcl trace command can be used to respond to changes to variables occur, these changes are array, read, write and unset. 


When one of these events occurs, a sub-script is execute and a number of values passed to it. In the case of an array operation, these are the array name, the member, and the operation.

Following this it is then possible, with a bit of string splicing, to obtain the value of the value of the changed array member.

Example:


proc AAA {args} {
    lassign $args a b c
    puts [set ${a}($b)]    
    }


trace add variable ::conze::editor::block write AAA
set ::conze::editor::block(::gnocl::_WID26_,start) 5


Thursday, February 24, 2022

Slow startup of Gnocl based applications in Ubuntu 20.4

 The recent changes to the Ubuntu 20.4 deployment sometimes sees slow startup times of between 25-60secs. Thankfully someone has solved the problem. I've downloaded the module and it works for me.


https://itsfoss.community/t/solved-apps-opening-too-slow-in-ubuntu-20-04/4578/2

With help from a teammate in investigating the common problem with our apps, he discovered a cure by installing the deprecated gtk2 library module. Available in the 20.04 distro.

All you need to do is to run this command:

sudo apt install appmenu-gtk2-module

and then rebooting. You need to reboot to get the new library working.

This allows older applications based on the older menu API to function normally. Solved the issue with Boinc Manager and GKrellm config menu.

Ref: https://launchpad.net/ubuntu/bionic/+package/appmenu-gtk2-module 478

Saturday, February 05, 2022

Creating Empty Lists

Just what it 'says on the tin', create a list of empty strings.

 

proc emptyList {n} {
    for {set i 0} {$i < $n} {incr i} { lappend res {} }
    return $res
}