Sign in Join
Wiki copytemporary

Textmode IDE development: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11See also [[Textmode IDE]] for more user-oriented hints, and [[go32v2 development]] for hints about the particular dos problems of the IDE.
22
33## General problems
44
55While the obvious task for the textmode IDE is of course fixing several or some of the 80 bugs, some other stuff comes to mind as future projects. Nearly all have to do with the fact that the IDE effectively stopped evolving significantly since 1.0 times. A lot of problems and ugliness lies in the TP/DOS legacy from this period:
66
77- the fact that it uses Dos, rather than Sysutils for its filename operations.
88 - now that the compiler uses sysutils mostly, the DOS versions are the less tested ones.
99 - the fact that shortstrings (or parts of them) are used for filenames.
1010 - under windows there is no support for unc-paths
1111
1212- Even the shortstring filename handling is far from perfect, since the IDE clearly hasn't had the end-user testing for *nix targets that dos/win32 had. Grepping for fixfilename() might yield such problems (like e.g. bug \#5614), where filenames are pretty printing, however effectively killing case sensitive filesystems. Bringing this up to ansistring/sysutils level might also help to unify these routines between textmode IDE and Lazarus.
1313
1414- Some functionality is deprecated or not active or documented. Examples are browser and code folding (see comments of bug \#6696 Some of the functionality mentioned in \#11583 might also be "newer"). Note that this kind of functionality is often not finished, e.g. afaik there is no way to save folds. (make them persistent some how). Also the editor components seem to have incremental syntaxhighlighting under ifdef.
1515
1616- Another major problem is that the docs have significantly grown. On a PII-233 (128MB and a more recent 20GB disc) it took 20-40 minutes to install the HTML files from the help. Nowadays we have chm support in the FPC tree, maybe it is time to kill all the old helpfile formats and standarize on CHM for a while. (removing the need to have separate files HTML is I think more important than killing e.g. .tph) **Initial CHM support added to trunk** See the separate section about this topic.
1717
1818- On *nix, terminals are swiftly adopting UTF-8 as output type. Supporting this, even very minimally (say ISO8859-1+linedrawing) will be a quite complex task. Required FV rewrite is [[Free Vision|done]] as of February, 2022.
1919
2020## Compatibility
2121
2222In the past the Textmode IDE was compatible with lots of compilers and platforms that are dead. This compatibility has not been maintained/tested for close to a decade, so it is doubtful it works at all. So IMHO it can be removed, and dependencies on things like sysutils are no longer forbidden.
2323
2424## ansistringification
2525
2626Since FV has reduced in meaning, maybe it can be modernised using the delphi model a bit (streaming and constructors/destructors). I know this is heresy, but a tpobj version could continue to exist. It is mainly for the IDE. I also don't know if it is worthwhile at all (most notably if FV exploits the static nature of objects...).
2727
2828Maybe a good first approximation would be to try to introduce ansistring everywhere. (**Florian has said he has tried this in the past, but that he got stuck. I did an attempt and also got stuck.**)
2929
3030I did a real minor attempt to kill some redundant string routines, but are stuck with the fact that one can't import sysutils into a major TV or IDE because that will cause incompatibilities due to the pstring type. (which is defined both by TV as by sysutils). This is probably the reason why wutils wraps so many sysutils routines, together with the fact that cross-unit overloading seems a bit ambiguous if the relevant parameter types are convertible to eachother (e.g. shortstring and ansistring, or char) It would be major FV re-engineering, and a significant loss of backwards compatibility to fix this. )
3131
3232It could be easily remedied by reworking TV/IDE to use a "pshortstring" everywhere, which is still compatible with pstring for backwards compatibility as long as sysutils isn't added.
3333
3434A second stage would replace all path related strings by ansistrings.
3535
3636For this it is also interesting to look at the C++ version, since there some features only more recently introduced to pascal are added (operator overloading, generics). However a new codebase doesn't have to strictly follow C++, since FPC has certain features that are useful (open arrays, arrays of const, dyn arrays) too.
3737
3838**note:** it seems that (static) TP objects are not initialized/finalized. Using ansistrings with them is thus hazardous. Heap TP objects seem to be initialized/finalized. **Fixed by Sergei r16632,16635**
3939
4040## Chm Support
4141
4242The [[chm]] support was mainly meant to remedy the defects of the loose html based help; mostly install time, HD size (fragmentation, uncompressed) the fact that indexing must be done on the fly, and the constant little problems with filenames in generated HTML files.
4343
4444Extract the loose HTML help on a Athlon XP2000 takes 8 minutes, and creating the index another 5. CHM reduces this to effectively zero, and adds the full text search capability. On the P-II 233MHz that I occasionally use for DOS testing, times can be over an hour on plain dos.
4545
4646The CHM support has been in the IDE since 2.2.4, and most seems to be working. Sometimes the html generation from the latex documents has problems, but strictly speaking that is not a chm problem
4747
4848The LaTeX docs used to be a problem, but recently there has been progress in this department, see [[chm backend for fpdoc|Chm backend for fpdoc, latex part.]] Other improvements to be done:
4949
5050- Links over CHM file boundaries still have to be fixed, this is needed for an effective main page. I already have created a simple main page that works in Windows. (and can generate it) (**done** an initial implementation)
5151- installation into the IDE by the installer. (**done but** not properly installed yet)
5252- Index majeur?
5353- index for latex pages. (**done** for ref archive from ref.kwd)
5454- preparing the main index takes several seconds on a XP 2000+, specially with LCL.chm installed. Might be annoying on slow computers. Cache? It might also be that the index collection, suffers from the inserted sorting dimensioning problem. (tcollections and tlist are both one big array of pointers. (Ordered) Inserting in such an large array requires a lot of fields to move to make room )
5555- there are problems with labels. E.g. from the main TOCs. For now they are stripped, but maybe first labels should be tried, and only then revert to main page.
5656- The ref/user/prog chms are in UTF-8 which is not nice for the textmode IDE. (fixed in +/- 2.4.0, there might be detail bugs left though)
5757
5858### CHM boundaries problem
5959
6060This problem is partial to a deeper problem in the textmode IDE. The way a help page/topic is identified in the textmode IDE is by two (16-bit?) integers. One is the fileid, the other is the topicid in the file.
6161
6262HTML and CHM's however work string based. IOW a string for file, and a string for the topic (combination of path/file#label). This is solved by allocating a fileid for each chm dynamically onload, and similarly for the topic files. The html subsystem maintains a links-in-current topic cache, and the indexes into that cache act as topicids. (in other wpords a bit dynamic, not all URLs in the chm have one).
6363
6464However since helpfiles are loaded on a need-to basis, and one might encounter a link to a.chm/path/file in another chm before a.chm is loaded, making it hard to resolve the IDs. This is currently solved by having a registry of CHM files as a global. However that totally bypasses the central helpsystem.
6565
6666The plain HTML help didn't suffer from this because they cheated: all HTML must be installed in one directory, and links are fixed in the HTML itself. (refer to hardcoded paths ../prog/) So the entire HTML became one big helpfile in practice. Which is fine as a hack, but not really nice or reproducible for other formats.
6767
6868A minor rewrite that changes the identification to something else (a record with both string and topic id's?) is a possibility, but for that I must first dig up examples of all helpfile types supported and test how they work.
6969
7070## Files of the IDE
7171
7272Here a short list of the units in the IDE, and their contents. A rough size in kb is added to indicate the relative size of the unit.
7373
7474| Unit | Size | Remark |
7575|----|----|----|
7676| fp | 14k | The main program for the IDE. Parameter processing and a *lot* (400 lines) of initialization. |
7777| fpcalc | 14k | Calculator object for the IDE |
7878| fpcatch | 6k | IDE exception handling. |
7979| fpcodcmp | 20k | Code Complete routines |
8080| fpcodtmp | 18k | Code Template routines |
8181| fpcompil | 38k | Compiler call routines for the IDE |
8282| fpconst | 17k | Constants used by the IDE |
8383| fpcygwin | 2k | Cygwin helpers (versioning, dll name) |
8484| fpdebug | 103k | Debugger call routines for the IDE |
8585| fpdesk | 29k | Desktop loading/saving routines |
8686| fpdpansi | 3k | Unit to export current screen buffer to an ansi file (screendump) |
8787| fpevalw | 2k | Debug expression evaluator dialog ? |
8888| fphelp | 24k | Help routines for the IDE |
8989| fpide | 72k | Main IDEApp object |
9090| fpini | 24k | Write/Read Options to INI File |
9191| fpintf | 8k | Misc routines for the IDE. compiling/running related mostly. |
9292| fpkeys | 8k | Learn keys routines for the IDE |
9393| fpredir | 19k | Unit to redirect output and error to files |
9494| fpregs | 50k | (cpu)Register debug routines for the IDE |
9595| fpswitch | 49k | Compiler switches routines for the IDE |
9696| fpsymbol | 58k | Symbol browse support routines for the IDE |
9797| fptemplt | 7k | Template support routines for the IDE |
9898| fptools | 47k | Tool (menu) support for the IDE |
9999| fpusrscr | 41k | User screen support routines |
100100| fputils | 11k | Utilility routines used by the IDE. Path/file/string related mostly. |
101101| fpvars | 5k | Global variables for the IDE |
102102| fpviews | 131k | Views and view-related functions for the IDE |
103103| pmode | 6k | Support routines for DPMI programs (dos support) |
104104| vesa | 20k | VESA (graphmode switching) support routines |
105105| wansi | 28k | ANSI support |
106106| wcedit | 58k | Code editor template objects |
107107| wchmhwrap | 5k | Chm wrapper. CHM reader parts that deal with classes, to obtain a clean TV - Delphi model separation |
108108| wconsole | 2k | Contains some routines that save/restore console state when executing built programs. |
109109| wconsts | 0k | Strings for common utilities. A handful of numeric consts, and a big includefile with textual constants (localisation?) |
110110| weditor | 208k | Code editor template objects |
111111| whelp | 27k | Help support & Borland OA .HLP reader objects and routines (the latter are moved to woahelp?) |
112112| whlpview | 41k | Help display objects. The base widgets for the help system (?) |
113113| whtml | 30k | base object definitions for html help? |
114114| whtmlhlp | 43k | Main html parser. (for separate html files, and the base of .chm support) |
115115| whtmlscn | 28k | HTML scanner objects |
116116| winclip | 5k | Functions that wrap the windows clipboard for Dos and Windows |
117117| windebug | 4k | Helper functions for use of GDB under Windows. cygdrive + update of running program's windowtitle. |
118118| wini | 12k | Ini file using TP objects |
119119| wnghelp | 13k | Help support for Norton Guide (.NG) files |
120120| woahelp | 15k | Borland OA .HLP reader objects and routines |
121121| wos2help | 19k | Help support for OS/2 (.INF) help files |
122122| wresourc | 22k | (TP?) Resource File support objects and routines |
123123| wtphwrit | 7k | Routines to create .tph files |
124124| [[fv:wutils|wutils]] | 32k | Utils, mostly collections, string routines and file(name/path) routines. |
125125| wviews | 69k | Enhanced View s(widgets) (special for IDE?) |
126126| wvphelp | 4k | Help support for (.VPH) help files |
127127| wwinhelp | 49k | Help support for Windows Help (.HLP) files |
128128| compunit | 0k | (compiler/ dir) build unit for the compiler. |
129129| gdbcon | 2k | (fakegdb/) fake gdb controller unit to be used when no gdb support is included |
130130| gdbint | 5k | (fakegdb/) fake gdb controller unit to be used when no gdb support is included |
131131| | | |
132132
133133Some functionality seems to be split between a w* unit and a fp* unit. (wini,fpini, wviews, fpview). Possibly this is an artifact of an older division between reusable and non reusable units. The fact that there are multiple utility units is also a bit of an indicator for this.
134134
135135If you know/find out what the criteria for it is, please add it here. If you find out something about a certain unit, make a link out of it prefixed with fv: (see the wutils example).
136136
137137Besides units, there are also a bunch of include files, most of which seem to be part of fpide, and group routines according to menu category (file, edit, compile etc)
138138
139139| Unit | Size | Unit | Remark |
140140|--------------|------|---------|-------------------------------------------------|
141141| empty.inc | 0k | test | Part of IDE testproject, not IDE itself. |
142142| fpmansi.inc | 4k | fpide | Ansi dump capability |
143143| fpmcomp.inc | 4k | fpide | Compiler menu entries |
144144| fpmdebug.inc | 8k | fpide | Debug menu entries |
145145| fpmedit.inc | 4k | fpide | Edit menu entries (one proc only) |
146146| fpmfile.inc | 8k | fpide | File menu entries |
147147| fpmhelp.inc | 12k | fpide | Help menu entries |
148148| fpmopts.inc | 48k | fpide | Options menu entries |
149149| fpmrun.inc | 16k | fpide | Run menu entries |
150150| fpmsrch.inc | 8k | fpide | Search menu entries |
151151| fpmtools.inc | 12k | fpide | Tools menu entries |
152152| fpmwnd.inc | 8k | fpide | Window menu entries |
153153| globdir.inc | 4k | MANY | IDE project wide defines, included in 19 files. |
154154| wconstse.inc | 8k | wconsts | English constants. |
155155| wconstsh.inc | 4k | wconsts | Hungarian constants. |
156156| | | | |
157157
158158### Classchart of objects + FV + IDE
159159
160160An improvised classchart (objectchart?) of all code containing TP style objects ( unit objects, FV and the IDE source) is available here: [Object Chart (Postscript view with GV)](http://www.stack.nl/~marcov/objectchart.ps) or [pdf version, less often updated](http://www.stack.nl/~marcov/objectchart.pdf)
161161
162162## Debugging the IDE
163163
164164Note that the methods describe here are mostly for *nix.
165165
166166### With GDB tty
167167
168168Normally one would debug the IDE as follows (Unix)
169169
170170Terminal Window 1:
171171
172-`tty`
172+```text
173+tty
174+```
173175
174176Example output:
175177
176-`/dev/pts/5`\
177-` `
178+```text
179+/dev/pts/5
180+```
178181
179182Terminal Window 2:
180183
181184``` bash
182185gdb ./fp
183186tty /dev/pts/5
184187r
185188```
186189
187190The tty command should then reroute all I/O to tty /dev/pts/5 (Terminal window 1), leaving Terminal Window 2 free to communicate with GDB.
188191
189192Unfortunately, due to the special keyboard support of the textmode IDE (to capture all CTRL-ALT variants) input is not properly rerouted. This means you can debug IDE startup (and more if you save state smartly), but not the normal working. This method is mainly useful when debugging the start of the IDE.
190193
191194### With GDB attach
192195
193196This method works better if you want to debug after the IDE has start up.
194197
195198Terminal Window 1:
196199
197-`Run the IDE from the command line, and wait till it has start up.  `
200+```text
201+Run the IDE from the command line, and wait till it has start up.
202+```
198203
199204Terminal Window 2:
200205
201-`Find the PID of the running IDE In window 1 using ps aux |grep fp`\
202-`Start gdb with the correct "fp" file (the one that is running!)`\
203-`Type attach <pid> on the GDB cmdline`\
204-`Note that gdb will immediately break upon attach. If you want to carry on, type "c" (continue)`
206+``` pascal
207+Find the PID of the running IDE In window 1 using ps aux |grep fp
208+Start gdb with the correct "fp" file (the one that is running!)
209+Type attach <pid> on the GDB cmdline
210+Note that gdb will immediately break upon attach. If you want to carry on, type "c" (continue)
211+```
205212
206213### Writeln like
207214
208215While developing the CHM package I needed to debug browsing also. For this, at first I simply wrote to stderr, and pipe the output to a different terminal (using bash as shell)
209216
210217Terminal Window 1
211218
212219``` bash
213220tty
214221```
215222
216223Example output:
217224
218-`/dev/pts/5`
225+```text
226+/dev/pts/5
227+```
219228
220229Terminal Window 2
221230
222231``` bash
223232./fp 2> /dev/pts/5
224233```
225234
226235However, while this would work, it seems sometimes buffering is a problem. Adding a flush would help, but then you have to go after all those writelns again. So it is better to extract it to a procedure. Such a procedure already existed in wutils, and I enhanced it a bit. There are two versions now. "DebugMessage" is the old one, and DebugMessageS is the new one.
227236
228237To avoid any garbage on the cmdline, all debug messages are always placed under IFDEF. Historically the define "DEBUG" was used for it, but apparantly this is also used in the compiler, and a broken debug feature in the compiler breaks debugging the IDE this way. So I use WDEBUG (mostly in whtmlhlp). The typical debug code fragment then becomes:
229238
230239``` pascal
231240{$IFDEF WDEBUG}
232241 DebugMessageS({$i %file%',' Adding Name "'+Name+'"',%line%,'1');
233242{$endif WDEBUG}
234243```
235244
236245Note that we use a compiler feature to fill in filename + linenumber for us.
237246
238247On Windows:
239248
240249```dos
241250fp.exe 2> logme.txt
242251```
243252
244253### Exceptions to stderr
245254
246255When debugging the IDE, I often change the RTL to log errors to stderr instead of stdout, since stderr is logged using the above 2\> redirects, I use the following patch:
247256
248-` ===================================================================`\
249-` --- sysutils/sysutils.inc       (revision 12440)`\
250-` +++ sysutils/sysutils.inc       (working copy)`\
251-` @@ -234,7 +234,7 @@`\
252-`    i : longint;`\
253-`    hstdout : ^text;`\
254-`  begin`\
255-` -  hstdout:=@stdout;`\
256-` +  hstdout:=@stderr;`\
257-`    Writeln(hstdout^,'An unhandled exception occurred at $',HexStr(PtrUInt(Addr),sizeof(PtrUInt)*2),' :');`
257+``` pascal
258+ ===================================================================
259+ --- sysutils/sysutils.inc (revision 12440)
260+ +++ sysutils/sysutils.inc (working copy)
261+ @@ -234,7 +234,7 @@
262+ i : longint;
263+ hstdout : ^text;
264+ begin
265+ - hstdout:=@stdout;
266+ + hstdout:=@stderr;
267+ Writeln(hstdout^,'An unhandled exception occurred at $',HexStr(PtrUInt(Addr),sizeof(PtrUInt)*2),' :');
268+```
258269
259270---
260271*From the Free Pascal wiki, page "Textmode IDE development", as it stood on 2022-11-08 after a change by Unxed, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
261272Category: FPC development

Back to history