MCPcopy Create free account
hub / github.com/RetiredWizard/PyDOS / undo_redo

Method undo_redo

pye.py:512–540  ·  view source on GitHub ↗
(self, undo, redo)

Source from the content-addressed store, hash-verified

510 self.undo.append([lnum, span, text, key, self.col, chain])
511 self.redo = []
512 def undo_redo(self, undo, redo):
513 chain = True
514 redo_start = len(redo)
515 while len(undo) > 0 and chain:
516 action = undo.pop()
517 if not action[3] in (KEY_INDENT, KEY_DEDENT, KEY_COMMENT):
518 self.cur_line = action[0]
519 self.col = action[4]
520 if len(redo) >= self.undo_limit:
521 del redo[0]
522 if action[1] >= 0:
523 redo.append(action[0:1] + [len(action[2])] +
524 [self.content[action[0]:action[0] + action[1]]] + action[3:])
525 if action[0] < self.total_lines:
526 self.content[action[0]:action[0] + action[1]] = action[2]
527 else:
528 self.content += action[2]
529 else:
530 redo.append(action[0:1] + [1] +
531 [self.content[action[0]:action[0] - action[1] + 1]] + action[3:])
532 del self.content[action[0]:action[0] - action[1]]
533 self.content[action[0]] = action[2][0]
534 chain = action[5]
535 if (len(redo) - redo_start) > 0:
536 redo[-1][5] = True
537 redo[redo_start][5] = False
538 self.total_lines = len(self.content)
539 self.changed = '' if self.hash == self.hash_buffer() else '*'
540 self.clear_mark()
541 def set_mark(self, flag=999999999):
542 if self.mark is None:
543 self.mark = (self.cur_line, self.col)

Callers 1

handle_edit_keysMethod · 0.95

Calls 2

hash_bufferMethod · 0.95
clear_markMethod · 0.95

Tested by

no test coverage detected