77msgstr ""
88"Project-Id-Version :Python 3.12\n "
99"Report-Msgid-Bugs-To :\n "
10- "POT-Creation-Date :2024-04-16 00:03 +0000\n "
10+ "POT-Creation-Date :2024-09-09 16:09 +0000\n "
1111"PO-Revision-Date :2018-05-23 14:36+0000\n "
1212"Last-Translator :Adrian Liaw <adrianliaw2000@gmail.com>\n "
1313"Language-Team :Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -141,20 +141,34 @@ msgid ""
141141"after the name of the corresponding C variable. ::"
142142msgstr ""
143143
144+ #: ../../howto/curses.rst:90
145+ msgid ""
146+ "import curses\n"
147+ "stdscr = curses.initscr()"
148+ msgstr ""
149+
144150#: ../../howto/curses.rst:93
145151msgid ""
146152"Usually curses applications turn off automatic echoing of keys to the "
147153"screen, in order to be able to read keys and only display them under certain "
148154"circumstances. This requires calling the :func:`~curses.noecho` function. ::"
149155msgstr ""
150156
157+ #: ../../howto/curses.rst:98
158+ msgid "curses.noecho()"
159+ msgstr ""
160+
151161#: ../../howto/curses.rst:100
152162msgid ""
153163"Applications will also commonly need to react to keys instantly, without "
154164"requiring the Enter key to be pressed; this is called cbreak mode, as "
155165"opposed to the usual buffered input mode. ::"
156166msgstr ""
157167
168+ #: ../../howto/curses.rst:104
169+ msgid "curses.cbreak()"
170+ msgstr ""
171+
158172#: ../../howto/curses.rst:106
159173msgid ""
160174"Terminals usually return special keys, such as the cursor keys or navigation "
@@ -165,19 +179,34 @@ msgid ""
165179"keypad mode. ::"
166180msgstr ""
167181
182+ #: ../../howto/curses.rst:113
183+ msgid "stdscr.keypad(True)"
184+ msgstr ""
185+
168186#: ../../howto/curses.rst:115
169187msgid ""
170188"Terminating a curses application is much easier than starting one. You'll "
171189"need to call::"
172190msgstr ""
173191
192+ #: ../../howto/curses.rst:118
193+ msgid ""
194+ "curses.nocbreak()\n"
195+ "stdscr.keypad(False)\n"
196+ "curses.echo()"
197+ msgstr ""
198+
174199#: ../../howto/curses.rst:122
175200msgid ""
176201"to reverse the curses-friendly terminal settings. Then call the :func:"
177202"`~curses.endwin` function to restore the terminal to its original operating "
178203"mode. ::"
179204msgstr ""
180205
206+ #: ../../howto/curses.rst:126
207+ msgid "curses.endwin()"
208+ msgstr ""
209+
181210#: ../../howto/curses.rst:128
182211msgid ""
183212"A common problem when debugging a curses application is to get your terminal "
@@ -193,6 +222,25 @@ msgid ""
193222"by importing the :func:`curses.wrapper` function and using it like this::"
194223msgstr ""
195224
225+ #: ../../howto/curses.rst:137
226+ msgid ""
227+ "from curses import wrapper\n"
228+ "\n"
229+ "def main(stdscr):\n"
230+ " # Clear screen\n"
231+ " stdscr.clear()\n"
232+ "\n"
233+ " # This raises ZeroDivisionError when i == 10.\n"
234+ " for i in range(0, 11):\n"
235+ " v = i-10\n"
236+ " stdscr.addstr(i, 0, '10 divided by {} is {}'.format(v, 10/v))\n"
237+ "\n"
238+ " stdscr.refresh()\n"
239+ " stdscr.getkey()\n"
240+ "\n"
241+ "wrapper(main)"
242+ msgstr ""
243+
196244#: ../../howto/curses.rst:153
197245msgid ""
198246"The :func:`~curses.wrapper` function takes a callable object and does the "
@@ -227,6 +275,13 @@ msgid ""
227275"window object. ::"
228276msgstr ""
229277
278+ #: ../../howto/curses.rst:178
279+ msgid ""
280+ "begin_x = 20; begin_y = 7\n"
281+ "height = 5; width = 40\n"
282+ "win = curses.newwin(height, width, begin_y, begin_x)"
283+ msgstr ""
284+
230285#: ../../howto/curses.rst:182
231286msgid ""
232287"Note that the coordinate system used in curses is unusual. Coordinates are "
@@ -282,6 +337,24 @@ msgid ""
282337"will be displayed. ::"
283338msgstr ""
284339
340+ #: ../../howto/curses.rst:223
341+ msgid ""
342+ "pad = curses.newpad(100, 100)\n"
343+ "# These loops fill the pad with letters; addch() is\n"
344+ "# explained in the next section\n"
345+ "for y in range(0, 99):\n"
346+ " for x in range(0, 99):\n"
347+ " pad.addch(y,x, ord('a') + (x*x+y*y) % 26)\n"
348+ "\n"
349+ "# Displays a section of the pad in the middle of the screen.\n"
350+ "# (0,0) : coordinate of upper-left corner of pad area to display.\n"
351+ "# (5,5) : coordinate of upper-left corner of window area to be filled\n"
352+ "# with pad content.\n"
353+ "# (20, 75) : coordinate of lower-right corner of window area to be\n"
354+ "# : filled with pad content.\n"
355+ "pad.refresh( 0,0, 5,5, 20,75)"
356+ msgstr ""
357+
285358#: ../../howto/curses.rst:238
286359msgid ""
287360"The :meth:`!refresh` call displays a section of the pad in the rectangle "
@@ -515,6 +588,13 @@ msgid ""
515588"you could code::"
516589msgstr ""
517590
591+ #: ../../howto/curses.rst:364
592+ msgid ""
593+ "stdscr.addstr(0, 0,\" Current mode: Typing mode\" ,\n"
594+ " curses.A_REVERSE)\n"
595+ "stdscr.refresh()"
596+ msgstr ""
597+
518598#: ../../howto/curses.rst:368
519599msgid ""
520600"The curses library also supports color on those terminals that provide it. "
@@ -548,6 +628,12 @@ msgstr ""
548628msgid "An example, which displays a line of text using color pair 1::"
549629msgstr ""
550630
631+ #: ../../howto/curses.rst:391
632+ msgid ""
633+ "stdscr.addstr(\" Pretty text\" , curses.color_pair(1))\n"
634+ "stdscr.refresh()"
635+ msgstr ""
636+
551637#: ../../howto/curses.rst:394
552638msgid ""
553639"As I said before, a color pair consists of a foreground and background "
@@ -571,13 +657,21 @@ msgid ""
571657"background, you would call::"
572658msgstr ""
573659
660+ #: ../../howto/curses.rst:408
661+ msgid "curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)"
662+ msgstr ""
663+
574664#: ../../howto/curses.rst:410
575665msgid ""
576666"When you change a color pair, any text already displayed using that color "
577667"pair will change to the new colors. You can also display new text in this "
578668"color with::"
579669msgstr ""
580670
671+ #: ../../howto/curses.rst:414
672+ msgid "stdscr.addstr(0,0,\" RED ALERT!\" , curses.color_pair(1))"
673+ msgstr ""
674+
581675#: ../../howto/curses.rst:416
582676msgid ""
583677"Very fancy terminals can change the definitions of the actual colors to a "
@@ -643,6 +737,18 @@ msgid ""
643737"program may look something like this::"
644738msgstr ""
645739
740+ #: ../../howto/curses.rst:462
741+ msgid ""
742+ "while True:\n"
743+ " c = stdscr.getch()\n"
744+ " if c == ord('p'):\n"
745+ " PrintDocument()\n"
746+ " elif c == ord('q'):\n"
747+ " break # Exit the while loop\n"
748+ " elif c == curses.KEY_HOME:\n"
749+ " x = y = 0"
750+ msgstr ""
751+
646752#: ../../howto/curses.rst:471
647753msgid ""
648754"The :mod:`curses.ascii` module supplies ASCII class membership functions "
@@ -662,6 +768,14 @@ msgid ""
662768"number of characters. ::"
663769msgstr ""
664770
771+ #: ../../howto/curses.rst:484
772+ msgid ""
773+ "curses.echo() # Enable echoing of characters\n"
774+ "\n"
775+ "# Get a 15-character string, with the cursor on the top line\n"
776+ "s = stdscr.getstr(0,0, 15)"
777+ msgstr ""
778+
665779#: ../../howto/curses.rst:489
666780msgid ""
667781"The :mod:`curses.textpad` module supplies a text box that supports an Emacs-"
@@ -670,6 +784,27 @@ msgid ""
670784"results either with or without trailing spaces. Here's an example::"
671785msgstr ""
672786
787+ #: ../../howto/curses.rst:495
788+ msgid ""
789+ "import curses\n"
790+ "from curses.textpad import Textbox, rectangle\n"
791+ "\n"
792+ "def main(stdscr):\n"
793+ " stdscr.addstr(0, 0,\" Enter IM message: (hit Ctrl-G to send)\" )\n"
794+ "\n"
795+ " editwin = curses.newwin(5,30, 2,1)\n"
796+ " rectangle(stdscr, 1,0, 1+5+1, 1+30+1)\n"
797+ " stdscr.refresh()\n"
798+ "\n"
799+ " box = Textbox(editwin)\n"
800+ "\n"
801+ " # Let the user edit until Ctrl-G is struck.\n"
802+ " box.edit()\n"
803+ "\n"
804+ " # Get resulting contents\n"
805+ " message = box.gather()"
806+ msgstr ""
807+
673808#: ../../howto/curses.rst:513
674809msgid ""
675810"See the library documentation on :mod:`curses.textpad` for more details."