mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Adapted to modern times. Cosmetic and comment changes.
This commit is contained in:
parent
0e71dc1106
commit
63f4cdcdb8
1 changed files with 23 additions and 7 deletions
|
@ -1,4 +1,6 @@
|
||||||
#! /usr/local/python
|
#! /usr/local/bin/python
|
||||||
|
|
||||||
|
# :set tabsize=4:
|
||||||
|
|
||||||
# A STDWIN-based front end for the Python interpreter.
|
# A STDWIN-based front end for the Python interpreter.
|
||||||
#
|
#
|
||||||
|
@ -9,6 +11,11 @@
|
||||||
#
|
#
|
||||||
# BUGS AND CAVEATS:
|
# BUGS AND CAVEATS:
|
||||||
#
|
#
|
||||||
|
# I wrote this about two years ago. There are now some features in
|
||||||
|
# Python that make it possible to overcome some of the bugs below,
|
||||||
|
# but I haven't the time to adapt it; it's just meant as a little
|
||||||
|
# thing to get you started...
|
||||||
|
#
|
||||||
# Although this supports multiple windows, the whole application
|
# Although this supports multiple windows, the whole application
|
||||||
# is deaf and dumb when a command is running in one window.
|
# is deaf and dumb when a command is running in one window.
|
||||||
#
|
#
|
||||||
|
@ -150,6 +157,7 @@ def pdispatch(event):
|
||||||
type, win, detail = event
|
type, win, detail = event
|
||||||
if type == WE_CLOSE:
|
if type == WE_CLOSE:
|
||||||
do_close(win)
|
do_close(win)
|
||||||
|
return
|
||||||
elif type == WE_SIZE:
|
elif type == WE_SIZE:
|
||||||
win.editor.move((0, 0), win.getwinsize())
|
win.editor.move((0, 0), win.getwinsize())
|
||||||
elif type == WE_COMMAND and detail == WC_RETURN:
|
elif type == WE_COMMAND and detail == WC_RETURN:
|
||||||
|
@ -168,7 +176,7 @@ def pdispatch(event):
|
||||||
mp.callback[item](win)
|
mp.callback[item](win)
|
||||||
else:
|
else:
|
||||||
void = win.editor.event(event)
|
void = win.editor.event(event)
|
||||||
if win.editor:
|
if win in mainloop.windows:
|
||||||
# May have been deleted by close...
|
# May have been deleted by close...
|
||||||
win.setdocsize(0, win.editor.getrect()[1][1])
|
win.setdocsize(0, win.editor.getrect()[1][1])
|
||||||
if type in (WE_CHAR, WE_COMMAND):
|
if type in (WE_CHAR, WE_COMMAND):
|
||||||
|
@ -190,7 +198,7 @@ def replace(win, text):
|
||||||
win.editor.replace(text)
|
win.editor.replace(text)
|
||||||
# Resize the window to display the text
|
# Resize the window to display the text
|
||||||
win.setdocsize(0, win.editor.getrect()[1][1]) # update the size before..
|
win.setdocsize(0, win.editor.getrect()[1][1]) # update the size before..
|
||||||
win.editor.setfocus(win.editor.getfocus()) # move focus to the change - dml
|
win.editor.setfocus(win.editor.getfocus()) # move focus to the change
|
||||||
|
|
||||||
|
|
||||||
# File menu handlers
|
# File menu handlers
|
||||||
|
@ -238,12 +246,13 @@ def do_close(win):
|
||||||
except os.error:
|
except os.error:
|
||||||
pass
|
pass
|
||||||
mainloop.unregister(win)
|
mainloop.unregister(win)
|
||||||
|
win.close()
|
||||||
#
|
#
|
||||||
def do_quit(win):
|
def do_quit(win):
|
||||||
# Call win.dispatch instead of do_close because there
|
# Call win.dispatch instead of do_close because there
|
||||||
# may be 'alien' windows in the list.
|
# may be 'alien' windows in the list.
|
||||||
for win in mainloop.windows:
|
for win in mainloop.windows[:]:
|
||||||
mainloop.dispatch(WE_CLOSE, win, None) # need to catch failed close
|
mainloop.dispatch((WE_CLOSE, win, None)) # need to catch failed close
|
||||||
|
|
||||||
|
|
||||||
# Edit menu handlers
|
# Edit menu handlers
|
||||||
|
@ -314,14 +323,14 @@ def do_exec(win):
|
||||||
if a == b:
|
if a == b:
|
||||||
# There is no selected text, just an insert point;
|
# There is no selected text, just an insert point;
|
||||||
# so execute the current line.
|
# so execute the current line.
|
||||||
while 0 < a and alltext[a-1] <> '\n': a = a-1 # Find beginning of line.
|
while 0 < a and alltext[a-1] <> '\n': a = a-1 # Find beginning of line.
|
||||||
while b < n and alltext[b] <> '\n': # Find end of line after b.
|
while b < n and alltext[b] <> '\n': # Find end of line after b.
|
||||||
b = b+1
|
b = b+1
|
||||||
text = alltext[a:b] + '\n'
|
text = alltext[a:b] + '\n'
|
||||||
else:
|
else:
|
||||||
# Execute exactly the selected text.
|
# Execute exactly the selected text.
|
||||||
text = win.editor.getfocustext()
|
text = win.editor.getfocustext()
|
||||||
if text[-1:] <> '\n': # Make sure text ends with newline.
|
if text[-1:] <> '\n': # Make sure text ends with \n.
|
||||||
text = text + '\n'
|
text = text + '\n'
|
||||||
while b < n and alltext[b] <> '\n': # Find end of line after b.
|
while b < n and alltext[b] <> '\n': # Find end of line after b.
|
||||||
b = b+1
|
b = b+1
|
||||||
|
@ -502,3 +511,10 @@ def testsyntax(s):
|
||||||
# Call the main program.
|
# Call the main program.
|
||||||
#
|
#
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
||||||
|
# This was originally coded on a Mac, so...
|
||||||
|
# Local variables:
|
||||||
|
# py-indent-offset: 4
|
||||||
|
# tab-width: 4
|
||||||
|
# end:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue