Class ::tycho::HTML


Inherits: ::tycho::Edit - Related constructs - Source File - Contents: itk_options - public methods - public proc - protected methods - protected variable
This widget parses HTML using the library by Stephen Uhler and displays it in a Tk text widget. Only local file accesses are currently supported (no HTTP, FTP, etc). The HTML source can be specified using the -data option or indirectly using the -file option. If the HTML will have references to other files (such as image files) that are relative, then the reference directory should be specified using the -directory option if the -data option was used. Otherwise, the directory is inferred from the -file option.

Itk_options

-directory
The directory for relative references to images and the like,.
-size 2
The size of normal text will be 14 points plus the size adjustment set with this option.

Public constructs

Public Methods

altFile
Query the user for a filename, and if the selected file has the extension ".html", ".htm", or "htl", insert its contents in place of the currently displayed HTML. Otherwise, view its contents in a new window.
appletViewer
Start up appletviewer on the current file.
back
Go back to the previous view, popping it off the stack.
clear
Clear the current text.
execTcl x y
Execute the Tcl code under the "current" mark. The Tcl code is simply the largest contiguous region of text tagged "tcl". The code is executed in the global scope, and the result is displayed.
help
Open a help window.
hyperJump filename {point {}} {push 1}
Open a file and go to its internal point identified by name. If the filename has the extension ".html", ".htm", or "htl", and this window is inside a Displayer object, then open it in this same window. If the filename is the empty string, then move the view to a location within the same file. If filename is relative (does not begin with "/", "~", or "$"), then prepend the directory of the file currently being viewed. Then, expand the filename using ::tycho::expandPath and open the resulting file with ::tycho::File::openContext, which will choose an editor based on the filename extension. Finally, invoke seeFragment to view the specified point within the file. The format for the point argument depends on the type of file being opened. For HTML files, it will normally be the name of an anchor in the file or specified "yview" location within the file. For text files, it will normally be either "{line linenumber}" or "{range start end}", where start and end have the form linenumber.characternumber. If the third argument, which is optional, has value 0, then the jump is not recorded for backtracking.

NOTE: This method really should support the syntax "filename#fragment" in the filename argument. Someday.

insertData data
Insert the specified data, cancelling any previous rendering.
isRendering
Return 1 if rendering is in progress, and 0 otherwise.
lastDirectory
Return the directory for relative references to images and the like.
linkEnter xpos ypos
Display the link destination in the status bar for the link below the specified mouse position.
openSource
Open the source file using an editor specialized for editing HTML.
print
Print the selection or, if there is no selection, the entire contents. At the moment, this first warns the user that it is not fully implemented, querying him or her to see whether to proceed. Then, it queries the user for the print command to use. A temporary file is created and then deleted to do the printing. The name of that file will be appended to the end of the command specified by the user before it is invoked.
raiseWindow
Raise this window and also the source window, if it is open.
reload
Reload from the last saved version of the current file. This method first disables read-only status (if it is set), then replaces the current data with data from the current file, and then sets read-only status. The data is marked unmodified after loading the file, and the clipboard is restored to its form prior to the reload. The actual replacement of the data occurs via the method insertData.
seeFragment point
Goto the specified hypertext reference, line number, or range. The point argument can take any of three forms:
   {line linenumber}
   {range startindex endindex}
   {yview fraction}
   name
In the first three forms, the point is a list beginning with the keyword "line", "range", or "yview". If the point has neither of these forms, then it is interpreted as the name of named anchor in the HTML file. In all cases, the background color of the matching text is changed temporarily. Notice that this will not be visible if the "range" form is used and the two indices are equal. As a side effect, the selection (if there is one) is cleared.
setRendering val
Indicate whether rendering is currently in progress.
stopRendering
Stop the rendering. This simply disables the HMrender proc by setting a flag that causes HMrender to return immediately without doing anything.
textWinName
Return the full path name of the text widget. Note that this path name is defined as a command at the global scope. This is intended only to be used for interfacing to legacy Tcl/Tk code that interacts directly with a Tk text widget. A null string is returned if for some reason the text window name does not exist (due to an error in construction).
windowMenuAddAll label
Add me to the window menus of all open File objects. This is redefined in order to coordinate the source window, which may be open.
windowMenuRemoveAll filename
Remove a filename from the window menus of all open File objects. This is redefined in order to coordinate the source window, which may be open.

Public Proc

render obj {html {}}
Render the given HTML text in the given HTML window. If the given HTML text is not given or is a null string, then use the value of the -data option for the given object as the text. This is a procedure rather than a method because the object it operates on may be destroyed during the rendering process. It should be invoked in the background, using "after", not in the constructor! Otherwise, the constructor does not complete until rendering is finished. Moreover, the "update" calls in the rendering are dangerous in a constructor.

Protected constructs

Protected Methods

preference mode args
Access the preferences associated with this widget. This method overrides the default method in ::tycho::TWidget to access the "viewhtml" preferences.
configureContextMenu
Configure the popup menu according to context. For HTML viewers, this looks for a corresponding itcl file and offers to open that if it finds one.

Protected Variable

isrendering 0
Indicate whether a rendering operation is in progress.

Index of classes