Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable shortcuts #490

Open
mardukbp opened this issue Jun 5, 2015 · 9 comments
Open

Configurable shortcuts #490

mardukbp opened this issue Jun 5, 2015 · 9 comments

Comments

@mardukbp
Copy link

mardukbp commented Jun 5, 2015

The shortcuts for folding and unfolding cells are convenient in an English keyboard, however, in a Spanish keyboard [ = Shift + {. Therefore, it would be more natural to type Ctrl-Alt-{ and Ctrl-Alt-}.

For the above reasons, I suggest that the shortcuts be configurable in .wxMaxima or in the GUI.

@gunterkoenigsmann
Copy link
Member

They are configurable by changing the the menu entry text of the
spanish translation. So just send us a patch against locales/es.po in
the sourcecode of wxMaxima and we will see what we can do.
I assume you already do have git or another way to create patches. If
not a suitable git client that can create patches should be available
at git-scm.com.

Kind regards,

Gunter.

@mardukbp
Copy link
Author

mardukbp commented Jun 5, 2015

I edited directly wxMaximaFrame.cpp and recompiled but it did not work. When I pressed Ctrl-Alt-{ I got { in the notebook.

@gunterkoenigsmann
Copy link
Member

It is always good to have a C++ programmer in the team!
...and according to your test things are more complicated than I
thought: Hotkeys are only processed if they are skip()'ed by
MathCtrl::OnKeyDown(). If not they are processed as ordinary keys.
The question is now if we can safely do so without removing the
possibility of entering the signs { and } in another language's
keyboard: On german keyboards entering these characters means you have
to press Shift+Alt (or AltGr) at the same time so two modifiers might
be involved in this keypress. I assume Ctrl isn't used for such a
purpose in any language but I don't really know...

Kind regards,

Gunter.

@mardukbp
Copy link
Author

mardukbp commented Jun 6, 2015

I am sorry to disappoint you, but I am no C++ programmer. I just know enough of a lot of languages to do what I need. In the case of C++ I only know the C subset.

I found this in StackOverflow. It might help.

@gunterkoenigsmann
Copy link
Member

C++ isn't too compicated:
In standard C if you want to implement a big functionality a big problem is to avoid that for this functionality you have to use nearly all variable names you could think of. If you then add some other thing to your program that is equally big and uses similar concepts (perhaps a h.264 codec) you surely will have a collision of variable names - if you don't bundle all variables that belong to one object (one codec, in this case) into a struct.

C++ is now based on objects which basically means

  • that you try to bundle as much of every functionality into a struct
  • That you bundle all functions a functionality needs into the struct, as well: If they aren't used on the struct they were designed for they won't make any sense anyway.
  • A struct that provides it own functions is named class.
  • and you can derive a new class from a already existing one by telling the compiler: I just need exactly this thing - but with these five functions added and these three ones replaced by the following
    ones code: ...

There is much magic involved in finding out which functions now really have to be called when you try to use one that has been replaced several times - but that magic is part of the compiler and you won't see that it is there as long as it works right. Additional magic allows every object to have a constructor that can allocate memory or hardware on creation of the thing this class describes - and a destructor that automagically frees the resources and the memory as soon as your struct is no more needed. You'll never can forget to close a file manually: You just make sure that the object that holds all functions to write to a file is a local variable in a block or function - and as soon as you leave this block or function the local variable is no more needed and the file will be closed by the compiler.

The other half is giving all things their complicated names:

  • The Structs that contain functions, as well, are named classes
  • If you create a variable of the type you defined as a class this
    class this variable is named an object
  • The functions that are bundled with them are named methods and so
    on.

One object that is important for our case is the parameter event of OnKeyDown function of the class MathCtrl:

it contains functions like event.ShiftDown() that returns true if shift has been pressed,
Similarily event.ControlDown() telly you control has been pressed.
event.GetUnicodeKeyCode() will that tell you which character the user has pressed as long with the eventual shift or control key...
...and if you determine that the thing you have found definitively either is useless or is a hotkey you can just call event.Skip() and the event will be passed to wxWidget's hotkey management code. This code
will find the shortcut you defined: As your shortcut contains a Control keypress it is no ordinary character and wxWidgets will understand it as soon as it is found in the translation of a menu item.

The other half of problem is still valid, though: Can we really send Ctrl+Shift+{ to the shortcut management code without breaking things for any of the hundreds of keyboard layouts that are to be found in the wild?

Kind regards,

    Gunter.

On Sa, Jun 6, 2015 at 2:04 , Marduk Bolaños notifications@github.com
wrote:

I am sorry to disappoint you, but I am no C++ programmer. I just know
enough of a lot of languages to do what I need. In the case of C++ I
only know the C subset.

I found this in StackOverflow. It might help.


Reply to this email directly or view it on GitHub.

@mardukbp
Copy link
Author

mardukbp commented Jun 6, 2015 via email

@gunterkoenigsmann
Copy link
Member

Did do some research: In 2013 wxMaxima did allow Alt+Ctrl+any key as a shortcut and nobody except of me protested => Ctrl+Alt+{ and Ctrl+Alt+} are passed to the shortcut processing routines again.


Seems like a good point, that with the user interface language.

The convenient function of wxWidgets that it automatically adds all shortcuts mentioned in menu items makes configuring shortcuts a little bit harder - and I don't like the idea that every user whose keybord disagrees with the american one has to learn a new configuration language and to edit a file by hand => If anybody wrote this function I would propose:

  • A new tab in the configuration dialogue entitled "additional shortcuts"
  • This Tab contrains a wxGrid or similar in which every line contains
    • a drop-down box with every action one can think of. The list of menu available actions can be taken from wxMaximaFrame::Event.
    • Checkboxes for Alt, Shift and Control and
    • a box that contains the letter that has to be pressed along with these keys.
  • wxMaximaFrame::wxMaximaFrame (which is automatically called if a main window contents is generated) already adds some alternative shortcuts for events. The code block that does this can be found by searching for SetAcceleratorTable. The hotkeys from the configuration dialogue could be added here.
  • And MathCtrl::OnKeyDown would have to be modified to call Skip() on all key events that match these shortcuts.

Won't do this myself, though, since my keyboard is nearly american.

@mardukbp
Copy link
Author

mardukbp commented Jun 8, 2015

Thank you! It's great that you outlined what has to be done. I would say do not close the issue and please add the labels enhancement and feature request.

@gunterkoenigsmann
Copy link
Member

Good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants