Wednesday, July 20, 2011

gnocl::text now supports pango markup

Spent some time today looking at how to implement the rendering Pango markup strings in the gnocl::text widget. Found a module in the StarDict app that was exactly what was needed! It took a couple of minutes to added it to the gnocl sources, modify the makefile text.c module.

Screenshot:




Test script.

# test-text-pango.tcl
#!/bin/sh
#\
exec tclsh "$0" "$@"

package require Gnocl

set pango_string(0)  {%<<span foreground="blue">Hello</span> <span foreground="red">World</span>}
set pango_string(1)  {<span foreground="blue">Hello</span> <span foreground="red">World</span>}
set pango_string(2)  {%<<span foreground="blue">Hello</span> <span foreground="red">World</span>}

set txt [gnocl::text]
gnocl::window -child $txt -width 600 -height 150

# the string is parse, and the leading %< stripped
$txt insert end $pango_string(0)\n
$txt insert end $pango_string(1)\n
$txt insert end $pango_string(2)

No comments: