File browser

A file browser displays the files in a directory and allows the user to traverse the directories in the file system and select one or more files. Using a FileBrowserVBT consists of the following steps.
  1. Create the file browser with a call like:
    NEW(FileBrowserVBT.T).init()
    
  2. Create a helper and associate it with the file browser. A helper is a type-in field that displays the path name of the directory and allows the user to type new path names. It is created with a call like:
    NEW(FileBrowserVBT.Helper).init(hmargin, vmargin, font, sh)
    
    where hmargin and vmargin are the horizontal and vertical margins from left and top boundaries of the helper's domain where the text of the path name begins, font is the font for the path name and sh is the shadow used by the helper for the background and foreground colors. The helper is associated with the file browser as follows:
    SetHelper(file_browser, helper)
    
  3. Create a directory menu and associate it with the file browser. A directory menu is the list of directories and files in the current directory. A directory menu is created by
    NEW(FileBrowserVBT.DirMenu).init(font, sh)
    
    where font is the font used for the contents of the directory and sh is the shadow whose background and foreground components are used for the foreground and background colors of directory menu. The directory menu is associated with the File Browser by
    SetDirMenu(file_browser, directory_menu)
    
The program Browser.m3 illustrates the use of FileBroswerVBT. In the main body of the program the current directory of the file browser is set by calling FileBrowserVBT.Set. This directory is used to set the initial list of file names displayed by the browser. The appearance of the program while running is captured in the following images: