Commit Graph

193 Commits

Author SHA1 Message Date
Guido van Rossum 9745f5a74f Tim Peters: made replacement atomic for undo/redo. 1999-06-08 12:54:56 +00:00
Guido van Rossum 0fcd635d41 Tim Peters:
+ Set usetabs=1.  Editing pyclbr.py was driving me nuts <0.6 wink>.
usetabs=1 is the Emacs pymode default too, and thanks to indentwidth !=
tabwidth magical usetabs disabling, new files are still created with tabs
turned off.  The only implication is that if you open a file whose first
indent is a single tab, IDLE will now magically use tabs for that file (and
set indentwidth to 8).  Note that the whole scheme doesn't work right for
PythonWin, though, since Windows users typically set tabwidth to 4; Mark
probably has to hide the IDLE algorithm from them (which he already knows).

+ Changed comment_region_event to stick "##" in front of every line.  The
"holes" previously left on blank lines were visually confusing (made it
needlessly hard to figure out what to uncomment later).
1999-06-08 12:54:23 +00:00
Guido van Rossum 3f75741844 Remove unnecessary reference to pyclbr from test() code. 1999-06-07 15:38:40 +00:00
Guido van Rossum 729afc1dff Tim Peters:
Smarter logic for finding a parse synch point.

Does a half to a fifth the work in normal cases; don't notice the speedup,
but makes  more breathing room for other extensions.

Speeds terrible cases by at least a factor of 10. "Terrible" == e.g. you put
""" at the start of Tkinter.py, undo it, zoom to the bottom, and start
typing in code.  Used to take about 8 seconds for ENTER to respond, now some
large fraction of a second.  The new code gets indented correctly, despite
that it all remains "string colored" until the colorizer catches up (after
which, ENTER appears instantaneous again).
1999-06-07 14:28:14 +00:00
Guido van Rossum febebe9e79 Might as well enable CallTips by default.
If there are too many complaints I'll remove it again or fix it.
1999-06-04 19:21:19 +00:00
Guido van Rossum f4a15089a3 New offerings by Tim Peters; he writes:
IDLE is now the first Python editor in the Universe not confused by my
doctest.py <wink>.

As threatened, this defines IDLE's is_char_in_string function as a
method of EditorWindow.  You just need to define one similarly in
whatever it is you pass as editwin to AutoIndent; looking at the
EditorWindow.py part of the patch should make this clear.
1999-06-03 14:32:16 +00:00
Guido van Rossum b10cb9a383 Enclose pattern in quotes in status message. 1999-06-03 14:25:49 +00:00
Guido van Rossum 23c115f1c9 Mark Hammond fixed some comments and improved the way the tip text is
constructed.
1999-06-03 12:07:50 +00:00
Guido van Rossum 094189f108 My fix to Mark's code: restore the universal check on <KeyRelease>.
Always cancel on <Key-Escape> or <ButtonPress>.
1999-06-02 18:18:57 +00:00
Guido van Rossum 6290dabdbb A version that Mark Hammond posted to the newsgroup. Has some newer
stuff for getting the tip.  Had to fix the Key-( and Key-) events
for Unix.  Will have to re-apply my patch for catching KeyRelease and
ButtonRelease events.
1999-06-02 18:12:55 +00:00
Guido van Rossum 85b9735768 Call tips by Mark Hammond (plus tiny fix by me.) 1999-06-02 16:10:19 +00:00
Guido van Rossum 1709041e73 Changes by Mark Hammond: (1) support optional output_sep argument to
the constructor so he can eliminate the sys.ps2 that PythonWin leaves
in the source; (2) remove duplicate history items.
1999-06-02 12:06:47 +00:00
Guido van Rossum 808fa4993e Changes by Mark Hammond to allow using IDLE extensions in PythonWin as
well: make three dialog routines instance variables.
1999-06-02 11:05:19 +00:00
Guido van Rossum d395aeeaa4 Change by Mark Hammond to allow using IDLE extensions in PythonWin as
well: make three dialog routines instance variables.
1999-06-02 11:04:29 +00:00
Guido van Rossum a954ba1d6c Hah! A fix of my own to Tim's code!
Unix bindings for <<toggle-tabs>> and <<change-indentwidth>> were
missing, and somehow that meant the events were never generated,
even though they were in the menu.  The new Unix bindings are now
the same as the Windows bindings (M-t and M-u).
1999-06-01 20:06:44 +00:00
Guido van Rossum bbaba85402 Tim Peters again:
The new version (attached) is fast enough all the time in every real module
I have <whew!>.  You can make it slow by, e.g., creating an open list with
5,000 90-character identifiers (+ trailing comma) each on its own line, then
adding an item to the end -- but that still consumes less than a second on
my P5-166.  Response time in real code appears instantaneous.

Fixed some bugs.

New feature:  when hitting ENTER and the cursor is beyond the line's leading
indentation, whitespace is removed on both sides of the cursor; before
whitespace was removed only on the left; e.g., assuming the cursor is
between the comma and the space:

def something(arg1, arg2):
                   ^ cursor to the left of here, and hit ENTER
               arg2):   # new line used to end up here
              arg2):    # but now lines up the way you expect

New hack:  AutoIndent has grown a context_use_ps1 Boolean config option,
defaulting to 0 (false) and set to 1 (only) by PyShell.  Reason:  handling
the fancy stuff requires looking backward for a parsing synch point; ps1
lines are the only sensible thing to look for in a shell window, but are a
bad thing to look for in a file window (ps1 lines show up in my module
docstrings often).  PythonWin's shell should set this true too.

Persistent problem:  strings containing def/class can still screw things up
completely.  No improvement.  Simplest workaround is on the user's head, and
consists of inserting e.g.

def _(): pass

(or any other def/class) after the end of the multiline string that's
screwing them up.  This is especially irksome because IDLE's syntax coloring
is *not* confused, so when this happens the colors don't match the
indentation behavior they see.
1999-06-01 19:55:34 +00:00
Guido van Rossum a6be3870b3 Tim Peters again:
[Tim, after adding some bracket smarts to AutoIndent.py]
> ...
> What it can't possibly do without reparsing large gobs of text is
> suggest a reasonable indent level after you've *closed* a bracket
> left open on some previous line.
> ...

The attached can, and actually fast enough to use -- most of the time.  The
code is tricky beyond belief to achieve that, but it works so far; e.g.,

        return len(string.expandtabs(str[self.stmt_start :
                                         ^ indents to caret
                                         i],
                                     ^ indents to caret
                                     self.tabwidth)) + 1
    ^ indents to caret

It's about as smart as pymode now, wrt both bracket and backslash
continuation rules.  It does require reparsing large gobs of text, and if it
happens to find something that looks like a "def" or "class" or sys.ps1
buried in a multiline string, but didn't suck up enough preceding text to
see the start of the string, it's completely hosed.  I can't repair that --
it's just too slow to reparse from the start of the file all the time.

AutoIndent has grown a new num_context_lines tuple attribute that controls
how far to look back, and-- like other params --this could/should be made
user-overridable at startup and per-file on the fly.
1999-06-01 19:52:34 +00:00
Guido van Rossum 8113cdc3a8 New file by Tim Peters:
One new file in the attached, PyParse.py.  The LineStudier (whatever it was
called <wink>) class was removed from AutoIndent; PyParse subsumes its
functionality.
1999-06-01 19:49:21 +00:00
Guido van Rossum d93f739556 Tim Peters keeps revising this module (more to come):
Removed "New tabwidth" menu binding.

Added "a tab means how many spaces?" dialog to block tabify and untabify.  I
think prompting for this is good now:  they're usually at-most-once-per-file
commands, and IDLE can't let them change tabwidth from the Tk default
anymore, so IDLE can no longer presume to have any idea what a tab means.

Irony:  for the purpose of keeping comments aligned via tabs, Tk's
non-default approach is much nicer than the Emacs/Notepad/Codewright/vi/etc
approach.
1999-06-01 19:47:56 +00:00
Guido van Rossum 74311b2c27 1. Catch NameError on import (could be raised by case mismatch on Windows).
2. No longer need to reset pyclbr cache and show watch cursor when calling
   ClassBrowser -- the ClassBrowser takes care of pyclbr and the TreeWidget
   takes care of the watch cursor.
3. Reset the focus to the current window after error message about class
   browser on buffer without filename.
1999-06-01 18:27:14 +00:00
Guido van Rossum 292dd2d1af Missed a few. 1999-06-01 18:23:19 +00:00
Guido van Rossum ec9cca776a Rewritten based on TreeWidget.py 1999-06-01 18:21:31 +00:00
Guido van Rossum 1ff48ec852 Object browser, based on TreeWidget.py. 1999-06-01 18:20:56 +00:00
Guido van Rossum 7419f4b290 Tree widget done right. 1999-06-01 18:19:17 +00:00
Guido van Rossum d3a518b661 As yet unused code for tool tips. 1999-06-01 18:19:02 +00:00
Guido van Rossum ee03611a8d Ensure sys.argv[0] is the script name on Run Script. 1999-06-01 18:18:27 +00:00
Guido van Rossum 96cf271be9 Move zoom height functionality to separate function. 1999-06-01 18:17:02 +00:00
Guido van Rossum 32465f4148 A few icons used by ../TreeWidget.py and its callers. 1999-06-01 15:04:51 +00:00
Guido van Rossum 8234dfcccb New version by Tim Peters improves block opening test. 1999-06-01 15:03:30 +00:00
Guido van Rossum b6f8cf123e Rename History to IdleHistory.
Add isatty() to pseudo files.
1999-05-21 04:46:17 +00:00
Guido van Rossum 945507edf6 Make initial stack viewer wider 1999-05-21 04:45:45 +00:00
Guido van Rossum 2092b439be New wishes 1999-05-21 04:45:20 +00:00
Guido van Rossum def2c96718 Much improved autoindent and handling of tabs,
by Tim Peters.
1999-05-21 04:38:27 +00:00
Guido van Rossum 318a70d976 Tim Peters writes:
I'm still unsure, but couldn't stand the virtual event trickery so tried a
different sin (adding undo_block_start/stop methods to the Text instance in
EditorWindow.py).  Like it or not, it's efficient and works <wink>.  Better
idea?

Give the attached a whirl.  Even if you hate the implementation, I think
you'll like the results.  Think I caught all the "block edit" cmds,
including Format Paragraph, plus subtler ones involving smart indents and
backspacing.
1999-05-03 15:49:52 +00:00
Guido van Rossum 2d6a568a0f Tim Peters writes:
[W]hile trying to dope out how redirection works, stumbled into two
possible glitches.  In the first, it doesn't appear to make sense to try to
rename a command that's already been destroyed; in the second, the name
"previous" doesn't really bring to mind "ignore the previous value" <wink>.
1999-05-03 15:38:56 +00:00
Guido van Rossum 7238401488 Support for using idle as a package. 1999-04-30 19:39:25 +00:00
Guido van Rossum 78608120de Avoid listing files more than once (e.g. foomodule.so has two hits:
once for foo + module.so, once for foomodule + .so).
1999-04-30 15:14:05 +00:00
Guido van Rossum 26c2cb4bd1 Tim Peters strikes again:
Ho ho ho -- that's trickier than it sounded!  The colorizer is working with
"line.col" strings instead of Text marks, and the absolute coordinates of
the point of interest can change across the self.update call (voice of
baffled experience, when two quick backspaces no longer fooled it, but a
backspace followed by a quick ENTER did <wink>).

Anyway, the attached appears to do the trick.  CPU usage goes way up when
typing quickly into a long triple-quoted string, but the latency is fine for
me (a relatively fast typist on a relatively slow machine).  Most of the
changes here are left over from reducing the # of vrbl names to help me
reason about the logic better; I hope the code is a *little* easier to
1999-04-26 22:20:38 +00:00
Guido van Rossum 9dd52099fa Provide full arguments to __import__ so it works in packagized IDLE. 1999-04-23 14:01:25 +00:00
Guido van Rossum 06b787bdd1 Bunch of updates necessary due to recent changes; added docs for File
menu, command line and color preferences.
1999-04-22 23:20:17 +00:00
Guido van Rossum dc7bfc44a2 Remove obsolete 'script' menu. 1999-04-22 23:09:23 +00:00
Guido van Rossum 4c6d0c7382 Several wishes fulfilled. 1999-04-22 22:32:32 +00:00
Guido van Rossum 70f6d99753 Moved classes OnDemandOutputWindow and PseudoFile here,
from ScriptBinding.py where they are no longer needed.
1999-04-22 22:28:42 +00:00
Guido van Rossum 1f3de5d7b9 Mostly rewritten. Instead of the old Run module and Debug module,
there are two new commands:

Import module (F5) imports or reloads the module and also adds its
name to the __main__ namespace.  This gets executed in the PyShell
window under control of its debug settings.

Run script (Control-F5) is similar but executes the contents of the
file directly in the __main__ namespace.
1999-04-22 22:27:40 +00:00
Guido van Rossum 27f550cdd5 Nits: document use of $IDLESTARTUP; display idle version 1999-04-22 20:56:23 +00:00
Guido van Rossum e1e1488319 New version to celebrate new command line 1999-04-22 20:50:52 +00:00
Guido van Rossum 3d0ff00c08 Added flush(), for completeness. 1999-04-22 20:50:33 +00:00
Guido van Rossum eeb88076e7 A lot of changes to make the command line more useful. You can now do:
idle.py -e file ...    -- to edit files
  idle.py script arg ... -- to run a script
  idle.py -c cmd arg ... -- to run a command
Other options, see also the usage message (also new!) for more details:
  -d       -- enable debugger
  -s       -- run $IDLESTARTUP or $PYTHONSTARTUP
  -t title -- set Python Shell window's title
sys.argv is set accordingly, unless -e is used.
sys.path is absolutized, and all relevant paths are inserted into it.

Other changes:
- the environment in which commands are executed is now the __main__ module
- explicitly save sys.stdout etc., don't restore from sys.__stdout__
- new interpreter methods execsource(), execfile(), stuffsource()
- a few small nits
1999-04-22 20:49:35 +00:00
Guido van Rossum 9f5362bfa6 Some more TODO items. Made up my mind about command line args,
Run/Import, __main__.
1999-04-22 14:07:33 +00:00
Guido van Rossum e62e76c383 Super-elegant patch by Tim Peters that speeds up colorization
dramatically (up to 15 times he claims).  Works by reading more than
one line at a time, up to 100-line chunks (starting with one line and
then doubling up to the limit).  On a typical machine (e.g. Tim's
P5-166) this doesn't reduce interactive responsiveness in a noticeable
way.
1999-04-22 13:38:40 +00:00