/Mac/Modules/te/_TEmodule.c

http://unladen-swallow.googlecode.com/ · C · 1339 lines · 1198 code · 131 blank · 10 comment · 74 complexity · ceff86830da476b7ece1783c503f48e5 MD5 · raw file

  1. /* =========================== Module _TE =========================== */
  2. #include "Python.h"
  3. #ifndef __LP64__
  4. #include "pymactoolbox.h"
  5. /* Macro to test whether a weak-loaded CFM function exists */
  6. #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
  7. PyErr_SetString(PyExc_NotImplementedError, \
  8. "Not available in this shared library/OS version"); \
  9. return NULL; \
  10. }} while(0)
  11. #include <Carbon/Carbon.h>
  12. #ifdef USE_TOOLBOX_OBJECT_GLUE
  13. extern PyObject *_TEObj_New(TEHandle);
  14. extern int _TEObj_Convert(PyObject *, TEHandle *);
  15. #define TEObj_New _TEObj_New
  16. #define TEObj_Convert _TEObj_Convert
  17. #endif
  18. #define as_TE(h) ((TEHandle)h)
  19. #define as_Resource(teh) ((Handle)teh)
  20. /*
  21. ** Parse/generate TextStyle records
  22. */
  23. static PyObject *
  24. TextStyle_New(TextStylePtr itself)
  25. {
  26. return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
  27. &itself->tsColor);
  28. }
  29. static int
  30. TextStyle_Convert(PyObject *v, TextStylePtr p_itself)
  31. {
  32. long font, face, size;
  33. if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
  34. return 0;
  35. p_itself->tsFont = (short)font;
  36. p_itself->tsFace = (Style)face;
  37. p_itself->tsSize = (short)size;
  38. return 1;
  39. }
  40. static PyObject *TE_Error;
  41. /* ------------------------- Object type TE ------------------------- */
  42. PyTypeObject TE_Type;
  43. #define TEObj_Check(x) ((x)->ob_type == &TE_Type || PyObject_TypeCheck((x), &TE_Type))
  44. typedef struct TEObject {
  45. PyObject_HEAD
  46. TEHandle ob_itself;
  47. } TEObject;
  48. PyObject *TEObj_New(TEHandle itself)
  49. {
  50. TEObject *it;
  51. if (itself == NULL) {
  52. PyErr_SetString(TE_Error,"Cannot create null TE");
  53. return NULL;
  54. }
  55. it = PyObject_NEW(TEObject, &TE_Type);
  56. if (it == NULL) return NULL;
  57. it->ob_itself = itself;
  58. return (PyObject *)it;
  59. }
  60. int TEObj_Convert(PyObject *v, TEHandle *p_itself)
  61. {
  62. if (!TEObj_Check(v))
  63. {
  64. PyErr_SetString(PyExc_TypeError, "TE required");
  65. return 0;
  66. }
  67. *p_itself = ((TEObject *)v)->ob_itself;
  68. return 1;
  69. }
  70. static void TEObj_dealloc(TEObject *self)
  71. {
  72. TEDispose(self->ob_itself);
  73. self->ob_type->tp_free((PyObject *)self);
  74. }
  75. static PyObject *TEObj_TESetText(TEObject *_self, PyObject *_args)
  76. {
  77. PyObject *_res = NULL;
  78. char *text__in__;
  79. long text__len__;
  80. int text__in_len__;
  81. #ifndef TESetText
  82. PyMac_PRECHECK(TESetText);
  83. #endif
  84. if (!PyArg_ParseTuple(_args, "s#",
  85. &text__in__, &text__in_len__))
  86. return NULL;
  87. text__len__ = text__in_len__;
  88. TESetText(text__in__, text__len__,
  89. _self->ob_itself);
  90. Py_INCREF(Py_None);
  91. _res = Py_None;
  92. return _res;
  93. }
  94. static PyObject *TEObj_TEGetText(TEObject *_self, PyObject *_args)
  95. {
  96. PyObject *_res = NULL;
  97. CharsHandle _rv;
  98. #ifndef TEGetText
  99. PyMac_PRECHECK(TEGetText);
  100. #endif
  101. if (!PyArg_ParseTuple(_args, ""))
  102. return NULL;
  103. _rv = TEGetText(_self->ob_itself);
  104. _res = Py_BuildValue("O&",
  105. ResObj_New, _rv);
  106. return _res;
  107. }
  108. static PyObject *TEObj_TEIdle(TEObject *_self, PyObject *_args)
  109. {
  110. PyObject *_res = NULL;
  111. #ifndef TEIdle
  112. PyMac_PRECHECK(TEIdle);
  113. #endif
  114. if (!PyArg_ParseTuple(_args, ""))
  115. return NULL;
  116. TEIdle(_self->ob_itself);
  117. Py_INCREF(Py_None);
  118. _res = Py_None;
  119. return _res;
  120. }
  121. static PyObject *TEObj_TESetSelect(TEObject *_self, PyObject *_args)
  122. {
  123. PyObject *_res = NULL;
  124. long selStart;
  125. long selEnd;
  126. #ifndef TESetSelect
  127. PyMac_PRECHECK(TESetSelect);
  128. #endif
  129. if (!PyArg_ParseTuple(_args, "ll",
  130. &selStart,
  131. &selEnd))
  132. return NULL;
  133. TESetSelect(selStart,
  134. selEnd,
  135. _self->ob_itself);
  136. Py_INCREF(Py_None);
  137. _res = Py_None;
  138. return _res;
  139. }
  140. static PyObject *TEObj_TEActivate(TEObject *_self, PyObject *_args)
  141. {
  142. PyObject *_res = NULL;
  143. #ifndef TEActivate
  144. PyMac_PRECHECK(TEActivate);
  145. #endif
  146. if (!PyArg_ParseTuple(_args, ""))
  147. return NULL;
  148. TEActivate(_self->ob_itself);
  149. Py_INCREF(Py_None);
  150. _res = Py_None;
  151. return _res;
  152. }
  153. static PyObject *TEObj_TEDeactivate(TEObject *_self, PyObject *_args)
  154. {
  155. PyObject *_res = NULL;
  156. #ifndef TEDeactivate
  157. PyMac_PRECHECK(TEDeactivate);
  158. #endif
  159. if (!PyArg_ParseTuple(_args, ""))
  160. return NULL;
  161. TEDeactivate(_self->ob_itself);
  162. Py_INCREF(Py_None);
  163. _res = Py_None;
  164. return _res;
  165. }
  166. static PyObject *TEObj_TEKey(TEObject *_self, PyObject *_args)
  167. {
  168. PyObject *_res = NULL;
  169. CharParameter key;
  170. #ifndef TEKey
  171. PyMac_PRECHECK(TEKey);
  172. #endif
  173. if (!PyArg_ParseTuple(_args, "h",
  174. &key))
  175. return NULL;
  176. TEKey(key,
  177. _self->ob_itself);
  178. Py_INCREF(Py_None);
  179. _res = Py_None;
  180. return _res;
  181. }
  182. static PyObject *TEObj_TECut(TEObject *_self, PyObject *_args)
  183. {
  184. PyObject *_res = NULL;
  185. #ifndef TECut
  186. PyMac_PRECHECK(TECut);
  187. #endif
  188. if (!PyArg_ParseTuple(_args, ""))
  189. return NULL;
  190. TECut(_self->ob_itself);
  191. Py_INCREF(Py_None);
  192. _res = Py_None;
  193. return _res;
  194. }
  195. static PyObject *TEObj_TECopy(TEObject *_self, PyObject *_args)
  196. {
  197. PyObject *_res = NULL;
  198. #ifndef TECopy
  199. PyMac_PRECHECK(TECopy);
  200. #endif
  201. if (!PyArg_ParseTuple(_args, ""))
  202. return NULL;
  203. TECopy(_self->ob_itself);
  204. Py_INCREF(Py_None);
  205. _res = Py_None;
  206. return _res;
  207. }
  208. static PyObject *TEObj_TEPaste(TEObject *_self, PyObject *_args)
  209. {
  210. PyObject *_res = NULL;
  211. #ifndef TEPaste
  212. PyMac_PRECHECK(TEPaste);
  213. #endif
  214. if (!PyArg_ParseTuple(_args, ""))
  215. return NULL;
  216. TEPaste(_self->ob_itself);
  217. Py_INCREF(Py_None);
  218. _res = Py_None;
  219. return _res;
  220. }
  221. static PyObject *TEObj_TEDelete(TEObject *_self, PyObject *_args)
  222. {
  223. PyObject *_res = NULL;
  224. #ifndef TEDelete
  225. PyMac_PRECHECK(TEDelete);
  226. #endif
  227. if (!PyArg_ParseTuple(_args, ""))
  228. return NULL;
  229. TEDelete(_self->ob_itself);
  230. Py_INCREF(Py_None);
  231. _res = Py_None;
  232. return _res;
  233. }
  234. static PyObject *TEObj_TEInsert(TEObject *_self, PyObject *_args)
  235. {
  236. PyObject *_res = NULL;
  237. char *text__in__;
  238. long text__len__;
  239. int text__in_len__;
  240. #ifndef TEInsert
  241. PyMac_PRECHECK(TEInsert);
  242. #endif
  243. if (!PyArg_ParseTuple(_args, "s#",
  244. &text__in__, &text__in_len__))
  245. return NULL;
  246. text__len__ = text__in_len__;
  247. TEInsert(text__in__, text__len__,
  248. _self->ob_itself);
  249. Py_INCREF(Py_None);
  250. _res = Py_None;
  251. return _res;
  252. }
  253. static PyObject *TEObj_TESetAlignment(TEObject *_self, PyObject *_args)
  254. {
  255. PyObject *_res = NULL;
  256. short just;
  257. #ifndef TESetAlignment
  258. PyMac_PRECHECK(TESetAlignment);
  259. #endif
  260. if (!PyArg_ParseTuple(_args, "h",
  261. &just))
  262. return NULL;
  263. TESetAlignment(just,
  264. _self->ob_itself);
  265. Py_INCREF(Py_None);
  266. _res = Py_None;
  267. return _res;
  268. }
  269. static PyObject *TEObj_TEUpdate(TEObject *_self, PyObject *_args)
  270. {
  271. PyObject *_res = NULL;
  272. Rect rUpdate;
  273. #ifndef TEUpdate
  274. PyMac_PRECHECK(TEUpdate);
  275. #endif
  276. if (!PyArg_ParseTuple(_args, "O&",
  277. PyMac_GetRect, &rUpdate))
  278. return NULL;
  279. TEUpdate(&rUpdate,
  280. _self->ob_itself);
  281. Py_INCREF(Py_None);
  282. _res = Py_None;
  283. return _res;
  284. }
  285. static PyObject *TEObj_TEScroll(TEObject *_self, PyObject *_args)
  286. {
  287. PyObject *_res = NULL;
  288. short dh;
  289. short dv;
  290. #ifndef TEScroll
  291. PyMac_PRECHECK(TEScroll);
  292. #endif
  293. if (!PyArg_ParseTuple(_args, "hh",
  294. &dh,
  295. &dv))
  296. return NULL;
  297. TEScroll(dh,
  298. dv,
  299. _self->ob_itself);
  300. Py_INCREF(Py_None);
  301. _res = Py_None;
  302. return _res;
  303. }
  304. static PyObject *TEObj_TESelView(TEObject *_self, PyObject *_args)
  305. {
  306. PyObject *_res = NULL;
  307. #ifndef TESelView
  308. PyMac_PRECHECK(TESelView);
  309. #endif
  310. if (!PyArg_ParseTuple(_args, ""))
  311. return NULL;
  312. TESelView(_self->ob_itself);
  313. Py_INCREF(Py_None);
  314. _res = Py_None;
  315. return _res;
  316. }
  317. static PyObject *TEObj_TEPinScroll(TEObject *_self, PyObject *_args)
  318. {
  319. PyObject *_res = NULL;
  320. short dh;
  321. short dv;
  322. #ifndef TEPinScroll
  323. PyMac_PRECHECK(TEPinScroll);
  324. #endif
  325. if (!PyArg_ParseTuple(_args, "hh",
  326. &dh,
  327. &dv))
  328. return NULL;
  329. TEPinScroll(dh,
  330. dv,
  331. _self->ob_itself);
  332. Py_INCREF(Py_None);
  333. _res = Py_None;
  334. return _res;
  335. }
  336. static PyObject *TEObj_TEAutoView(TEObject *_self, PyObject *_args)
  337. {
  338. PyObject *_res = NULL;
  339. Boolean fAuto;
  340. #ifndef TEAutoView
  341. PyMac_PRECHECK(TEAutoView);
  342. #endif
  343. if (!PyArg_ParseTuple(_args, "b",
  344. &fAuto))
  345. return NULL;
  346. TEAutoView(fAuto,
  347. _self->ob_itself);
  348. Py_INCREF(Py_None);
  349. _res = Py_None;
  350. return _res;
  351. }
  352. static PyObject *TEObj_TECalText(TEObject *_self, PyObject *_args)
  353. {
  354. PyObject *_res = NULL;
  355. #ifndef TECalText
  356. PyMac_PRECHECK(TECalText);
  357. #endif
  358. if (!PyArg_ParseTuple(_args, ""))
  359. return NULL;
  360. TECalText(_self->ob_itself);
  361. Py_INCREF(Py_None);
  362. _res = Py_None;
  363. return _res;
  364. }
  365. static PyObject *TEObj_TEGetOffset(TEObject *_self, PyObject *_args)
  366. {
  367. PyObject *_res = NULL;
  368. short _rv;
  369. Point pt;
  370. #ifndef TEGetOffset
  371. PyMac_PRECHECK(TEGetOffset);
  372. #endif
  373. if (!PyArg_ParseTuple(_args, "O&",
  374. PyMac_GetPoint, &pt))
  375. return NULL;
  376. _rv = TEGetOffset(pt,
  377. _self->ob_itself);
  378. _res = Py_BuildValue("h",
  379. _rv);
  380. return _res;
  381. }
  382. static PyObject *TEObj_TEGetPoint(TEObject *_self, PyObject *_args)
  383. {
  384. PyObject *_res = NULL;
  385. Point _rv;
  386. short offset;
  387. #ifndef TEGetPoint
  388. PyMac_PRECHECK(TEGetPoint);
  389. #endif
  390. if (!PyArg_ParseTuple(_args, "h",
  391. &offset))
  392. return NULL;
  393. _rv = TEGetPoint(offset,
  394. _self->ob_itself);
  395. _res = Py_BuildValue("O&",
  396. PyMac_BuildPoint, _rv);
  397. return _res;
  398. }
  399. static PyObject *TEObj_TEClick(TEObject *_self, PyObject *_args)
  400. {
  401. PyObject *_res = NULL;
  402. Point pt;
  403. Boolean fExtend;
  404. #ifndef TEClick
  405. PyMac_PRECHECK(TEClick);
  406. #endif
  407. if (!PyArg_ParseTuple(_args, "O&b",
  408. PyMac_GetPoint, &pt,
  409. &fExtend))
  410. return NULL;
  411. TEClick(pt,
  412. fExtend,
  413. _self->ob_itself);
  414. Py_INCREF(Py_None);
  415. _res = Py_None;
  416. return _res;
  417. }
  418. static PyObject *TEObj_TESetStyleHandle(TEObject *_self, PyObject *_args)
  419. {
  420. PyObject *_res = NULL;
  421. TEStyleHandle theHandle;
  422. #ifndef TESetStyleHandle
  423. PyMac_PRECHECK(TESetStyleHandle);
  424. #endif
  425. if (!PyArg_ParseTuple(_args, "O&",
  426. ResObj_Convert, &theHandle))
  427. return NULL;
  428. TESetStyleHandle(theHandle,
  429. _self->ob_itself);
  430. Py_INCREF(Py_None);
  431. _res = Py_None;
  432. return _res;
  433. }
  434. static PyObject *TEObj_TEGetStyleHandle(TEObject *_self, PyObject *_args)
  435. {
  436. PyObject *_res = NULL;
  437. TEStyleHandle _rv;
  438. #ifndef TEGetStyleHandle
  439. PyMac_PRECHECK(TEGetStyleHandle);
  440. #endif
  441. if (!PyArg_ParseTuple(_args, ""))
  442. return NULL;
  443. _rv = TEGetStyleHandle(_self->ob_itself);
  444. _res = Py_BuildValue("O&",
  445. ResObj_New, _rv);
  446. return _res;
  447. }
  448. static PyObject *TEObj_TEGetStyle(TEObject *_self, PyObject *_args)
  449. {
  450. PyObject *_res = NULL;
  451. short offset;
  452. TextStyle theStyle;
  453. short lineHeight;
  454. short fontAscent;
  455. #ifndef TEGetStyle
  456. PyMac_PRECHECK(TEGetStyle);
  457. #endif
  458. if (!PyArg_ParseTuple(_args, "h",
  459. &offset))
  460. return NULL;
  461. TEGetStyle(offset,
  462. &theStyle,
  463. &lineHeight,
  464. &fontAscent,
  465. _self->ob_itself);
  466. _res = Py_BuildValue("O&hh",
  467. TextStyle_New, &theStyle,
  468. lineHeight,
  469. fontAscent);
  470. return _res;
  471. }
  472. static PyObject *TEObj_TEStylePaste(TEObject *_self, PyObject *_args)
  473. {
  474. PyObject *_res = NULL;
  475. #ifndef TEStylePaste
  476. PyMac_PRECHECK(TEStylePaste);
  477. #endif
  478. if (!PyArg_ParseTuple(_args, ""))
  479. return NULL;
  480. TEStylePaste(_self->ob_itself);
  481. Py_INCREF(Py_None);
  482. _res = Py_None;
  483. return _res;
  484. }
  485. static PyObject *TEObj_TESetStyle(TEObject *_self, PyObject *_args)
  486. {
  487. PyObject *_res = NULL;
  488. short mode;
  489. TextStyle newStyle;
  490. Boolean fRedraw;
  491. #ifndef TESetStyle
  492. PyMac_PRECHECK(TESetStyle);
  493. #endif
  494. if (!PyArg_ParseTuple(_args, "hO&b",
  495. &mode,
  496. TextStyle_Convert, &newStyle,
  497. &fRedraw))
  498. return NULL;
  499. TESetStyle(mode,
  500. &newStyle,
  501. fRedraw,
  502. _self->ob_itself);
  503. Py_INCREF(Py_None);
  504. _res = Py_None;
  505. return _res;
  506. }
  507. static PyObject *TEObj_TEReplaceStyle(TEObject *_self, PyObject *_args)
  508. {
  509. PyObject *_res = NULL;
  510. short mode;
  511. TextStyle oldStyle;
  512. TextStyle newStyle;
  513. Boolean fRedraw;
  514. #ifndef TEReplaceStyle
  515. PyMac_PRECHECK(TEReplaceStyle);
  516. #endif
  517. if (!PyArg_ParseTuple(_args, "hO&O&b",
  518. &mode,
  519. TextStyle_Convert, &oldStyle,
  520. TextStyle_Convert, &newStyle,
  521. &fRedraw))
  522. return NULL;
  523. TEReplaceStyle(mode,
  524. &oldStyle,
  525. &newStyle,
  526. fRedraw,
  527. _self->ob_itself);
  528. Py_INCREF(Py_None);
  529. _res = Py_None;
  530. return _res;
  531. }
  532. static PyObject *TEObj_TEGetStyleScrapHandle(TEObject *_self, PyObject *_args)
  533. {
  534. PyObject *_res = NULL;
  535. StScrpHandle _rv;
  536. #ifndef TEGetStyleScrapHandle
  537. PyMac_PRECHECK(TEGetStyleScrapHandle);
  538. #endif
  539. if (!PyArg_ParseTuple(_args, ""))
  540. return NULL;
  541. _rv = TEGetStyleScrapHandle(_self->ob_itself);
  542. _res = Py_BuildValue("O&",
  543. ResObj_New, _rv);
  544. return _res;
  545. }
  546. static PyObject *TEObj_TEStyleInsert(TEObject *_self, PyObject *_args)
  547. {
  548. PyObject *_res = NULL;
  549. char *text__in__;
  550. long text__len__;
  551. int text__in_len__;
  552. StScrpHandle hST;
  553. #ifndef TEStyleInsert
  554. PyMac_PRECHECK(TEStyleInsert);
  555. #endif
  556. if (!PyArg_ParseTuple(_args, "s#O&",
  557. &text__in__, &text__in_len__,
  558. ResObj_Convert, &hST))
  559. return NULL;
  560. text__len__ = text__in_len__;
  561. TEStyleInsert(text__in__, text__len__,
  562. hST,
  563. _self->ob_itself);
  564. Py_INCREF(Py_None);
  565. _res = Py_None;
  566. return _res;
  567. }
  568. static PyObject *TEObj_TEGetHeight(TEObject *_self, PyObject *_args)
  569. {
  570. PyObject *_res = NULL;
  571. long _rv;
  572. long endLine;
  573. long startLine;
  574. #ifndef TEGetHeight
  575. PyMac_PRECHECK(TEGetHeight);
  576. #endif
  577. if (!PyArg_ParseTuple(_args, "ll",
  578. &endLine,
  579. &startLine))
  580. return NULL;
  581. _rv = TEGetHeight(endLine,
  582. startLine,
  583. _self->ob_itself);
  584. _res = Py_BuildValue("l",
  585. _rv);
  586. return _res;
  587. }
  588. static PyObject *TEObj_TEContinuousStyle(TEObject *_self, PyObject *_args)
  589. {
  590. PyObject *_res = NULL;
  591. Boolean _rv;
  592. short mode;
  593. TextStyle aStyle;
  594. #ifndef TEContinuousStyle
  595. PyMac_PRECHECK(TEContinuousStyle);
  596. #endif
  597. if (!PyArg_ParseTuple(_args, "hO&",
  598. &mode,
  599. TextStyle_Convert, &aStyle))
  600. return NULL;
  601. _rv = TEContinuousStyle(&mode,
  602. &aStyle,
  603. _self->ob_itself);
  604. _res = Py_BuildValue("bhO&",
  605. _rv,
  606. mode,
  607. TextStyle_New, &aStyle);
  608. return _res;
  609. }
  610. static PyObject *TEObj_TEUseStyleScrap(TEObject *_self, PyObject *_args)
  611. {
  612. PyObject *_res = NULL;
  613. long rangeStart;
  614. long rangeEnd;
  615. StScrpHandle newStyles;
  616. Boolean fRedraw;
  617. #ifndef TEUseStyleScrap
  618. PyMac_PRECHECK(TEUseStyleScrap);
  619. #endif
  620. if (!PyArg_ParseTuple(_args, "llO&b",
  621. &rangeStart,
  622. &rangeEnd,
  623. ResObj_Convert, &newStyles,
  624. &fRedraw))
  625. return NULL;
  626. TEUseStyleScrap(rangeStart,
  627. rangeEnd,
  628. newStyles,
  629. fRedraw,
  630. _self->ob_itself);
  631. Py_INCREF(Py_None);
  632. _res = Py_None;
  633. return _res;
  634. }
  635. static PyObject *TEObj_TENumStyles(TEObject *_self, PyObject *_args)
  636. {
  637. PyObject *_res = NULL;
  638. long _rv;
  639. long rangeStart;
  640. long rangeEnd;
  641. #ifndef TENumStyles
  642. PyMac_PRECHECK(TENumStyles);
  643. #endif
  644. if (!PyArg_ParseTuple(_args, "ll",
  645. &rangeStart,
  646. &rangeEnd))
  647. return NULL;
  648. _rv = TENumStyles(rangeStart,
  649. rangeEnd,
  650. _self->ob_itself);
  651. _res = Py_BuildValue("l",
  652. _rv);
  653. return _res;
  654. }
  655. static PyObject *TEObj_TEFeatureFlag(TEObject *_self, PyObject *_args)
  656. {
  657. PyObject *_res = NULL;
  658. short _rv;
  659. short feature;
  660. short action;
  661. #ifndef TEFeatureFlag
  662. PyMac_PRECHECK(TEFeatureFlag);
  663. #endif
  664. if (!PyArg_ParseTuple(_args, "hh",
  665. &feature,
  666. &action))
  667. return NULL;
  668. _rv = TEFeatureFlag(feature,
  669. action,
  670. _self->ob_itself);
  671. _res = Py_BuildValue("h",
  672. _rv);
  673. return _res;
  674. }
  675. static PyObject *TEObj_TEGetHiliteRgn(TEObject *_self, PyObject *_args)
  676. {
  677. PyObject *_res = NULL;
  678. OSErr _err;
  679. RgnHandle region;
  680. #ifndef TEGetHiliteRgn
  681. PyMac_PRECHECK(TEGetHiliteRgn);
  682. #endif
  683. if (!PyArg_ParseTuple(_args, "O&",
  684. ResObj_Convert, &region))
  685. return NULL;
  686. _err = TEGetHiliteRgn(region,
  687. _self->ob_itself);
  688. if (_err != noErr) return PyMac_Error(_err);
  689. Py_INCREF(Py_None);
  690. _res = Py_None;
  691. return _res;
  692. }
  693. static PyObject *TEObj_as_Resource(TEObject *_self, PyObject *_args)
  694. {
  695. PyObject *_res = NULL;
  696. Handle _rv;
  697. #ifndef as_Resource
  698. PyMac_PRECHECK(as_Resource);
  699. #endif
  700. if (!PyArg_ParseTuple(_args, ""))
  701. return NULL;
  702. _rv = as_Resource(_self->ob_itself);
  703. _res = Py_BuildValue("O&",
  704. ResObj_New, _rv);
  705. return _res;
  706. }
  707. static PyMethodDef TEObj_methods[] = {
  708. {"TESetText", (PyCFunction)TEObj_TESetText, 1,
  709. PyDoc_STR("(Buffer text) -> None")},
  710. {"TEGetText", (PyCFunction)TEObj_TEGetText, 1,
  711. PyDoc_STR("() -> (CharsHandle _rv)")},
  712. {"TEIdle", (PyCFunction)TEObj_TEIdle, 1,
  713. PyDoc_STR("() -> None")},
  714. {"TESetSelect", (PyCFunction)TEObj_TESetSelect, 1,
  715. PyDoc_STR("(long selStart, long selEnd) -> None")},
  716. {"TEActivate", (PyCFunction)TEObj_TEActivate, 1,
  717. PyDoc_STR("() -> None")},
  718. {"TEDeactivate", (PyCFunction)TEObj_TEDeactivate, 1,
  719. PyDoc_STR("() -> None")},
  720. {"TEKey", (PyCFunction)TEObj_TEKey, 1,
  721. PyDoc_STR("(CharParameter key) -> None")},
  722. {"TECut", (PyCFunction)TEObj_TECut, 1,
  723. PyDoc_STR("() -> None")},
  724. {"TECopy", (PyCFunction)TEObj_TECopy, 1,
  725. PyDoc_STR("() -> None")},
  726. {"TEPaste", (PyCFunction)TEObj_TEPaste, 1,
  727. PyDoc_STR("() -> None")},
  728. {"TEDelete", (PyCFunction)TEObj_TEDelete, 1,
  729. PyDoc_STR("() -> None")},
  730. {"TEInsert", (PyCFunction)TEObj_TEInsert, 1,
  731. PyDoc_STR("(Buffer text) -> None")},
  732. {"TESetAlignment", (PyCFunction)TEObj_TESetAlignment, 1,
  733. PyDoc_STR("(short just) -> None")},
  734. {"TEUpdate", (PyCFunction)TEObj_TEUpdate, 1,
  735. PyDoc_STR("(Rect rUpdate) -> None")},
  736. {"TEScroll", (PyCFunction)TEObj_TEScroll, 1,
  737. PyDoc_STR("(short dh, short dv) -> None")},
  738. {"TESelView", (PyCFunction)TEObj_TESelView, 1,
  739. PyDoc_STR("() -> None")},
  740. {"TEPinScroll", (PyCFunction)TEObj_TEPinScroll, 1,
  741. PyDoc_STR("(short dh, short dv) -> None")},
  742. {"TEAutoView", (PyCFunction)TEObj_TEAutoView, 1,
  743. PyDoc_STR("(Boolean fAuto) -> None")},
  744. {"TECalText", (PyCFunction)TEObj_TECalText, 1,
  745. PyDoc_STR("() -> None")},
  746. {"TEGetOffset", (PyCFunction)TEObj_TEGetOffset, 1,
  747. PyDoc_STR("(Point pt) -> (short _rv)")},
  748. {"TEGetPoint", (PyCFunction)TEObj_TEGetPoint, 1,
  749. PyDoc_STR("(short offset) -> (Point _rv)")},
  750. {"TEClick", (PyCFunction)TEObj_TEClick, 1,
  751. PyDoc_STR("(Point pt, Boolean fExtend) -> None")},
  752. {"TESetStyleHandle", (PyCFunction)TEObj_TESetStyleHandle, 1,
  753. PyDoc_STR("(TEStyleHandle theHandle) -> None")},
  754. {"TEGetStyleHandle", (PyCFunction)TEObj_TEGetStyleHandle, 1,
  755. PyDoc_STR("() -> (TEStyleHandle _rv)")},
  756. {"TEGetStyle", (PyCFunction)TEObj_TEGetStyle, 1,
  757. PyDoc_STR("(short offset) -> (TextStyle theStyle, short lineHeight, short fontAscent)")},
  758. {"TEStylePaste", (PyCFunction)TEObj_TEStylePaste, 1,
  759. PyDoc_STR("() -> None")},
  760. {"TESetStyle", (PyCFunction)TEObj_TESetStyle, 1,
  761. PyDoc_STR("(short mode, TextStyle newStyle, Boolean fRedraw) -> None")},
  762. {"TEReplaceStyle", (PyCFunction)TEObj_TEReplaceStyle, 1,
  763. PyDoc_STR("(short mode, TextStyle oldStyle, TextStyle newStyle, Boolean fRedraw) -> None")},
  764. {"TEGetStyleScrapHandle", (PyCFunction)TEObj_TEGetStyleScrapHandle, 1,
  765. PyDoc_STR("() -> (StScrpHandle _rv)")},
  766. {"TEStyleInsert", (PyCFunction)TEObj_TEStyleInsert, 1,
  767. PyDoc_STR("(Buffer text, StScrpHandle hST) -> None")},
  768. {"TEGetHeight", (PyCFunction)TEObj_TEGetHeight, 1,
  769. PyDoc_STR("(long endLine, long startLine) -> (long _rv)")},
  770. {"TEContinuousStyle", (PyCFunction)TEObj_TEContinuousStyle, 1,
  771. PyDoc_STR("(short mode, TextStyle aStyle) -> (Boolean _rv, short mode, TextStyle aStyle)")},
  772. {"TEUseStyleScrap", (PyCFunction)TEObj_TEUseStyleScrap, 1,
  773. PyDoc_STR("(long rangeStart, long rangeEnd, StScrpHandle newStyles, Boolean fRedraw) -> None")},
  774. {"TENumStyles", (PyCFunction)TEObj_TENumStyles, 1,
  775. PyDoc_STR("(long rangeStart, long rangeEnd) -> (long _rv)")},
  776. {"TEFeatureFlag", (PyCFunction)TEObj_TEFeatureFlag, 1,
  777. PyDoc_STR("(short feature, short action) -> (short _rv)")},
  778. {"TEGetHiliteRgn", (PyCFunction)TEObj_TEGetHiliteRgn, 1,
  779. PyDoc_STR("(RgnHandle region) -> None")},
  780. {"as_Resource", (PyCFunction)TEObj_as_Resource, 1,
  781. PyDoc_STR("() -> (Handle _rv)")},
  782. {NULL, NULL, 0}
  783. };
  784. static PyObject *TEObj_get_destRect(TEObject *self, void *closure)
  785. {
  786. return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->destRect);
  787. }
  788. #define TEObj_set_destRect NULL
  789. static PyObject *TEObj_get_viewRect(TEObject *self, void *closure)
  790. {
  791. return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->viewRect);
  792. }
  793. #define TEObj_set_viewRect NULL
  794. static PyObject *TEObj_get_selRect(TEObject *self, void *closure)
  795. {
  796. return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->selRect);
  797. }
  798. #define TEObj_set_selRect NULL
  799. static PyObject *TEObj_get_lineHeight(TEObject *self, void *closure)
  800. {
  801. return Py_BuildValue("h", (*self->ob_itself)->lineHeight);
  802. }
  803. #define TEObj_set_lineHeight NULL
  804. static PyObject *TEObj_get_fontAscent(TEObject *self, void *closure)
  805. {
  806. return Py_BuildValue("h", (*self->ob_itself)->fontAscent);
  807. }
  808. #define TEObj_set_fontAscent NULL
  809. static PyObject *TEObj_get_selPoint(TEObject *self, void *closure)
  810. {
  811. return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->selPoint);
  812. }
  813. #define TEObj_set_selPoint NULL
  814. static PyObject *TEObj_get_selStart(TEObject *self, void *closure)
  815. {
  816. return Py_BuildValue("h", (*self->ob_itself)->selStart);
  817. }
  818. #define TEObj_set_selStart NULL
  819. static PyObject *TEObj_get_selEnd(TEObject *self, void *closure)
  820. {
  821. return Py_BuildValue("h", (*self->ob_itself)->selEnd);
  822. }
  823. #define TEObj_set_selEnd NULL
  824. static PyObject *TEObj_get_active(TEObject *self, void *closure)
  825. {
  826. return Py_BuildValue("h", (*self->ob_itself)->active);
  827. }
  828. #define TEObj_set_active NULL
  829. static PyObject *TEObj_get_just(TEObject *self, void *closure)
  830. {
  831. return Py_BuildValue("h", (*self->ob_itself)->just);
  832. }
  833. #define TEObj_set_just NULL
  834. static PyObject *TEObj_get_teLength(TEObject *self, void *closure)
  835. {
  836. return Py_BuildValue("h", (*self->ob_itself)->teLength);
  837. }
  838. #define TEObj_set_teLength NULL
  839. static PyObject *TEObj_get_txFont(TEObject *self, void *closure)
  840. {
  841. return Py_BuildValue("h", (*self->ob_itself)->txFont);
  842. }
  843. #define TEObj_set_txFont NULL
  844. static PyObject *TEObj_get_txFace(TEObject *self, void *closure)
  845. {
  846. return Py_BuildValue("h", (*self->ob_itself)->txFace);
  847. }
  848. #define TEObj_set_txFace NULL
  849. static PyObject *TEObj_get_txMode(TEObject *self, void *closure)
  850. {
  851. return Py_BuildValue("h", (*self->ob_itself)->txMode);
  852. }
  853. #define TEObj_set_txMode NULL
  854. static PyObject *TEObj_get_txSize(TEObject *self, void *closure)
  855. {
  856. return Py_BuildValue("h", (*self->ob_itself)->txSize);
  857. }
  858. #define TEObj_set_txSize NULL
  859. static PyObject *TEObj_get_nLines(TEObject *self, void *closure)
  860. {
  861. return Py_BuildValue("h", (*self->ob_itself)->nLines);
  862. }
  863. #define TEObj_set_nLines NULL
  864. static PyGetSetDef TEObj_getsetlist[] = {
  865. {"destRect", (getter)TEObj_get_destRect, (setter)TEObj_set_destRect, "Destination rectangle"},
  866. {"viewRect", (getter)TEObj_get_viewRect, (setter)TEObj_set_viewRect, "Viewing rectangle"},
  867. {"selRect", (getter)TEObj_get_selRect, (setter)TEObj_set_selRect, "Selection rectangle"},
  868. {"lineHeight", (getter)TEObj_get_lineHeight, (setter)TEObj_set_lineHeight, "Height of a line"},
  869. {"fontAscent", (getter)TEObj_get_fontAscent, (setter)TEObj_set_fontAscent, "Ascent of a line"},
  870. {"selPoint", (getter)TEObj_get_selPoint, (setter)TEObj_set_selPoint, "Selection Point"},
  871. {"selStart", (getter)TEObj_get_selStart, (setter)TEObj_set_selStart, "Start of selection"},
  872. {"selEnd", (getter)TEObj_get_selEnd, (setter)TEObj_set_selEnd, "End of selection"},
  873. {"active", (getter)TEObj_get_active, (setter)TEObj_set_active, "TBD"},
  874. {"just", (getter)TEObj_get_just, (setter)TEObj_set_just, "Justification"},
  875. {"teLength", (getter)TEObj_get_teLength, (setter)TEObj_set_teLength, "TBD"},
  876. {"txFont", (getter)TEObj_get_txFont, (setter)TEObj_set_txFont, "Current font"},
  877. {"txFace", (getter)TEObj_get_txFace, (setter)TEObj_set_txFace, "Current font variant"},
  878. {"txMode", (getter)TEObj_get_txMode, (setter)TEObj_set_txMode, "Current text-drawing mode"},
  879. {"txSize", (getter)TEObj_get_txSize, (setter)TEObj_set_txSize, "Current font size"},
  880. {"nLines", (getter)TEObj_get_nLines, (setter)TEObj_set_nLines, "TBD"},
  881. {NULL, NULL, NULL, NULL},
  882. };
  883. #define TEObj_compare NULL
  884. #define TEObj_repr NULL
  885. #define TEObj_hash NULL
  886. #define TEObj_tp_init 0
  887. #define TEObj_tp_alloc PyType_GenericAlloc
  888. static PyObject *TEObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
  889. {
  890. PyObject *_self;
  891. TEHandle itself;
  892. char *kw[] = {"itself", 0};
  893. if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, TEObj_Convert, &itself)) return NULL;
  894. if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
  895. ((TEObject *)_self)->ob_itself = itself;
  896. return _self;
  897. }
  898. #define TEObj_tp_free PyObject_Del
  899. PyTypeObject TE_Type = {
  900. PyObject_HEAD_INIT(NULL)
  901. 0, /*ob_size*/
  902. "_TE.TE", /*tp_name*/
  903. sizeof(TEObject), /*tp_basicsize*/
  904. 0, /*tp_itemsize*/
  905. /* methods */
  906. (destructor) TEObj_dealloc, /*tp_dealloc*/
  907. 0, /*tp_print*/
  908. (getattrfunc)0, /*tp_getattr*/
  909. (setattrfunc)0, /*tp_setattr*/
  910. (cmpfunc) TEObj_compare, /*tp_compare*/
  911. (reprfunc) TEObj_repr, /*tp_repr*/
  912. (PyNumberMethods *)0, /* tp_as_number */
  913. (PySequenceMethods *)0, /* tp_as_sequence */
  914. (PyMappingMethods *)0, /* tp_as_mapping */
  915. (hashfunc) TEObj_hash, /*tp_hash*/
  916. 0, /*tp_call*/
  917. 0, /*tp_str*/
  918. PyObject_GenericGetAttr, /*tp_getattro*/
  919. PyObject_GenericSetAttr, /*tp_setattro */
  920. 0, /*tp_as_buffer*/
  921. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
  922. 0, /*tp_doc*/
  923. 0, /*tp_traverse*/
  924. 0, /*tp_clear*/
  925. 0, /*tp_richcompare*/
  926. 0, /*tp_weaklistoffset*/
  927. 0, /*tp_iter*/
  928. 0, /*tp_iternext*/
  929. TEObj_methods, /* tp_methods */
  930. 0, /*tp_members*/
  931. TEObj_getsetlist, /*tp_getset*/
  932. 0, /*tp_base*/
  933. 0, /*tp_dict*/
  934. 0, /*tp_descr_get*/
  935. 0, /*tp_descr_set*/
  936. 0, /*tp_dictoffset*/
  937. TEObj_tp_init, /* tp_init */
  938. TEObj_tp_alloc, /* tp_alloc */
  939. TEObj_tp_new, /* tp_new */
  940. TEObj_tp_free, /* tp_free */
  941. };
  942. /* ----------------------- End object type TE ----------------------- */
  943. static PyObject *TE_TEScrapHandle(PyObject *_self, PyObject *_args)
  944. {
  945. PyObject *_res = NULL;
  946. Handle _rv;
  947. #ifndef TEScrapHandle
  948. PyMac_PRECHECK(TEScrapHandle);
  949. #endif
  950. if (!PyArg_ParseTuple(_args, ""))
  951. return NULL;
  952. _rv = TEScrapHandle();
  953. _res = Py_BuildValue("O&",
  954. ResObj_New, _rv);
  955. return _res;
  956. }
  957. static PyObject *TE_TEGetScrapLength(PyObject *_self, PyObject *_args)
  958. {
  959. PyObject *_res = NULL;
  960. long _rv;
  961. #ifndef TEGetScrapLength
  962. PyMac_PRECHECK(TEGetScrapLength);
  963. #endif
  964. if (!PyArg_ParseTuple(_args, ""))
  965. return NULL;
  966. _rv = TEGetScrapLength();
  967. _res = Py_BuildValue("l",
  968. _rv);
  969. return _res;
  970. }
  971. static PyObject *TE_TENew(PyObject *_self, PyObject *_args)
  972. {
  973. PyObject *_res = NULL;
  974. TEHandle _rv;
  975. Rect destRect;
  976. Rect viewRect;
  977. #ifndef TENew
  978. PyMac_PRECHECK(TENew);
  979. #endif
  980. if (!PyArg_ParseTuple(_args, "O&O&",
  981. PyMac_GetRect, &destRect,
  982. PyMac_GetRect, &viewRect))
  983. return NULL;
  984. _rv = TENew(&destRect,
  985. &viewRect);
  986. _res = Py_BuildValue("O&",
  987. TEObj_New, _rv);
  988. return _res;
  989. }
  990. static PyObject *TE_TETextBox(PyObject *_self, PyObject *_args)
  991. {
  992. PyObject *_res = NULL;
  993. char *text__in__;
  994. long text__len__;
  995. int text__in_len__;
  996. Rect box;
  997. short just;
  998. #ifndef TETextBox
  999. PyMac_PRECHECK(TETextBox);
  1000. #endif
  1001. if (!PyArg_ParseTuple(_args, "s#O&h",
  1002. &text__in__, &text__in_len__,
  1003. PyMac_GetRect, &box,
  1004. &just))
  1005. return NULL;
  1006. text__len__ = text__in_len__;
  1007. TETextBox(text__in__, text__len__,
  1008. &box,
  1009. just);
  1010. Py_INCREF(Py_None);
  1011. _res = Py_None;
  1012. return _res;
  1013. }
  1014. static PyObject *TE_TEStyleNew(PyObject *_self, PyObject *_args)
  1015. {
  1016. PyObject *_res = NULL;
  1017. TEHandle _rv;
  1018. Rect destRect;
  1019. Rect viewRect;
  1020. #ifndef TEStyleNew
  1021. PyMac_PRECHECK(TEStyleNew);
  1022. #endif
  1023. if (!PyArg_ParseTuple(_args, "O&O&",
  1024. PyMac_GetRect, &destRect,
  1025. PyMac_GetRect, &viewRect))
  1026. return NULL;
  1027. _rv = TEStyleNew(&destRect,
  1028. &viewRect);
  1029. _res = Py_BuildValue("O&",
  1030. TEObj_New, _rv);
  1031. return _res;
  1032. }
  1033. static PyObject *TE_TESetScrapLength(PyObject *_self, PyObject *_args)
  1034. {
  1035. PyObject *_res = NULL;
  1036. long length;
  1037. #ifndef TESetScrapLength
  1038. PyMac_PRECHECK(TESetScrapLength);
  1039. #endif
  1040. if (!PyArg_ParseTuple(_args, "l",
  1041. &length))
  1042. return NULL;
  1043. TESetScrapLength(length);
  1044. Py_INCREF(Py_None);
  1045. _res = Py_None;
  1046. return _res;
  1047. }
  1048. static PyObject *TE_TEFromScrap(PyObject *_self, PyObject *_args)
  1049. {
  1050. PyObject *_res = NULL;
  1051. OSErr _err;
  1052. #ifndef TEFromScrap
  1053. PyMac_PRECHECK(TEFromScrap);
  1054. #endif
  1055. if (!PyArg_ParseTuple(_args, ""))
  1056. return NULL;
  1057. _err = TEFromScrap();
  1058. if (_err != noErr) return PyMac_Error(_err);
  1059. Py_INCREF(Py_None);
  1060. _res = Py_None;
  1061. return _res;
  1062. }
  1063. static PyObject *TE_TEToScrap(PyObject *_self, PyObject *_args)
  1064. {
  1065. PyObject *_res = NULL;
  1066. OSErr _err;
  1067. #ifndef TEToScrap
  1068. PyMac_PRECHECK(TEToScrap);
  1069. #endif
  1070. if (!PyArg_ParseTuple(_args, ""))
  1071. return NULL;
  1072. _err = TEToScrap();
  1073. if (_err != noErr) return PyMac_Error(_err);
  1074. Py_INCREF(Py_None);
  1075. _res = Py_None;
  1076. return _res;
  1077. }
  1078. static PyObject *TE_TEGetScrapHandle(PyObject *_self, PyObject *_args)
  1079. {
  1080. PyObject *_res = NULL;
  1081. Handle _rv;
  1082. #ifndef TEGetScrapHandle
  1083. PyMac_PRECHECK(TEGetScrapHandle);
  1084. #endif
  1085. if (!PyArg_ParseTuple(_args, ""))
  1086. return NULL;
  1087. _rv = TEGetScrapHandle();
  1088. _res = Py_BuildValue("O&",
  1089. ResObj_New, _rv);
  1090. return _res;
  1091. }
  1092. static PyObject *TE_TESetScrapHandle(PyObject *_self, PyObject *_args)
  1093. {
  1094. PyObject *_res = NULL;
  1095. Handle value;
  1096. #ifndef TESetScrapHandle
  1097. PyMac_PRECHECK(TESetScrapHandle);
  1098. #endif
  1099. if (!PyArg_ParseTuple(_args, "O&",
  1100. ResObj_Convert, &value))
  1101. return NULL;
  1102. TESetScrapHandle(value);
  1103. Py_INCREF(Py_None);
  1104. _res = Py_None;
  1105. return _res;
  1106. }
  1107. static PyObject *TE_LMGetWordRedraw(PyObject *_self, PyObject *_args)
  1108. {
  1109. PyObject *_res = NULL;
  1110. UInt8 _rv;
  1111. #ifndef LMGetWordRedraw
  1112. PyMac_PRECHECK(LMGetWordRedraw);
  1113. #endif
  1114. if (!PyArg_ParseTuple(_args, ""))
  1115. return NULL;
  1116. _rv = LMGetWordRedraw();
  1117. _res = Py_BuildValue("b",
  1118. _rv);
  1119. return _res;
  1120. }
  1121. static PyObject *TE_LMSetWordRedraw(PyObject *_self, PyObject *_args)
  1122. {
  1123. PyObject *_res = NULL;
  1124. UInt8 value;
  1125. #ifndef LMSetWordRedraw
  1126. PyMac_PRECHECK(LMSetWordRedraw);
  1127. #endif
  1128. if (!PyArg_ParseTuple(_args, "b",
  1129. &value))
  1130. return NULL;
  1131. LMSetWordRedraw(value);
  1132. Py_INCREF(Py_None);
  1133. _res = Py_None;
  1134. return _res;
  1135. }
  1136. static PyObject *TE_as_TE(PyObject *_self, PyObject *_args)
  1137. {
  1138. PyObject *_res = NULL;
  1139. TEHandle _rv;
  1140. Handle h;
  1141. #ifndef as_TE
  1142. PyMac_PRECHECK(as_TE);
  1143. #endif
  1144. if (!PyArg_ParseTuple(_args, "O&",
  1145. ResObj_Convert, &h))
  1146. return NULL;
  1147. _rv = as_TE(h);
  1148. _res = Py_BuildValue("O&",
  1149. TEObj_New, _rv);
  1150. return _res;
  1151. }
  1152. #endif /* __LP64__ */
  1153. static PyMethodDef TE_methods[] = {
  1154. #ifndef __LP64__
  1155. {"TEScrapHandle", (PyCFunction)TE_TEScrapHandle, 1,
  1156. PyDoc_STR("() -> (Handle _rv)")},
  1157. {"TEGetScrapLength", (PyCFunction)TE_TEGetScrapLength, 1,
  1158. PyDoc_STR("() -> (long _rv)")},
  1159. {"TENew", (PyCFunction)TE_TENew, 1,
  1160. PyDoc_STR("(Rect destRect, Rect viewRect) -> (TEHandle _rv)")},
  1161. {"TETextBox", (PyCFunction)TE_TETextBox, 1,
  1162. PyDoc_STR("(Buffer text, Rect box, short just) -> None")},
  1163. {"TEStyleNew", (PyCFunction)TE_TEStyleNew, 1,
  1164. PyDoc_STR("(Rect destRect, Rect viewRect) -> (TEHandle _rv)")},
  1165. {"TESetScrapLength", (PyCFunction)TE_TESetScrapLength, 1,
  1166. PyDoc_STR("(long length) -> None")},
  1167. {"TEFromScrap", (PyCFunction)TE_TEFromScrap, 1,
  1168. PyDoc_STR("() -> None")},
  1169. {"TEToScrap", (PyCFunction)TE_TEToScrap, 1,
  1170. PyDoc_STR("() -> None")},
  1171. {"TEGetScrapHandle", (PyCFunction)TE_TEGetScrapHandle, 1,
  1172. PyDoc_STR("() -> (Handle _rv)")},
  1173. {"TESetScrapHandle", (PyCFunction)TE_TESetScrapHandle, 1,
  1174. PyDoc_STR("(Handle value) -> None")},
  1175. {"LMGetWordRedraw", (PyCFunction)TE_LMGetWordRedraw, 1,
  1176. PyDoc_STR("() -> (UInt8 _rv)")},
  1177. {"LMSetWordRedraw", (PyCFunction)TE_LMSetWordRedraw, 1,
  1178. PyDoc_STR("(UInt8 value) -> None")},
  1179. {"as_TE", (PyCFunction)TE_as_TE, 1,
  1180. PyDoc_STR("(Handle h) -> (TEHandle _rv)")},
  1181. #endif /* __LP64__ */
  1182. {NULL, NULL, 0}
  1183. };
  1184. void init_TE(void)
  1185. {
  1186. PyObject *m;
  1187. #ifndef __LP64__
  1188. PyObject *d;
  1189. PyMac_INIT_TOOLBOX_OBJECT_NEW(TEHandle, TEObj_New);
  1190. PyMac_INIT_TOOLBOX_OBJECT_CONVERT(TEHandle, TEObj_Convert);
  1191. #endif /* __LP64__ */
  1192. m = Py_InitModule("_TE", TE_methods);
  1193. #ifndef __LP64__
  1194. d = PyModule_GetDict(m);
  1195. TE_Error = PyMac_GetOSErrException();
  1196. if (TE_Error == NULL ||
  1197. PyDict_SetItemString(d, "Error", TE_Error) != 0)
  1198. return;
  1199. TE_Type.ob_type = &PyType_Type;
  1200. if (PyType_Ready(&TE_Type) < 0) return;
  1201. Py_INCREF(&TE_Type);
  1202. PyModule_AddObject(m, "TE", (PyObject *)&TE_Type);
  1203. /* Backward-compatible name */
  1204. Py_INCREF(&TE_Type);
  1205. PyModule_AddObject(m, "TEType", (PyObject *)&TE_Type);
  1206. #endif /* __LP64__ */
  1207. }
  1208. /* ========================= End module _TE ========================= */