shtmlview - text widget with basic support for html markup rendering
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.
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
Creates and configures a shtmlview widget.
Each shtmlview widget created with the above command supports the following commands and options:
Displays the previous htmlpage in the browsing history if any.
Displays the htmlpage given by filename.
Search and hilights the given string from the current index either in the given direction either forward (default) or backwards.
Displays the next htmlpage in the browsing history if any.
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.
This command exposes the internal text widget. See the following example:
::shtmlview::shtmlview .help .help browse index.html .help helptext configure -background yellow
Displays the first htmlpage which was called by pathName browse or set by -home.
Displays a standard file dialog to open a htmlpage to be displayed in the shtmlview::shtmlview widget.
Reloads and redisplays the current htmlpage visible inside the shtmlview::shtmlview widget.
Returns the current URL displayed in the ::shtmlview::shtmlview widget.
To configure the internal text widget the helptext command courld be used directly.
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.
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.
Stephen Uhler, Clif Flynt and Robert Heller.
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.
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.
text
html, text, widget
Copyright © 2018-2020, Detlef Groth <detlef@dgroth.de>
Copyright © 1995-1999, Stephen Uhler
Copyright © 2000, Clif Flynt
Copyright © 2009, Robert Heller