Skip to content

bpo-1529353: IDLE: squeeze large output in the shell #7626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a7e130a
bpo-1529353: update the Squeezer extension and its tests
taleinat Jun 11, 2018
0af6a62
bpo-1529353: use idlelib.textview for previewing squeezed output
taleinat Aug 12, 2018
71fb2c1
Merge branch 'master' into bpo-1529353
taleinat Aug 12, 2018
bda6572
Refactor Squeezer from an extension to an integral part of IDLE.
taleinat Aug 13, 2018
53e74d9
Merge branch 'master' into bpo-1529353
taleinat Aug 27, 2018
902091e
Update Squeezer's tests given the latest changes
taleinat Aug 27, 2018
6d7035b
add ability to control text wrapping in IDLE's text viewer
taleinat Aug 28, 2018
45fb1a6
ask for user confirmation before expanding huge squeezed outputs
taleinat Aug 28, 2018
18106e8
increase Squeezer's default auto-squeeze-min-lines from 30 to 50
taleinat Aug 28, 2018
2c795e3
move 'copy' and 'preview' squeezed output actions to a context menu
taleinat Aug 28, 2018
1a1288a
Squeezer: rename "preview" to "view"
taleinat Aug 28, 2018
f753b37
Squeezer: remove tooltip configuration options (delay set to 80ms)
taleinat Aug 30, 2018
6087d3f
Squeezer: remove expand/view-last-squeezed events
taleinat Aug 30, 2018
b7d27cb
Squeezer: make view window non-modal and add horizontal scrollbar
taleinat Aug 30, 2018
ce07987
Merge remote-tracking branch 'origin/master' into pr_7626.
terryjreedy Sep 25, 2018
9676991
Correct error in merge resolution.
terryjreedy Sep 25, 2018
e768e0f
Make test_squeezer runnable.
terryjreedy Sep 25, 2018
fcc9084
bpo-1529353: explicitly create root Tk() objects in tests
taleinat Sep 25, 2018
468d9ec
bpo-1529353: reformat doc-strings as PEP8 and rename test classes
taleinat Sep 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/idlelib/config-main.def
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ font-size= 10
font-bold= 0
encoding= none

[PyShell]
auto-squeeze-min-lines= 50

[Indent]
use-spaces= 1
num-spaces= 4
Expand Down
39 changes: 35 additions & 4 deletions Lib/idlelib/configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
from idlelib.codecontext import CodeContext
from idlelib.parenmatch import ParenMatch
from idlelib.paragraph import FormatParagraph
from idlelib.squeezer import Squeezer

changes = ConfigChanges()
# Reload changed options in the following classes.
reloadables = (AutoComplete, CodeContext, ParenMatch, FormatParagraph)
reloadables = (AutoComplete, CodeContext, ParenMatch, FormatParagraph,
Squeezer)


class ConfigDialog(Toplevel):
Expand Down Expand Up @@ -1748,9 +1750,9 @@ def delete_custom_keys(self):
self.customlist.SetMenu(item_list, item_list[0])
# Revert to default key set.
self.keyset_source.set(idleConf.defaultCfg['main']
.Get('Keys', 'default'))
.Get('Keys', 'default'))
self.builtin_name.set(idleConf.defaultCfg['main'].Get('Keys', 'name')
or idleConf.default_keys())
or idleConf.default_keys())
# User can't back out of these changes, they must be applied now.
changes.save_all()
self.cd.save_all_changed_extensions()
Expand Down Expand Up @@ -1817,6 +1819,10 @@ def create_page_general(self):
frame_context: Frame
context_title: Label
(*)context_int: Entry - context_lines
frame_shell: LabelFrame
frame_auto_squeeze_min_lines: Frame
auto_squeeze_min_lines_title: Label
(*)auto_squeeze_min_lines_int: Entry - auto_squeeze_min_lines
frame_help: LabelFrame
frame_helplist: Frame
frame_helplist_buttons: Frame
Expand All @@ -1842,6 +1848,9 @@ def create_page_general(self):
self.paren_bell = tracers.add(
BooleanVar(self), ('extensions', 'ParenMatch', 'bell'))

self.auto_squeeze_min_lines = tracers.add(
StringVar(self), ('main', 'PyShell', 'auto-squeeze-min-lines'))

self.autosave = tracers.add(
IntVar(self), ('main', 'General', 'autosave'))
self.format_width = tracers.add(
Expand All @@ -1855,8 +1864,10 @@ def create_page_general(self):
text=' Window Preferences')
frame_editor = LabelFrame(self, borderwidth=2, relief=GROOVE,
text=' Editor Preferences')
frame_shell = LabelFrame(self, borderwidth=2, relief=GROOVE,
text=' Shell Preferences')
frame_help = LabelFrame(self, borderwidth=2, relief=GROOVE,
text=' Additional Help Sources ')
text=' Additional Help Sources ')
# Frame_window.
frame_run = Frame(frame_window, borderwidth=0)
startup_title = Label(frame_run, text='At Startup')
Expand Down Expand Up @@ -1918,6 +1929,13 @@ def create_page_general(self):
self.context_int = Entry(
frame_context, textvariable=self.context_lines, width=3)

# Frame_shell.
frame_auto_squeeze_min_lines = Frame(frame_shell, borderwidth=0)
auto_squeeze_min_lines_title = Label(frame_auto_squeeze_min_lines,
text='Auto-Squeeze Min. Lines:')
self.auto_squeeze_min_lines_int = Entry(
frame_auto_squeeze_min_lines, width=4,
textvariable=self.auto_squeeze_min_lines)

# frame_help.
frame_helplist = Frame(frame_help)
Expand All @@ -1943,6 +1961,7 @@ def create_page_general(self):
# Body.
frame_window.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
frame_editor.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
frame_shell.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
frame_help.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
# frame_run.
frame_run.pack(side=TOP, padx=5, pady=0, fill=X)
Expand Down Expand Up @@ -1983,6 +2002,11 @@ def create_page_general(self):
context_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
self.context_int.pack(side=TOP, padx=5, pady=5)

# frame_auto_squeeze_min_lines
frame_auto_squeeze_min_lines.pack(side=TOP, padx=5, pady=0, fill=X)
auto_squeeze_min_lines_title.pack(side=LEFT, anchor=W, padx=5, pady=5)
self.auto_squeeze_min_lines_int.pack(side=TOP, padx=5, pady=5)

# frame_help.
frame_helplist_buttons.pack(side=RIGHT, padx=5, pady=5, fill=Y)
frame_helplist.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
Expand Down Expand Up @@ -2018,6 +2042,10 @@ def load_general_cfg(self):
self.context_lines.set(idleConf.GetOption(
'extensions', 'CodeContext', 'maxlines', type='int'))

# Set variables for shell windows.
self.auto_squeeze_min_lines.set(idleConf.GetOption(
'main', 'PyShell', 'auto-squeeze-min-lines', type='int'))

# Set additional help sources.
self.user_helplist = idleConf.GetAllExtraHelpSourcesList()
self.helplist.delete(0, 'end')
Expand Down Expand Up @@ -2211,6 +2239,9 @@ def detach(self):

CodeContext: Maxlines is the maximum number of code context lines to
display when Code Context is turned on for an editor window.

Shell Preferences: Auto-Squeeze Min. Lines is the minimum number of lines
of output to automatically "squeeze".
'''
}

Expand Down
7 changes: 4 additions & 3 deletions Lib/idlelib/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
import importlib.util
import os
import platform
import re
import string
import sys
import tokenize
import traceback
import webbrowser
Expand Down Expand Up @@ -50,7 +48,6 @@ class EditorWindow(object):
from idlelib.undo import UndoDelegator
from idlelib.iomenu import IOBinding, encoding
from idlelib import mainmenu
from tkinter import Toplevel, EventType
from idlelib.statusbar import MultiStatusBar
from idlelib.autocomplete import AutoComplete
from idlelib.autoexpand import AutoExpand
Expand All @@ -59,6 +56,7 @@ class EditorWindow(object):
from idlelib.paragraph import FormatParagraph
from idlelib.parenmatch import ParenMatch
from idlelib.rstrip import Rstrip
from idlelib.squeezer import Squeezer
from idlelib.zoomheight import ZoomHeight

filesystemencoding = sys.getfilesystemencoding() # for file names
Expand Down Expand Up @@ -319,6 +317,9 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
text.bind("<<zoom-height>>", self.ZoomHeight(self).zoom_height_event)
text.bind("<<toggle-code-context>>",
self.CodeContext(self).toggle_code_context_event)
squeezer = self.Squeezer(self)
text.bind("<<squeeze-current-text>>",
squeezer.squeeze_current_text_event)

def _filename_to_unicode(self, filename):
"""Return filename as BMP unicode so diplayable in Tk."""
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/htest.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _wrapper(parent): # htest #
'msg': "Click the 'Show GrepDialog' button.\n"
"Test the various 'Find-in-files' functions.\n"
"The results should be displayed in a new '*Output*' window.\n"
"'Right-click'->'Goto file/line' anywhere in the search results "
"'Right-click'->'Go to file/line' anywhere in the search results "
"should open that file \nin a new EditorWindow."
}

Expand Down
6 changes: 3 additions & 3 deletions Lib/idlelib/idle_test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@ def test_get_section_list(self):

self.assertCountEqual(
conf.GetSectionList('default', 'main'),
['General', 'EditorWindow', 'Indent', 'Theme',
['General', 'EditorWindow', 'PyShell', 'Indent', 'Theme',
'Keys', 'History', 'HelpFiles'])
self.assertCountEqual(
conf.GetSectionList('user', 'main'),
['General', 'EditorWindow', 'Indent', 'Theme',
['General', 'EditorWindow', 'PyShell', 'Indent', 'Theme',
'Keys', 'History', 'HelpFiles'])

with self.assertRaises(config.InvalidConfigSet):
Expand Down Expand Up @@ -452,7 +452,7 @@ def test_remove_key_bind_names(self):

self.assertCountEqual(
conf.RemoveKeyBindNames(conf.GetSectionList('default', 'extensions')),
['AutoComplete', 'CodeContext', 'FormatParagraph', 'ParenMatch','ZzDummy'])
['AutoComplete', 'CodeContext', 'FormatParagraph', 'ParenMatch', 'ZzDummy'])

def test_get_extn_name_for_event(self):
userextn.read_string('''
Expand Down
Loading