FFTR/FTR(1) FFTR/FTR(1) NAME fftr - IRIX Interactive Desktop optimized file-type rules compiler ftr - IRIX Interactive Desktop optimized file-type rules compiler SYNOPSIS fftr -o outputFile.otr [ ftrFile | otrFile ] ... ftr -o outputFile.otr [ ftrFile | otrFile ] ... DESCRIPTION fftr is a utility used to compile file-type rule (FTR) files. It creates optimized type rule (OTR) files. The ftr command, a link to the fftr command, does not support the older compiled type rule (CTR) format files anymore. An FTR file contains a list of file-type rules. Each rule describes how a file of a particular type will appear within the IRIX Interactive Desktop and defines what functions the user can perform on the file by double-clicking on it or choosing menu items that manipulate it. (A menu becomes active when an icon is selected; this menu is accessible to the user from both the Selected toolchest and the right mouse button.) A file-type rule also defines the method by which a file is given a type and how files of a particular type are to be printed. Arguments whose names end with `.ftr' are assumed to be FTR files. Arguments whose names end with `.otr' are assumed to be OTR files. Arguments whose names end with `.ctr' are assumed to be CTR files, which are no longer supported in IRIX 6.3 and later releases. The FTR files are compiled and combined with the pre-compiled OTR files. The resulting OTR file is left in the file whose name is given with the -o option. The fftr and ftr commands can compile and combine up to 200 files. There may be only one output file and it must have the suffix `.otr'. The output file must not be also an input file. IRIX 6.5 reintroduces support for personal icons. Users can create FTR files under their $HOME/.desktop-<hostname>/filetype/ directory (where <hostname> is the result of running the hostname(1) command), copy the /usr/lib/filetype/Makefile.personal file to that directory as Makefile, and type "make" to create personal icons. For details, users can view the contents of the Makefile.personal file. For more information about the entire IRIX Interactive Desktop environment, see the IID(1) man page. FTR FILE FORMAT FTR files are made up of lists of TYPE declarations and CONVERT declarations. A TYPE declaration looks like this, where each of the items between triangle brackets <> should be replaced appropriately: TYPE <filetype name> MAP <name space> <value> MATCH <match rule>; LEGEND <human-readable description of the file type> SUPERTYPE <filetype name> SPECIALFILE DROPIF <drop type(s)> CMD OPEN <open shell script> CMD ALTOPEN <altopen shell script> CMD DROP <drop shell script> CMD PRINT <print shell script> MENUCMD "<menu string>" <menu shell script> SETVAR <variable name> <variable value> ICON <icon program>; The TYPE declaration must come first. The <filetype name> declares the name of the file type and is a one-word ASCII string. Legal type names can be any legal C-language variable name. Example TYPE declaration: TYPE Directory All rules that follow a TYPE declaration apply to that type, until the next TYPE declaration or CONVERT declaration is encountered in the FTR file. Each TYPE declaration should have a unique name. The remaining rules (MAP, MATCH, LEGEND, SPECIALFILE, etc.) may appear in any order after the TYPE rule. The MAP rules specify a list of all mappings from the desktop name space to a non-desktop name space. Desktop name space is defined by the TYPE names. One can use the MAP rule to translate from a desktop TYPE to another name space, such as ICCCM. The following keywords are currently defined to indicate various mappings: ICCCM name space: MAP SelectionTarget <ICCCM selection target type> MIME name space: MAP MimeType <Mime type> Macintosh name space: MAP MacTypeInfo <mac type: 4 chars> <mac creator: 4 chars> ICCCM Example: TYPE AIFFSoundFile MAP SelectionTarget AIFF_FILE The MATCH rule is a logical expression that determines whether a particular file is of the declared TYPE. A MATCH rule consists of a C- style logical expression made up of functions and expressions. The following C language operators may be used in a MATCH expression: + - * / & | ^ ! % ( ) The following C-language conditional operators may be used in a MATCH expression: && || == != < > <= >= The == operator works for string comparisons as well as for numerical expressions. The following constants may be used in a MATCH expression: true false True evaluates to the number 1 and false evaluates to the number 0. Numbers in a match expression may be expressed in decimal, octal, or hexadecimal notation. Octal numbers are expressed with a leading zero, such as 0732. Hexadecimal numbers are expressed with a leading `0x' such as 0xf03C. Decimal number are expressed normally, but may not have a leading zero. The following expression functions are available: ascii Returns true if the first 512 bytes of the file are all printable ASCII characters. char(n) Returns the nth byte of the file, as a signed character; range -128 to 127. dircontains("string") Returns true if the file is a directory and contains the file named by string. glob("string") Returns true if the file's name matches string; allows the following expansions in string for pattern matching: { } [ ] * ? and backslash (see sh(1) filename expansion). linkcount Returns the number of hard links to the file. long(n) Returns the signed long integer located at the nth byte of the file; range -2^31 to 2^31-1. mode Returns the mode bits of the file (see chmod(1)). print(expr or string) Prints the value of the expression expr or string to stdout each time the function is evaluated; used for debugging MATCH rules. Always returns true. short(n) Returns the signed short integer located at the nth byte of the file; range -32768 to 32767. size Returns the size of the file in bytes. string(n,m) Returns a string from the file that is m bytes (characters) long, beginning at the nth byte of the file. uchar(n) Returns the nth byte of the file as an unsigned character; range 0 to 255. tag Returns the specific IRIX Interactive Desktop application tag injected into a MIPS executable or shell script by the tag injection tool (see tag(1)). Returns 65535 if the file is not a tagged file. mactype Returns the mac type attribute. It returns a four character long string on success, representing the mac type, and "????" on failure or error. maccreator Returns the mac creator attribute. It returns a four character long string on success, representing the mac creator, and "????" on failure or error. ushort(n) Returns the unsigned short integer located at the nth byte of the file; range 0 to 65535. ulong(n) Returns the unsigned long integer located at the nth byte of the file; range 0 to 2^32-1. Example MATCH rule: MATCH dircontains(".dumpster"); A common mistake with MATCH expressions is to forget the semicolon at the end of the expression. It is required; the ftr compiler will produce a syntax error if it is missing. The LEGEND rule is a human-readable description of the file type. Example LEGEND rule: LEGEND C program source file Legends that are longer than 25 characters may be truncated in some circumstances. Be aware that legends will be presented to users who may not understand computer jargon. The SUPERTYPE rule tells the IRIX Interactive Desktop to treat the file as a subtype of another type. This can be accessed through the isSuper command in the OPEN, ALTOPEN, DROP, and MENUCMD rules. A common use of the SUPERTYPE rule is to check isSuper(Ascii) in an OPEN rule to determine if a file can be used by a simple text editor. The IRIX Interactive Desktop uses SUPERTYPE and isSuper(Directory) to determine if a file is a subtype of the Directory type, in order to handle certain filesystem manipulations correctly. Example SUPERTYPE rule: SUPERTYPE Executable The DROPIF rule tells the IRIX Interactive Desktop to allow only those files to be dropped whose type matches the type names specified in this rule. If they do not match then the drop rule will not get executed. Example DROPIF rule: DROPIF MailFile MailFolder The SPECIALFILE rule declares that a file type is not a plain file. Block and char device nodes, named pipes, directories, and UNIX domain sockets are special files. Special files are not opened by the MATCH rule (described below). The presence of this rule suffices to mark the file type as not a plain file. Example SPECIALFILE rule: SPECIALFILE The CMD OPEN, CMD ALTOPEN, CMD DROP, and CMD PRINT rules determine how an icon behaves when a user interacts with it, whether it is by double- clicking, double-clicking with the Alt key depressed, dragging and dropping another icon on it, or printing it with the menu Print command. The CMD rules consist of a Bourne shell expression which is executed when the user performs the appropriate interaction (double-clicking, drag- dropping, etc.) on the file. Example CMD OPEN rule: CMD OPEN dirview $LEADER $REST Example CMD ALTOPEN rule: CMD ALTOPEN $WINEDITOR $LEADER $REST Example CMD DROP rule: CMD DROP $TARGET $SELECTED Example CMD PRINT rule: CMD PRINT routeprint -t $LEADERTYPE $LEADER $REST The SETVAR rule is used to define a variable specific to the type. It takes two arguments, <variable name>, the name of the variable, and <variable value>, the value of the variable. Legal variable names can be any legal C-language variable names. These variables can be used by either the desktop or some other application. Currently, two variables are defined and recognized this way by the desktop. The noLaunchEffect variable, when set to True, turns off the visual launch effect for that icon type. The noLaunchSound variable, when set to True, turns off the launch sound for the specified type. Example SETVAR rule: SETVAR noLaunchEffect True disables the visual launch effect. In the desktop, these variables are used to turn off the visual launch effect for all device icon types, and to turn off the launch sound for all sound icon types. The MENUCMD rule is used to put entries on the icon's menu. It takes as argument a string which is inserted as a menu entry and a Bourne shell expression which is executed if the menu item is selected. For localization, the quoted <menu string> is often prepended with a line number indexing into the /usr/lib/locale/$LANG/MSGFILES/sgidesktop.str file. Based on the current LANG environment variable setting, the string on the specified line in the appropriate translated sgidesktop.str file will appear on the Selected menu. See locale(1) for more information. Several FTR variables are expanded before the shell expressions in CMD and MENUCMD rules are executed. They are described in EXPANDED VARIABLES, below. Example MENUCMD rule: MENUCMD :458:"Edit" $WINEDITOR $LEADER The ICON rule is used to specify how an icon is drawn. Icons are described by an icon description program written in a C- and GL-like language. Normally icon geometry is stored separately from the FTR file and incorporated using the include command. (This enables the icon's picture and file-type rules to be edited separately.) The syntax for including icon geometry files into file-type rules is the following: include("relativePath"); where "relativePath" is a literal string such as "iconlib/MyApp.fti" or "../iconlib/generic.exec.open.fti". Icon geometry files (`.fti' files) can be created and edited with the graphical drawing program iconsmith(1G). The following C-language operators may be used in an ICON description: + - * / & | ^ ! % ( ) { } The following C-language conditional operators may be used in an icon description: && || == != < > <= >= The following constants may be used in an icon description: true false The following icon color constants may be used in an icon description routine: iconcolor outlinecolor shadowcolor These three standard colors change value automatically when the icon is selected, opened, passed over by the mouse pointer (located), or otherwise manipulated. For example, iconcolor usually appears white onscreen. However, when the user selects an icon containing iconcolor, its iconcolor parts change from white to yellow. When some icon is dropped on an icon containing iconcolor, its iconcolor parts change from white to royal blue. Similarly, outlinecolor usually appears black and shadowcolor usually appears dark gray, but these colors can change in response to the user's mouse events. The following icon status variables are set by IRIX Interactive Desktop, and may be used in an icon description routine: current disabled opened located selected Each of these variables has a value of either true or false. They can be used in a conditional statement to alter the icon picture when the icon has been manipulated in various ways from the desktop. For example, the following ICON rule will cause the icon to display the picture MyAppClosed.fti superimposed over the horizontal "carpet" generic.exec.closed.fti, until the user double-clicks the icon, at which time it will change to show the picture MyAppOpen.fti superimposed over the vertical carpet generic.exec.open.fti: ICON { if (opened) { include("../iconlib/generic.exec.open.fti"); include("iconlib/MyAppOpen.fti"); } else { include("../iconlib/generic.exec.closed.fti"); include("iconlib/MyAppClosed.fti"); } } The order of inclusion matters; each successive picture included will appear superimposed on top of the previously included pictures. Throughout the desktop, the horizontal carpet indicates that an icon is an executable that is not running, while the vertical carpet indicates a running executable. Icon pictures are typically stored in directories named iconlib (see The IRIX Interactive Desktop Integration Guide for more details). Other legal C variables may be used in an icon description routine without need of declaration; all variables are represented as type float. The icon description functions comprise, for the most part, a very restricted subset of the C-language version of the IRIS Graphics Library, modified for 2-D drawing. The valid icon description functions are: arc(x,y,r,startang,endang) Draw an arc starting at icon coordinates x,y, radius r, starting at angle startang, ending at angle endang. Angle measures are in tenths of degrees. arcf(x,y,r,startang,endang) Like arc, but filled with the current pen color. bclos(color) Like pclos (see below) but uses color for the border (outline) color of the polygon. bgnclosedline() Begin drawing a closed, unfilled figure drawn in the current pen color. Used in conjunction with vertex and endclosedline. bgnline() Like bgnclosedline, except the figure is not closed. Used in conjunction with vertex and endline. bgnoutlinepolygon() Begin drawing a polygon filled with the current pen color. The polygon is outlined with a color specified by endoutlinepolygon. Also used in conjunction with vertex. bgnpoint() Begin drawing a series of unconnected points defined using calls to vertex. Used in conjunction with vertex and endpoint. bgnpolygon() Like bgnoutlinepolygon except the polygon is not outlined. Used in conjunction with vertex and endpolygon. color(n) Set the current pen color index to n. draw(x,y) Draw a line in the current color from the current pen location to x,y. endclosedline() Finishes a closed, unfilled figure started with bgnclosedline. endline() Finishes an open, unfilled figure started with bgnline. endoutlinepolygon(color) Finishes a filled polygon started with bgnoutlinepolygon and outlines it with color. endpoint() Finishes a series of points started with bgnpoint. endpolygon() Finishes a filled, unoutlined polygon started with bgnpolygon. for(assignment;expr;assignment) Standard C-language for-loop. if(expr) expr [ else expr ] Standard C-language if statement. move(x,y) Move the current pen location to x,y. pclos() Draw a line in the current pen color that closes the current polygon, and fill the polygon with the current color. pdr(x,y) Draw the side of a filled polygon in the current pen color, from the current pen location to x,y. pmv(x,y) Begin a filled polygon at location x,y. print(expr or string) Print the value of the expression expr or string to stdout. Used for debugging icon programs. vertex(x,y) Specifies a coordinate used for drawing points, lines, and polygons by bgnpoint, bgnline, bgnpolygon, etc. The IRIX Interactive Desktop User Interface Guidelines contains detailed guidelines for creating icons. The following is a brief list of suggested style conventions to maintain when drawing icons: Use the iconcolor, outlinecolor, and shadowcolor as icons' typical colors. Be sparing with the use of other accent colors. This will help preserve the impact of color when it is needed. Create icons that maintain the overall 3-D feel that the basic IRIX Interactive Desktop icons have. The IRIX Interactive Desktop Integration Guide describes how to use iconsmith(1G) to draw icons in the proper perspective. The generic executable and generic data file icons, supplied in /usr/lib/filetype/iconlib, establish extensible themes that icon designers can work from to make it easier for users to recognize the icons quickly. Use ICON rules from the standard system and default FTR files as a background for unique representations. A CONVERT declaration looks like this: CONVERT <source type> <destination type> COST <non-negative integer> FILTER <filter expression> The CONVERT declaration must come first. It declares a method for converting one type of file to another. For example, CONVERT NroffFile PostScriptFile declares a method of converting an nroff file to a PostScript file. All print-conversion rules following a CONVERT rule apply to that conversion until another CONVERT rule or a TYPE rule is encountered. The COST rule indicates the incremental cost of a conversion. See Programming the IRIX Interactive Desktop for more details on the print conversion pipeline. If no COST rule is specified, the cost of the conversion is taken to be zero. Example COST rule: COST 50 The FILTER rule is a Bourne shell expression that is executed to perform the conversion. The file of type <source type> will be piped into the <filter expression> shell expression and the output of the conversion will be placed on the stdout of the expression. The CURRENTPRINTER variable, described below, is used during execution of the shell expression. Example FILTER rule: FILTER /usr/sbin/gzcat EXPANDED VARIABLES Before a CMD or MENUCMD shell script is given to the shell for execution, the following FTR variables are expanded. Note that these variables are expanded in place rather than being set as environment variables. $LEADER If one or more icons are currently selected from the IRIX Interactive Desktop, $LEADER is replaced by the icon whose text field is highlighted. $REST If more than one icon is currently selected from the IRIX Interactive Desktop, $REST is replaced by the list of names of all selected icons except the highlighted icon (see LEADER above). Otherwise, it is replaced by "". $LEADERTYPE If one or more icons are currently selected from the IRIX Interactive Desktop, $LEADERTYPE is replaced by the TYPE of the icon whose text field is highlighted. $RESTTYPE When more than one icon is currently selected from the IRIX Interactive Desktop, $RESTTYPE is replaced by the TYPE for all selected icons except the highlighted icon, if the remainder of the selected icons are all the same TYPE. If they are not the same TYPE, or only one icon is selected, $RESTTYPE is replaced by "". $RESTTYPELIST Replaced by the list of TYPEs corresponding to the arguments in REST. If only one icon is selected, $RESTTYPELIST is replaced by "". $ARGC Replaced by the number of selected icons. ARGC is always >= 1 (except when calling the transfer manager with nothing selected). $TARGET Replaced only for the CMD DROP rule, $TARGET is replaced by the name of the icon being dropped upon. $TARGETTYPE Replaced only for the CMD DROP rule, $TARGETTYPE is replaced by the TYPE of the icon being dropped upon. $SELECTED Replaced only for the CMD DROP rule, $SELECTED is replaced by the names of the icons being dropped on TARGET. $SELECTED is equivalent to ($REST $LEADER). $SELECTEDTYPE Replaced only for the CMD DROP rule. If all the icons named in SELECTED are of the same TYPE, $SELECTEDTYPE is replaced by that TYPE, or "" otherwise. $SELECTEDTYPELIST Replaced only for the CMD DROP rule. Replaced by a list of TYPEs corresponding to the TYPEs of the selected icons named in SELECTED. If only one icon is selected, it is replaced by "". $WINEDITOR Replaced by the name of the text editor that should be invoked if the shell expression needs an editor. The default editor is jot. This variable can be set to any window-based editor in the user's .cshrc or .profile, or if $EDITOR is set and $WINEDITOR is not set, $WINEDITOR becomes `winterm -c $EDITOR'. $WINTERM Replaced by the name of the window terminal that should be invoked if the shell expression needs a window terminal. Currently supported window terminals are wsh and xterm. The default window terminal is wsh. $CURRENTPRINTER Replaced by routeprint for FILTER rules. It is replaced by the unique name of the currently selected printer. The current printer may be set by the user with the Print Manager, or by the -s option to routeprint. See routeprint(1). The following variables are used by various system administration tasks and their objects. See sysmgr(1) for Desktop System Administration. These variables were used in the file devices.ftr under the /usr/lib/filetype/devices directory. $LEADERUNIT The selected device's unit number. $LEADERCONTROLLERNUMBER The selected device's controller number. $LEADERMOUNTPOINT The directory where the selected device's filesystem is mounted. $LEADERDEVICEFILE The /dev file associated with the selected icon device. The following variable(s) are not supported anymore: $LEADEROID FILES /usr/sbin/fftr /usr/sbin/ftr /usr/lib/filetype/* $HOME/.desktop-`hostname`/filetype/* SEE ALSO IRIX Interactive Desktop User Interface Guidelines, IRIX Interactive Desktop Integration Guide, fm(1), iconsmith(1), isSuper(1), tag(1), filetype(1), fileopen(1), filealtopen(1), winterm(1), IID(1) Page 13