QTest::sendKeyEvent on Mac with a real (native) Ctrl modifier - qt

QTest::sendKeyEvent(...Qt::ControlModifier) causes a Command Key sent on Mac (and vice versa all QKeyEvents on Mac having Command pressed report the Qt::ControlModifier).
What I need to do in order to achieve a real Ctrl key sending ?

Two solutions exists:
Disable the mapping transformation: QCoreApplication::setAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
Use the Qt::MetaModifier (Control key on mac is by default mapped to Qt::MetaModifier)
As mentioned in the docs, this mapping is normally expected by macOS users, as shortcuts are normally using the Command key instead of the Control (which is used on other platforms).
References:
https://doc.qt.io/qt-6/qt.html#ApplicationAttribute-enum

Related

Return Key in Edit Command Mode Shortcuts - Jupyter Notebook

While willing to write ↩a as a new shortcut for the run all cells above command I could not find how to specify the return symbol in Jupyter Notebook.
Writing return-a or ↩-ain the Edit Command Mode does not work and the modifier is not specified in the help dialog.
Any idea?
Return is not a modifier so shortcut like ↩-a make little sens (pressing enter and A at the same time. ↩,a meaning Return key followed by A key make more sens, but Enter is so pervasive for many actions that it is not usable in user shortcuts. I would suggest you to open an issue on jupyter/notebook on GitHub to ask for return to be added as a convenient way to map to ↩ , though even if we do that we can't guaranty that it will work. If you are willing to try to code that yourself, have a look at keyboard.js, the mapping from enter to displaying ↩ is already done in quickhelp.js, for mac at least.

Disabling BCD testsigning option using registry

My code should disable testsigning BCD option using Windows registry. The same as command line bcdedit -set testsigning off.
I can't do shellexecute with cmd. I found one Testsigning reference in registry, in HKLM\SYSTEM\ControlSet001\Control\SystemStartOptions value, but this value contains current kernel run options, not options for next start.
So, I can't use it.
I found that testsigning option are saved in HLKM\BCD00000000\Objects\{%GUID%}\Elements\16000049, but this GUID is different on different PC's.
How I could acquire it?
If you don't bother of activating it for all boot entries:
Enumerate all key names beneath "Objects"
Write your registry values in a loop into every found key name.
Using NT native API your approach could look something like the following pseudocode:
while(numEntries < index){
NtEnumerateKey(index++, &pGuidKeyname...);
RtlStringCbPrintfW(buf, %s, rootkey,pGuidKeyname);
NtSetValueKey(buf, "YES");
}

Returning from the '+' to '>' prompt in command line of R Studio

I know the prompt changes from < to + when the command line in R expects you to complete the current command. Is there a way (say, shortcut key) to immediately terminate the command being written and revert from the '+' mode to the regular console '>'?
Press 'Esc' key will bring you back to the prompt (<). You don't need to type word 'Esc'.
I suspect you are using a usb keyboard that has chromatic color controls via software. It sometimes mess up the keys therefore simply do a factory reset of your keyboard via install software. Then pressing "Esc" will revert to the
"greater than sign"

How do I create a UUID (GUID) in Livecode (or HyperTalk)?

How do I create a UUID (= Universally unique identifier, or GUID = Globally Unique Identifier, Microsoft speak) in Livecode or Hypercard?
The aim of UUIDs is to give practically unique keys to pieces of information without a central coordination.
References
Type 4 UUID (Wikipedia)
How to create a GUID in JavaScript
Is there any difference between GUID and UUID?
If you're on a Unix (like Linux or MacOS), you could use the shell() function to call the uuidgen Terminal command. It should be something like
put shell("uuidgen") into theUUID
That's a bit heavy-handed (creates a shell, runs a command line application in it, then quits it again), but will work on older LiveCode versions, and isn't that different from what a shell script does.
In HyperCard, you'd have to use AppleScript, either in an object whose script is set to AppleScript, or using the "do X as AppleScript" command. Not sure if AppleScript can natively build UUIDs, but if it can't, AppleScript can be used to run shell scripts. (The shell() function doesn't exist in HyperCard, it was invented by SuperCard, IIRC).
In case none of that helps, here's a specification that describes how to create a standard UUID: http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt It's not specific to any programming language.
In LiveCode 6.1 (released today) you can create a uuid using the uuid function. Type 4 random uuid is the default and type 3 and 5 digest based uuids are also implemented.
The following function creates a type 4 (random) UUID:
function getUUID
local tUUIDpattern
local tUUID
local tHexDigits
put "xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx" into tUUIDpattern
put "1234567890abcdef" into tHexDigits
repeat for each char tChar in tUUIDpattern
if tChar = "x" then
put any char of tHexDigits after tUUID
else
put tChar after tUUID
end if
end repeat
return tUUID
end getUUID
by now (at least in version 6.6.1) one can use put uuid(random) without shell
if the type is empty or random a version 4 (random) UUID is returned. A cryptographic quality pseudo-random number generator is used to generate the randomness.
If the type is md5 a version 3 UUID is returned.
If the type is sha1 a version 5 UUID is returned.

How to set user command in Qt Fakevim?

(1) For example, I want to set map gd g* in Qt's Fakevim like below but failed.
(2) And also I'd like to set F3 as the save command, how to do it?
(3) In Fakevim, it provides an option "Read .vimrc", but where to find the file .vimrc?
Thank you!
It doesn't look like there is a lot of documentation for FakeVim, so official sources might not exist. Most of this was obtained by experimentation.
If you want to dig deeper, I guess there's no source as official as the actual source: http://qt.gitorious.org/qt-creator/qt-creator/blobs/0809986e501415fe2c8508800b94b5b3169dc048/src/plugins/fakevim/fakevimplugin.cpp
User commands
First off, realize that in Tools>Options>FakeVim>User Command Mapping, you're only setting what your user actions will perform, not how you perform them.
By default, user command #1 is triggered by pressing Alt-V, then 1.
Alt-V, then 2, triggers user action #2, and so on.
You can change the keyboard shortcuts through the general QtCreator configuration interface, under Tools>Options>Environment>Keyboard. There is a "FakeVim" section with all the user actions listed. Select your user action of choice, press the little "erase" icon in the input field under "Shortcut", then press your desired shortcut key, which should appear in the input field.
Second, to finish a command where you would normally press enter, you should literally type in <CR> after the commands. You also need to enter in ':' to enter command mode.
So if you wanted to map the vim save command, ":w", to F3 via FakeVim, you would:
Go to Tools>Options>FakeVim>User Command Mapping.
Enter ":w<CR>" as one of the user commands (say #7).
Go to Tools>Options>Environment>Keyboard.
Find the FakeVim action "UserAction7".
Set F3 as a shortcut for it.
Now, every time you're in the editor, you should be able to click F3 and have the FakeVim :w command execute, which will save your file.
Note that there is also an option to set a shortcut for "Save" directly in the QtCreator keyboard settings, so for this particular shortcut you don't actually need to go through FakeVim.
Setting shortcuts for other vim commands should be similar. Note that you're restricted to the subset of vim commands that FakeVim implements. Refer to the source, linked above, for checking any particular command you're wondering about.
Vimrc file
On Linux this would be ~/.vimrc, a file in the user's home directory. I presume you're asking about Windows.
The best source I can find is this bug report about it being hard to use Fakevim's vimrc on Windows: https://bugreports.qt.io/browse/QTCREATORBUG-8748
Following that, the file Fakevim looks for is ".vimrc" in %USERPROFILE% (you can enter a name like that in Explorer to go to the folder). However, it's tricky to access a file with a name like that on Windows. (Thus why the real vim uses '_vimrc' on Windows -- but FakeVim apparently doesn't, at least at the moment.)
Here is a superuser page with workarounds for how to create such files on Windows: https://superuser.com/questions/64471/create-rename-a-file-folder-that-begins-with-a-dot-in-windows

Resources