| OLD | NEW |
| 1 """This implements a virtual screen. This is used to support ANSI terminal | 1 """This implements a virtual screen. This is used to support ANSI terminal |
| 2 emulation. The screen representation and state is implemented in this class. | 2 emulation. The screen representation and state is implemented in this class. |
| 3 Most of the methods are inspired by ANSI screen control codes. The ANSI class | 3 Most of the methods are inspired by ANSI screen control codes. The ANSI class |
| 4 extends this class to add parsing of ANSI escape codes. | 4 extends this class to add parsing of ANSI escape codes. |
| 5 | 5 |
| 6 $Id: screen.py 486 2007-07-13 01:04:16Z noah $ | 6 PEXPECT LICENSE |
| 7 |
| 8 This license is approved by the OSI and FSF as GPL-compatible. |
| 9 http://opensource.org/licenses/isc-license.txt |
| 10 |
| 11 Copyright (c) 2012, Noah Spurrier <noah@noah.org> |
| 12 PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY |
| 13 PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE |
| 14 COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. |
| 15 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 16 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 17 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 18 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 22 |
| 7 """ | 23 """ |
| 8 | 24 |
| 9 import copy | 25 import copy |
| 10 | 26 |
| 11 NUL = 0 # Fill character; ignored on input. | 27 NUL = 0 # Fill character; ignored on input. |
| 12 ENQ = 5 # Transmit answerback message. | 28 ENQ = 5 # Transmit answerback message. |
| 13 BEL = 7 # Ring the bell. | 29 BEL = 7 # Ring the bell. |
| 14 BS = 8 # Move cursor left. | 30 BS = 8 # Move cursor left. |
| 15 HT = 9 # Move cursor to next tab stop. | 31 HT = 9 # Move cursor to next tab stop. |
| 16 LF = 10 # Line feed. | 32 LF = 10 # Line feed. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 168 |
| 153 def insert_abs (self, r, c, ch): | 169 def insert_abs (self, r, c, ch): |
| 154 | 170 |
| 155 """This inserts a character at (r,c). Everything under | 171 """This inserts a character at (r,c). Everything under |
| 156 and to the right is shifted right one character. | 172 and to the right is shifted right one character. |
| 157 The last character of the line is lost. | 173 The last character of the line is lost. |
| 158 """ | 174 """ |
| 159 | 175 |
| 160 r = constrain (r, 1, self.rows) | 176 r = constrain (r, 1, self.rows) |
| 161 c = constrain (c, 1, self.cols) | 177 c = constrain (c, 1, self.cols) |
| 162 for ci in range (self.cols, c, -1): | 178 for ci in range (self.cols, c, -1): |
| 163 self.put_abs (r,ci, self.get_abs(r,ci-1)) | 179 self.put_abs (r,ci, self.get_abs(r,ci-1)) |
| 164 self.put_abs (r,c,ch) | 180 self.put_abs (r,c,ch) |
| 165 | 181 |
| 166 def insert (self, ch): | 182 def insert (self, ch): |
| 167 | 183 |
| 168 self.insert_abs (self.cur_r, self.cur_c, ch) | 184 self.insert_abs (self.cur_r, self.cur_c, ch) |
| 169 | 185 |
| 170 def get_abs (self, r, c): | 186 def get_abs (self, r, c): |
| 171 | 187 |
| 172 r = constrain (r, 1, self.rows) | 188 r = constrain (r, 1, self.rows) |
| 173 c = constrain (c, 1, self.cols) | 189 c = constrain (c, 1, self.cols) |
| 174 return self.w[r-1][c-1] | 190 return self.w[r-1][c-1] |
| 175 | 191 |
| 176 def get (self): | 192 def get (self): |
| 177 | 193 |
| 178 self.get_abs (self.cur_r, self.cur_c) | 194 self.get_abs (self.cur_r, self.cur_c) |
| 179 | 195 |
| 180 def get_region (self, rs,cs, re,ce): | 196 def get_region (self, rs,cs, re,ce): |
| 181 | 197 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 387 |
| 372 """Clears all tabs.""" | 388 """Clears all tabs.""" |
| 373 | 389 |
| 374 pass | 390 pass |
| 375 | 391 |
| 376 # Insert line Esc [ Pn L | 392 # Insert line Esc [ Pn L |
| 377 # Delete line Esc [ Pn M | 393 # Delete line Esc [ Pn M |
| 378 # Delete character Esc [ Pn P | 394 # Delete character Esc [ Pn P |
| 379 # Scrolling region Esc [ Pn(top);Pn(bot) r | 395 # Scrolling region Esc [ Pn(top);Pn(bot) r |
| 380 | 396 |
| OLD | NEW |