|
45 | 45 | mcprint mvaddchnstr mvaddchstr mvcur mvinchnstr |
46 | 46 | mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr |
47 | 47 | mvwinchnstr mvwinchstr mvwinnstr |
48 | | - restartterm ripoffline scr_dump |
49 | | - scr_init scr_restore scr_set scrl set_curterm setterm |
| 48 | + restartterm ripoffline |
| 49 | + scrl set_curterm setterm |
50 | 50 | tgetent tgetflag tgetnum tgetstr tgoto timeout tputs |
51 | 51 | vidattr vidputs waddchnstr waddchstr |
52 | 52 | wcolor_set winchnstr winchstr winnstr wmouse_trafo wscrl |
@@ -5039,6 +5039,22 @@ static PyType_Spec PyCursesScreen_Type_spec = { |
5039 | 5039 | Py_RETURN_NONE; \ |
5040 | 5040 | } |
5041 | 5041 |
|
| 5042 | +/* |
| 5043 | + * Function body for a module function that dumps or restores the whole screen |
| 5044 | + * through a file named by a single filesystem-path argument (filename). |
| 5045 | + */ |
| 5046 | +#define ScreenDumpFunctionBody(X) \ |
| 5047 | +{ \ |
| 5048 | + PyCursesStatefulInitialised(module); \ |
| 5049 | + PyObject *bytes; \ |
| 5050 | + if (!PyUnicode_FSConverter(filename, &bytes)) { \ |
| 5051 | + return NULL; \ |
| 5052 | + } \ |
| 5053 | + int rtn = X(PyBytes_AS_STRING(bytes)); \ |
| 5054 | + Py_DECREF(bytes); \ |
| 5055 | + return curses_check_err(module, rtn, # X, NULL); \ |
| 5056 | +} |
| 5057 | + |
5042 | 5058 | /********************************************************************* |
5043 | 5059 | Global Functions |
5044 | 5060 | **********************************************************************/ |
@@ -5612,6 +5628,77 @@ _curses_getwin(PyObject *module, PyObject *file) |
5612 | 5628 | return res; |
5613 | 5629 | } |
5614 | 5630 |
|
| 5631 | +/*[clinic input] |
| 5632 | +_curses.scr_dump |
| 5633 | +
|
| 5634 | + filename: object |
| 5635 | + The file to write to. |
| 5636 | + / |
| 5637 | +
|
| 5638 | +Write the current contents of the virtual screen to a file. |
| 5639 | +
|
| 5640 | +The file can later be used to restore the screen with scr_restore(), |
| 5641 | +scr_init() or scr_set(). |
| 5642 | +[clinic start generated code]*/ |
| 5643 | + |
| 5644 | +static PyObject * |
| 5645 | +_curses_scr_dump(PyObject *module, PyObject *filename) |
| 5646 | +/*[clinic end generated code: output=4425cfa505ac9577 input=358db4b370975345]*/ |
| 5647 | +ScreenDumpFunctionBody(scr_dump) |
| 5648 | + |
| 5649 | +/*[clinic input] |
| 5650 | +_curses.scr_restore |
| 5651 | +
|
| 5652 | + filename: object |
| 5653 | + The file to read from. |
| 5654 | + / |
| 5655 | +
|
| 5656 | +Set the virtual screen to the contents of a file made by scr_dump(). |
| 5657 | +
|
| 5658 | +The next call to doupdate() or refresh() restores the screen to those |
| 5659 | +contents. |
| 5660 | +[clinic start generated code]*/ |
| 5661 | + |
| 5662 | +static PyObject * |
| 5663 | +_curses_scr_restore(PyObject *module, PyObject *filename) |
| 5664 | +/*[clinic end generated code: output=71d669fb560fa57b input=30b1d6b2c328dd55]*/ |
| 5665 | +ScreenDumpFunctionBody(scr_restore) |
| 5666 | + |
| 5667 | +/*[clinic input] |
| 5668 | +_curses.scr_init |
| 5669 | +
|
| 5670 | + filename: object |
| 5671 | + The file to read from. |
| 5672 | + / |
| 5673 | +
|
| 5674 | +Initialize the assumed terminal contents from a scr_dump() file. |
| 5675 | +
|
| 5676 | +Use it as what the terminal currently displays, for example after |
| 5677 | +another program has drawn the screen. |
| 5678 | +[clinic start generated code]*/ |
| 5679 | + |
| 5680 | +static PyObject * |
| 5681 | +_curses_scr_init(PyObject *module, PyObject *filename) |
| 5682 | +/*[clinic end generated code: output=2e861d381d710419 input=81c45e4702124ef6]*/ |
| 5683 | +ScreenDumpFunctionBody(scr_init) |
| 5684 | + |
| 5685 | +/*[clinic input] |
| 5686 | +_curses.scr_set |
| 5687 | +
|
| 5688 | + filename: object |
| 5689 | + The file to read from. |
| 5690 | + / |
| 5691 | +
|
| 5692 | +Use a scr_dump() file as both the virtual screen and the terminal. |
| 5693 | +
|
| 5694 | +This combines the effects of scr_restore() and scr_init(). |
| 5695 | +[clinic start generated code]*/ |
| 5696 | + |
| 5697 | +static PyObject * |
| 5698 | +_curses_scr_set(PyObject *module, PyObject *filename) |
| 5699 | +/*[clinic end generated code: output=6056fdec12c5935f input=d248c20543cc289b]*/ |
| 5700 | +ScreenDumpFunctionBody(scr_set) |
| 5701 | + |
5615 | 5702 | /*[clinic input] |
5616 | 5703 | _curses.halfdelay |
5617 | 5704 |
|
@@ -7715,6 +7802,10 @@ static PyMethodDef cursesmodule_methods[] = { |
7715 | 7802 | _CURSES_RESIZETERM_METHODDEF |
7716 | 7803 | _CURSES_RESIZE_TERM_METHODDEF |
7717 | 7804 | _CURSES_SAVETTY_METHODDEF |
| 7805 | + _CURSES_SCR_DUMP_METHODDEF |
| 7806 | + _CURSES_SCR_INIT_METHODDEF |
| 7807 | + _CURSES_SCR_RESTORE_METHODDEF |
| 7808 | + _CURSES_SCR_SET_METHODDEF |
7718 | 7809 | #if defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102 |
7719 | 7810 | _CURSES_GET_ESCDELAY_METHODDEF |
7720 | 7811 | _CURSES_SET_ESCDELAY_METHODDEF |
|
0 commit comments