The difficult art of explaning

Posted by Esben Mose Hansen Sun, 11 Oct 2009 18:04:00 GMT

Sometimes, explaining abstract concepts concisely in an easy-to-understand language is everything but simple. Consider Klipper's config dialog as I recently adjusted it to look

Now, if you already know the difference between selection and primary when talking about the X clipboard, the radio button and the check box are both pretty clear, at least in my opinion. If not, I hope that the verbose what-is text might bridge the confusion, but I am not so sure. So, dear readers, do any of you understand what I'm trying to say? Can some of it be clearer? If you do not understand what I'm going on about, see below, where I'll try to explain at length what selection and primary is all about.

X does not have one clipboard but several clipboards, of which 2 are actually commonly used. They are often named after their XAtoms, "SELECTION" and "PRIMARY". Traditionally, X has supported highlightning an area with the mouse and then middle-clicking to paste this selection elsewhere. This is done via the SELECTION clipboard. Practically speaking, that means that if an area is selected in well-behaved X program XAPP, it will notify X that that XAPP now has the SELECTION. Thus, when the middle mouse button is clicked somewhere, the clicked application can ask X "give me the contents of SELECTION", and X can send the request on to XAPP, which can then send back the answer. Reasonable simple, even if I did leave out all the details about formats. Completely independent of this, X also has a clipboard like known in most other desktop environments, in which the user, usually by a keystroke like ctrl-C or a menu selection makes the application tell X "I now have the PRIMARY", and when the user selects paste somewhere, the content of the PRIMARY is pasted via. the same mechanism as the SELECTION above.

Now, many people find this to be confusing and/or annoying in practice. Keeping track of 2 different clipboards requires the user to remember "Did I just select it or did I copy it to the clipboard? If I selected it, I have to grab my mouse and use the middle button, otherwise I will have to press ctrl-V to paste." Thus, Klipper provide the ability to synchronize the PRIMARY and the SELECTION, ensuring that whatever method the user used to copy to the clipboard(s), all methods works for pasting. For the traditionalists, the option to keep the clipboards separate is also provided.

So what is this "ignore selection" all about? Well, if you use the separate option above, the clipboard history will still be populated from the mouse selection, and Klipper's actions will still be triggered. Some people do not want this: they wish Klipper to keep its endearing hands off SELECTION and only act on PRIMARY. So that is the last option. This will make the clipboard be almost completely like the Windows clipboard, except that you can still accidentally paste the mouse selection by pressing the middle mouse button, which is an X thing through and through.

Again, I'd value people's comments, and I do believe the comment system is actually working now. Otherwise, please direct comments to me by email.

PS: Now at 98 bugs. They seem to come in as quickly as I can fix them.

Posted in  | Tags , ,  | 23 comments | 17 trackbacks

One Klipper feature to fix many bugs: Introducing more flexibility in actions

Posted by Esben Mose Hansen Sat, 10 Oct 2009 06:56:00 GMT

One very common request for Klipper is "do stuff with the clipboard". E.g.

  1. Search google for something selected.
  2. Count the number of words, lines whatever for the current clipboard
  3. Strip the clipboard of special formatting

Now, as you might know, Klipper has actions. An action is like a filter that looks for patterns in the clipboard. An example pattern could be "bug: followed by a number". If the pattern matches, the action springs into life offering to do one of several commands in a small popup. Each command offers something, like "find the KDE bug with this number" or "find Debian bug with this number" or what have you. Now, a small popup appearing whenever you copy something is annoying for many, and thus you have the option of disabling the automagic popup and instead invoking the scanning manually by pressing ctrl-alt-r (by defeault).

As the attentive reader will note, the first item on the list above is almost satisfied by actions: Simply define a pattern that matches (nearly) everything and have it invoke a command to search google. The snag appears if you like the automagic popup, as even the most avid popup lover would be somewhat frustrated to have the popup appear at every copy! So I have added an option to actions, so that they can be configured to only trigger on a manual invocation by deselecting the "Automatic" checkbox in the configuration dialog.

.

The two remaining items on the list just need one more thing: The output of a command should go back on the clipboard. For this purpose, I made it so any command's output can either be Ignored (old, default), Add'ed to the clipboard history or Replace the original. That way, the user can set up an action to run something through wc -c to get the character count right onto the clipboard. Neat!

During the course of fixing this, I also fixed an unfortunate interaction. Sometime back, the bright idea was born that clipboard snippets could be run through KDE's magic system of handling URL's. In that way, if e.g. a file on the harddisk was copied to the clipboard, Klipper could offer to open the file in an appropriate program. Neat! Unfortunately, a bug was introduced so that this only worked if at least one normal action was present. And then all the default actions were removed because they were "old and unneeded". Apparently, a lot of distributions, including the pecked-on Kubuntu, actually caught this and continues to install the old file full of actions, but a few (like SuSE I think) did not and thus revealed the bug. Much confusion ensured, until a user noticed that adding a dummy action fixed the problem. Ah well, it is fixed now. I would also like to resurrect some actions, perhaps disabled, so the user has a few examples to go by.

Next up: Making klipper work with Eclipse. Which calls for me to install that exotic IDE. Wouldn't it just be easier if everyone switched to KDevelop instead ;)? Which is by the way really awsome these days, beta or no.

Posted in  | Tags , ,  | 10293 comments | 15 trackbacks