Automatically Generated Keyboard Accelerators (replacing kaccelgen.h)

Albert Astals Cid aacid at
Mon Jun 9 18:14:07 BST 2008

A Dilluns 09 Juny 2008, Mark Summerfield va escriure:
> Hi,
> At present KDE uses kaccelgen.h to automatically generate keyboard
> accelerators.
> The algorithm used is very easy to understand, but produces poor
> results---for example, in many real use cases it can only generate
> accelerators for half or fewer of the strings it is given.
> I have created a completely different algorithm that is more
> sophisticated (but still perfectly understandable) and that can produce
> optimal results every time. One theoretical drawback is that my
> algorithm can take a lot longer to run than the current one---O(n!) vs.
> O(n). But by tuning my algorithm for speed it still equals or betters
> the existing algorithm in all the cases I've tested and has a runtime
> performance of single or double figure milliseconds---so it is fast
> enough to generate menu accelerators dynamically.

While you are at it, what would totally rock if you could make the generator 
not assign acceletators to keys that can't be accelerators, for example with 
a spanish keyboard you can not type ó with a single keystroke (altough ó 
exists and is completely correct) so Alt + ó as accelerator won't work.

But probably this involves fiddling with keymaps and stuff and is not easy.


More information about the kde-core-devel mailing list