Poor interface design
Friday, 2. February 2007, 16:41:33
Problem 1: I can't type quotes inside any Java application. No joking, under GNU/Linux, the Sun Java virtual machine seems to have problems with deadkeys, and I have US-International keyboard.
Solution 1: Open another program and copy/paste the quote character.
Solution 2: Write a macro inside NetBeans so I can type a combination and it enters a quote.
Solution 3: Press AltGr+quote. This works anywhere inside X.
Being a Vim addicted user, I usually typed Ctrl+N and Ctrl+P inside NetBeans... (If you don't know what those keys do, open Vim and type :help i_^N)
But today I accidentally found two shortcuts that do exactly what Ctrl+N and Ctrl+P do inside Vim! They are Ctrl+L and Ctrl+K. Of course, I wanted to remap these two actions to the same keys as in Vim. Then I found one of the most scaring dialogs:
The NetBeans keymap window
Before showing how it is, let's see how Opera Software designed that dialog in Opera browser for desktop.

Oh, how neatly arranged and organized. It has two columns, one for the keyboard shortcut and another for the action. It also has a quick-find field, an invaluable feature when the program has more than just a few actions and shortcuts. And this dialog is also used for editing mouse gestures. Very neat, well-thought, well-designed and easy-to-use.
Now beware! The NetBeans keymap window is coming! Don't say I haven't warned you!

All actions are available at this dialog, and they are divided into 16 categories:

The keyboard shortcut is just a string between square brackets concatenated to action name. There are no columns. There is no font change, no color change, no bold, no spacing... Nothing that you can easily spot.
Well, I discovered the Ctrl+L shortcut and wanted to change it, but I have no idea on what is the action it calls. I would seach... but there is no search field, and I won't waste my time looking at all actions, one-by-one.
Enough bad design for now. And if someone knows what are the actions of Ctrl+L and Ctrl+K, please tell me.
P.S.: Dear Firefox users, I'm so sorry about you. Your browser does not even have a shortcut editor. I know, you can search until you find an extension that adds that feature. And hope that extension works. Until then, you need to live with backspace not going back to previous page...
Sobre o Firefox, na verdade o browser assume o comportamento do OS onde está instalado, por isso que no Windows ele adota o backspace como voltar. Pra burlar isso, vá no about:config e mude a opção "browser.backspace_action" para 0. O backspace passará a funcionar como "Voltar".
Abraço!
nunesvn@gmail.com
Maicon Vinicius Nunes
By mknun, # 7. February 2007, 11:21:37
Crie um arquivo jfix.c com o conteúdo abaixo:
----------------------------------------------------
INICIO DO ARQUIVO
----------------------------------------------------
/*
* Quick-and-dirty fix for Java deadkey bug
*
* Version 0.1 (2006-10-05)
* Written by Marcelo de Gomensoro Malheiros <mgm * univates.br>
*
* This code is placed into Public Domain.
*
* Only tested on Linux:
* (Ubuntu 6.06 + X.Org 7.0 + Brazilian kbd + JDK 1.5.0_08)
*
* You should compile it into a dynamic library with:
*
* $ gcc -fPIC -rdynamic -c -Wall jfix.c
* $ gcc -shared -Wl,-soname,libjfix.so -o libjfix.so jfix.o -lc -ldl
*
* Then you should preload this library before running a Swing Java program:
*
* $ (export LD_PRELOAD=<full path>/libjfix.so ; java Application)
*
* Note: you should not set it globally, because it will affect other programs.
*/
#define LIBX11 "/usr/X11/lib/libX11.so.6"
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
int XmbLookupString(XIC ic, XKeyPressedEvent *event, char *buffer_return,
int bytes_buffer, KeySym *keysym_return,
Status *status_return)
{
static void *library = NULL;
static int (*function)(XIC, XKeyPressedEvent*, char*, int, KeySym*, Status*);
char *error = 0;
int rc;
if (!library)
{
/* Open target library */
library = dlopen(LIBX11, RTLD_LAZY);
if (!library)
{
fprintf(stderr, "%s", dlerror());
exit(EXIT_FAILURE);
}
/* Get a pointer to the desired function */
function = dlsym(library, "XmbLookupString");
if ((error = dlerror()) != NULL)
{
fprintf(stderr, "%s\n", error);
exit(EXIT_FAILURE);
}
}
/* Call original function */
rc = function(ic, event, buffer_return, bytes_buffer, keysym_return,
status_return);
/* If the keysym found is the character equivalent of a deadkey then
force output in string form only */
if (*status_return == XLookupBoth &&
(*keysym_return == XK_abovedot ||
*keysym_return == XK_acute ||
*keysym_return == XK_apostrophe ||
*keysym_return == XK_asciicircum ||
*keysym_return == XK_asciitilde ||
*keysym_return == XK_breve ||
*keysym_return == XK_caron ||
*keysym_return == XK_cedilla ||
*keysym_return == XK_diaeresis ||
*keysym_return == XK_doubleacute ||
*keysym_return == XK_grave ||
*keysym_return == XK_macron ||
*keysym_return == XK_ogonek ||
*keysym_return == XK_quotedbl ||
*keysym_return == XK_quoteleft ||
*keysym_return == XK_quoteright))
{
*status_return = XLookupChars;
}
return rc;
}
-----------------------------------------------
FIM DO ARQUIVO
-----------------------------------------------
Mantenha as linhas comentadas, vamos prestigiar o cara que fez o Patch que a Sun não se prestou a fazer.
Adapte a linha #define LIBX11 para o caminho correto da libX11.so.6 no seu sistema. No Slackware o caminho é esse aí.
Compile como descrito no cabeçalho do arquivo, ou seja:
gcc -fPIC -rdynamic -c -Wall jfix.c
e
gcc -shared -Wl,-soname,libjfix.so -o libjfix.so jfix.o -lc -ldl
Mova o arquivo resultante libjfix.so pra uma pasta apropriada, tipo /usr/lib/
e depois coloque no seu /etc/profile, ou um outro lugar qualquer que rode na inicializaçao do sistema, a instrução seguinte:
export LD_PRELOAD=/usr/lib/libjfix.so
O autor do patch não recomenda que se coloque isso num local tão generalizado, e sim o uso por sessão, mas usando assim não encontrei problema algum, e todas as aplicações Java passaram a ter as deadkeys de volta.
Reinicia e tá pronto!
Recomendo que tu traduzas este micro tutorial para o inglês, porque o teu blog é um dos sites que aparecem quando alguém pesquisa o assunto.
Abraço,
Maicon Vinicius Nunes
nunesvn@gmail.com
By mknun, # 7. February 2007, 15:03:22