So I wanted to change the keyboard shortcut that's assigned to "Comment Selection" to something that makes sense for me. I don't use many keyboard shortcuts, mainly because I have a hard time remembering all of them.
So, I wanted to change the one that is assigned to "Comment Selection". The default is Ctrl + K, Ctrl + C. I don't like the concept of having to do "2" keystroke combinations to accomplish this. I want to be able to quickly hightlight, enter the keystroke, and then move on, all while leaving one hand on mouse, and one on keyboard.
Too much info...
I changed my keystroke to be Ctrl + Shift + C, but the "event" never fires. It shows up in the options "Edit.CommentSelection" just fine. I overwrote the previous 3 values ("global", "text editor", "data warehouse designer"). I see there are other events that fire when Ctrl + Shift combination is used, so that rules out the possibility of not being able to use the Shift key, which was my original thought.
Any other suggestions on how to get this working for me?
From the discussion above, it seems that the shortcut was already assigned to Edit.CopywithHeaders (which is the default assignment for that shortcut). Removing that assignment will fix your problem.
Related
I want to understand if it is possible to fix LGS bugs, with scripts.
(I'm using a G600 mouse that has gshift ( shiftstate= ? ), holding that on the mouse turns on a certain 2nd layer for all buttons until I release.
The problem: if I assign to the 2nd layer (gshift pressed/holded), double click on MOUSE_BUTTON 1 (lmb).
Then LGS starts sending a double click, all the time, regardless of profile, or gshift state.
Also there is same problem: by default MOUSE_BUTTON 5 and 4, are assigned as "forward", "backward". And they send a double click by default.
If by activating the 2nd layer (gshift), we assign something else to them (any other keyboard character), the double click disappears. But until we activate another profile which still has the previous settings.
That is, if we assign any option in gshift to Mouse_buttons 1-6, it can cause double click.
Any ideas to solve the problem would be welcome!
P.s. I don't want to use G-Hub as I also use 2 older devices (G13,G510) which are not supported by Ghub
tried edit XML file, but no luck
I want to keep all syntax highlighting, autocomplete, commands etc. of Emacs c-mode (and I'll add in company-mode or similar shortly) but I want to disable everything in c-mode which:
Reformats other than if I C-<command> or M-<command> ask it to.
Moves my cursor around the source, even momentarily, unless I asked for it. For example, closing parens/braces highlighting the matching one.
Ever i) inserts anything I didn't type (other than 1 Tab = 4 spaces) or ii) refuses to insert something I did type because formatting.
Reformats, repaginates, realigns or otherwise edits the source for any reason, including on paste, on save, or because the moon is gibbous.
I've already set (setq-default c-basic-offset 4) and (setq-default indent-tabs-mode nil).
I have tried:
C-x C-l a.k.a. c-toggle-electric-state a.k.a. (setq-default c-electric-flag nil) which fixes some of 4, but Tab still reformats code when it feels inclined, and I'm guessing isn't alone; and doesn't fix 2 or 3.
c-auto-align-backslashes which fixes one above case only.
(setq c-syntactic-indentation nil) which partially fixes 4, but breaks 1 and 3 (for instance, Tab doesn't insert at the cursor), and doesn't fix 2.
text-mode which obviously removes all the c-mode features I want to keep.
Various searches and dives into https://www.gnu.org/software/emacs/manual/html_mono/ccmode.html, which carefully documents 2^1024 settings but doesn't exhibit an "all formatting off" switch that I can find.
Scanning https://sourceforge.net/p/cc-mode/cc-mode/ci/default/tree/ for obvious flags to disable (*blork*?)
I've been at this for hours, so any help gratefully received.
Update: More thrashing around: installing emacs source code (apt-get install emacs24-el) and using C-h k <key combo> to find the function called when a key is pressed. M-x find-function to browse that source to work out what it's actually doing and look for hooks. (setq-default indent-tabs-mode nil) to stick with spaces, not tabs. (setq-default blink-matching-paren nil) to prevent cursor jump on closing parens/braces. I still can't disable formatting, or achieve 1, 2, 3 and 4, but I'm getting better at whack-a-mole.
First observation: this is a difficult sort of question to answer, because "disable everything that does ...." is a bit unspecific. However...
Item 2. (Moving point momentarily to the matching open paren when you type a close paren) is easy: (setq blink-matching-paren nil). This is in the Emacs manual on page "Matching Parentheses". (Whoops! You've already found that one).
You don't like the action of the tab key; what do you want it to do? It's bound to c-indent-command, which indents the current line inwards or outwards to the "correct" position. I'm guessing you want simply to insert spaces to bring point to the next 4*nth position. How about tab-to-tab-stop? Try (define-key c-mode-base-map "\t" 'tab-to-tab-stop). Note that defining it in the default key map would not work, since the major mode key map takes priority over it.
Having done C-c C-l to disable the automatic indentation on typing, e.g., a ;, does typing a ; still do anything to offend? If so, you could disable its "special" features entirely with (define-key c-mode-base-map ";" 'self-insert-command)
Again, a list of specific things you don't like, even a long list, is a lot easier to deal with than "everything which inserts anything I didn't type". The maintainer of the mode just doesn't mentally classify things that way.
Anyhow, I hope you manage to get things sorted out.
I am trying to keep track of the pressed keys. I have glutIgnoreKeyRepeat(1) and I register the key events (down/up for normal and special) in an object that keeps track of the keys pressed (called the list of pressed keys from now on) so that I just check in my display function if a key is pressed by looking in that list.
The problem is with SHIFT: Different keys register as DOWN and UP (depending on whether SHIFT was pressed or not) for the same physical keyboard key (eg.
a and A, 1 and !, [ and { etc.)
Consider this (with {key1 key2} representing my list of pressed keys after the event):
initial state : {} no keys listed as pressed
SHIFT DOWN : {SHIFT}
a DOWN : {SHIFT A} (because SHIFT is still down, capital 'A' registers as the key down.
SHIFT UP: {A}
a UP: {A} (because SHIFT is not pressed, lower 'a' registers as the key up, so a is removed from the pressed key list (which actually doesn't exist), and A still remains)
final state: {A} even though no keys are still pressed on the keyboard.
For alpha keys I can solve this by adding/removing the lower case of the keys (a instead of A).
But what about 1 and ! or [ and {. glutGetModifiers doesn't help here. Or what if a key is pressed, the window looses focus, the key is released and the window gains focus again (there is no event to tell that the key was released when the windows lost focus)?
Is there a general solution to check if a key is pressed? (platform dependent solutions are ok, another library is not for me, but maybe for others who need to solve this)
What you want are the keycodes, the physical number of the key being pressed on the keyboard. These are different on Apple and PC keyboards, and can also be different on keyboards in other countries where the letters change positions.
Most programs don't care about keycodes, they want actual letters and modifier keys, so the system event handler provides a translation from keycode into the intended character/special key. GLUT is designed to be simple, portable, and cross-platform, so uses these routines.
If you're writing a game or simulator, just lowercasing everything is probably good enough. For that kind of high speed interaction, most players won't want to distinguish between 1 and !, or 2 and #. The Ins/Del and arrow key blocks (usually) don't have multiple symbols anyway, and the numeric keypad is too far away for most people to hold down a modifier key at the same time.
If you really, truly, need to track every key state, sorry GLUT won't work for you. On MacOS you ask the NSKeyEvent for the keycode, on MS Windows you use DirectX, on Linux you use the XKeyPress|ReleaseEvent keycode.
Hope this helps.
I'm trying to make a simple text editor with winapi, its working for simple letter, but its not with capital letter or shift key.
char keys[256];
int x = 0;
while (1)
{
for (x = 0; x <= 256; x++)
{
if (GetAsyncKeyState(x) == -32767)
{
char c[5];
GetKeyboardState(keys);
ToAscii(x, MapVirtualKey(x, 0), keys, c, 0);
putchar(c[0]);
}
}
}
The behaviors of keyboard input are far more complex than what you think. Your method doesn't work because:
GetAsyncKeyState can miss keys. What happens when the user hits a key between calls?
What happens when you hold down a key? What about keyboard repeat?
Most critically, your code assumes a 1:1 relationship between key and character. You don't have any mechanism to deal with combinations like shift / caps lock state, or dead keys.
It would be better if you tried to explain what you're trying to do, and you can get advice on the right way to approach it. Trying to re-invent the behaviors of such a fundamental input device is not likely to be the best approach.
GetAsyncKeyState is likely not the way to go here: the real way to make a text editor type control is to instead handle the WM_KEYDOWN and WM_CHAR messages. Windows will send these to your WndProc when your HWND has focus. This is the technique used by the Windows EDIT and RichEdit controls.
Use WM_KEYDOWN to handle the non-character keys - like arrows (VK_LEFT, VK_RIGHT), page up and so on; and use WM_CHAR for text characters. WM_KEYDOWN tells you the key pressed using a VK_ value, and doesn't take shift state into account; while WM_CHAR does take shift state, so gives you 'A' vs 'a' or '1' vs '!' as appropriate. (Note that you have to have TranslateMessage in your messsage loop for this to happen.)
Having said all that, an even easier/better thing to do is just use the existing Windows EDIT or RichEdit controls and let them do the work for you - there's rarely a good reason to reinvent the wheel - unless you're playing around for fun and learning Win32 perhaps. Writing a proper text editor is pretty complex; there's a lot of non-obvious stuff to consider, especially when you get into non-English text: you'd need to ensure it works correctly with right-to-left text (Arabic, Hebrew), works with IMEs which are used to enter Japanese and Chinese characters. And you have to ensure that your control is accessible to screenreaders so that users with visual impairments can still use the control. EDIT and RichEdit do all this for you.
The actual Notepad app, for example, is just a wrapper for an EDIT control; while WordPad just wraps a RichEdit control; both let the control do all the hard work, and just add the extra UI and file save/load functionality on top.
Try to call
GetKeyState(VK_CAPITAL);
before
GetKeyboardState(keys);
I'm using the standard .Net Winforms datagridview control to display & manipulate data, however I have (or thought so) suppressed user deletion via:
this.dataGridViewTestSteps.AllowUserToDeleteRows = false;
Now pressing 'Del' does in fact not delete rows, but surprisingly Pressing [Shift] and [Del] at the same time does. What's up with Shift-key overriding the property set above? Is there anything I can do to fully disallow deletion?
Oh my - the solution is apparently rather simple, but somewhat unexpected: Shift + Del seems to be a system wide alternative to Ctrl + X. E.g. when editing a text in notepad.exe, selecting some characters and pressing Shift + Del it seems to have the same effect & functionality as a standard Cut / Ctrl + X would do.
Since I do handle Ctrl + x in my application, it does proceed and 'delete' these rows, even though they are actually placed on the clipboard.
So this has nothing to do in particular with the datagridview, usercode for ctrl + x is simply also called when shift + del is pressed.