Sunday, January 10, 2021

Autocorrection, string swapping and balancing quotations in gnocl::text widgets.

Although the basic GtkTextView is a lightweight plain vanilla text editing widget, it can be spiced up to do more interesting things, operations that would normally be expected in a word processing application. It is possible to embed such larger editors into a Gtk window, and the legacy binding to the Abiwidget is an example of that. Using such objects comes with the caveat that the widget is effectively an app within an app, rather than a component.

The gnocl::text object has three options, -balanceQuotes, -swap and -corrections which pushes the uses of the widget towards creative writing rather than just editing a simple text file. 

All three options work in connection with the widget's 'key-release-event' signal to analyse the text buffer contents adjacent to the insert cursor. Setting the -balanceQuotes option to 1 will result in the any " or ' becoming modified to single or double open quotes dependent upon leading or trailing characters. It also enables the correct insertion of apostrophe's in the creation of English possessives.

The -swap option accepts an even list of char mappings resulting in substitution taking place at the point of insertion. Although IBUS allows switching between input methods, and character map applications allow specific glyphs to be inserted, these can be cumbersome or inconvenient. Character mapping allows convenient changes to be made by the user, during runtime.

At a more targeted way -corrections options allows whole words to be swap whist typing. This is useful to ensure the correct application of cumbersome to remember diacritics or where an acronym or abbreviation can be fully expanded.

For example:

$txt configure -balanceQuotes 1

$txt configure -swap {
        aa ā
        ii ī
        ^o ô
        ;s ś
        .h ḥ }
 

$txt configure -corrections {
        maha māha
        mudra mūdra
        Avalokiteshvara Avalôkiteśvara
        prajna prajñā
        AAPP {astasahasrika prajanparamita sutra}
        SDPS {sadharma pundarika sutra}
        }

Other uses for this functionality includes user-defined active spelling checking.


 

Saturday, January 02, 2021

January 2021 Update

From the coding point of view December was a very busy month. Lots of updates in terms of fixes and the introduction of extra functionality. See the notes below. Another useful change was the ability to download stable versions of gnocl directly from the main website.

What, however, will the new year bring? I've already begun the process of integrating support for the canvas into main core, it makes sense, especially if the creation of graphics is needed. Once done, I'll take a look at integrating some the functionality from the other legacy modules. With that done, perhaps its time for a version increment, perhaps to 1.0 at long last!

'Why, hasn't it happened already?' one might ask. In short, all the additional work needed to update the online documentation and creating a comprehensive demonstration application. This is largely done now, especially with the internal help functionality added to the core.

Just to show that the gnocl::canvas is now up and running, here's that old familiar screenshot on 0.9.96.

 
 

   gnocl::selection
      o new command, retrieve currently selected text on display.
    gnocl::button, gnocl::toolbar button
      o -onClicked has new substitution string, %s, the currently selected text.
    gnocl::text
      o some minor bug fixes.
    gnocl::dialog
      o new option -showHelp, tidied up code.
    gnocl::colorSelectionDialog
      o -title now works (can override locale settings)
      o new option -showHelp, show help button,
        OK - returns colours values: R,G,B,a. range 0-65535.
        Cancel - empty string
        Help - returns "HELP"
    Legacy support for deprecated Gtk+ widgets now removed.
    The following have been removed completely from the Gnocl C-sources.
        gnocl::curve
        gnocl::gammaCurve
        gnocl::ruler
    Whereas the following commands will treated as synonymns
        gnocl::about - gnocl::aboutDialog
        gnocl::fileSelection - gnocl::fileChooserDialog
        gnocl::optionMenu - gnocl::comboBox
        gnocl::combo - gnocl::comboEntry
    gnocl::fileSelection
      o options -parent and -icon.
    gnocl::scale
      o -data option now works correctly.
    gnocl::inventory
      o crash fixed.
    gnocl::fileChooserButton
      o -onFileSet %F substitution string changed to %u.
    gnocl::folderChooserButton
      o -onFolderSet now works, responds to "selection-changed" signal.
    gnocl::fontButton
      o new option -borderwidth
    gnocl::colorButton
      o new option -borderwidth

Monday, December 07, 2020

December News


 

 

 

 

 

Only a couple of updates to the code this month. 

 

 gnocl::toggleButton
 new option -iconSize, set to one of: menu, small, large, button, dnd or dialog.

gnocl::button
 -iconSize now works properly, set to one of: menu, small, large, button, dnd or dialog.

gnocl::image
 new command size, returns size of a valid image file.

gnocl::font renamed to gnocl::pangoFont
convert pango font string to valid Tcl tagged list.



Tuesday, November 03, 2020

gnocl::sticky - a minimal borderless window

 

Sometimes you just want to drop a small toolbar or widget holder on screen without all the decorations and controls. This code minimal minimal object is about as simple as it gets. 


proc gnocl::sticky { {orientation "horizontal"} } {
    if { [lsearch "vertical horizontal" $orientation] == -1 } { 
      return -code error \
      "Error! \"$orientation\" should be one of vertical or horizontal (default."  
    }   
    set box [gnocl::box -orientation $orientation \-borderWidth 0 -padding 0]
    set wid [gnocl::window -decorated 0 -child $box -height 25 -width 25]
    if { $orientation == "vertical"} { set tmp height} else {set tmp width}
    set eBox [gnocl::eventBox -borderWidth 0 -${tmp}Request 5 -background black]
    $eBox configure \
        -onButtonPress { %w configure -data "%x %y" -background red} \
        -onButtonRelease { %w configure -data "%x %y" -background black } \
        -onMotion { %t_ configure -x [expr %X - [lindex %d 0]] -y [expr %Y - [lindex %d 1]] }
    $box add $eBox -fill 1 -expand 0
    rename $wid ${wid}_
    # overload the basic window object
    proc $wid { cmd args } {      
        set wid [lindex [::info level 0] 0]   
        switch $cmd {
            remove -
            add { [${wid}_ cget -child] $cmd {*}$args }
            default { ${wid}_ $cmd {*}$args }
            }
    }
    return $wid
}

Sunday, November 01, 2020

October News


 

 

Just a few updates:


    gnocl::fixed
       o new option for move command, -align {x y} ; pair of floats (0-1.0) for positioning
    gnocl::pixBuf
       o new command getOrientation, returns either portrait or landscape
    gnocl::pointer
       o new command, get returns pointer screen x y coordinates
    gnocl::window
       o pointer command now has -screen option to return screen coordinates
    gnocl::toolBar
       o -iconSize and -style configure and cget fixed.
    gnocl::text
       o -shadow option now works properly (applied to scrolled window container).
       o search now has new option -wholeword <boolean> ; select between wholewords (1) and substring (0, default)
    gnocl::callback
        o new subcommands, prepend and append. Extend widget signal callback scripts.

Monday, October 19, 2020

September updates:


 

A  little late in the offering, but a few enhancements were made to the core options since the last posting.


2020-09:

gnocl::window
        o -icon option now recognizes %# (stock item) %/ (file) and %? (buffer) percent strings.


2020-08:
    gnocl::notebook
        o new command: getLabel
    gnocl::toolbar
        o new option: -widthGroup.

Friday, August 28, 2020

August News

A bit late, but a couple of updates in July. The text search applying to whole words may present some issues where pattern matching on sub-strings was used. A later version may see the introduction of a -subString option.

 2020-07:
    gnocl::label
        o new options: -editable, boolean. Use in conjunction with the edit command.
         -onEnter, -onLeave, allows reaction to potential label rollover effects.
    gnocl::text
        o search will now ignore word embedded search patterns, i.e. search whole word only.

json_shell_utils.tcl