Macro editor seems to show line numbers modulo 100000
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Macro editor seems to show line numbers modulo 100000
FreeCAD's macro editor seems to truncate line numbers to 5 digits, printing them modulo 100000. This explains the fact that puzzled me, at least, that in an earlier post I seemed to be creating about 200,000 facets with only about 97,000 lines of macro code which consisted almost entirely of top-level (not in a loop or function) calls to facets.append(Part.Face(Part.makePolygon(...). Actually I had a lot more than 97,000 lines but the editor was displaying the last line number incorrectly. This was seen in FreeCAD 0.18. I did try to search this forum to see if this issue had been reported before (and possibly fixed in a later version), but the forum's search engine thinks that both "line" and "number" are words too common to search for. Screenshot shows the line number turning over from 99999 to 00000.
Re: Macro editor seems to show line numbers modulo 100000
A Macro with more than 99999 lines is obviously a non sense, python itself is advising to not exceed 2000 lines.
The point is that FreeCAD python editor is made to make simple things not full fledged programs, and is good for what is designed for.
Using 0.18.4 and reporting errorfor it is also a non sense as even if there will be a bug, it will not be fixed as it is not supported . Actually a release for 0.21 is imminent and probably a 0.20.3 bugfix release.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Macro editor seems to show line numbers modulo 100000
The width of the line number area is hard-coded to:
in TextEdit.cpp (that is, the width of the four zeros, plus ten points). Numbers are shown right-aligned, so you're generally only going to be able to see the last five or so digits. The use-case here, where the "macro" appears to itself be programmatically-generated (and is extremely long), was not anticipated. Fixing this would mean dynamically resizing the line number area width based on the number of lines in the file: not impossible, and maybe a good project for someone who is looking for an introduction to the FreeCAD codebase.
Code: Select all
QtTools::horizontalAdvance(fontMetrics(), QLatin1String("0000")) + 10;
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: Macro editor seems to show line numbers modulo 100000
A trivial fix would be to just change the hard-coding from 4 to 5 digits. I don't think it would be such an inconvenience to have that column one character wider.chennes wrote: ↑Mon May 22, 2023 2:15 am The width of the line number area is hard-coded to:in TextEdit.cpp (that is, the width of the four zeros, plus ten points). Numbers are shown right-aligned, so you're generally only going to be able to see the last five or so digits. The use-case here, where the "macro" appears to itself be programmatically-generated (and is extremely long), was not anticipated. Fixing this would mean dynamically resizing the line number area width based on the number of lines in the file: not impossible, and maybe a good project for someone who is looking for an introduction to the FreeCAD codebase.Code: Select all
QtTools::horizontalAdvance(fontMetrics(), QLatin1String("0000")) + 10;