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

Method handle_edit_keys

pye.py:575–961  ·  view source on GitHub ↗
(self, key, char)

Source from the content-addressed store, hash-verified

573 self.cur_line = start_row
574 self.clear_mark()
575 def handle_edit_keys(self, key, char):
576 l = self.content[self.cur_line]
577 if key == KEY_NONE:
578 self.col = self.vcol
579 if self.mark is not None:
580 self.delete_mark(False)
581 l = self.content[self.cur_line]
582 chain = True
583 else:
584 chain = False
585 self.undo_add(self.cur_line, [l], 0x20 if char == " " else 0x41, 1, chain)
586 self.content[self.cur_line] = l[:self.col] + char + l[self.col:]
587 self.col += len(char)
588 return key
589 elif key == KEY_SHIFT_CTRL_LEFT:
590 self.set_mark()
591 key = KEY_WORD_LEFT
592 elif key == KEY_SHIFT_CTRL_RIGHT:
593 self.set_mark()
594 key = KEY_WORD_RIGHT
595 elif key == KEY_MOUSE:
596 if char[2] == 0x22:
597 key = KEY_GET if self.is_dir else KEY_FIND
598 elif char[1] < Editor.height:
599 col = char[0] + self.margin
600 line = char[1] + self.top_line
601 if (col, line) == self.mouse_last[:2] and (time.time() - self.mouse_last[2]) < 2:
602 self.mouse_last = (0, 0, 0)
603 if self.mark is None and col < len(l) and self.issymbol(l[col], Editor.word_char):
604 self.col = self.skip_while(l, col, Editor.word_char, -1) + 1
605 self.set_mark()
606 self.col = self.skip_while(l, self.col, Editor.word_char, 1)
607 else:
608 key = KEY_MARK
609 else:
610 if self.mark is not None:
611 if self.mark_order(self.cur_line, self.col) * self.mark_order(line, col) < 0:
612 self.mark = self.cur_line, self.col
613 self.cur_line, self.col = line, col
614 self.mouse_last = (col, line, time.time())
615 if key == KEY_DOWN:
616 self.move_down()
617 elif key == KEY_UP:
618 self.move_up()
619 elif key == KEY_LEFT:
620 self.move_left()
621 elif key == KEY_RIGHT:
622 self.move_right(l)
623 elif key == KEY_WORD_LEFT:
624 self.col = self.vcol
625 if self.skip_up():
626 l = self.content[self.cur_line]
627 pos = self.skip_until(l, self.col - 1, Editor.word_char, -1)
628 self.col = self.skip_while(l, pos, Editor.word_char, -1) + 1
629 elif key == KEY_WORD_RIGHT:
630 if self.skip_down(l):
631 l = self.content[self.cur_line]
632 pos = self.skip_until(l, self.col, Editor.word_char, 1)

Callers 1

edit_loopMethod · 0.95

Calls 15

delete_markMethod · 0.95
undo_addMethod · 0.95
set_markMethod · 0.95
issymbolMethod · 0.95
skip_whileMethod · 0.95
mark_orderMethod · 0.95
move_downMethod · 0.95
move_upMethod · 0.95
move_leftMethod · 0.95
move_rightMethod · 0.95
skip_upMethod · 0.95
skip_untilMethod · 0.95

Tested by

no test coverage detected