Fortran library that would enable me to capture arrow key movement - windows-7

I would like to use arrow keys to move some points in a QuickWin plot in my console applications. Is there a library out there providing support for something like that?

There are quite a few function calls supported by quickwin: try incharqq, getcharqq or peekcharqq. You'll have to write a noddy program to find out what the key sequences for the arrow keys are.
The call that you may be missing is passdirkeysqq with the parameter PASS_DIR_TRUE. This will enable you to see the direction keys. Each one comes out as 2 keys with the lead character being 224.
If you are not getting any success with this, try using the numeric keypad.

Related

Lazarus cross platform equivalent to MapVirtualKey

I have been able to successfully retrieve ascii characters from VK codes
using lazarus/fpc and the mapvirtualkey function in windows.
Is there a cross platform (macOS specifically) lazarus/fpc equivalent to mapvirtualkey? Is there any other way to get the ascii/unicode character that corresponds to a VK code under the current keyboard layout using lazarus/fpc on macOS?
Thank you in advance!
Edit: (Rephrased question) The onKeyDown events on Lazarus on a Mac provide a "Key" parameter. Is there a way on the mac to convert this parameter to the ascii/unicode character that corresponds to this "Key"?
I'm kind of confused about what you want also.
But maybe this helps:
Look in the lcltype unit in the lazarus folders, this contains all the "virtual Key" constants (search for vk_ ).
So the "Key" parameter is getting the double value corresponding to VK_RETURN when the Return/Enter key is pressed. And so on with all the extended keyboard characters.
You can use the Ord() and Chr() functions with these values as well which, I believe, will give you want you want (?).
If you are going to use these codes don't forget to add lcltype to your "uses" section.
HTH.

How to create custom escape sequence in mac terminal

I don't understand how to create custom escape sequence for Ctrl+Shift+S like in this question
My problem is that I want to use Ctrl+Shift+S in emacs no-window mode under MacOS terminal. Currently I'm trying to bind this escape sequence to Ctrl+Shift+F12 but I have troubles creating that escape sequence. Maybe there is a batter way to use complex (Ctrl-Shift+anykey) bindings in MacOS terminal with emacs in no-window mode?
You're probably assuming that F12 is a character. It is not. Conventionally, function keys send a sequence of characters.
In Terminal's preferences screen, you can review (most of) the key bindings:
You can also add a key definition (after deciding what characters it ought to send), and associate the Shift and Control modifiers with that key:
For the sake of example, I used the sequence that xterm would send. However, Terminal is not the same as xterm, and you may find other sequences more interesting.
Regarding the related question "What is the correct escape code for control/shift/s": there is no correct escape code because terminals (unless specially configured as illustrated above) do not distinguish between shifted- and unshifted-control characters. To determine what is "correct", you will have to examine your emacs bindings to see what you should send to make it recognize the function you are asking about.

How curses differs Enter from Ctrl+Enter and other key strokes with overlapping escape sequences?

As far as I can see, in Konsole both CTRL+ENTER and ENTER look like byte 13 in the stdin of the running app. But when I run mc which obviously uses ncurses lib, pressing CTRL+ENTER inserts the name of the file into the command line while ENTER opens the file. How is it implemented? I tried to look into sources, but they are totally unreadable for me.
mc (midnight commander) doesn't use ncurses for input, but may use it for output. Essentially it is looking for specific character sequences.
mc makes little use of the terminfo database, essentially only to check on the xterm mouse- and alternate-screen features.
In principle, it could read the user-defined capabilities from the ncurses terminfo database (see for example ncurses trapping extended keys (Control-left, Shift-Function etc)), but it does not.
Since you are looking at sources, see the source of mc, in lib/tty/key.c, which contains tables which mc uses as a set of predefined keys. Doing it that way "works" when mc is configured to use slang, for instance, though it has the drawback that it's hardcoded and may not actually match your terminal.
However - as I said, mc does its own input. Further down in key.c, you may see a chunk in get_modifier() ifdef'd with HAVE_TEXTMODE_X11_SUPPORT. Inside that is a call which ultimately goes to XQueryPointer, which mc uses to find the current state of the modifier keys — if it happens to be running in an X display, and if the feature is enabled. You are probably seeing that.

Converting NSString to keyCode+modifiers for AXUIElementPostKeyboardEvent

Edit: Turns out, I was misled during my initial explorations of the accessibility APIs. Once I found the secure text field in the AX hierarchy, I was easily able to set the value. Not sure what to do with this question beyond that, but I wanted to update this for future searchers.
I'm working on some code that will post keyboard events to targeted applications using the Accessibility APIs. So far, I have been able to write a trivial app that allows me to type in a string value and then post keyboard events with those key codes to the targeted application. In reality, the strings would be read from another location.
What I have not yet been able to figure out is how to ascertain whether and which modifier keys should also be posted. For instance, when I type Hello, world! into my test application, the input is sent to the other application as hello, world1 because I am not yet including the modifier keys to create the upper case H and the exclamation point. This is made doubly complicated by multi-keystroke characters like é or ü. Sending é sends a raw e with no accent for example.
Is there a simple method I am overlooking for discerning the modifiers to combine with a keycode for creating a particular NSString or unichar? If not, does anyone have a suggestion of how to proceed? So far, the best I have come up with is calling UCKeyTranslate with all possible modifier combinations until I find one that matches the unichar I get using -[NSString characterAtIndex:] I'm not sure this is scalable or reliable, though, given the multi-keystroke nature of some characters as noted above.
Thanks in advance!
This probably won't help. But just in case: Is it really necessary to send keyboard events? Because that is going to get really difficult if you need to support, say, Kotoeri.
It's a simple matter to override insertText: and doCommandBySelector: and send the results of the key sequence, rather than the individual keystrokes.
I have found a example which does the trick but it's incomplete:It will not be a general solution in any case ...how can this handle multiple keyboard layouts ?
There is an cgquartz obsolete function to do so: CGPostKeyboardEvent (not sure it's possible to pass only the char?) may be can still be used (marked undocumented with some side effect to but .. ).
EDIT: UCKeyTranslate as a way to build a dictionary. Interesting but how the OS do this? A better answer should be hidden somewhere !

Portable keycodes in X11?

I want to get mapping-independent key codes, but documentation says that "keycode" in XKeyEvent structure depends on hardware and driver and I can't rely on it. How can I get some portable key codes like VK_* in Windows?
You want key syms, not key codes.
See XKeycodeToKeysym() and /usr/include/X11/keysymdef.h
To be strictly correct (especially with internationalization) you need a whole bunch of code along the lines of http://git.gnome.org/browse/gtk+/tree/gdk/x11/gdkkeys-x11.c
However, if you're using raw Xlib instead of a toolkit you probably don't care about this kind of thing (if you do you're in for years of work), and XKeycodeToKeysym() is good enough for US keyboards.

Resources