Inherits:
::tycho::ListBrowser
-
Related constructs -
Source File -
Contents:
public methods
- public procs
- protected methods
- protected variable
- protected commons
This file browser displays a list of the files in the current
directory, permitting the user to select a file or directory by
clicking or by typing the name in an entry box. File completion (only
in the current directory) is supported via the Tab key, as is
glob-style pattern matching. The file browser has a "Help" button and
a "New Directory" button. When the user selects a directory, the
listbox is normally updated to reflect the contents of that
directory. However, if a Tycho editor has been registered by
contents, extension, or name, then that editor is invoked instead
(see the register commands in the File class). When the user has
selected a file, the file browser self-destructs. If the -command
option is specified, then the value of the option is taken as a
command to execute before self destructing. The filename selected by
the user (with the complete path, and which may represent a file that
does not exist) is appended to the command as an argument.
For example, the following command will query the user for a file name,
and then post that filename in top-level window:
::tycho::FileBrowser .w -command ::tycho::post
.w centerOnScreen
The FileBrowser
class maintains its own notion of the
current working directory that is not necessarily the same as the
current working directory of the Tcl interpreter. Each instance of
the FileBrowser
updates this when the user selects a new
directory. If multiple file browsers are open at once, they navigate
the file system independently. But the most recently selected
directory will then be the default directory of any newly created
file browser.
For information about the difference between Unix, Mac and Windows filenames
see the tcl filename documentation. In the Itcl2.2 distribution, this
file is at itcl2.2/tcl7.6/doc/filename.n, and is in Unix Man page format.
Public constructs
-
help
- Open a help window.
-
mkdir
- Make a new directory and list its contents in the list box.
Also, make this new directory the common working directory.
-
setCWD
cwd
- Set the global current working directory.
-
setLastFile
name
- Set the global filename that appears by default.
Protected constructs
-
processItem
filename
- Check and process the user selection. If the argument is the name of a
file, then the command specified with the -command option is invoked
with that filename as an argument, and a 1 is returned. If the argument
is a directory name, then the listbox is updated with the contents
of the directory and a 0 is returned. If the argument is an
empty string, then nothing is done and a zero is returned. If the
specified filename exists but is not readable, an error is triggered.
If the filename does not exist as either a file or a directory, then
the command given by the -command option is invoked on that file. If
the entry is invalid for some reason, the user is warned and the
method returns 0.
-
updateListbox
- Fill the listbox with filenames. Classify directories and files.
Directories are inserted at the top and are arranged alphabetically.
Files are listed next, also alphabetically.
-
localCWD
- A local version of the CWD is kept in case multiple file browsers
are open at once (each has to have its own notion of the current
working directory).
-
fileLastOpened
- The last file opened.
-
CWD
- The directory last visited.
Index of classes
Author: Edward A. Lee
Contributor: Based on a Tcl/Tk version by Wei-Jen Huang and
Mario Jorge Silva.
Version: @(#)FileBrowser.itcl 1.43 12/15/96
Copyright: (c) 1990-1996 The Regents of the University of California.