shtmlview(n) 0.9.1 shtmlview "basic html viewer widget"

Name

shtmlview - text widget with basic support for html markup rendering

Table Of Contents

Synopsis

Description

The shtmlview::shtmlview package provides the shtmlview::shtmlview widget which is a standard tk text widget with support for rendering a reasonable subset of html tags. It is tought as a fallback widget in cases where no other possibilities exists to display html markup inside a Tk application. It can be also used a help viewer or in other cases where the developer has control about the used html tags. Comments and feedbacks are welcome. The shtmlview::shtmlview widget overloads the text widget and provides new commands, named back, browse, dosearch, forward, home, open, reload, url and new options, named -browsecmd, -home, -tablesupport, -toolbar

The ::shtmlview::shtmlview command creates creates a new window (given by the pathName argument) and makes it into ::shtmlview::shtmlview widget. The ::shtmlview::shtmlview command returns its pathName argument. At the time this command is invoked, there must not exist a window named pathName, but pathName's parent must exist.

::shtmlview::shtmlview is a pure Tcl/Tk widget based on the library htmllib developed in the 90ties by Stephen Uhler and Clif Flynt. This library was wrapped into the excellent mega-widget framework snit by Robert Heller in 2009. His widget however was tied directly into a help system. The author of this document just isolated the display part and added some functions such as changing font size and a few buttons in the toolbar. Also a rudimentary display of data tables was added.

An ::shtmlview::shtmlview widget is not a web-browser. It can be used in cases where the developer has control over the used subset of HTML markup or as a fallback mechanism where no other possibilities exists to display html documents. The API described in this document is not the whole API offered by the snit object ::shtmlview::shtmlview. Instead, it is the subset of that API that is expected not to change.

Installation

The shtmlview::shtmlview package is delivered as a tcl module file which simplifies installation of tcl libraries as single files. Just copy the shtmlview directory somewhere and add the parent library of the shtmlview folder to your Tcl module path. Let's assume that the shtmlview folder is inside /path/to/folder . Then the following should work:

tcl::tm::path add /path/to/folder
package require shtmlview::shtmlview

COMMANDS

::shtmlview::shtmlview pathName ?options?

Creates and configures a shtmlview widget.

WIDGET COMMANDS

Each shtmlview widget created with the above command supports the following commands and options:

pathName back

Displays the previous htmlpage in the browsing history if any.

pathName browse filename

Displays the htmlpage given by filename.

pathName dosearch string direction

Search and hilights the given string from the current index either in the given direction either forward (default) or backwards.

pathName forward

Displays the next htmlpage in the browsing history if any.

pathName getTextWidget

This commands returns the internal pathname of the text widget. The developer can that way thereafter deal directly with the internal text widget if required. Alternatively the helptext command can be used. See below.

pathName helptext cmd ?options?

This command exposes the internal text widget. See the following example:

    ::shtmlview::shtmlview .help 
    .help browse index.html
    .help helptext configure -background yellow
pathName home

Displays the first htmlpage which was called by pathName browse or set by -home.

pathName open

Displays a standard file dialog to open a htmlpage to be displayed in the shtmlview::shtmlview widget.

pathName reload

Reloads and redisplays the current htmlpage visible inside the shtmlview::shtmlview widget.

pathName url

Returns the current URL displayed in the ::shtmlview::shtmlview widget.

WIDGET OPTIONS

To configure the internal text widget the helptext command courld be used directly.

-browsecmd cmd

Each time a htmlpage is rendered the given -browsecmd is invoked. The actual URL is appended as first argument to the command.

-home string

Set's the homepage filename of the shtmlview widget. If not set, the first page browsed will be automatically set as the home page.

-tablesupport boolean

If true (default) the widget will provide some table support. This will have some undesired results if table tags are misused as markup tool. Simple html tables with th and td tags should display however well if no internal markup inside those tags is implemented.

-toolbar boolean

If true (default) a toolbar will be displayed on top providing standard buttons for methods back, forward and home as well as search facilities for the widget.

BINDINGS FOR THE WIDGET

The widget contain standard navigation key bindings to browse the content of an html page. Furthermore the keypress s and r are bound to the start of forward and reverse searches in the content. The keys b and f are bound to browsing forward and backward in the browse history.

EXAMPLE

    package require Tk
    package require shtmlview::shtmlview
    proc browsed {url} {
        puts "You browsed $url"
    }
    set help [::shtmlview::shtmlview .help -toolbar true  -browsecmd browsed]
    $help browse index.html
    pack $help -fill both -expand true -side left

Further examples are in the source package for shtmlview::shtmlview.

Thanks

Stephen Uhler, Clif Flynt and Robert Heller.

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such to the author of this package. Please also report any ideas for enhancements you may have for either package and/or documentation.

Code Copyright

BSD License type:

Sun Microsystems, Inc. The following terms apply to all files a ssociated with the software unless explicitly disclaimed in individual files.

The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply.

IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

RESTRICTED RIGHTS: Use, duplication or disclosure by the government is subject to the restrictions as set forth in subparagraph (c) (1) (ii) of the Rights in Technical Data and Computer Software Clause as DFARS 252.227-7013 and FAR 52.227-19.

See Also

text

Keywords

html, text, widget