Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 17836, Comment multiple lines of your code with a single key-stroke

by Nafis Sadykov Email: Anonymous


This OpenTools keybinding introduces 'Ctrl+/' shortcut for fast multi-line commenting.
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 5.0  to 7.0 737 downloads
Copyright: No significant restrictions


Size: 2,937 bytes
Updated on Thu, 12 Jun 2003 15:16:11 GMT
Originally uploaded on Tue, 23 Apr 2002 18:28:16 GMT
SHA1 Hash: 88A03AFCC7E3E07CE7A0F0146A3494722C25549A
MD5 Hash: 77070BC9447BC6071AAE6AA228C81648

    Explore the files in this upload

Description
Keybinding for Delphi(5, 6, 7) and C++Builder(5, 6) editors. Introduces 'Ctrl+/' shortcut for fast multi-line commenting.

How it works: Select text block (with a mouse) and press 'Ctrl+/' to comment/uncomment the lines contained.

Quite useful when one needs to comment and uncomment multiple lines of code often (e.g. during debugging).

Installation: just install as you'd install a new component (clicking "Component-> Install Component" menu), then compile and install the resulting package.
Note: for C++Builder - don't forget to add the path of your Builder's Source\ToolsAPI folder to your package's library paths (in Project Options) to compile.
----------------
Notes on implementation code:

Implementation would have been straightforward except for the fact that, due to some reasons, 'Ctrl+/' shortcut (and some others) are just not caught by IDE for us when implementing IOTAKeyboardBinding in a usual way.

So we need some additional steps to take:

1) Use IOTAKeyBindingServices.SetDefaultKeyProc() to define a callback for all the shortcuts pressed, so that we could sort them out ourselves.
This step doesn’t help much by itself. Though all the shortcuts are reported duly to our callback – all(!) of them come with the same(!) KeyCode parameter value (possibly due to some IOTA bug).
So, there seems to be no way of differentiating between the shortcuts in our default key procedure. Except to

2) Use GetKeyboardState() WinAPI call to check the pressed keys independently.

Using the both steps above to overcome the current IOTA key binding services limitation lets us get our 'Ctrl+/' shortcut nicely.
The rest of the code is pretty straightforward. See comments in code for details.
----------------
05 May, 2002 - uploaded slightly improved version.
12 June, 2003 - checked for Delphi7

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03