X-mailer: m, by Cameron Simpson To: KathW From: Cameron Simpson Reply-to: cs@zip.com.au Errors-to: cs@zip.com.au Return-receipt-to: cs@zip.com.au Organization: Canon Information Systems Research Australia, Sydney, Oz Subject: cut/paste setup in X11 ... Ok, this is how it works in xterms. Traditional xterms do cut ("copy" in Windows-speak - the source is not removed) with button 1 (the leftmost button in stock setups). Click-and-drag to pull out the text you want. Single-click-and-drag does characters, double-click-and-drag does words, and tripple-click-and-drag does lines. I tend to do words and lines mostly - I find aiming at individual characters tedious and usually not what I want anyway. Paste is normally bound to the middle button. The third button does extension - you can do mark-and-end with this if you like (I don't, myself). Exactly which buttons do the cut/paste stuff is entirely under user control. Some background: Every X client is made of widgets (buttons, text areas, etc). Every client has a name and class (eg "emacs" and "Editor") and so does every widget. Also, all widgets have a set of properties (foreground colour, width etc). Customisation of X clients is done with the Resources database. The resource database is a list of strings of the form: pattern: value The pattern is a string matching a set of widget properties, and the value is what the X client uses when defining that widget. The pattern is a set of names separated by dots or stars. You can be very specific or very general with the patterns to make gross or coarse changes to how clients appear. When an X client initiates a widget it looks up each of the widgets' properties in the database for a value. There is a default value in the client if there's no overriding entry in the database, so you get workable stuff with no db whatsoever. This "database" is actually a rather disjointed thing - the client will search: - the resources stored in the display - the .Xdefaults file (one of a set - this is a personal thing) - the AppDefaults file (one of a set - this is a system thing) - the client's compiler-in values in that order. Many people put their customisations in the .Xdefaults file. For the ordinary user this works fairly well. For the sysadmin, or the user who regularly logs in remotely and runs clients on different hosts or as different users, this works less well because it inherently depends on the client being able to find and read that file. On a remote host, or if you're not the user who started the X session, this may not work. Accordingly, I put my resources on the display where everything can find them. As the first command in my .xinitrc I have: xrdb -load $HOME/.Xdefaults which copies my .Xdefaults file's contents into the display. Problem solved. Ok, knowing how to manipulate the db, what do we put in it? The property consulted when defining a widget has a name like: client.widget1.subwidget.subsubwidget.property The most specific pattern in the db which matches the property will be used for the value. So we might have: *foreground: black xterm*foreground: blue and (in the absence of other settings) most clients' foreground colours would be black, except for xterm, which would be blue. Back to the task at hand. For the cut/paste stuff we're interested in the xterm.VT100.Translations property, which governs the actions keyboard and mouse buttons fire up. This is one of the most unusual and complicated properties, as instead of setting some absolute value in it, it's more common (almost universally so) to put in a value which says "use your compiled in value for everything except the following". Here's mine: xterm*.VT100.Translations: #override \n\ F1 : string(0x1b) \n \ F10 : secure() \n \ End : scroll-forw(100,page) \n \ Prior : scroll-back(1,halfpage) \n \ Next : scroll-forw(1,halfpage) \n\ Meta : string(0x1b) insert() \n\ Alt : string(0x1b) insert() \n\ Shift : ignore() \n\ Shift : insert-selection(PRIMARY,CUT_BUFFER0)\n\ ~Ctrl ~Meta : ignore() \n\ ~Ctrl ~Meta : ignore() \n The "#override" says that the following stuff overrides the default, but to leave everything else as-is. The "\n"s are newlines, the "\"s are line extensions. The \n and \ get eaten during the parse, so the value really looks like this: #override F1 : string(0x1b) F10 : secure() End : scroll-forw(100,page) Prior : scroll-back(1,halfpage) Next : scroll-forw(1,halfpage) Meta : string(0x1b) insert() Alt : string(0x1b) insert() ~Ctrl ~Meta : ignore() ~Ctrl ~Meta : ignore() In order, this means: Pressing F1 is the same as pressing Escape (ASCII code 0x1b) because on my keyboard they're right over each other and I keep missing. F10 toggles the "secure" keyboard mode, the ensure nobody is snooping on my xterm when I type a password (normally you have to use one of the popup menus to toggle this mode - a PITA). Pressing the "End" key scrolls immediately to the bottom of the xterm's history. Pressing PgUp and PgDown (aka Prior and Next) scroll the xterm half a screen in whichever direction. Between them, End, PgUp and PgDown mean I don't use scroll bars very much. Pressing a key while holding Meta or Alt types an escape and then the key (thus Meta-a is like typing Escape and then "a"). This is used by some command-line history functions. Finally, the cut/paste stuff: My cut/paste bindings are: button-1 is cut, shift-button1 is paste. Thus is done as follows: Since button-1 without any Shift Control etc is already ok, we do nothing further about that. Next we make Shift-Button-1 do paste: Shift : ignore() Turn off the down transition of button 1 when Shift is held. Shift : insert-selection(PRIMARY,CUT_BUFFER0 On the up-transition (the second half of the keypress) we insert whatever's in eitehr the PRIMARY or CUT_BUFFER0 fields of the display. (This pick-one is an historical artifact). Then we turn off buttons 2 and 3: ~Ctrl ~Meta : ignore() ~Ctrl ~Meta : ignore() The ~Ctrl ~Meta mean we're only affecting the action for when neither Control nor Meta are held down. So, if you put some variation of the above in your .Xdefaults file (the version with all the "\n"s and "\"s) and put xrdb -load $HOME/.Xdefaults in your .xinitrc at the start, that should have some effect on your ability to cut and paste. Of course, the take effect immediately, without quitting and restarting X, set up your .Xdefaults file and just say xrdb -load $HOME/.Xdefaults at a shell prompt. -- Cameron Simpson, DoD#743 cs@zip.com.au http://www.zip.com.au/~cs/ I suppose the solution would be to close the composition window and let my article sit for half an hour or so once I've finished with it, and then go back and proofread it once more. But that would be a pain in the proverbial bifurcated derriere. Part of the experience of flaming is to load a searing missive into the conceptual breech of my SPARCcannon and pull the imaginary lanyard whilst flushed with the adrenaline of mortal combat. - Geoff Miller,