tpad

[ Intro | Download | Docs | How to install/upgrade | Bugs | Notes for qvwm users | Contributing | Mirrors ]

help

Command line usage

To get a summary of the available command line options, use the -h option:

$ ./tpad -h
Application initialization failed: Command-specific options:
 -colormap: Colormap for main window
 -display:  Display to use
 -geometry: Initial geometry for window
 -name:     Name to use for application
 -sync:     Use synchronous mode for display server
 -visual:   Visual for main window
 -use:      Id of window in which to embed application
 --:        Pass all remaining arguments through to script

tpad Version 1.3
WinXP enhanced Notepad clone

usage: tpad [-Rh] [+#] [file ...]

The simplest way to invoke tpad is just by using the name of the tpad executable:

$ tpad

The most frequently used additional command line argument is the path of the file to edit which is optional (this is the same as using the Open option under the File menu to load the same file):

$ tpad myprog.c

Another common need which can be accomplished by the command line is to invoke the editor and position the cursor at the beginning of a certain line. For example, imagine the C compiler signalled there is an error on line number 23. To fix that with tpad use this command:

$ tpad +23 myprog.c

Note that line numbers start from 1 which is a common convention. The plus sign is used because it is not very common to have a file name beginning with it. While in tpad you can always use the "Goto line" option in the Edit menu to reposition the cursor at the beginning of a line given its number.

In the rare cases when you have a file with a name beginning with +, use a full path or a relative one that starts with ./ to avoid misinterpreting the file name as a line number:

$ tpad ./+COMMENT
$ tview /var/db/pkg/tpad-1.3/+DESC

If you know in advance that you have to edit more than one file, you can decide which files to edit with a single command. An example requiring editing three files named file1, file2 and file3:

$ tpad file1 file2 file3

This will open tpad and load file1 (if exists). When you are finished with editing file1, use the Next option under the File menu to load the next file in sequence (in this case file2) and so on.

If you require to move the cursor to a certain line at startup and at the same time you are asking for editing multiple files in sequence, you will note that the +# option only applies to the first file of the sequence:

$ tpad +10 file1 file2 file3

You will need to use the "Goto line" option under the Edit menu for quickly positioning of the cursor for subsequent files.

Being a wish(1) script, tpad also supports all the command-line options described in the OPTIONS summary of the wish manpage. They all can be mixed with those specific to tpad. For example, suppose you want to edit the file screen.txt using a textarea of 80x25 characters (the same typical size as a terminal):

$ tpad -geometry 80x25 screen.txt

And if you want to start editing from line 12:

$ tpad +12 -geometry 80x25 screen.txt
$ tpad -geometry 80x25 +12 screen.txt

Using tpad as a viewer

When tpad is invoked as tview or the -R option is used, it acts as a simple pager or viewer for one or multiple files in sequence. In this mode, no characters may be inserted or deleted from the text and no insertion cursor will be displayed. The menu options presented will be limited to those that don't modify the text (e.g. the Save command in the File menu will not be available). For example, suppose you want to just have a look at the Unix user database file. In this case you can use either of these commands:

$ tpad -R /etc/passwd
$ tview /etc/passwd

To avoid modifying and saving a file by mistake, you can't switch from the viewer to the editor. If you want to edit a file, you will need to exit from tview and load tpad instead.

Note that tpad and tview are not separate executables and they share the same configuration file. Instead tview is just a hard or symbolic link to tpad, depending whether you are using the tpad source distribution or one of the packages. For more information about file links check the ln(1) manual page which surely comes with your Unix version.

Of course you can view multiple files in sequence, e.g.:

$ tpad -R /etc/resolv.conf /etc/hosts
$ tview /etc/resolv.conf /etc/hosts

Make other programs invoke tpad

Another issue related to invoking tpad from the command line is how to make other programs invoke tpad. Most programs that let a user edit a file using his favorite editor adhere to the following convention to set the external editor to invoke: they check the EDITOR environment variable; if it doesn't exist, they usually default on invoking vi(1), otherwise they will invoke the command named in this variable. For example, in Tcl this is expressed by the following statements:

set editor vi
if {[info exists env(EDITOR)]} {
  set editor $env(EDITOR)
}

So in order to make other programs to use tpad instead of vi or something else, you need to assign "tpad" to the EDITOR environment variable. Also make sure that this variable is marked for automatic export to the environment of subsequently executed commands (child processes). How to do this depends on the type of shell you are using. Here I'll only cover the most commonly used shell types.

sh, bash
export EDITOR=tpad
csh, tcsh
setenv EDITOR tpad
tclsh, wish
set env(EDITOR) tpad

If you want this variable to be automatically setted every time you login, add the set instruction into your per-user shell configuration file, which for the above shells is, respectively:

sh
~/.profile
bash
~/.bashrc
csh, tcsh
~/.cshrc
tclsh
~/.tclshrc
wish
~/.wishrc

Remote execution

Suppose you are working on a computer named alpha and you want to execute a copy of tpad installed into another computer named beta using alpha's display for interacting. I'm supposing both computers are connetted through a TCP/IP network and alpha and beta are their TCP/IP host names, which is the most common case.

With the term "display" or "X display" I mean the set of a keyboard, one or more monitors and a mouse all used together for interacting. If alpha has multiple displays, they are numbered starting from 0 (:0, :1, :2, etc). If the keyboard and mouse belonging to display number :X control more than one monitor, the monitors also are numbered starting from 0 (:X.0, :X.1, :X.2, etc). The most simple and common situation is that alpha has a single display (:0) with a single monitor (:0.0) and you can refer to it from beta using the string "alpha:0" or "alpha:0.0". Locally from alpha you can omit the host name and refer to the display by simply saying ":0" or ":0.0".

Note that even if you have only one physical display, you can have multiple X virtual sessions running on the same display, for example under different users and with different window managers. This is the same as having multiple physical displays, although only one virtual display can be used at a time. For example to start a new X session under display :1 with startx(1) use this:

(alpha) $ exec startx -- :1

That said, the recipe to run tpad (or every other X application) remotely is the following:

  1. On alpha, you need to authorize beta to make connections to the alpha X server:
    (alpha) $ xhost +beta
    
  2. From alpha, login to beta, using one of the available methods, for example telnet(1), rlogin(1) or ssh(1).
  3. Now you can choose between two methods to specify what remote display to use on beta and execute tpad (or another X application):

Please note that the alpha computer is only used as a display or remote graphic terminal: beta's CPU does all the work and loading and saving files acts upon the beta's filesystem (unless alpha exports parts of its filesystem to beta through NFS).

Troubleshooting

If it doesn't work, please check that the X server on alpha listens for incoming TCP/IP connections. For example under FreeBSD use the command sockstat(1) to check this:

(alpha) $ sockstat -4l

Under Linux Slackware use netstat(1):

(alpha) $ netstat --ip -l

If you are using startx(1) on alpha to initialize an X session, try to use the -listen_tcp option with it to enable using remote X display, which may be disabled by default for security reasons (this is true under FreeBSD). If it continues not to work, please contact your network administrator to make sure there is no firewall stopping beta from connecting to alpha on port number 6000+(display number of alpha).

Hints for securing the X connection

In the previous example, we were limiting access on our X server running on alpha to all users of beta, using xhost(1) in this way:

(alpha) $ xhost +beta

This is secure enough only if you are the only user of beta or you trust all the other beta users. If this is not the case, you will need a more sophisticate access control mechanism. With XFree86 comes a man page (Xsecurity(7)) that has the full list and descriptions of the available access control systems.

[ Return to Contents ]

Valid HTML 4.01! Petition for a Software Patent Free Europe Eliminate DRM noooxml

Last modified: Sunday, 18-Apr-2010 09:38:13 UTC