How I can add some items to the code completion combobox of the Delphi IDE - delphi

I'm working in a Delphi IDE expert and I wonder if it's possible add new items to the code completion combobox displayed by the Delphi IDE when the user press CtrlSpace
UPDATE:
What I need is add items to the code completion list based in a specified type.
example suppose which I have a type called TMytype, what I want to do is add addional items to the code completion list when the user type a variable of the type TMytype
check this image

I found your question somewhat confusing but if you are in search of credible source on "Custom Live Templates" and the like on Delphi, head to the blog of Cary Jensen here.
Edit:
Looking forward to further improvement of the scope of the question, I suggest here another direction to explore:
Source code manipulation using IOTAEditor, IOTASourceEditor, IOTAEditReader and the like
Some Parsing for sanity check prior to apply any modification.
Adoption of Client DataSet as a format to store data (It's serializable) to simplify the coding of IDE editors.

Perhaps I haven't fully grasped the extent of what you are asking here, but you can add templates simply by going to 'View|Templates' from the Delphi IDE. This then opens a template viewer. Press the '+' icon. It opens a template1.xml document which you can then edit so create your new item.
If you wish to do this programatically, just add an xml file (of the same format) to the ..\RAD Studio\code_templates folder.

Related

Is there any editor or popular editor extension that automatically remove quotes/brackets?

There are too many text editors, which have the function, that if I just select a piece of the code and press the quote/bracket key, the selected code becomes wrapped into the type of the quotes/brackets I pressed. But do you know any or are you using any, which has also the function, that if I select the piece of the code wrapped into the quotes/brackets and press the same quote/bracket key or some key combination, that piece of code becomes unwrapped?
Also if you know any editor or popular editor extension that automatically remove all quotes/brackets from the code, please write it too. Everything would be helpful.
We are doing some research and this question is still unanswered. Please help us if you know anything about.
I create a simple Zeus (Windows) Lua script that does this for the quote case (i.e. the macro wraps any marked area in quotes).
In a similar fashion another script could be written for the brackets case.
Also as this simple script shows, this should be possible in any scriptable editor.
The script can be found here: http://www.zeusedit.com/zforum/viewtopic.php?t=7148
SynWrite editor (Windows) can do scripting for u. You can write Python plugin in 10min, and assign it a hotkey, so selection (or all text) will dequote, or what ever.
Finally, I've made it by writing my own extension to my favourite editor.

Remove AddIn path from UDF in Excel formula

My addin was xla, now I use excelDNA, so it becomes xll,
When I open spreadsheet built in previous version of My addin,
for the UDF, it shows myUDF with path of xla. e.g "C:\Program Files\Installation folder\MyUDFs.xla!MyUDF",
when I click Edit link and change source to "C:...\MyUDFs.xll"
I got a pop up which says
"Excel cannot update one or more links in this workbook. To update the links, open all the link source files(click Edit Links on the Data tab).
To be sure all calculations are updated. press F9"
I click OK, then the path of MyUDF changes from xla to xll, e.g. C:\Program Files\Installation folder\MyUDFs.xll!MyUDF
For clients, this will break all their spreadsheets (could be 100+) built in previous version.
I know I can write a VBA code to remove paths from all MyUDF. but it is not ideal since users have to open up spreadsheet and put the code in spreadsheet and run.
I wonder if there is a better/more convenient way for clients to solve the issue
thanks
Internally, Excel stores different information for an .xla function
and an .xll function. It's not so easy to around so that you can make
an .xll that is compatible with functions that were entered into the
sheet as functions in an .xla.
You can also see how Excel stores this information by poking around inside the .xmlx file a bit.
This Wilmott discussion might be relevant:
http://www.wilmott.com/messageview.cfm?catid=10&threadid=79763
For your case the best I can suggest is adding a conversion macro to
your .xll, and having the user press the 'Fix-up' button when they
open spreadsheets that have not been converted yet.
This is the solution I use at last. I keep my xla addin, in xll, I register the same MyUDF with the same sigature(while, almost the same, optional parameters are not supported in xll, but are used in my xla) and set IsHidden = true. So there is only one MyUDF shows up in insert function list. When you type in =MyUDF and click function wizard, the version in xll shows up in function argument window. In Excel 2007, when I type =MyUDF, there is no function in drop down. In Excel 2010, when I type =MyUDF, there is a drop down. So the solution works better in Excel 2010.

Form Designer Save and Load

i made a simple form designer in delphi, drag and drop a button on the form and it draws it, but the thing is i cant save/load this project since i dunno how to, is there anyway that i could be abel to save it to .rc file and load it from there?
That depends how you programmed your form designer. In forms created in Delphi's designer all components (and subcomponents) are referenced from TForm.Components array property. All controls are also referenced in TForm.Controls array property (if you remove an container control, all it's subcontrols are destroyed too).
If you have followed that pattern, all you have to do is monitor additions to the TForm.Components array (maybe using an overriden TForm.Notification method) and using this data to build your persistent form's file.
The VCL contains methods for using its builtin DFM support. There is a sample in the Delphi 2009 documentation for ObjectBinaryToText; I guess this works for D7 too. And IIRC there already was a code fragment for ComponentToString in the D5 help - search for ObjectBinaryToText.
Delphi stores form layout in *.dfm file. You can use it's structure to save your projects. File is textual and readable by humans. It is not hard to parse file like that rading one line by one. If you need more help, ask for it.
You can use something like delphi .DFM. Counting all objects and then read their attributes and write them into a file. Example Code:
For i:0 To Form1.ComponentsCount-1 Do Begin
// Read Component Attributes And Write Them In Your Format
End;
If you just want to save the form you designed in your designer, use something like TFileStream to create the RC file when the user saves. You might be better off with your own file format for your forms, with the option to export as an RC file, as RC files arent really meant to useful for storing any design time info you may need.

Does Texniccenter or any other tex editor auto-complete references in Latex?

I want to use a latex editor that has auto completion feature for existing references in a latex file. Do you know any good ones? I am trying to find this feature in texniccenter, but I guess it doesn't exist or I could't find it yet.
Update:
Ok, I found how to enable auto completion in Texniccenter. I needed first create a project. Then open the file in this project (or copy its text). Now Ctrl-Space inside a \ref{} tag completes the reference automatically.
Texlipse does this, also with Ctrl+Space.
Inlage includes such a function, too. New commands and new environments will also appear in the auto completion list. If you use extern BibTex files the \cite{} command will open a list with your articles and books from you .bib file.
Ok, I found it. I needed first create a project. Then open the file in this project (or copy its text). Now Ctrl-Space inside a \ref{} tag completes the reference automatically.
Kile has reference completion. If you type Ctrl+Space inside of a \ref{}, you get a list of all the references (that existed last time you compiled, of course).
LEd presents a click list of them when in a \ref{}
The RefTeX mode for Emacs will do what you're asking for: the shortcut C-c ) activates the "insert a \ref" mode (of course, you can customize which type of reference: fancyref, hyperref, etc) and pressing TAB will allow you to start typing and autocomplete by tabbing again after typing some characters.
It also figures out (or asks if it can't) what sort of ref you're inserting and shows a list of all the defined \labels in your document, selectable with the arrow keys or C-n / C-p.
Now we just need a Vi user to come along and tell us how to do it there...
Now texmaker does, not need any special key.

Delphi Short Cut to add Date and Name Comment

Does anyone know of a short cut to place my name and the date where the cursor is i.e.
//021208 DarkAxi0m
so i don't keep check what the date is when i'm adding comments.
Im using Delphi7, with CnPack And GExperts Installed.
I think it should be able to be done with one of those experts.
I use GExperts to do this, like so:
in the
GExperts\Configuration
Select the Editor Experts tab.
In the list of experts, select
Insert Date\Time
Click on the configuration, insert the desired text:
'//' ddmmyy 'DarkAxi0m: '
//021208 DarkAxi0m:
After, to insert your new Date name comment all you need to do is:
ctrl+alt+a
I setup most programmers at the job like that.
It is also simple to do with GExperts' Expand Macro Template (found in Editor Experts).
I use this expansion to insert yyyy-mm-dd at the current position:
%YEAR%-%MONTH%-%DAY%|
For a solution that will work in most applications under Windows, not only in Delphi, you can use Authotkey (free, autohotkey.com). One of its many features is the ability to expand strings that you type - typically used for autocorrecting typos.
I start all my shortcut strings with a semicolon, since it practically never leads strings I type in real life, so in your example, to insert a comment-date-username sequence, I would want to type semicolon, slash, slash:
;//
The Authotkey script (which you can put in an .ahk text file and add the file to Autostart) would look like this:
::;//:: ; this means: when I type ";//", do what follows
FormatTime, curDate,, yyyy-MM-dd ; the double comma is intended
SendInput // %curDate% %A_UserName% ; variable expansion
return
This produces the following output:
// 2008-12-05 moodforaday
AHK syntax is a little dense, but there is an extensive help file.
On edit: this script could be expanded to apply the correct comment syntax depending on the IDE you are working in at the moment. You would detect active window title, find a signature substring ("Delphi") and choose the proper comment character(s). This way you could type the same hotstring to insert your comment regardless of the current IDE or language. You can also use SendInput to position the caret the way Delphi templates do.
Never mind found one in CnPack/Soure Templates
Added the template
//%Date% DarkAxi0m
Note: i should look in the menus more closely
You might also look at the Live Templates feature, which can be scripted to do just what you want:
http://cc.codegear.com/Item/24990
Don't be put off by the name, it includes a template script to include the date, time, including the ability to format it as you want.
Here is a variation with GExperts (www.gexperts.org) that makes it easy to search for changes based on developer or date.
Example of output and comment:
//07.25.2009 (SLB20090725) - Added 3rd optional parameter.
Besides an easily readable date I can easy search for comments programmer, by year, year+month etc.)
For example I can search for (SLB200905 for any comments I logged in May of 2009.
To do:
Under the GExperts menu open Configuration... (at the bottom of the list) then select the Editor Experts tab.
Locate 'Insert Date/Time' and double click on it.
//mm.dd.yyyy '(ABC'yyyymmdd') -'
Where ABC is the programmers name, initials, id, or whatever.
Then use Ctrl-Alt-A when in Delphi's IDE to insert
This should work in any verison of Delphi supported by GExperts.

Resources