
The output of the program is shown in the figure.
Output of file_browser.c
We use the convenience routine XmCreateScrolledText() to create a ScrolledText area. We specify that the
Text widget displays 12 lines by 70 columns of text by setting the XmNrows and XmNcolumns resources. These
settings are used only at initialization. Once the application is up and running, the user can resize the window and
effectively change those dimensions.
The XmNeditable resource is set to False to prevent the user from editing the contents of the Text widget. Since
we do not provide a way to write changes back to the file, we don't want to mislead the user into thinking that the file
is editable. Since a noneditable Text widget should not display an insertion cursor, we remove it by setting
XmNcursorPositionVisible to False.
The FileSelectionDialog is created and managed when the user selects the Open button from the File menu. The user
can exit the program by selecting the Exit button from this menu. The read_file() routine is activated when the
user presses the OK button in the FileSelectionDialog or enters RETURN in the TextField widget. This function gets
the specified file and checks its type. If the file chosen is not a regular file (e.g., if it is a directory, device, tty, etc.) or
if it cannot be opened, an error is reported and the function simply returns. If you are unfamiliar with the use of the