mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	IDLE -- Restrict shell prompt manipulaton to the shell. (#4143)
Editor and output windows only see an empty last prompt line. This simplifies the code and fixes a minor bug when newline is inserted. Sys.ps1, if present, is read on Shell start-up, but is not set or changed.
This commit is contained in:
		
							parent
							
								
									ed6554c487
								
							
						
					
					
						commit
						e86172d63a
					
				
					 3 changed files with 19 additions and 24 deletions
				
			
		|  | @ -857,15 +857,17 @@ def __init__(self, flist=None): | |||
|             fixwordbreaks(root) | ||||
|             root.withdraw() | ||||
|             flist = PyShellFileList(root) | ||||
|         # | ||||
| 
 | ||||
|         OutputWindow.__init__(self, flist, None, None) | ||||
|         # | ||||
| ##        self.config(usetabs=1, indentwidth=8, context_use_ps1=1) | ||||
| 
 | ||||
|         self.usetabs = True | ||||
|         # indentwidth must be 8 when using tabs.  See note in EditorWindow: | ||||
|         self.indentwidth = 8 | ||||
|         self.context_use_ps1 = True | ||||
|         # | ||||
| 
 | ||||
|         self.sys_ps1 = sys.ps1 if hasattr(sys, 'ps1') else '>>> ' | ||||
|         self.prompt_last_line = self.sys_ps1.split('\n')[-1] | ||||
|         self.prompt = self.sys_ps1  # Changes when debug active | ||||
| 
 | ||||
|         text = self.text | ||||
|         text.configure(wrap="char") | ||||
|         text.bind("<<newline-and-indent>>", self.enter_callback) | ||||
|  | @ -878,7 +880,7 @@ def __init__(self, flist=None): | |||
|         if use_subprocess: | ||||
|             text.bind("<<view-restart>>", self.view_restart_mark) | ||||
|             text.bind("<<restart-shell>>", self.restart_shell) | ||||
|         # | ||||
| 
 | ||||
|         self.save_stdout = sys.stdout | ||||
|         self.save_stderr = sys.stderr | ||||
|         self.save_stdin = sys.stdin | ||||
|  | @ -951,7 +953,7 @@ def close_debugger(self): | |||
|                 debugger_r.close_remote_debugger(self.interp.rpcclt) | ||||
|             self.resetoutput() | ||||
|             self.console.write("[DEBUG OFF]\n") | ||||
|             sys.ps1 = ">>> " | ||||
|             self.prompt = self.sys_ps1 | ||||
|             self.showprompt() | ||||
|         self.set_debugger_indicator() | ||||
| 
 | ||||
|  | @ -963,7 +965,7 @@ def open_debugger(self): | |||
|             dbg_gui = debugger.Debugger(self) | ||||
|         self.interp.setdebugger(dbg_gui) | ||||
|         dbg_gui.load_breakpoints() | ||||
|         sys.ps1 = "[DEBUG ON]\n>>> " | ||||
|         self.prompt = "[DEBUG ON]\n" + self.sys_ps1 | ||||
|         self.showprompt() | ||||
|         self.set_debugger_indicator() | ||||
| 
 | ||||
|  | @ -1248,11 +1250,7 @@ def restart_shell(self, event=None): | |||
| 
 | ||||
|     def showprompt(self): | ||||
|         self.resetoutput() | ||||
|         try: | ||||
|             s = str(sys.ps1) | ||||
|         except: | ||||
|             s = "" | ||||
|         self.console.write(s) | ||||
|         self.console.write(self.prompt) | ||||
|         self.text.mark_set("insert", "end-1c") | ||||
|         self.set_line_and_column() | ||||
|         self.io.reset_undo() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Terry Jan Reedy
						Terry Jan Reedy