complete and speedup pty attribute implementation
This commit is contained in:
		| @@ -1,7 +1,8 @@ | |||||||
| # f1 - fenrir help | # f1 - fenrir help | ||||||
| ^[OP=toggle_tutorial_mode | ^[OP=toggle_tutorial_mode | ||||||
| # double tap control+end read attributes | # double tap control+end read attributes | ||||||
| 2,^[[1;5F=attribute_cursor | ^[[1;5F=attribute_cursor | ||||||
|  | #2,^[[1;5F=attribute_cursor | ||||||
| # escape - stop speech | # escape - stop speech | ||||||
| ^[=shut_up | ^[=shut_up | ||||||
| # context menu key - stop speech | # context menu key - stop speech | ||||||
| @@ -75,4 +76,4 @@ alt+f12 - quit fenrir | |||||||
| # alt+end - temperarily disable speech | # alt+end - temperarily disable speech | ||||||
| ^[[1;3F=temp_disable_speech | ^[[1;3F=temp_disable_speech | ||||||
| # control+end - toggle auto read | # control+end - toggle auto read | ||||||
| ^[[1;5F=toggle_auto_read | #^[[1;5F=toggle_auto_read | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ from fenrirscreenreader.utils import screen_utils | |||||||
| class Terminal: | class Terminal: | ||||||
|     def __init__(self, columns, lines, p_in): |     def __init__(self, columns, lines, p_in): | ||||||
|         self.text = '' |         self.text = '' | ||||||
|         self.attributes = [] |         self.attributes = None | ||||||
|         self.screen = pyte.HistoryScreen(columns, lines) |         self.screen = pyte.HistoryScreen(columns, lines) | ||||||
|         self.screen.set_mode(pyte.modes.LNM) |         self.screen.set_mode(pyte.modes.LNM) | ||||||
|         self.screen.write_process_input = \ |         self.screen.write_process_input = \ | ||||||
| @@ -22,9 +22,31 @@ class Terminal: | |||||||
|         self.stream.attach(self.screen) |         self.stream.attach(self.screen) | ||||||
|     def feed(self, data): |     def feed(self, data): | ||||||
|         self.stream.feed(data) |         self.stream.feed(data) | ||||||
|  |              | ||||||
|  |     def updateAttributes(self, initialize = False): | ||||||
|  |         buffer = self.screen.buffer     | ||||||
|  |         lines = None | ||||||
|  |         if not initialize: | ||||||
|  |             lines = self.screen.dirty | ||||||
|  |         else: | ||||||
|  |             lines = range(self.screen.lines) | ||||||
|  |             self.attributes = [[list(attribute[1:]) + [False, 'default', 'default'] for attribute in line.values()] for line in buffer.values()]             | ||||||
|  |              | ||||||
|  |         for y in lines: | ||||||
|  |             try: | ||||||
|  |                 t = self.attributes[y] | ||||||
|  |             except: | ||||||
|  |                 self.attributes.append([]) | ||||||
|  |  | ||||||
|  |             self.attributes[y] = [list(attribute[1:]) + [False, 'default', 'default'] for attribute in (buffer[y].values())] | ||||||
|  |             if len(self.attributes[y]) < self.screen.columns: | ||||||
|  |                 diff = self.screen.columns - len(self.attributes[y]) | ||||||
|  |                 self.attributes[y] += [['default', 'default', False, False, False, False, False, False, 'default', 'default']]   * diff | ||||||
|  |  | ||||||
|     def resize(self, lines, columns): |     def resize(self, lines, columns): | ||||||
|         self.screen.resize(lines, columns) |         self.screen.resize(lines, columns) | ||||||
|         self.setCursor() |         self.setCursor() | ||||||
|  |         self.updateAttributes(True) | ||||||
|     def setCursor(self, x = -1, y = -1): |     def setCursor(self, x = -1, y = -1): | ||||||
|         xPos = x |         xPos = x | ||||||
|         yPos = y |         yPos = y | ||||||
| @@ -37,8 +59,7 @@ class Terminal: | |||||||
|     def GetScreenContent(self): |     def GetScreenContent(self): | ||||||
|         cursor = self.screen.cursor |         cursor = self.screen.cursor | ||||||
|         self.text = '\n'.join(self.screen.display) |         self.text = '\n'.join(self.screen.display) | ||||||
|         buffer = self.screen.buffer |         self.updateAttributes(self.attributes == None) | ||||||
|         self.attributes = [[list(attribute[1:]) + [False, 'default', 'default'] for attribute in line.values()] for line in buffer.values()] |  | ||||||
|         self.screen.dirty.clear()             |         self.screen.dirty.clear()             | ||||||
|         return {"cursor": (cursor.x, cursor.y), |         return {"cursor": (cursor.x, cursor.y), | ||||||
|             'lines': self.screen.lines, |             'lines': self.screen.lines, | ||||||
| @@ -92,7 +113,6 @@ class driver(screenDriver): | |||||||
|                 break |                 break | ||||||
|             # exit on interrupt available |             # exit on interrupt available | ||||||
|             if interruptFd in r: |             if interruptFd in r: | ||||||
|                 print('i') |  | ||||||
|                 break |                 break | ||||||
|             data = os.read(fd, len) |             data = os.read(fd, len) | ||||||
|             if data == b'': |             if data == b'': | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user