XP(1) XP(1) local NAME xp - print a file in an X window SYNOPSIS xp [ -toolkitoption... ] [ -option... ] [ file... ] DESCRIPTION xp displays the first file in an Athena Text widget and offers a menu whereby each file may be subsequently opened and displayed (in the same window). If no file argument is given, or if the argument `-' is given, xp reads from the standard input. If the standard input is a terminal, input is terminated by an EOF condition. In all cases no output appears until EOF is detected, however if 0 or 1 filenames are given and EOF is detected immediately then xp exits silently. OPTIONS xp accepts all of the standard X Toolkit command line options as well as the following (if the option begins with a `+' instead of a `-', the option is restored to its default value): -c command Commence by executing command. -m Cause searches to look at multiple files, i.e. set resource searchMany true. -i Make searches case insensitive, i.e. set resource caseSensitive false. -w Cause searches not to wrap, i.e set resource searchWrap false. See also the section on RESOURCES. USAGE The files menu is activated by clicking button 2. Clicking on button 1 displays the next file and button 3 the previous. This assignment of mouse buttons is designed to be analogous to that of the scrollbar. The split command button allows two views of the same file to be shown in separate panes. Selecting another file from the files menu leaves the upper pane showing the original file. All commands and actions refer to the lower pane, but you may use the flip command to reverse the contents of the two panes. Though displaying a file in a readonly text widget xp uses the caret as follows: - 1 - Formatted: November 14, 2024 XP(1) XP(1) local a "split" is made just below the caret if possible, searches start from the caret, you can find the number of the line containing the caret, moving through the file via searching or line number sets the caret, and if the current file is re-opened by selecting it from the files menu then xp trys to maintain the old position of the caret - you can use this to see if the file has grown. The input text widget (bottom right) accepts a few ed/vi-like commands. In the following description of the commands the line containing the caret is termed the current line. Commands which set the caret scroll the text to make the caret visible if necessary, and may also centre the new current line. The commands are: nnn Set the caret to the start of line nnn. . Scroll text to centre the current line. .= Output the number of the current line. = Output the number of the lines in the file +nnn Set the caret to the start of the line nnn lines beyond the current line. Remember nnn for subseqent default. =nnn Set the caret to the start of the line nnn lines before the current line. Remember nnn for subseqent default. $ Set the caret to the start of the last line. /RE Forward full regular expression search, from caret, with optional wrap round at eof. Set the selection to the matched text, set the caret to the end of that selection. Use previous RE if RE empty ?RE Backward full regular expression search, from caret, with optional wrap around at start of file. Set the selection to the matched text, set the caret to the start of that selection. Use previous RE if RE empty. ! Execute the rest of the line as a shell command using system(3). xp replaces the character % with the current filename. | Execute the rest of the line as a shell command using popen(3), passing the currently displayed file as standard input. q quit All commands must be terminated by <return>. - 2 - Formatted: November 14, 2024 XP(1) XP(1) local A <return> by itself moves the caret one line on and scrolls forward one line. Note, shell commands may not be executed if xp is invoked with the -display argument or the display resource set. This is a defensive measure allowing one to use xp to display output on someone else's screen without letting them run programs with your user id. REGULAR EXPRESSION SYNTAX A regular expression is zero or more branches, separated by `|'. It matches anything that matches one of the branches. A branch is zero or more pieces, concatenated. It matches a match for the first, followed by a match for the second, etc. A piece is an atom possibly followed by `*', `+', or `?'. An atom followed by `*' matches a sequence of 0 or more matches of the atom. An atom followed by `+' matches a sequence of 1 or more matches of the atom. An atom followed by `?' matches a match of the atom, or the null string. An atom is a regular expression in parentheses (matching a match for the regular expression), a range (see below), `.' (matching any single character), `^' (matching the null string at the beginning of the input string), `$' (matching the null string at the end of the input string), a `\' followed by a single character (matching that character), or a single character with no other significance (matching that character). A range is a sequence of characters enclosed in `[]'. It normally matches any single character from the sequence. If the sequence begins with `^', it matches any single character not from the rest of the sequence. If two characters in the sequence are separated by `-', this is shorthand for the full list of ASCII characters between them (e.g. `[0-9]' matches any decimal digit) To include a literal `]' in the sequence, make it the first character (following a possible `^'). To include a literal `-', make it the first or last character. AMBIGUITY If a regular expression could match two different parts of the input string, it will match the one which begins earliest. If both begin in the same place but match different lengths, or match the same length in different ways, life gets messier, as follows. In general, the possibilities in a list of branches are considered in left-to-right order, the possibilities for `*', `+', and `?' are considered longest-first, nested constructs are considered from the outermost in, and concatenated constructs are considered leftmost- first. The match that will be chosen is the one that uses the earliest possibility in the first choice that has to be made. If there is more than one choice, the next will be made in the same - 3 - Formatted: November 14, 2024 XP(1) XP(1) local manner (earliest possibility) subject to the decision on the first choice. And so forth. For example, `(ab|a)b*c' could match `abc' in one of two ways. The first choice is between `ab' and `a'; since `ab' is earlier, and does lead to a successful overall match, it is chosen. Since the `b' is already spoken for, the `b*' must match its last possibility-the empty string-since it must respect the earlier choice. In the particular case where no `|'s are present and there is only one `*', `+', or `?', the net effect is that the longest possible match will be chosen. So `ab*', presented with `xabbbby', will match `abbbb'. Note that if `ab*' is tried against `xabyabbbz', it will match `ab' just after `x', due to the begins-earliest rule. (In effect, the decision on where to start the match is the first choice to be made, hence subsequent choices must respect it even if this leads them to less-preferred alternatives.) EXAMPLE The shell script: man $@ | col -b | cat -s | xp -i -name "xm:$*" -geometry x40& pops up a manual page in an xp window, 40 lines long with case insensitive searching enabled. TRANSLATIONS xp contains 3 text widgets, two for output only (one of which may not be displayed) and one for command input. To make it easy to input commands without having the input widget (bottom right) take the input focus, and without introducing input modes, default translations are set up such that keyboard input within the output text widgets is redirected to the input widget apart from those standard Text widget translations that refer to vertical motion. Unfortunately those vertical motion must be included in the translations explicitly. It is possible to specify translations which bind keys to arbitrary keyboard input commands eg. *vpaned.Text.translations: #override \n\ Ctrl<Key>E: Cmnd("!xterm -e vi %&")\n\ Ctrl<Key>/: Cmnd(/)\n\ Ctrl<Key>?: Cmnd(?) though the default translations do not do this. RESOURCES xp has the following application specific resources: - 4 - Formatted: November 14, 2024 XP(1) XP(1) local searchWrap (Class SearchWrap) If true (default) then forward regular expression searches wrap around to beginning of file when reaching EOF and likewise for reverse searches. searchMany (Class SearchMany) If true (not the default) then regular expression searches continue across file boundaries. If searchWrap is also true then rather than searches wrapping round at the end of file they wrap round from the end of the last file to the first and vice-versa, for forward and backward searches respectively. caseSensitive (Class CaseSensitive) If true (the default) then regular expression searches are case sensitive. command (Class Command) A command executed initially as if typed into the text input widget (but with no need of a trailing <return> ). setIconName (Class SetIconName) When true (default) causes xp to append the current filename to the xp icon name. setTitle (Class SetTitle) When true (default) causes xp to append the current filename to the xp title. terse (Class Terse) When true (not the default) prevents error message popups. WIDGETS In order to specify resources, it is useful to know the hierarchy of the widgets which compose xp. In the notation below, indentation indicates hierarchical structure. The widget class name is given first, followed by the widget instance name. Xp xp TopLevelShell shell Paned paned Paned vpaned Text textmain Grip grip Text textsplit Grip grip Paned hpaned Command quit MenuButton files - 5 - Formatted: November 14, 2024 XP(1) XP(1) local SimpleMenu filesmenu SmeBSB file1 SmeBSB file2 . . . MenuButton options SimpleMenu optionsmenu SmeBSB wrap word SmeBSB wrap line SmeBSB horiz scroll SmeLine line SmeBSB case insensitive SmeBSB search wrap SmeBSB search many SmeLine line SmeBSB terse Command help Command reopen Toggle split Command flip Text textinput Grip grip TopLevelShell helpshell Paned helppaned Label helplabel Text helptext Command helpdismiss TransientShell errorshell Form errorform Label errorlabel Command errordismiss ENVIRONMENT DISPLAY to get the default host and display number. FILES /usr/lib/X11/app-defaults/Xp - specifies required resources SEE ALSO cat(1), ed(1), egrep(1), X(1) Athena Widget Set AUTHOR Gerry Tomlinson (gerry.tomlinson@newcastle.ac.uk) COPYRIGHT Copyright 1992, The Computing Laboratory, University of Newcastle Upon Tyne ACKNOWLEDGMENTS Regular expression code and description are by Henry Spencer @ U of - 6 - Formatted: November 14, 2024 XP(1) XP(1) local Toronto Zoology, henry@zoo.toronto.edu. They are intended to be compatible with the Bell V8 regexp(3) but are not derived from Bell code. BUGS The regular expression syntax probably doesn't exactly match that of the egrep(1) on your system. Doesn't handle binary files. - 7 - Formatted: November 14, 2024