Commit b6cf9df279fc6c957419b4a5e7ba690a7292b41d
1 parent
c501d7d9
Exists in
master
and in
5 other branches
Todos os principais métodos aparentam estar ok.
Showing
5 changed files
with
28 additions
and
2 deletions
Show diff stats
src/include/pw3270/class.h
| @@ -184,7 +184,7 @@ | @@ -184,7 +184,7 @@ | ||
| 184 | string ebc2asc(string &str); | 184 | string ebc2asc(string &str); |
| 185 | 185 | ||
| 186 | // Get/Set/Text with charset translation | 186 | // Get/Set/Text with charset translation |
| 187 | - string get_string(int baddr, size_t len); | 187 | + string get_string(int baddr = 0, size_t len = -1); |
| 188 | string get_string_at(int row, int col, size_t sz); | 188 | string get_string_at(int row, int col, size_t sz); |
| 189 | int set_string_at(int row, int col, const char *str); | 189 | int set_string_at(int row, int col, const char *str); |
| 190 | int cmp_string_at(int row, int col, const char *text); | 190 | int cmp_string_at(int row, int col, const char *text); |
src/python/get.cc
| @@ -132,3 +132,23 @@ PyObject * terminal_get_string_at(PyObject *self, PyObject *args) { | @@ -132,3 +132,23 @@ PyObject * terminal_get_string_at(PyObject *self, PyObject *args) { | ||
| 132 | return PyString_FromString(rc.c_str()); | 132 | return PyString_FromString(rc.c_str()); |
| 133 | 133 | ||
| 134 | } | 134 | } |
| 135 | + | ||
| 136 | +PyObject * terminal_get_contents(PyObject *self) { | ||
| 137 | + | ||
| 138 | + string rc; | ||
| 139 | + | ||
| 140 | + try { | ||
| 141 | + | ||
| 142 | + rc = ((pw3270_TerminalObject *) self)->session->get_string(); | ||
| 143 | + | ||
| 144 | + } catch(std::exception &e) { | ||
| 145 | + | ||
| 146 | + PyErr_SetString(terminalError, e.what()); | ||
| 147 | + return NULL; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + return PyString_FromString(rc.c_str()); | ||
| 151 | + | ||
| 152 | + | ||
| 153 | + | ||
| 154 | +} |
src/python/private.h
| @@ -64,6 +64,7 @@ | @@ -64,6 +64,7 @@ | ||
| 64 | PyObject * terminal_disconnect(PyObject *self, PyObject *args); | 64 | PyObject * terminal_disconnect(PyObject *self, PyObject *args); |
| 65 | 65 | ||
| 66 | PyObject * terminal_get_string_at(PyObject *self, PyObject *args); | 66 | PyObject * terminal_get_string_at(PyObject *self, PyObject *args); |
| 67 | + PyObject * terminal_get_contents(PyObject *self); | ||
| 67 | PyObject * terminal_set_string_at(PyObject *self, PyObject *args); | 68 | PyObject * terminal_set_string_at(PyObject *self, PyObject *args); |
| 68 | PyObject * terminal_cmp_string_at(PyObject *self, PyObject *args); | 69 | PyObject * terminal_cmp_string_at(PyObject *self, PyObject *args); |
| 69 | 70 |
src/python/py3270.cc
| @@ -103,7 +103,7 @@ static PyTypeObject pw3270_TerminalType = { | @@ -103,7 +103,7 @@ static PyTypeObject pw3270_TerminalType = { | ||
| 103 | 0, /*tp_as_mapping*/ | 103 | 0, /*tp_as_mapping*/ |
| 104 | 0, /*tp_hash */ | 104 | 0, /*tp_hash */ |
| 105 | 0, /*tp_call*/ | 105 | 0, /*tp_call*/ |
| 106 | - 0, /*tp_str*/ | 106 | + terminal_get_contents, /*tp_str*/ |
| 107 | 0, /*tp_getattro*/ | 107 | 0, /*tp_getattro*/ |
| 108 | 0, /*tp_setattro*/ | 108 | 0, /*tp_setattro*/ |
| 109 | 0, /*tp_as_buffer*/ | 109 | 0, /*tp_as_buffer*/ |
src/python/sample.py
| @@ -18,6 +18,11 @@ print term.IsReady() | @@ -18,6 +18,11 @@ print term.IsReady() | ||
| 18 | 18 | ||
| 19 | print term.GetStringAt(14,19,38) | 19 | print term.GetStringAt(14,19,38) |
| 20 | 20 | ||
| 21 | +print "-----------------------------------------------------------------------" | ||
| 22 | +print term | ||
| 23 | +print "-----------------------------------------------------------------------" | ||
| 24 | + | ||
| 25 | + | ||
| 21 | 26 | ||
| 22 | 27 | ||
| 23 | 28 |