mailing-list for TeXmacs Users

Text archives Help


Re: [TeXmacs] scheme functions for keyboard input


Chronological Thread 
  • From: Scott Michael Sullivan <address@hidden>
  • To: Miguel de Benito Delgado <address@hidden>, address@hidden
  • Subject: Re: [TeXmacs] scheme functions for keyboard input
  • Date: Thu, 30 Jan 2014 15:41:45 -0700

Thanks!

I've already figured out how to set static keyboard maps, but I would really like to create dynamic keymaps. For example, suppose I wanted to map the pauli matrices to M-x, M-y, and M-z during a texmacs session, without opening the Guile interpreter (obviously I would also need to set aside a shortcut for mapping, let's call it "C-m"). I want a function where I could type out the x-matrix, select it, type "C-m M-x <enter>", and from now on in this session, typing "M-x" creates the x-matrix. This type of dynamic mapping is only one example of what I have in mind.

My goal for now is being able to type mathematics extremely fast, mainly since I have to do a lot of physics assignments for grad school. I currently use pencil/paper for everything, but if I could type math faster than I could write, I would switch over to Texmacs for everything (also I like that sage can add powerful functionality).

Anyways, will I have to write a c++ plugin, or can I do everything in Scheme? I suppose I could redefine the keyboard-press for search-mode. But how do I tell texmacs to enter/leave search-mode?

Best,
Scott


On Thu, Jan 30, 2014 at 7:29 AM, Miguel de Benito Delgado <address@hidden> wrote:
Hi,

On Thu, Jan 30, 2014 at 8:08 AM, Scott Michael Sullivan <address@hidden> wrote:
Is there a way in scheme to read input from the keyboard, while not adding anything to the texmacs buffer? I'm trying to write functions which can redefine keyboard maps on the fly, and I require this sort of functionality.

Keyboard events are captured by c++ code (especifically by QTMWidget if you are using the Qt port, then sent to editor_rep::handle_keypress()) and redirected to the scheme handlers "keyboard-press". You can search in the scheme code for examples of how you may use contextual overloading to handle keypresses only when the editor is in a particular state or "mode" (e.g. while in "search mode" keypresses are handled differently: they produce no output in the editor but instead are interpreted as part of the search string)

However, if you want to set keyboard maps then you may skip the low level stuff and use kbd-map and all the related infrastructure. Just look for the definition of kbd-map and around it you'll find lots of related interesting stuff.

Best,
--
Miguel de  Benito.




Archive powered by MHonArc 2.6.19.

Top of page