Loading ballontranslator/ui/textedit_area.py +3 −2 Original line number Diff line number Diff line Loading @@ -85,10 +85,11 @@ class SourceTextEdit(QTextEdit): change_from = self.input_method_from input_method_used = True elif self.change_added > 0: len_text = len(self.toPlainText()) text = self.toPlainText() len_text = len(text) cursor = self.textCursor() if self.change_added > len_text: if self.change_added > len_text or change_from + self.change_added > len_text: self.change_added = 1 change_from = self.textCursor().position() - 1 cursor.setPosition(change_from) Loading ballontranslator/ui/textedit_commands.py +7 −2 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ from .misc import FontFormat, doc_replace, doc_replace_no_shift from .texteditshapecontrol import TextBlkShapeControl from .page_search_widget import PageSearchWidget, Matched from .imgtrans_proj import ProjImgTrans from .scene_textlayout import PUNSET_HALF def propagate_user_edit(src_edit: Union[TransTextEdit, TextBlkItem], target_edit: Union[TransTextEdit, TextBlkItem], pos: int, added_text: str, input_method_used: bool): Loading @@ -21,15 +22,19 @@ def propagate_user_edit(src_edit: Union[TransTextEdit, TextBlkItem], target_edit new_count = src_edit.document().characterCount() removed = ori_count + len(added_text) - new_count new_editblock = False if input_method_used or added_text not in PUNSET_HALF: new_editblock = True cursor = target_edit.textCursor() if len(added_text) > 0: cursor.setPosition(pos) if removed > 0: cursor.setPosition(pos + removed, QTextCursor.MoveMode.KeepAnchor) if input_method_used: if new_editblock: cursor.beginEditBlock() cursor.insertText(added_text) if input_method_used: if new_editblock: cursor.endEditBlock() elif removed > 0: if removed == 1: Loading ballontranslator/ui/textitem.py +1 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ class TextBlkItem(QGraphicsTextItem): # input_method_used = True # cursor.setPosition(change_from) # cursor.setPosition(change_from + self.change_added, QTextCursor.MoveMode.KeepAnchor) if self.change_added > len_text: if self.change_added > len_text or change_from + self.change_added > len_text: self.change_added = 1 change_from = self.textCursor().position() - 1 cursor.setPosition(change_from) Loading Loading
ballontranslator/ui/textedit_area.py +3 −2 Original line number Diff line number Diff line Loading @@ -85,10 +85,11 @@ class SourceTextEdit(QTextEdit): change_from = self.input_method_from input_method_used = True elif self.change_added > 0: len_text = len(self.toPlainText()) text = self.toPlainText() len_text = len(text) cursor = self.textCursor() if self.change_added > len_text: if self.change_added > len_text or change_from + self.change_added > len_text: self.change_added = 1 change_from = self.textCursor().position() - 1 cursor.setPosition(change_from) Loading
ballontranslator/ui/textedit_commands.py +7 −2 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ from .misc import FontFormat, doc_replace, doc_replace_no_shift from .texteditshapecontrol import TextBlkShapeControl from .page_search_widget import PageSearchWidget, Matched from .imgtrans_proj import ProjImgTrans from .scene_textlayout import PUNSET_HALF def propagate_user_edit(src_edit: Union[TransTextEdit, TextBlkItem], target_edit: Union[TransTextEdit, TextBlkItem], pos: int, added_text: str, input_method_used: bool): Loading @@ -21,15 +22,19 @@ def propagate_user_edit(src_edit: Union[TransTextEdit, TextBlkItem], target_edit new_count = src_edit.document().characterCount() removed = ori_count + len(added_text) - new_count new_editblock = False if input_method_used or added_text not in PUNSET_HALF: new_editblock = True cursor = target_edit.textCursor() if len(added_text) > 0: cursor.setPosition(pos) if removed > 0: cursor.setPosition(pos + removed, QTextCursor.MoveMode.KeepAnchor) if input_method_used: if new_editblock: cursor.beginEditBlock() cursor.insertText(added_text) if input_method_used: if new_editblock: cursor.endEditBlock() elif removed > 0: if removed == 1: Loading
ballontranslator/ui/textitem.py +1 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ class TextBlkItem(QGraphicsTextItem): # input_method_used = True # cursor.setPosition(change_from) # cursor.setPosition(change_from + self.change_added, QTextCursor.MoveMode.KeepAnchor) if self.change_added > len_text: if self.change_added > len_text or change_from + self.change_added > len_text: self.change_added = 1 change_from = self.textCursor().position() - 1 cursor.setPosition(change_from) Loading