Repository navigation
IDLE editor line numbers #61737
Copy link
Copy link
Closed
Labels
3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifetopic-IDLEtype-featureA feature request or enhancementA feature request or enhancement
Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = 'https://github.com/terryjreedy'
closed_at = <Date 2019-07-23.13:35:22.751>
created_at = <Date 2013-03-24.05:13:33.676>
labels = ['3.8', 'expert-IDLE', 'type-feature', '3.7', '3.9']
title = 'IDLE editor line numbers'
updated_at = <Date 2019-07-27.03:46:56.205>
user = 'https://github.com/rovitotv'bugs.python.org fields:
activity = <Date 2019-07-27.03:46:56.205>
actor = 'miss-islington'
assignee = 'terry.reedy'
closed = True
closed_date = <Date 2019-07-23.13:35:22.751>
closer = 'taleinat'
components = ['IDLE']
creation = <Date 2013-03-24.05:13:33.676>
creator = 'Todd.Rovito'
dependencies = ['3068']
files = ['29567', '34395', '34397', '35689', '35723', '36194', '36285', '36384', '36387', '48455']
hgrepos = []
issue_num = 17535
keywords = ['patch']
message_count = 59.0
messages = ['185115', '185164', '185166', '185170', '185173', '185181', '185543', '185805', '213386', '220973', '221256', '221321', '221341', '223086', '224504', '224911', '225377', '225379', '225384', '225387', '225402', '225411', '225416', '225418', '225419', '226048', '226372', '229709', '248131', '302325', '302340', '324885', '327602', '345417', '345418', '347184', '347238', '347257', '347258', '347281', '347297', '347403', '347702', '348266', '348267', '348331', '348332', '348333', '348334', '348360', '348372', '348469', '348472', '348473', '348479', '348491', '348537', '348538', '348539']
nosy_count = 17.0
nosy_names = ['rhettinger', 'terry.reedy', 'taleinat', 'ned.deily', 'roger.serwy', 'markroseman', 'jesstess', 'THRlWiTi', 'Todd.Rovito', 'serhiy.storchaka', 'JayKrish', 'Saimadhav.Heblikar', 'malin', 'Big Stone', 'miss-islington', 'mthompsonwhs', 'aeros']
pr_nums = ['14030', '14916', '14917', '14959', '14973', '14974']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue17535'
versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifetopic-IDLEtype-featureA feature request or enhancementA feature request or enhancement
Activity
rovitotv commentedon Mar 24, 2013
I think it could be very helpful to add line numbers along the left side of the editor window. The feature could be toggled on/off easily enough. This was mentioned in the "Invent with Python" blog about IDLE so obviously other people would like the feature.
rovitotv commentedon Mar 24, 2013
I got the extension from Roger Serwy's IDLEX, it is one of my favorite extensions. In addition to adding the extension I updated the documentation both idle.rst and help.txt. Finally I tested the patch on Mac OS X and it works great. This patch is for 3.4 but it does work with 2.7 but the documentation for 2.7 is not synced. Thanks.
rovitotv commentedon Mar 24, 2013
For this patch to work correctly the option menu must be present so bpo-17532 http://bugs.python.org/issue17532 has to be resolved.
serwy commentedon Mar 24, 2013
Todd, the LineNumbers.py extension from the IdleX project contains
work-arounds for interacting cleanly with the Code Context extension. It
also has a hack for dealing with the shortcomings of the
Percolator/Delegator ordering.
There are other shortcomings in the extension that I could not address
from IDLE's extension loading architecture. Notably, IDLE does not have
a method to broadcast that a font was changed, so the extension polls
every second to see what the font is. The Code Context extension also
does this. This is clearly an inefficient way to handle identifying a
configuration change.
I released IdleX with the University of Illinois. Presently, the code is
under the NCSA license agreement and assigned to the Board of Trustees.
If the PSF would allow inclusion as-is, then I'm all for it. Otherwise I
will need to ask UIUC about how to re-license the code.
rovitotv commentedon Mar 25, 2013
The NCSA license is very permissive I would be surprised if the PSF didn't accept it since both are BSD based. Needless to say I am not a lawyer and I am not sure who to speak with about this issue.
I was able to find some precedence with the PEP-3146 which proposed the merging of Unladen Swallow with CPython. Unladen Swallow used LLVM which also used the NCSA license. But the merge never happened so I don't know what to think.
Does this mean all the extensions from IDLEX are under NCSA license even Terminal.py?
I am flexible please let me know how you want to proceed....
serwy commentedon Mar 25, 2013
The file uploaded in 2010 falls under my PSF contributor agreement which
has the Apache V2.0 license. The updates to the code in the latest
version of IdleX fall under the NCSA license.
terryjreedy commentedon Mar 30, 2013
PSF accepts contributions from authors under Contributor Agreements. It does not grab software from 3rd parties, no matter how lenient the license. Roger, if you assigned all rights to the University, you should talk with them about either getting some back or about the University signing a corporate agreement. Also, there is a new psf 'legal' list for discussing legal matters.
And yes, I am interested in line numbers also. I do not need them to edit my own files, but they are handy when communicating about stdlib files.
serwy commentedon Apr 2, 2013
I received permission from UIUC to relicense IdleX code used for contributions into Python.
SaimadhavHeblikar commentedon Mar 13, 2014
As a part of my GSOC 2014 proposal, i had prepared a mockup which adds linenumbering feature to a text widget.I am adding the mockup along with a image.
Working:
Intercepts low level calls and detects if any of the actions modify current view.If they do , then re-render the line numbers.Uses a canvas to display,(using create_text)
*Also contains code to add breakpoints.Not a part of this issue,so ignore that aspect
SaimadhavHeblikar commentedon Jun 19, 2014
Attached is a patch which adds linenumbering to IDLE. [1] is the current discussion regarding this topic at idle-dev.
This patch is a initial patch. It is missing menu and config additions. I have posted it in this state, so that we can catch platform specific bugs and performance related issues(if any). In the patch, all major additions are in a new file LineNumber.py. This is keeping easier debugging in mind. The code will be restructured in the next version of the patch, which will have the above said additions and performance optimization(if any).
I will be working on menu additions, config dialog additions and performance optimization in the mean time.
For those who are interested, I used tk.call(self.text, 'dlineinfo', '%d.0' % linenum) instead of text.dlineinfo('%d.0' % linenum), because using any text.* method, used to cause a continuous increase in memory usage. I found this out the hard way, when, earlier I was making repeated text.index() calls.
---
[1] - https://mail.python.org/pipermail/idle-dev/2014-June/003456.html
SaimadhavHeblikar commentedon Jun 22, 2014
List of additions/changes
1. EditorWindow uses LineNumber.Text instead of tkinter.Text.
2. Added linenumber canvas to IDLE windows except PyShell
3. Some info about LineNumber.Text
a) Inherits tk.Text
b) Generates <<Changed>> virtual event, when insert, delete, replace,
cursor changes position, window resized, scrolled etc. Nothing else
is affected. The result of the original call is returned.
4. LineNumber.LineNumberCanvas info
a) font_color and breakpoint_color have default values
b) Linenumber and breakpoints disabled by default. Instantiating
a LineNumberCanvas object does not pack it.
c) Pack it programmatically by calling its "attach" method.
Compulsorily supply the text widget to attach to.
Supply other parameters like font_color, background,
breakpoint_color as necessary.
d) Unpack using "detach" method.
e) Breakpoint feature is enabled only if LineNumberCanvas can
"see" an EditorWindow instance called "editwin" as its attribute.
It(editwin) should implement set_breakpoint(linenumber) and
clear_breakpoint(linenumber) methods. EditorWindow responsible
for binding breakpoint action on the canvas to LineNumberCanvas'
toggle_breakpoint method.
f) Contains a htest for GUI testing linenumbering and breakpoints.
g) Any valid color can be set for linenumber canvas' background,
its font color and breakpoint color. NS: Breakpoint does not have
a background color.
h) Linenumber canvas enabled by default.
5. Linenumber preferences in configDialog's "General" tab.
Highlight preferences in configDialog's "Highlight" tab.
6. Other changes
a) Refactoring of PyShell's set_breakpoint_here, set_breakpoint,
clear_breakpoint_here and clear_breakpoint to make more consistent.
rhettinger commentedon Jun 22, 2014
FWIW, I don't think line numbers should be "enabled by default" for IDLE or any other editor. It isn't the norm and can be distracting. If you've ever tried to use IDLE to teach kids, you would value minimizing visual distractions.
taleinat commentedon Jun 23, 2014
Many IDEs do show line numbers by default. And it does make discussing code with others simpler, e.g. when teaching. But I tend to agree with Raymond that it would be better to keep the default interface clean. Anyone who will want line numbers will be able to turn them on them easily.
38 remaining items
miss-islington commentedon Jul 23, 2019
New changeset 1da6a31 by Miss Islington (bot) in branch '3.8':
bpo-17535: IDLE editor line numbers (GH-14030)
1da6a31
taleinat commentedon Jul 23, 2019
New changeset e9ec166 by Tal Einat in branch '3.7':
[3.7] bpo-17535: IDLE editor line numbers (GH-14030)
e9ec166
taleinat commentedon Jul 23, 2019
PR Merged! This will be in 3.8.0 and 3.7.5. Thanks to everyone who worked on this and took part in the discussion!
Special thanks to Saimadhav for preparing a patch and iterating on it several times; I picked up the work from where he left off, and it was a great starting point.
Special thanks also to Terry for stewarding the development of IDLE in general, and for working with me actively on the PR for this over the past month and a half.
terryjreedy commentedon Jul 24, 2019
A note on the first 3 comments in msg223086 of 2014-07-15.
I checked that this remains true when non-latin character sets are mixed in. I pasted the config font sample into a numbered editor and it worked perfectly. At least on Windows, tk fonts are vertically monospaced at least for this sample, and I assume for all. To do this, either ascii/latin/etc lines are over-spaced or hanji/kanji/hangul lines are underspaced. Source Code Pro, which I normally use, does the former. Courier does the latter.
I suggested 5 years ago that we might switch font change notification to events. I don't think so now. The current system allows control of the order in which texts within a code frame respond to config changes. It works better if code contexts, when present, change before the main text.
(I discussed 4. global versus local setting on 7/21.)
terryjreedy commentedon Jul 24, 2019
After-thought test 2: proportional fonts* work fine. Nearly all have monospaced digits, with extra space around '1' if there is no bottom bar. So those also have nicely aligned right-justified columns in the sidebar. And the one font I found with proportional digits, Miriam Libre, still had readable numbers.
which people, including me, have done with other languages, using a proportional font with python is not nearly as crazy as some people claim, and not to be totally disregarded. The main issue is line length and what happens when someone else views the same file with a fixed-pitch font.
aeros commentedon Jul 26, 2019
After testing it on Linux (through the latest dev version, launched with
./.python -m idlelib), the line numbers seem to be working quite well across several different fonts and font sizes. My only suggestion for minor visual improvement would be to increase the margin between the right side of the number and the line.While moving through a number of different fonts and sizes, I noticed a separate issue involving the window scaling based on the size of the font previews. This isn't an issue for smaller fonts, but when attempting to use larger fonts (upper 20s or into the 30s depending on the font in question) the 4 buttons ("Ok", "Apply", "Cancel", and "Help") in the settings menu (options > configure IDLE) are moved past the lower end of the screen, making them no longer visible to the user.
Either way, this change is pretty awesome. The only thing preventing me from using the IDLE more was the lack of line numbers, so I'll definitely be using it a lot more now. Thanks for the PR taleinat!
taleinat commentedon Jul 26, 2019
Thanks for trying this and giving such useful feedback, Kyle!
Interestingly, Terry just opened an issue about exactly what you mention regarding the font configuration window; see issue bpo-37628.
taleinat commentedon Jul 26, 2019
Correction: Terry commented on that issue (bpo-37628) earlier today; Raymond Hettinger originally reported it a about a week ago.
terryjreedy commentedon Jul 26, 2019
The current right margin is 1 pixel. Let's try making it 2.
taleinat commentedon Jul 26, 2019
See PR #59164. I added 2 pixels of horizontal padding to the line numbers text widget, and it certainly does look much nicer. Thanks for the suggestion, Kyle!
terryjreedy commentedon Jul 27, 2019
New changeset 46ebd4a by Terry Jan Reedy (Tal Einat) in branch 'master':
bpo-17535: Increase line number horizontal padding by 2 pixels (GH-14959)
46ebd4a
miss-islington commentedon Jul 27, 2019
New changeset 9e7697b by Miss Islington (bot) in branch '3.7':
bpo-17535: Increase line number horizontal padding by 2 pixels (GH-14959)
9e7697b
miss-islington commentedon Jul 27, 2019
New changeset f6ab188 by Miss Islington (bot) in branch '3.8':
bpo-17535: Increase line number horizontal padding by 2 pixels (GH-14959)
f6ab188