summaryrefslogtreecommitdiffstats
path: root/Mac/Demo/waste/htmled.py
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-06-08 15:35:45 (GMT)
committerThomas Wouters <thomas@python.org>2006-06-08 15:35:45 (GMT)
commit73e5a5b65d66f4fba9c4f626bcd6400f4a7215e6 (patch)
tree206b2ca44cf23af41ac27cb7b3744f2e60a3341d /Mac/Demo/waste/htmled.py
parent1ba5b3b425e970ec3e4a19165475aa68fa5ac893 (diff)
downloadcpython-73e5a5b65d66f4fba9c4f626bcd6400f4a7215e6.zip
cpython-73e5a5b65d66f4fba9c4f626bcd6400f4a7215e6.tar.gz
cpython-73e5a5b65d66f4fba9c4f626bcd6400f4a7215e6.tar.bz2
Merge the rest of the trunk.
Merged revisions 46490-46494,46496,46498,46500,46506,46521,46538,46558,46563-46567,46570-46571,46583,46593,46595-46598,46604,46606,46609-46753 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r46610 | martin.v.loewis | 2006-06-03 09:42:26 +0200 (Sat, 03 Jun 2006) | 2 lines Updated version (win32-icons2.zip) from #1490384. ........ r46612 | andrew.kuchling | 2006-06-03 20:09:41 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1472084] Fix description of do_tag ........ r46614 | andrew.kuchling | 2006-06-03 20:33:35 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1475554] Strengthen text to say 'must' instead of 'should' ........ r46616 | andrew.kuchling | 2006-06-03 20:41:28 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1441864] Clarify description of 'data' argument ........ r46617 | andrew.kuchling | 2006-06-03 20:43:24 +0200 (Sat, 03 Jun 2006) | 1 line Minor rewording ........ r46619 | andrew.kuchling | 2006-06-03 21:02:35 +0200 (Sat, 03 Jun 2006) | 9 lines [Bug #1497414] _self is a reserved word in the WATCOM 10.6 C compiler. Fix by renaming the variable. In a different module, Neal fixed it by renaming _self to self. There's already a variable named 'self' here, so I used selfptr. (I'm committing this on a Mac without Tk, but it's a simple search-and-replace. <crosses fingers>, so I'll watch the buildbots and see what happens.) ........ r46621 | fredrik.lundh | 2006-06-03 23:56:05 +0200 (Sat, 03 Jun 2006) | 5 lines "_self" is a said to be a reserved word in Watcom C 10.6. I'm not sure that's really standard compliant behaviour, but I guess we have to fix that anyway... ........ r46622 | andrew.kuchling | 2006-06-04 00:44:42 +0200 (Sun, 04 Jun 2006) | 1 line Update readme ........ r46623 | andrew.kuchling | 2006-06-04 00:59:23 +0200 (Sun, 04 Jun 2006) | 1 line Drop 0 parameter ........ r46624 | andrew.kuchling | 2006-06-04 00:59:59 +0200 (Sun, 04 Jun 2006) | 1 line Some code tidying; use curses.wrapper ........ r46625 | andrew.kuchling | 2006-06-04 01:02:15 +0200 (Sun, 04 Jun 2006) | 1 line Use True; value returned from main is unused ........ r46626 | andrew.kuchling | 2006-06-04 01:07:21 +0200 (Sun, 04 Jun 2006) | 1 line Use true division, and the True value ........ r46627 | andrew.kuchling | 2006-06-04 01:09:58 +0200 (Sun, 04 Jun 2006) | 1 line Docstring fix; use True ........ r46628 | andrew.kuchling | 2006-06-04 01:15:56 +0200 (Sun, 04 Jun 2006) | 1 line Put code in a main() function; loosen up the spacing to match current code style ........ r46629 | andrew.kuchling | 2006-06-04 01:39:07 +0200 (Sun, 04 Jun 2006) | 1 line Use functions; modernize code ........ r46630 | andrew.kuchling | 2006-06-04 01:43:22 +0200 (Sun, 04 Jun 2006) | 1 line This demo requires Medusa (not just asyncore); remove it ........ r46631 | andrew.kuchling | 2006-06-04 01:46:36 +0200 (Sun, 04 Jun 2006) | 2 lines Remove xmlrpc demo -- it duplicates the SimpleXMLRPCServer module. ........ r46632 | andrew.kuchling | 2006-06-04 01:47:22 +0200 (Sun, 04 Jun 2006) | 1 line Remove xmlrpc/ directory ........ r46633 | andrew.kuchling | 2006-06-04 01:51:21 +0200 (Sun, 04 Jun 2006) | 1 line Remove dangling reference ........ r46634 | andrew.kuchling | 2006-06-04 01:59:36 +0200 (Sun, 04 Jun 2006) | 1 line Add more whitespace; use a better socket name ........ r46635 | tim.peters | 2006-06-04 03:22:53 +0200 (Sun, 04 Jun 2006) | 2 lines Whitespace normalization. ........ r46637 | tim.peters | 2006-06-04 05:26:02 +0200 (Sun, 04 Jun 2006) | 16 lines In a PYMALLOC_DEBUG build obmalloc adds extra debugging info to each allocated block. This was using 4 bytes for each such piece of info regardless of platform. This didn't really matter before (proof: no bug reports, and the debug-build obmalloc would have assert-failed if it was ever asked for a chunk of memory >= 2**32 bytes), since container indices were plain ints. But after the Py_ssize_t changes, it's at least theoretically possible to allocate a list or string whose guts exceed 2**32 bytes, and the PYMALLOC_DEBUG routines would fail then (having only 4 bytes to record the originally requested size). Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG build's extra debugging fields. This won't make any difference on 32-bit boxes, but will add 16 bytes to each allocation in a debug build on a 64-bit box. ........ r46638 | tim.peters | 2006-06-04 05:38:04 +0200 (Sun, 04 Jun 2006) | 4 lines _PyObject_DebugMalloc(): The return value should add 2*sizeof(size_t) now, not 8. This probably accounts for current disasters on the 64-bit buildbot slaves. ........ r46639 | neal.norwitz | 2006-06-04 08:19:31 +0200 (Sun, 04 Jun 2006) | 1 line SF #1499797, Fix for memory leak in WindowsError_str ........ r46640 | andrew.macintyre | 2006-06-04 14:31:09 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1454481: Make thread stack size runtime tunable. ........ r46641 | andrew.macintyre | 2006-06-04 14:59:59 +0200 (Sun, 04 Jun 2006) | 2 lines clean up function declarations to conform to PEP-7 style. ........ r46642 | martin.blais | 2006-06-04 15:49:49 +0200 (Sun, 04 Jun 2006) | 15 lines Fixes in struct and socket from merge reviews. - Following Guido's comments, renamed * pack_to -> pack_into * recv_buf -> recv_into * recvfrom_buf -> recvfrom_into - Made fixes to _struct.c according to Neal Norwitz comments on the checkins list. - Converted some ints into the appropriate -- I hope -- ssize_t and size_t. ........ r46643 | ronald.oussoren | 2006-06-04 16:05:28 +0200 (Sun, 04 Jun 2006) | 3 lines "Import" LDFLAGS in Mac/OSX/Makefile.in to ensure pythonw gets build with the right compiler flags. ........ r46644 | ronald.oussoren | 2006-06-04 16:24:59 +0200 (Sun, 04 Jun 2006) | 2 lines Drop Mac wrappers for the WASTE library. ........ r46645 | tim.peters | 2006-06-04 17:49:07 +0200 (Sun, 04 Jun 2006) | 3 lines s_methods[]: Stop compiler warnings by casting s_unpack_from to PyCFunction. ........ r46646 | george.yoshida | 2006-06-04 19:04:12 +0200 (Sun, 04 Jun 2006) | 2 lines Remove a redundant word ........ r46647 | george.yoshida | 2006-06-04 19:17:25 +0200 (Sun, 04 Jun 2006) | 2 lines Markup fix ........ r46648 | martin.v.loewis | 2006-06-04 21:36:28 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1359618: Speed-up charmap encoder. ........ r46649 | georg.brandl | 2006-06-04 23:46:16 +0200 (Sun, 04 Jun 2006) | 3 lines Repair refleaks in unicodeobject. ........ r46650 | georg.brandl | 2006-06-04 23:56:52 +0200 (Sun, 04 Jun 2006) | 4 lines Patch #1346214: correctly optimize away "if 0"-style stmts (thanks to Neal for review) ........ r46651 | georg.brandl | 2006-06-05 00:15:37 +0200 (Mon, 05 Jun 2006) | 2 lines Bug #1500293: fix memory leaks in _subprocess module. ........ r46654 | tim.peters | 2006-06-05 01:43:53 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46655 | tim.peters | 2006-06-05 01:52:47 +0200 (Mon, 05 Jun 2006) | 16 lines Revert revisions: 46640 Patch #1454481: Make thread stack size runtime tunable. 46647 Markup fix The first is causing many buildbots to fail test runs, and there are multiple causes with seemingly no immediate prospects for repairing them. See python-dev discussion. Note that a branch can (and should) be created for resolving these problems, like svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH followed by merging rev 46647 to the new branch. ........ r46656 | andrew.kuchling | 2006-06-05 02:08:09 +0200 (Mon, 05 Jun 2006) | 1 line Mention second encoding speedup ........ r46657 | gregory.p.smith | 2006-06-05 02:31:01 +0200 (Mon, 05 Jun 2006) | 7 lines bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized char **log_list. feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2. ........ r46658 | gregory.p.smith | 2006-06-05 02:33:35 +0200 (Mon, 05 Jun 2006) | 5 lines fix a bug in the previous commit. don't leak empty list on error return and fix the additional rare (out of memory only) bug that it was supposed to fix of not freeing log_list when the python allocator failed. ........ r46660 | tim.peters | 2006-06-05 02:55:26 +0200 (Mon, 05 Jun 2006) | 9 lines "Flat is better than nested." Move the long-winded, multiply-nested -R support out of runtest() and into some module-level helper functions. This makes runtest() and the -R code easier to follow. That in turn allowed seeing some opportunities for code simplification, and made it obvious that reglog.txt never got closed. ........ r46661 | hyeshik.chang | 2006-06-05 02:59:54 +0200 (Mon, 05 Jun 2006) | 3 lines Fix a potentially invalid memory access of CJKCodecs' shift-jis decoder. (found by Neal Norwitz) ........ r46663 | gregory.p.smith | 2006-06-05 03:39:52 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885] ........ r46664 | tim.peters | 2006-06-05 03:43:03 +0200 (Mon, 05 Jun 2006) | 3 lines Remove doctest.testmod's deprecated (in 2.4) `isprivate` argument. A lot of hair went into supporting that! ........ r46665 | tim.peters | 2006-06-05 03:47:24 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46666 | tim.peters | 2006-06-05 03:48:21 +0200 (Mon, 05 Jun 2006) | 2 lines Make doctest news more accurate. ........ r46667 | gregory.p.smith | 2006-06-05 03:56:15 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902] ........ r46668 | gregory.p.smith | 2006-06-05 04:02:25 +0200 (Mon, 05 Jun 2006) | 3 lines mention the just committed bsddb changes ........ r46671 | gregory.p.smith | 2006-06-05 19:38:04 +0200 (Mon, 05 Jun 2006) | 3 lines * add support for DBSequence objects [patch #1466734] ........ r46672 | gregory.p.smith | 2006-06-05 20:20:07 +0200 (Mon, 05 Jun 2006) | 3 lines forgot to add this file in previous commit ........ r46673 | tim.peters | 2006-06-05 20:36:12 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46674 | tim.peters | 2006-06-05 20:36:54 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46675 | gregory.p.smith | 2006-06-05 20:48:21 +0200 (Mon, 05 Jun 2006) | 4 lines * fix DBCursor.pget() bug with keyword argument names when no data= is supplied [SF pybsddb bug #1477863] ........ r46676 | andrew.kuchling | 2006-06-05 21:05:32 +0200 (Mon, 05 Jun 2006) | 1 line Remove use of Trove name, which isn't very helpful to users ........ r46677 | andrew.kuchling | 2006-06-05 21:08:25 +0200 (Mon, 05 Jun 2006) | 1 line [Bug #1470026] Include link to list of classifiers ........ r46679 | tim.peters | 2006-06-05 22:48:49 +0200 (Mon, 05 Jun 2006) | 10 lines Access _struct attributes directly instead of mucking with getattr. string_reverse(): Simplify. assertRaises(): Raise TestFailed on failure. test_unpack_from(), test_pack_into(), test_pack_into_fn(): never use `assert` to test for an expected result (it doesn't test anything when Python is run with -O). ........ r46680 | tim.peters | 2006-06-05 22:49:27 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46681 | gregory.p.smith | 2006-06-06 01:38:06 +0200 (Tue, 06 Jun 2006) | 3 lines add depends = ['md5.h'] to the _md5 module extension for correctness sake. ........ r46682 | brett.cannon | 2006-06-06 01:51:55 +0200 (Tue, 06 Jun 2006) | 4 lines Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int. Closes bug #1501223. ........ r46684 | gregory.p.smith | 2006-06-06 01:59:37 +0200 (Tue, 06 Jun 2006) | 5 lines - bsddb: the __len__ method of a DB object has been fixed to return correct results. It could previously incorrectly return 0 in some cases. Fixes SF bug 1493322 (pybsddb bug 1184012). ........ r46686 | tim.peters | 2006-06-06 02:25:07 +0200 (Tue, 06 Jun 2006) | 7 lines _PySys_Init(): It's rarely a good idea to size a buffer to the exact maximum size someone guesses is needed. In this case, if we're really worried about extreme integers, then "cp%d" can actually need 14 bytes (2 for "cp" + 1 for \0 at the end + 11 for -(2**31-1)). So reserve 128 bytes instead -- nothing is actually saved by making a stack-local buffer tiny. ........ r46687 | neal.norwitz | 2006-06-06 09:22:08 +0200 (Tue, 06 Jun 2006) | 1 line Remove unused variable (and stop compiler warning) ........ r46688 | neal.norwitz | 2006-06-06 09:23:01 +0200 (Tue, 06 Jun 2006) | 1 line Fix a bunch of parameter strings ........ r46689 | thomas.heller | 2006-06-06 13:34:33 +0200 (Tue, 06 Jun 2006) | 6 lines Convert CFieldObject tp_members to tp_getset, since there is no structmember typecode for Py_ssize_t fields. This should fix some of the errors on the PPC64 debian machine (64-bit, big endian). Assigning to readonly fields now raises AttributeError instead of TypeError, so the testcase has to be changed as well. ........ r46690 | thomas.heller | 2006-06-06 13:54:32 +0200 (Tue, 06 Jun 2006) | 1 line Damn - the sentinel was missing. And fix another silly mistake. ........ r46691 | martin.blais | 2006-06-06 14:46:55 +0200 (Tue, 06 Jun 2006) | 13 lines Normalized a few cases of whitespace in function declarations. Found them using:: find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done (I was doing this all over my own code anyway, because I'd been using spaces in all defs, so I thought I'd make a run on the Python code as well. If you need to do such fixes in your own code, you can use xx-rename or parenregu.el within emacs.) ........ r46693 | thomas.heller | 2006-06-06 17:34:18 +0200 (Tue, 06 Jun 2006) | 1 line Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures ........ r46694 | tim.peters | 2006-06-06 17:50:17 +0200 (Tue, 06 Jun 2006) | 5 lines BSequence_set_range(): Rev 46688 ("Fix a bunch of parameter strings") changed this function's signature seemingly by mistake, which is causing buildbots to fail test_bsddb3. Restored the pre-46688 signature. ........ r46695 | tim.peters | 2006-06-06 17:52:35 +0200 (Tue, 06 Jun 2006) | 4 lines On python-dev Thomas Heller said these were committed by mistake in rev 46693, so reverting this part of rev 46693. ........ r46696 | andrew.kuchling | 2006-06-06 19:10:41 +0200 (Tue, 06 Jun 2006) | 1 line Fix comment typo ........ r46697 | brett.cannon | 2006-06-06 20:08:16 +0200 (Tue, 06 Jun 2006) | 2 lines Fix coding style guide bug. ........ r46698 | thomas.heller | 2006-06-06 20:50:46 +0200 (Tue, 06 Jun 2006) | 2 lines Add a hack so that foreign functions returning float now do work on 64-bit big endian platforms. ........ r46699 | thomas.heller | 2006-06-06 21:25:13 +0200 (Tue, 06 Jun 2006) | 3 lines Use the same big-endian hack as in _ctypes/callproc.c for callback functions. This fixes the callback function tests that return float. ........ r46700 | ronald.oussoren | 2006-06-06 21:50:24 +0200 (Tue, 06 Jun 2006) | 5 lines * Ensure that "make altinstall" works when the tree was configured with --enable-framework * Also for --enable-framework: allow users to use --prefix to specify the location of the compatibility symlinks (such as /usr/local/bin/python) ........ r46701 | ronald.oussoren | 2006-06-06 21:56:00 +0200 (Tue, 06 Jun 2006) | 3 lines A quick hack to ensure the right key-bindings for IDLE on osx: install patched configuration files during a framework install. ........ r46702 | tim.peters | 2006-06-07 03:04:59 +0200 (Wed, 07 Jun 2006) | 4 lines dash_R_cleanup(): Clear filecmp._cache. This accounts for different results across -R runs (at least on Windows) of test_filecmp. ........ r46705 | tim.peters | 2006-06-07 08:57:51 +0200 (Wed, 07 Jun 2006) | 17 lines SF patch 1501987: Remove randomness from test_exceptions, from ?iga Seilnacht (sorry about the name, but Firefox on my box can't display the first character of the name -- the SF "Unix name" is zseil). This appears to cure the oddball intermittent leaks across runs when running test_exceptions under -R. I'm not sure why, but I'm too sleepy to care ;-) The thrust of the SF patch was to remove randomness in the pickle protocol used. I changed the patch to use range(pickle.HIGHEST_PROTOCOL + 1), to try both pickle and cPickle, and randomly mucked with other test lines to put statements on their own lines. Not a bugfix candidate (this is fiddling new-in-2.5 code). ........ r46706 | andrew.kuchling | 2006-06-07 15:55:33 +0200 (Wed, 07 Jun 2006) | 1 line Add an SQLite introduction, taken from the 'What's New' text ........ r46708 | andrew.kuchling | 2006-06-07 19:02:52 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46709 | andrew.kuchling | 2006-06-07 19:03:46 +0200 (Wed, 07 Jun 2006) | 1 line Add an item; also, escape % ........ r46710 | andrew.kuchling | 2006-06-07 19:04:01 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46716 | ronald.oussoren | 2006-06-07 20:57:44 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/Tools one level up ........ r46717 | ronald.oussoren | 2006-06-07 20:58:01 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/PythonLauncher one level up ........ r46718 | ronald.oussoren | 2006-06-07 20:58:42 +0200 (Wed, 07 Jun 2006) | 2 lines mv Mac/OSX/BuildScript one level up ........ r46719 | ronald.oussoren | 2006-06-07 21:02:03 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/* one level up ........ r46720 | ronald.oussoren | 2006-06-07 21:06:01 +0200 (Wed, 07 Jun 2006) | 2 lines And the last bit: move IDLE one level up and adjust makefiles ........ r46723 | ronald.oussoren | 2006-06-07 21:38:53 +0200 (Wed, 07 Jun 2006) | 4 lines - Patch the correct version of python in the Info.plists at build time, instead of relying on a maintainer to update them before releases. - Remove the now empty Mac/OSX directory ........ r46727 | ronald.oussoren | 2006-06-07 22:18:44 +0200 (Wed, 07 Jun 2006) | 7 lines * If BuildApplet.py is used as an applet it starts with a version of sys.exutable that isn't usuable on an #!-line. That results in generated applets that don't actually work. Work around this problem by resetting sys.executable. * argvemulator.py didn't work on intel macs. This patch fixes this (bug #1491468) ........ r46728 | tim.peters | 2006-06-07 22:40:06 +0200 (Wed, 07 Jun 2006) | 2 lines Whitespace normalization. ........ r46729 | tim.peters | 2006-06-07 22:40:54 +0200 (Wed, 07 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46730 | thomas.heller | 2006-06-07 22:43:06 +0200 (Wed, 07 Jun 2006) | 7 lines Fix for foreign functions returning small structures on 64-bit big endian machines. Should fix the remaininf failure in the PPC64 Debian buildbot. Thanks to Matthias Klose for providing access to a machine to debug and test this. ........ r46731 | brett.cannon | 2006-06-07 23:48:17 +0200 (Wed, 07 Jun 2006) | 2 lines Clarify documentation for bf_getcharbuffer. ........ r46735 | neal.norwitz | 2006-06-08 07:12:45 +0200 (Thu, 08 Jun 2006) | 1 line Fix a refleak in recvfrom_into ........ r46736 | gregory.p.smith | 2006-06-08 07:17:08 +0200 (Thu, 08 Jun 2006) | 9 lines - bsddb: the bsddb.dbtables Modify method now raises the proper error and aborts the db transaction safely when a modifier callback fails. Fixes SF python patch/bug #1408584. Also cleans up the bsddb.dbtables docstrings since thats the only documentation that exists for that unadvertised module. (people really should really just use sqlite3) ........ r46737 | gregory.p.smith | 2006-06-08 07:38:11 +0200 (Thu, 08 Jun 2006) | 4 lines * Turn the deadlock situation described in SF bug #775414 into a DBDeadLockError exception. * add the test case for my previous dbtables commit. ........ r46738 | gregory.p.smith | 2006-06-08 07:39:54 +0200 (Thu, 08 Jun 2006) | 2 lines pasted set_lk_detect line in wrong spot in previous commit. fixed. passes tests this time. ........ r46739 | armin.rigo | 2006-06-08 12:56:24 +0200 (Thu, 08 Jun 2006) | 6 lines (arre, arigo) SF bug #1350060 Give a consistent behavior for comparison and hashing of method objects (both user- and built-in methods). Now compares the 'self' recursively. The hash was already asking for the hash of 'self'. ........ r46740 | andrew.kuchling | 2006-06-08 13:56:44 +0200 (Thu, 08 Jun 2006) | 1 line Typo fix ........ r46741 | georg.brandl | 2006-06-08 14:45:01 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking. ........ r46743 | georg.brandl | 2006-06-08 14:54:13 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502728: Correctly link against librt library on HP-UX. ........ r46745 | georg.brandl | 2006-06-08 14:55:47 +0200 (Thu, 08 Jun 2006) | 3 lines Add news for recent bugfix. ........ r46746 | georg.brandl | 2006-06-08 15:31:07 +0200 (Thu, 08 Jun 2006) | 4 lines Argh. "integer" is a very confusing word ;) Actually, checking for INT_MAX and INT_MIN is correct since the format code explicitly handles a C "int". ........ r46748 | nick.coghlan | 2006-06-08 15:54:49 +0200 (Thu, 08 Jun 2006) | 1 line Add functools.update_wrapper() and functools.wraps() as described in PEP 356 ........ r46751 | georg.brandl | 2006-06-08 16:50:21 +0200 (Thu, 08 Jun 2006) | 4 lines Bug #1502805: don't alias file.__exit__ to file.close since the latter can return something that's true. ........ r46752 | georg.brandl | 2006-06-08 16:50:53 +0200 (Thu, 08 Jun 2006) | 3 lines Convert test_file to unittest. ........
Diffstat (limited to 'Mac/Demo/waste/htmled.py')
-rw-r--r--Mac/Demo/waste/htmled.py830
1 files changed, 0 insertions, 830 deletions
diff --git a/Mac/Demo/waste/htmled.py b/Mac/Demo/waste/htmled.py
deleted file mode 100644
index d8cea1b..0000000
--- a/Mac/Demo/waste/htmled.py
+++ /dev/null
@@ -1,830 +0,0 @@
-# A minimal text editor.
-#
-# To be done:
-# - Functionality: find, etc.
-
-from Carbon.Menu import DrawMenuBar
-from FrameWork import *
-from Carbon import Win
-from Carbon import Qd
-from Carbon import Res
-from Carbon import Fm
-import waste
-import WASTEconst
-from Carbon import Scrap
-import os
-import EasyDialogs
-import macfs
-import string
-import htmllib
-
-WATCH = Qd.GetCursor(4).data
-
-LEFTMARGIN=0
-
-UNDOLABELS = [ # Indexed by WEGetUndoInfo() value
- None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style"]
-
-# Style and size menu. Note that style order is important (tied to bit values)
-STYLES = [
- ("Bold", "B"), ("Italic", "I"), ("Underline", "U"), ("Outline", "O"),
- ("Shadow", ""), ("Condensed", ""), ("Extended", "")
- ]
-SIZES = [ 9, 10, 12, 14, 18, 24]
-
-# Sizes for HTML tag types
-HTML_SIZE={
- 'h1': 18,
- 'h2': 14
-}
-
-BIGREGION=Qd.NewRgn()
-Qd.SetRectRgn(BIGREGION, -16000, -16000, 16000, 16000)
-
-class WasteWindow(ScrolledWindow):
- def open(self, path, name, data):
- self.path = path
- self.name = name
- r = windowbounds(400, 400)
- w = Win.NewWindow(r, name, 1, 0, -1, 1, 0)
- self.wid = w
- vr = LEFTMARGIN, 0, r[2]-r[0]-15, r[3]-r[1]-15
- dr = (0, 0, vr[2], 0)
- Qd.SetPort(w)
- Qd.TextFont(4)
- Qd.TextSize(9)
- flags = WASTEconst.weDoAutoScroll | WASTEconst.weDoOutlineHilite | \
- WASTEconst.weDoMonoStyled | WASTEconst.weDoUndo
- self.ted = waste.WENew(dr, vr, flags)
- self.ted.WEInstallTabHooks()
- style, soup = self.getstylesoup(self.path)
- self.ted.WEInsert(data, style, soup)
- self.ted.WESetSelection(0,0)
- self.ted.WECalText()
- self.ted.WEResetModCount()
- w.DrawGrowIcon()
- self.scrollbars()
- self.do_postopen()
- self.do_activate(1, None)
-
- def getstylesoup(self, pathname):
- if not pathname:
- return None, None
- oldrf = Res.CurResFile()
- try:
- rf = Res.FSpOpenResFile(self.path, 1)
- except Res.Error:
- return None, None
- try:
- hstyle = Res.Get1Resource('styl', 128)
- hstyle.DetachResource()
- except Res.Error:
- hstyle = None
- try:
- hsoup = Res.Get1Resource('SOUP', 128)
- hsoup.DetachResource()
- except Res.Error:
- hsoup = None
- Res.CloseResFile(rf)
- Res.UseResFile(oldrf)
- return hstyle, hsoup
-
- def do_idle(self, event):
- (what, message, when, where, modifiers) = event
- Qd.SetPort(self.wid)
- self.ted.WEIdle()
- if self.ted.WEAdjustCursor(where, BIGREGION):
- return
- Qd.SetCursor(Qd.GetQDGlobalsArrow())
-
- def getscrollbarvalues(self):
- dr = self.ted.WEGetDestRect()
- vr = self.ted.WEGetViewRect()
- vx = self.scalebarvalue(dr[0], dr[2], vr[0], vr[2])
- vy = self.scalebarvalue(dr[1], dr[3], vr[1], vr[3])
- return vx, vy
-
- def scrollbar_callback(self, which, what, value):
- if which == 'y':
- #
- # "line" size is minimum of top and bottom line size
- #
- topline_off,dummy = self.ted.WEGetOffset((1,1))
- topline_num = self.ted.WEOffsetToLine(topline_off)
- toplineheight = self.ted.WEGetHeight(topline_num, topline_num+1)
-
- botlinepos = self.ted.WEGetViewRect()[3]
- botline_off, dummy = self.ted.WEGetOffset((1, botlinepos-1))
- botline_num = self.ted.WEOffsetToLine(botline_off)
- botlineheight = self.ted.WEGetHeight(botline_num, botline_num+1)
-
- if botlineheight == 0:
- botlineheight = self.ted.WEGetHeight(botline_num-1, botline_num)
- if botlineheight < toplineheight:
- lineheight = botlineheight
- else:
- lineheight = toplineheight
- if lineheight <= 0:
- lineheight = 1
- #
- # Now do the command.
- #
- if what == 'set':
- height = self.ted.WEGetHeight(0, 0x3fffffff)
- cur = self.getscrollbarvalues()[1]
- delta = (cur-value)*height/32767
- if what == '-':
- delta = lineheight
- elif what == '--':
- delta = (self.ted.WEGetViewRect()[3]-lineheight)
- if delta <= 0:
- delta = lineheight
- elif what == '+':
- delta = -lineheight
- elif what == '++':
- delta = -(self.ted.WEGetViewRect()[3]-lineheight)
- if delta >= 0:
- delta = -lineheight
- self.ted.WEScroll(0, delta)
- else:
- if what == 'set':
- return # XXXX
- vr = self.ted.WEGetViewRect()
- winwidth = vr[2]-vr[0]
- if what == '-':
- delta = winwidth/10
- elif what == '--':
- delta = winwidth/2
- elif what == '+':
- delta = -winwidth/10
- elif what == '++':
- delta = -winwidth/2
- self.ted.WEScroll(delta, 0)
- # Pin the scroll
- l, t, r, b = self.ted.WEGetDestRect()
- vl, vt, vr, vb = self.ted.WEGetViewRect()
- if t > 0 or l > 0:
- dx = dy = 0
- if t > 0: dy = -t
- if l > 0: dx = -l
- self.ted.WEScroll(dx, dy)
- elif b < vb:
- self.ted.WEScroll(0, vb-b)
-
-
- def do_activate(self, onoff, evt):
- Qd.SetPort(self.wid)
- ScrolledWindow.do_activate(self, onoff, evt)
- if onoff:
- self.ted.WEActivate()
- self.parent.active = self
- self.parent.updatemenubar()
- else:
- self.ted.WEDeactivate()
-
- def do_update(self, wid, event):
- region = wid.GetWindowPort().visRgn
- if Qd.EmptyRgn(region):
- return
- Qd.EraseRgn(region)
- self.ted.WEUpdate(region)
- self.updatescrollbars()
-
- def do_postresize(self, width, height, window):
- l, t, r, b = self.ted.WEGetViewRect()
- vr = (l, t, l+width-15, t+height-15)
- self.ted.WESetViewRect(vr)
- self.wid.InvalWindowRect(vr)
- ScrolledWindow.do_postresize(self, width, height, window)
-
- def do_contentclick(self, local, modifiers, evt):
- (what, message, when, where, modifiers) = evt
- self.ted.WEClick(local, modifiers, when)
- self.updatescrollbars()
- self.parent.updatemenubar()
-
- def do_char(self, ch, event):
- self.ted.WESelView()
- (what, message, when, where, modifiers) = event
- self.ted.WEKey(ord(ch), modifiers)
- self.updatescrollbars()
- self.parent.updatemenubar()
-
- def close(self):
- if self.ted.WEGetModCount():
- save = EasyDialogs.AskYesNoCancel('Save window "%s" before closing?'%self.name, 1)
- if save > 0:
- self.menu_save()
- elif save < 0:
- return
- if self.parent.active == self:
- self.parent.active = None
- self.parent.updatemenubar()
- del self.ted
- self.do_postclose()
-
- def menu_save(self):
- if not self.path:
- self.menu_save_as()
- return # Will call us recursively
- #
- # First save data
- #
- dhandle = self.ted.WEGetText()
- data = dhandle.data
- fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line
- fp.write(data)
- if data[-1] <> '\r': fp.write('\r')
- fp.close()
- #
- # Now save style and soup
- #
- oldresfile = Res.CurResFile()
- try:
- rf = Res.FSpOpenResFile(self.path, 3)
- except Res.Error:
- Res.FSpCreateResFile(self.path, '????', 'TEXT', macfs.smAllScripts)
- rf = Res.FSpOpenResFile(self.path, 3)
- styles = Res.Resource('')
- soup = Res.Resource('')
- self.ted.WECopyRange(0, 0x3fffffff, None, styles, soup)
- styles.AddResource('styl', 128, '')
- soup.AddResource('SOUP', 128, '')
- Res.CloseResFile(rf)
- Res.UseResFile(oldresfile)
-
- self.ted.WEResetModCount()
-
- def menu_save_as(self):
- path = EasyDialogs.AskFileForSave(message='Save as:')
- if not path: return
- self.path = path
- self.name = os.path.split(self.path)[-1]
- self.wid.SetWTitle(self.name)
- self.menu_save()
-
- def menu_insert(self, fp):
- self.ted.WESelView()
- data = fp.read()
- self.ted.WEInsert(data, None, None)
- self.updatescrollbars()
- self.parent.updatemenubar()
-
- def menu_insert_html(self, fp):
- import htmllib
- import formatter
- f = formatter.AbstractFormatter(self)
-
- # Remember where we are, and don't update
- Qd.SetCursor(WATCH)
- start, dummy = self.ted.WEGetSelection()
- self.ted.WEFeatureFlag(WASTEconst.weFInhibitRecal, 1)
-
- self.html_init()
- p = MyHTMLParser(f)
- p.feed(fp.read())
-
- # Restore updating, recalc, set focus
- dummy, end = self.ted.WEGetSelection()
- self.ted.WECalText()
- self.ted.WESetSelection(start, end)
- self.ted.WESelView()
- self.ted.WEFeatureFlag(WASTEconst.weFInhibitRecal, 0)
- self.wid.InvalWindowRect(self.ted.WEGetViewRect())
-
- self.updatescrollbars()
- self.parent.updatemenubar()
-
- def menu_cut(self):
- self.ted.WESelView()
- if hasattr(Scrap, 'ZeroScrap'):
- Scrap.ZeroScrap()
- else:
- Scrap.ClearCurrentScrap()
- self.ted.WECut()
- self.updatescrollbars()
- self.parent.updatemenubar()
-
- def menu_copy(self):
- if hasattr(Scrap, 'ZeroScrap'):
- Scrap.ZeroScrap()
- else:
- Scrap.ClearCurrentScrap()
- self.ted.WECopy()
- self.updatescrollbars()
- self.parent.updatemenubar()
-
- def menu_paste(self):
- self.ted.WESelView()
- self.ted.WEPaste()
- self.updatescrollbars()
- self.parent.updatemenubar()
-
- def menu_clear(self):
- self.ted.WESelView()
- self.ted.WEDelete()
- self.updatescrollbars()
- self.parent.updatemenubar()
-
- def menu_undo(self):
- self.ted.WEUndo()
- self.updatescrollbars()
- self.parent.updatemenubar()
-
- def menu_setfont(self, font):
- font = Fm.GetFNum(font)
- self.mysetstyle(WASTEconst.weDoFont, (font, 0, 0, (0,0,0)))
- self.parent.updatemenubar()
-
- def menu_modface(self, face):
- self.mysetstyle(WASTEconst.weDoFace|WASTEconst.weDoToggleFace,
- (0, face, 0, (0,0,0)))
-
- def menu_setface(self, face):
- self.mysetstyle(WASTEconst.weDoFace|WASTEconst.weDoReplaceFace,
- (0, face, 0, (0,0,0)))
-
- def menu_setsize(self, size):
- self.mysetstyle(WASTEconst.weDoSize, (0, 0, size, (0,0,0)))
-
- def menu_incsize(self, size):
- self.mysetstyle(WASTEconst.weDoAddSize, (0, 0, size, (0,0,0)))
-
- def mysetstyle(self, which, how):
- self.ted.WESelView()
- self.ted.WESetStyle(which, how)
- self.parent.updatemenubar()
-
- def have_selection(self):
- start, stop = self.ted.WEGetSelection()
- return start < stop
-
- def can_paste(self):
- return self.ted.WECanPaste()
-
- def can_undo(self):
- which, redo = self.ted.WEGetUndoInfo()
- which = UNDOLABELS[which]
- if which == None: return None
- if redo:
- return "Redo "+which
- else:
- return "Undo "+which
-
- def getruninfo(self):
- all = (WASTEconst.weDoFont | WASTEconst.weDoFace | WASTEconst.weDoSize)
- dummy, mode, (font, face, size, color) = self.ted.WEContinuousStyle(all)
- if not (mode & WASTEconst.weDoFont):
- font = None
- else:
- font = Fm.GetFontName(font)
- if not (mode & WASTEconst.weDoFace): fact = None
- if not (mode & WASTEconst.weDoSize): size = None
- return font, face, size
-
- #
- # Methods for writer class for html formatter
- #
-
- def html_init(self):
- self.html_font = [12, 0, 0, 0]
- self.html_style = 0
- self.html_color = (0,0,0)
- self.new_font(self.html_font)
-
- def new_font(self, font):
- if font == None:
- font = (12, 0, 0, 0)
- font = map(lambda x:x, font)
- for i in range(len(font)):
- if font[i] == None:
- font[i] = self.html_font[i]
- [size, italic, bold, tt] = font
- self.html_font = font[:]
- if tt:
- font = Fm.GetFNum('Courier')
- else:
- font = Fm.GetFNum('Times')
- if HTML_SIZE.has_key(size):
- size = HTML_SIZE[size]
- else:
- size = 12
- face = 0
- if bold: face = face | 1
- if italic: face = face | 2
- face = face | self.html_style
- self.ted.WESetStyle(WASTEconst.weDoFont | WASTEconst.weDoFace |
- WASTEconst.weDoSize | WASTEconst.weDoColor,
- (font, face, size, self.html_color))
-
- def new_margin(self, margin, level):
- self.ted.WEInsert('[Margin %s %s]'%(margin, level), None, None)
-
- def new_spacing(self, spacing):
- self.ted.WEInsert('[spacing %s]'%spacing, None, None)
-
- def new_styles(self, styles):
- self.html_style = 0
- self.html_color = (0,0,0)
- if 'anchor' in styles:
- self.html_style = self.html_style | 4
- self.html_color = (0xffff, 0, 0)
- self.new_font(self.html_font)
-
- def send_paragraph(self, blankline):
- self.ted.WEInsert('\r'*(blankline+1), None, None)
-
- def send_line_break(self):
- self.ted.WEInsert('\r', None, None)
-
- def send_hor_rule(self, *args, **kw):
- # Ignore ruler options, for now
- dummydata = Res.Resource('')
- self.ted.WEInsertObject('rulr', dummydata, (0,0))
-
- def send_label_data(self, data):
- self.ted.WEInsert(data, None, None)
-
- def send_flowing_data(self, data):
- self.ted.WEInsert(data, None, None)
-
- def send_literal_data(self, data):
- data = string.replace(data, '\n', '\r')
- data = string.expandtabs(data)
- self.ted.WEInsert(data, None, None)
-
-class Wed(Application):
- def __init__(self):
- Application.__init__(self)
- self.num = 0
- self.active = None
- self.updatemenubar()
- waste.STDObjectHandlers()
- # Handler for horizontal ruler
- waste.WEInstallObjectHandler('rulr', 'new ', self.newRuler)
- waste.WEInstallObjectHandler('rulr', 'draw', self.drawRuler)
-
- def makeusermenus(self):
- self.filemenu = m = Menu(self.menubar, "File")
- self.newitem = MenuItem(m, "New window", "N", self.open)
- self.openitem = MenuItem(m, "Open...", "O", self.openfile)
- self.closeitem = MenuItem(m, "Close", "W", self.closewin)
- m.addseparator()
- self.saveitem = MenuItem(m, "Save", "S", self.save)
- self.saveasitem = MenuItem(m, "Save as...", "", self.saveas)
- m.addseparator()
- self.insertitem = MenuItem(m, "Insert plaintext...", "", self.insertfile)
- self.htmlitem = MenuItem(m, "Insert HTML...", "", self.inserthtml)
- m.addseparator()
- self.quititem = MenuItem(m, "Quit", "Q", self.quit)
-
- self.editmenu = m = Menu(self.menubar, "Edit")
- self.undoitem = MenuItem(m, "Undo", "Z", self.undo)
- self.cutitem = MenuItem(m, "Cut", "X", self.cut)
- self.copyitem = MenuItem(m, "Copy", "C", self.copy)
- self.pasteitem = MenuItem(m, "Paste", "V", self.paste)
- self.clearitem = MenuItem(m, "Clear", "", self.clear)
-
- self.makefontmenu()
-
- # Groups of items enabled together:
- self.windowgroup = [self.closeitem, self.saveitem, self.saveasitem,
- self.editmenu, self.fontmenu, self.facemenu, self.sizemenu,
- self.insertitem]
- self.focusgroup = [self.cutitem, self.copyitem, self.clearitem]
- self.windowgroup_on = -1
- self.focusgroup_on = -1
- self.pastegroup_on = -1
- self.undo_label = "never"
- self.ffs_values = ()
-
- def makefontmenu(self):
- self.fontmenu = Menu(self.menubar, "Font")
- self.fontnames = getfontnames()
- self.fontitems = []
- for n in self.fontnames:
- m = MenuItem(self.fontmenu, n, "", self.selfont)
- self.fontitems.append(m)
- self.facemenu = Menu(self.menubar, "Style")
- self.faceitems = []
- for n, shortcut in STYLES:
- m = MenuItem(self.facemenu, n, shortcut, self.selface)
- self.faceitems.append(m)
- self.facemenu.addseparator()
- self.faceitem_normal = MenuItem(self.facemenu, "Normal", "N",
- self.selfacenormal)
- self.sizemenu = Menu(self.menubar, "Size")
- self.sizeitems = []
- for n in SIZES:
- m = MenuItem(self.sizemenu, repr(n), "", self.selsize)
- self.sizeitems.append(m)
- self.sizemenu.addseparator()
- self.sizeitem_bigger = MenuItem(self.sizemenu, "Bigger", "+",
- self.selsizebigger)
- self.sizeitem_smaller = MenuItem(self.sizemenu, "Smaller", "-",
- self.selsizesmaller)
-
- def selfont(self, id, item, *rest):
- if self.active:
- font = self.fontnames[item-1]
- self.active.menu_setfont(font)
- else:
- EasyDialogs.Message("No active window?")
-
- def selface(self, id, item, *rest):
- if self.active:
- face = (1<<(item-1))
- self.active.menu_modface(face)
- else:
- EasyDialogs.Message("No active window?")
-
- def selfacenormal(self, *rest):
- if self.active:
- self.active.menu_setface(0)
- else:
- EasyDialogs.Message("No active window?")
-
- def selsize(self, id, item, *rest):
- if self.active:
- size = SIZES[item-1]
- self.active.menu_setsize(size)
- else:
- EasyDialogs.Message("No active window?")
-
- def selsizebigger(self, *rest):
- if self.active:
- self.active.menu_incsize(2)
- else:
- EasyDialogs.Message("No active window?")
-
- def selsizesmaller(self, *rest):
- if self.active:
- self.active.menu_incsize(-2)
- else:
- EasyDialogs.Message("No active window?")
-
- def updatemenubar(self):
- changed = 0
- on = (self.active <> None)
- if on <> self.windowgroup_on:
- for m in self.windowgroup:
- m.enable(on)
- self.windowgroup_on = on
- changed = 1
- if on:
- # only if we have an edit menu
- on = self.active.have_selection()
- if on <> self.focusgroup_on:
- for m in self.focusgroup:
- m.enable(on)
- self.focusgroup_on = on
- changed = 1
- on = self.active.can_paste()
- if on <> self.pastegroup_on:
- self.pasteitem.enable(on)
- self.pastegroup_on = on
- changed = 1
- on = self.active.can_undo()
- if on <> self.undo_label:
- if on:
- self.undoitem.enable(1)
- self.undoitem.settext(on)
- self.undo_label = on
- else:
- self.undoitem.settext("Nothing to undo")
- self.undoitem.enable(0)
- changed = 1
- if self.updatefontmenus():
- changed = 1
- if changed:
- DrawMenuBar()
-
- def updatefontmenus(self):
- info = self.active.getruninfo()
- if info == self.ffs_values:
- return 0
- # Remove old checkmarks
- if self.ffs_values == ():
- self.ffs_values = (None, None, None)
- font, face, size = self.ffs_values
- if font <> None:
- fnum = self.fontnames.index(font)
- self.fontitems[fnum].check(0)
- if face <> None:
- for i in range(len(self.faceitems)):
- if face & (1<<i):
- self.faceitems[i].check(0)
- if size <> None:
- for i in range(len(self.sizeitems)):
- if SIZES[i] == size:
- self.sizeitems[i].check(0)
-
- self.ffs_values = info
- # Set new checkmarks
- font, face, size = self.ffs_values
- if font <> None:
- fnum = self.fontnames.index(font)
- self.fontitems[fnum].check(1)
- if face <> None:
- for i in range(len(self.faceitems)):
- if face & (1<<i):
- self.faceitems[i].check(1)
- if size <> None:
- for i in range(len(self.sizeitems)):
- if SIZES[i] == size:
- self.sizeitems[i].check(1)
- # Set outline/normal for sizes
- if font:
- exists = getfontsizes(font, SIZES)
- for i in range(len(self.sizeitems)):
- if exists[i]:
- self.sizeitems[i].setstyle(0)
- else:
- self.sizeitems[i].setstyle(8)
-
- #
- # Apple menu
- #
-
- def do_about(self, id, item, window, event):
- EasyDialogs.Message("A simple single-font text editor based on WASTE")
-
- #
- # File menu
- #
-
- def open(self, *args):
- self._open(0)
-
- def openfile(self, *args):
- self._open(1)
-
- def _open(self, askfile):
- if askfile:
- path = EasyDialogs.AskFileForOpen(typeList=('TEXT',))
- if not path:
- return
- name = os.path.split(path)[-1]
- try:
- fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
- data = fp.read()
- fp.close()
- except IOError, arg:
- EasyDialogs.Message("IOERROR: %r" % (arg,))
- return
- else:
- path = None
- name = "Untitled %d"%self.num
- data = ''
- w = WasteWindow(self)
- w.open(path, name, data)
- self.num = self.num + 1
-
- def insertfile(self, *args):
- if self.active:
- path = EasyDialogs.AskFileForOpen(typeList=('TEXT',))
- if not path:
- return
- try:
- fp = open(path, 'rb') # NOTE binary, we need cr as end-of-line
- except IOError, arg:
- EasyDialogs.Message("IOERROR: %r" % (args,))
- return
- self.active.menu_insert(fp)
- else:
- EasyDialogs.Message("No active window?")
-
- def inserthtml(self, *args):
- if self.active:
- path = EasyDialogs.AskFileForOpen(typeList=('TEXT',))
- if not path:
- return
- try:
- fp = open(path, 'r')
- except IOError, arg:
- EasyDialogs.Message("IOERROR: %r" % (arg,))
- return
- self.active.menu_insert_html(fp)
- else:
- EasyDialogs.Message("No active window?")
-
-
- def closewin(self, *args):
- if self.active:
- self.active.close()
- else:
- EasyDialogs.Message("No active window?")
-
- def save(self, *args):
- if self.active:
- self.active.menu_save()
- else:
- EasyDialogs.Message("No active window?")
-
- def saveas(self, *args):
- if self.active:
- self.active.menu_save_as()
- else:
- EasyDialogs.Message("No active window?")
-
-
- def quit(self, *args):
- for w in self._windows.values():
- w.close()
- if self._windows:
- return
- self._quit()
-
- #
- # Edit menu
- #
-
- def undo(self, *args):
- if self.active:
- self.active.menu_undo()
- else:
- EasyDialogs.Message("No active window?")
-
- def cut(self, *args):
- if self.active:
- self.active.menu_cut()
- else:
- EasyDialogs.Message("No active window?")
-
- def copy(self, *args):
- if self.active:
- self.active.menu_copy()
- else:
- EasyDialogs.Message("No active window?")
-
- def paste(self, *args):
- if self.active:
- self.active.menu_paste()
- else:
- EasyDialogs.Message("No active window?")
-
- def clear(self, *args):
- if self.active:
- self.active.menu_clear()
- else:
- EasyDialogs.Message("No active window?")
-
- #
- # Other stuff
- #
-
- def idle(self, event):
- if self.active:
- self.active.do_idle(event)
- else:
- Qd.SetCursor(Qd.GetQDGlobalsArrow())
-
- def newRuler(self, obj):
- """Insert a new ruler. Make it as wide as the window minus 2 pxls"""
- ted = obj.WEGetObjectOwner()
- l, t, r, b = ted.WEGetDestRect()
- return r-l, 4
-
- def drawRuler(self, (l, t, r, b), obj):
- y = (t+b)/2
- Qd.MoveTo(l+2, y)
- Qd.LineTo(r-2, y)
- return 0
-
-class MyHTMLParser(htmllib.HTMLParser):
-
- def anchor_bgn(self, href, name, type):
- self.anchor = href
- if self.anchor:
- self.anchorlist.append(href)
- self.formatter.push_style('anchor')
-
- def anchor_end(self):
- if self.anchor:
- self.anchor = None
- self.formatter.pop_style()
-
-
-def getfontnames():
- names = []
- for i in range(256):
- n = Fm.GetFontName(i)
- if n: names.append(n)
- return names
-
-def getfontsizes(name, sizes):
- exist = []
- num = Fm.GetFNum(name)
- for sz in sizes:
- if Fm.RealFont(num, sz):
- exist.append(1)
- else:
- exist.append(0)
- return exist
-
-def main():
- App = Wed()
- App.mainloop()
-
-if __name__ == '__main__':
- main()