############################################################################ # # File: browser.icn # # Subject: Program to demonstrate file-navigation "dialog" # # Author: Ralph E. Griswold # # Date: May 4, 1998 # ############################################################################ # # This file is in the public domain. # ############################################################################ # # This program demonstrates the VIB navigation interface. # ############################################################################ # # Requires: Version 9 graphics # ############################################################################ # # Links: navitrix, vsetup # ############################################################################ link navitrix link vsetup global placeholder global vidgets $define LineLength 75 $define FileLength 500 procedure main() local root, root_cur, keyboard_cur nav_init() vidgets := ui() root := vidgets["root"] placeholder := vidgets["placeholder"] repeat { case Active() of { &window : { root_cur := root keyboard_cur := shortcuts } nav_window : { root_cur := nav_root keyboard_cur := nav_keyboard } } ProcessEvent(root_cur, , keyboard_cur) if \nav_state then process_file() } end procedure file_cb(vidget, value) case value[1] of { "find @F" : find_file() "quit @Q" : exit() } return end procedure find_file() WAttrib(nav_window, "canvas=normal") return end procedure process_file() local input, file_list, button static list_vidget, x, y, name_old initial { list_vidget := vidgets["list"] x := placeholder.ax + TextWidth("file: ") y := placeholder.ay + WAttrib("leading") - 2 # ad hoc name_old := "" } WAttrib(nav_window, "canvas=hidden") button := nav_state nav_state := &null if button == "Cancel" then fail input := open(nav_file) | { Notice("Cannot open " || image(nav_file) || ".") fail } file_list := [] every put(file_list, left(entab(!input), LineLength)) \ FileLength VSetItems(list_vidget, file_list) close(input) WAttrib("drawop=reverse") DrawString(x, y, name_old) # update nonterminal display DrawString(x, y, \nav_file | "") WAttrib("drawop=copy") name_old := \nav_file return end procedure shortcuts(e) if &meta then case map(e) of { "f" : find_file() "q" : exit() } return end #===<<vib:begin>>=== modify using vib; do not remove this marker line procedure ui_atts() return ["size=526,402", "bg=pale gray", "label=Browser"] end procedure ui(win, cbk) return vsetup(win, cbk, [":Sizer:::0,0,526,402:Browser",], ["file:Menu:pull::0,3,36,21:File",file_cb, ["find @F","quit @Q"]], ["list:List:r::14,44,500,340:",], ["menubar:Line:::0,26,525,26:",], ["placeholder:Label:::88,7,42,13:file: ",], ) end #===<<vib:end>>=== end of section maintained by vib