Turning TextPad into an IDE for any programming language!
Posted: Sat Aug 07, 2004 6:47 pm
Just registered TextPad (after using it for a long time, go figure -- I should have registered much earlier but my old copy was so stable and I never bothered to visit TextPad's website). I just discovered this forum.
Have been a programmer for almost 20 years, and am writing a programming-language interpretor from scratch, and am now starting to create an integrated debugger for my scripting language -- by using TextPad!
I found a way to turn TextPad into an IDE for just about any programming language I can create (or those that can attach to third party IDEs, or languages with debugger hooks, etc).
Single Stepping
Variable Watches
Breakpoints
Variable Watches
Error Highlighting
It all works in TextPad!
It only requires a small helper utility, read below...
It appears TextPad already contains a built-in API complete enough to make TextPad an IDE debugger for any custom scripting language that's ever developed.
I wrote my own custom scripting language and have full control over the interpretor source code. So far, I have found this information:
TextPad provides a DDE method for this. Execute this TextPad utility:
"C:\Program Files\TextPad 4\SYSTEM\DDEOPN32.EXE" file
with the following command line parameters.
D:\path\MyCustomScriptLanguage.SCR($Y, $X)
Replace $Y and $X with the line number and column number.
Replace the path with the actual path of file to be viewed.
I wrote a test utility that does this DDE technique of file-loading and cursor-positioning, and it actually works. For cursor positioning, I add the string (#,#) to the end of the path of the file to load, no spaces between path and the (#,#) where # is replaced by Y and X cursor coordinates in the document. If I do this DDE call while the file is loaded, the tab is automatically selected (convenient) and the cursor position is immediately moved to line Y and column X. You can use the Windows ShellExecute( ) with the above information. You can even use a Windows shortcut on your Windows desktop that automatically opens a specific document at an exact line number Y and and column X. If TextPad is already running, the document tab is created (or selected if already open). And the cursor is moved to the specified position. See how it is simple? See how it can already be used for singlestepping during IDE debugging! No need to figure out what DDE is, if you don't mind executing DDEOPN32.exe everytime you singlestep (fortunately, it's instantaneous enough)
That means I can use an external program to launch TextPad with the offending line, everytime my script interpretor finds an error with a line of code in a script. Perfect.
Even if TextPad has no other API than this, it is now already possible: I can simply use a Windows system keyhook to capture the F5, F9, F10, F11 keys (capture them in a background program that I write, even if TextPad in the foreground) to do single stepping, and do simulated breakpoints by using TextPad bookmarks. (I'd just have to keep track of which bookmarks are set and which are not. Basically, I'd capture the F9 key for setting execution breakpoints, and automate TextPad into setting a bookmark for that current line.).
ACTUALLY WORKS TODAY for all Textpad 4.x: Custom keyhook software running in the background would capture industry standard IDE keypresses:
Run - F5 - Simply execute the currently open document in my interpretor. My utility captures this keypress even if TextPad is in the foreground.
Singlestep - F10, F11 - Single step through my interpretor, and use the TextPad DDE to move the cursor to the currently-executing line of script. My utility captures this keypress even if TextPad is in the foreground.
Breakpoint - F9 - Set an execution breakpoint in my interpretor, set TextPad bookmark via simulated Ctrl+F2 keypress (for current line in TextPad, also execute TextPad's bookmark utility as a makeshift way of highlighting the current line as a breakpoint). Whenever my interpretor hits that breakpoint, it would use TextPad DDE to move the cursor to that currently-executing line of script. I can even use TextPad DDE followed by keyboard automation to re-highlight breakpoints (TextPad bookmarks) if TextPad ever gets restarted, which means bookmarks are cleared but the breakpoints are still 'set' within my own software. (My utility captures this F9 keypress even if TextPad is in the foreground.)
Variable Watch - Via Clipboard - Simply mark the text and do a Copy (Ctrl+C). This copies the current string to the clipboard, and my utility would automatically monitor the Windows Clipboard in the background, and if a variable name exists by the string in the clipboard, I would automatically pop-up a window from my utility displaying the current value of the variable highlighted)
Error Highlight - Use the existing TextPad DDE call to move the cursor onto the offending code, and display the error message via my utility. (runtime error, first compile error, etc)
Current Cursor Position - Done via spying on TextPad messages in the system-wide windows message-monitoring hook within my utility. I need my interpretor to know the current cursor position whenever doing things like setting a breakpoint, since there's no other way to monitor which lines in the text document have TextPad bookmarks (used as breakpoints)
Opinions? Is there a better way to coax TextPad to become a full interative debugger IDE, complete with breakpoints, single stepping, and variable watches? It indeed works with the aboveforementioned 'hacks', but it is faintly Rube-Goldbergish ... still much faster than writing my own IDE from scratch!!
Have been a programmer for almost 20 years, and am writing a programming-language interpretor from scratch, and am now starting to create an integrated debugger for my scripting language -- by using TextPad!
I found a way to turn TextPad into an IDE for just about any programming language I can create (or those that can attach to third party IDEs, or languages with debugger hooks, etc).
Single Stepping
Variable Watches
Breakpoints
Variable Watches
Error Highlighting
It all works in TextPad!
It only requires a small helper utility, read below...
It appears TextPad already contains a built-in API complete enough to make TextPad an IDE debugger for any custom scripting language that's ever developed.
I wrote my own custom scripting language and have full control over the interpretor source code. So far, I have found this information:
TextPad provides a DDE method for this. Execute this TextPad utility:
"C:\Program Files\TextPad 4\SYSTEM\DDEOPN32.EXE" file
with the following command line parameters.
D:\path\MyCustomScriptLanguage.SCR($Y, $X)
Replace $Y and $X with the line number and column number.
Replace the path with the actual path of file to be viewed.
I wrote a test utility that does this DDE technique of file-loading and cursor-positioning, and it actually works. For cursor positioning, I add the string (#,#) to the end of the path of the file to load, no spaces between path and the (#,#) where # is replaced by Y and X cursor coordinates in the document. If I do this DDE call while the file is loaded, the tab is automatically selected (convenient) and the cursor position is immediately moved to line Y and column X. You can use the Windows ShellExecute( ) with the above information. You can even use a Windows shortcut on your Windows desktop that automatically opens a specific document at an exact line number Y and and column X. If TextPad is already running, the document tab is created (or selected if already open). And the cursor is moved to the specified position. See how it is simple? See how it can already be used for singlestepping during IDE debugging! No need to figure out what DDE is, if you don't mind executing DDEOPN32.exe everytime you singlestep (fortunately, it's instantaneous enough)
That means I can use an external program to launch TextPad with the offending line, everytime my script interpretor finds an error with a line of code in a script. Perfect.
Even if TextPad has no other API than this, it is now already possible: I can simply use a Windows system keyhook to capture the F5, F9, F10, F11 keys (capture them in a background program that I write, even if TextPad in the foreground) to do single stepping, and do simulated breakpoints by using TextPad bookmarks. (I'd just have to keep track of which bookmarks are set and which are not. Basically, I'd capture the F9 key for setting execution breakpoints, and automate TextPad into setting a bookmark for that current line.).
ACTUALLY WORKS TODAY for all Textpad 4.x: Custom keyhook software running in the background would capture industry standard IDE keypresses:
Run - F5 - Simply execute the currently open document in my interpretor. My utility captures this keypress even if TextPad is in the foreground.
Singlestep - F10, F11 - Single step through my interpretor, and use the TextPad DDE to move the cursor to the currently-executing line of script. My utility captures this keypress even if TextPad is in the foreground.
Breakpoint - F9 - Set an execution breakpoint in my interpretor, set TextPad bookmark via simulated Ctrl+F2 keypress (for current line in TextPad, also execute TextPad's bookmark utility as a makeshift way of highlighting the current line as a breakpoint). Whenever my interpretor hits that breakpoint, it would use TextPad DDE to move the cursor to that currently-executing line of script. I can even use TextPad DDE followed by keyboard automation to re-highlight breakpoints (TextPad bookmarks) if TextPad ever gets restarted, which means bookmarks are cleared but the breakpoints are still 'set' within my own software. (My utility captures this F9 keypress even if TextPad is in the foreground.)
Variable Watch - Via Clipboard - Simply mark the text and do a Copy (Ctrl+C). This copies the current string to the clipboard, and my utility would automatically monitor the Windows Clipboard in the background, and if a variable name exists by the string in the clipboard, I would automatically pop-up a window from my utility displaying the current value of the variable highlighted)
Error Highlight - Use the existing TextPad DDE call to move the cursor onto the offending code, and display the error message via my utility. (runtime error, first compile error, etc)
Current Cursor Position - Done via spying on TextPad messages in the system-wide windows message-monitoring hook within my utility. I need my interpretor to know the current cursor position whenever doing things like setting a breakpoint, since there's no other way to monitor which lines in the text document have TextPad bookmarks (used as breakpoints)
Opinions? Is there a better way to coax TextPad to become a full interative debugger IDE, complete with breakpoints, single stepping, and variable watches? It indeed works with the aboveforementioned 'hacks', but it is faintly Rube-Goldbergish ... still much faster than writing my own IDE from scratch!!