python / cpython

The Python programming language
https://www.python.org
Other
62.88k stars 30.12k forks source link

IDLE: Refactor breakpoint related methods #66281

Open 22200024-de1a-4081-ad85-2ac04e6b54d2 opened 10 years ago

22200024-de1a-4081-ad85-2ac04e6b54d2 commented 10 years ago
BPO 22083
Nosy @terryjreedy
Files
  • pyshell-breakpoint-refactor.diff
  • pyshell-breakpoint-refactor-v2.diff
  • 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: ```python assignee = None closed_at = None created_at = labels = ['expert-IDLE', 'type-feature', '3.9'] title = 'IDLE: Refactor breakpoint related methods' updated_at = user = 'https://bugs.python.org/SaimadhavHeblikar' ``` bugs.python.org fields: ```python activity = actor = 'terry.reedy' assignee = 'none' closed = False closed_date = None closer = None components = ['IDLE'] creation = creator = 'Saimadhav.Heblikar' dependencies = [] files = ['36112', '36348'] hgrepos = [] issue_num = 22083 keywords = ['patch'] message_count = 3.0 messages = ['224062', '224909', '225194'] nosy_count = 3.0 nosy_names = ['terry.reedy', 'jesstess', 'Saimadhav.Heblikar'] pr_nums = [] priority = 'normal' resolution = None stage = 'needs patch' status = 'open' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue22083' versions = ['Python 3.9'] ```

    22200024-de1a-4081-ad85-2ac04e6b54d2 commented 10 years ago

    This refactoring is required to enable setting/clearing breakpoints, using linenumbering( whether using a Canvas implementation or a Text implementation http://bugs.python.org/issue17535) The patch ensures consistency between the set_breakpoint(_here) and clear_breakpoint(_here) methods. The clear_breakpoint_here, which is not present currently has been added. No functionality has been added or removed, so I think it should be safe to go forward.

    terryjreedy commented 10 years ago

    The _here methods are the event handlers for the right click context menu options. Set_breakpoint, as a separate method, is only needed in the restore_file_breaks (from breakpoint file) method. I gather that you are thinking of using set/clear_breakpoint when a line number is clicked.

    You have elsewhere suggested a different refactoring - replacing set and clear with toggle. That seems plausible as a good idea. If text will have no breakpoints set after self.text.update() # this enables setting "BREAK" tags to be visible in restore_file_breaks(), there would be no problem. If not, toggle would need a force_set option. We need to know when the circumstances of when restore_file_breaks is called.

    The bell is both undependable and uniformative. If breakpoints are not allowed for unnamed files, the context menu items should be grayed out (if possible, as done, for instance, for 'cut' when there is no selectionj). If a line numbers is clicked for unnamed, we should display a message box explaining.

    22200024-de1a-4081-ad85-2ac04e6b54d2 commented 10 years ago

    This patch does two things

    1. Refactor pyshell-breakpoint-refactor.diff to reflect changes in pyshell-breakpoint-refactor.diff

    As in pyshell-breakpoint-refactor.diff, the set/clear(_here) breakpoint methods are refactored into logical methods.

    1. If the filename is not set, text.bell() is replaced with a dialog to prompt the user to save the file.