本文整理汇总了Python中calibre.gui2.tweak_book.editor.text.TextEdit.mark_selected_text方法的典型用法代码示例。如果您正苦于以下问题:Python TextEdit.mark_selected_text方法的具体用法?Python TextEdit.mark_selected_text怎么用?Python TextEdit.mark_selected_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calibre.gui2.tweak_book.editor.text.TextEdit
的用法示例。
在下文中一共展示了TextEdit.mark_selected_text方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Editor
# 需要导入模块: from calibre.gui2.tweak_book.editor.text import TextEdit [as 别名]
# 或者: from calibre.gui2.tweak_book.editor.text.TextEdit import mark_selected_text [as 别名]
#.........这里部分代码省略.........
tprefs['insert_tag_mru'] = mru
self._build_insert_tag_button_menu()
def remove_insert_tag(self, name):
mru = tprefs['insert_tag_mru']
try:
mru.remove(name)
except ValueError:
pass
tprefs['insert_tag_mru'] = mru
self._build_insert_tag_button_menu()
def set_request_completion(self, callback=None, doc_name=None):
self.editor.request_completion = callback
self.editor.completion_doc_name = doc_name
def handle_completion_result(self, result):
return self.editor.handle_completion_result(result)
def undo(self):
self.editor.undo()
def redo(self):
self.editor.redo()
@property
def selected_text(self):
return self.editor.selected_text
def get_smart_selection(self, update=True):
return self.editor.smarts.get_smart_selection(self.editor, update=update)
# Search and replace {{{
def mark_selected_text(self):
self.editor.mark_selected_text()
def find(self, *args, **kwargs):
return self.editor.find(*args, **kwargs)
def find_text(self, *args, **kwargs):
return self.editor.find_text(*args, **kwargs)
def find_spell_word(self, *args, **kwargs):
return self.editor.find_spell_word(*args, **kwargs)
def replace(self, *args, **kwargs):
return self.editor.replace(*args, **kwargs)
def all_in_marked(self, *args, **kwargs):
return self.editor.all_in_marked(*args, **kwargs)
def go_to_anchor(self, *args, **kwargs):
return self.editor.go_to_anchor(*args, **kwargs)
# }}}
@property
def has_marked_text(self):
return self.editor.current_search_mark is not None
@dynamic_property
def is_modified(self):
def fget(self):
return self.editor.is_modified
def fset(self, val):
self.editor.is_modified = val
示例2: Editor
# 需要导入模块: from calibre.gui2.tweak_book.editor.text import TextEdit [as 别名]
# 或者: from calibre.gui2.tweak_book.editor.text.TextEdit import mark_selected_text [as 别名]
class Editor(QMainWindow):
has_line_numbers = True
modification_state_changed = pyqtSignal(object)
undo_redo_state_changed = pyqtSignal(object, object)
copy_available_state_changed = pyqtSignal(object)
data_changed = pyqtSignal(object)
cursor_position_changed = pyqtSignal()
def __init__(self, syntax, parent=None):
QMainWindow.__init__(self, parent)
if parent is None:
self.setWindowFlags(Qt.Widget)
self.is_synced_to_container = False
self.syntax = syntax
self.editor = TextEdit(self)
self.editor.setContextMenuPolicy(Qt.CustomContextMenu)
self.editor.customContextMenuRequested.connect(self.show_context_menu)
self.setCentralWidget(self.editor)
self.create_toolbars()
self.undo_available = False
self.redo_available = False
self.copy_available = self.cut_available = False
self.editor.modificationChanged.connect(self._modification_state_changed)
self.editor.undoAvailable.connect(self._undo_available)
self.editor.redoAvailable.connect(self._redo_available)
self.editor.textChanged.connect(self._data_changed)
self.editor.copyAvailable.connect(self._copy_available)
self.editor.cursorPositionChanged.connect(self._cursor_position_changed)
@dynamic_property
def current_line(self):
def fget(self):
return self.editor.textCursor().blockNumber()
def fset(self, val):
self.editor.go_to_line(val)
return property(fget=fget, fset=fset)
@property
def number_of_lines(self):
return self.editor.blockCount()
@dynamic_property
def data(self):
def fget(self):
ans = self.get_raw_data()
return ans.encode('utf-8')
def fset(self, val):
self.editor.load_text(val, syntax=self.syntax)
return property(fget=fget, fset=fset)
def init_from_template(self, template):
self.editor.load_text(template, syntax=self.syntax, process_template=True)
def get_raw_data(self):
return unicodedata.normalize('NFC', unicode(self.editor.toPlainText()).rstrip('\0'))
def replace_data(self, raw, only_if_different=True):
if isinstance(raw, bytes):
raw = raw.decode('utf-8')
current = self.get_raw_data() if only_if_different else False
if current != raw:
self.editor.replace_text(raw)
def apply_settings(self, prefs=None):
self.editor.apply_settings(prefs=None)
def set_focus(self):
self.editor.setFocus(Qt.OtherFocusReason)
def action_triggered(self, action):
action, args = action[0], action[1:]
func = getattr(self.editor, action)
func(*args)
def insert_image(self, href):
self.editor.insert_image(href)
def undo(self):
self.editor.undo()
def redo(self):
self.editor.redo()
@property
def selected_text(self):
return self.editor.selected_text
# Search and replace {{{
def mark_selected_text(self):
self.editor.mark_selected_text()
def find(self, *args, **kwargs):
return self.editor.find(*args, **kwargs)
def replace(self, *args, **kwargs):
return self.editor.replace(*args, **kwargs)
def all_in_marked(self, *args, **kwargs):
#.........这里部分代码省略.........
示例3: Editor
# 需要导入模块: from calibre.gui2.tweak_book.editor.text import TextEdit [as 别名]
# 或者: from calibre.gui2.tweak_book.editor.text.TextEdit import mark_selected_text [as 别名]
#.........这里部分代码省略.........
self.editor.insert_hyperlink(href, text)
def _build_insert_tag_button_menu(self):
m = self.insert_tag_menu
m.clear()
for name in tprefs['insert_tag_mru']:
m.addAction(name, partial(self.insert_tag, name))
def insert_tag(self, name):
self.editor.insert_tag(name)
mru = tprefs['insert_tag_mru']
try:
mru.remove(name)
except ValueError:
pass
mru.insert(0, name)
tprefs['insert_tag_mru'] = mru
self._build_insert_tag_button_menu()
def undo(self):
self.editor.undo()
def redo(self):
self.editor.redo()
@property
def selected_text(self):
return self.editor.selected_text
def get_smart_selection(self, update=True):
return self.editor.smarts.get_smart_selection(self.editor, update=update)
# Search and replace {{{
def mark_selected_text(self):
self.editor.mark_selected_text()
def find(self, *args, **kwargs):
return self.editor.find(*args, **kwargs)
def find_spell_word(self, *args, **kwargs):
return self.editor.find_spell_word(*args, **kwargs)
def replace(self, *args, **kwargs):
return self.editor.replace(*args, **kwargs)
def all_in_marked(self, *args, **kwargs):
return self.editor.all_in_marked(*args, **kwargs)
def go_to_anchor(self, *args, **kwargs):
return self.editor.go_to_anchor(*args, **kwargs)
# }}}
@property
def has_marked_text(self):
return self.editor.current_search_mark is not None
@dynamic_property
def is_modified(self):
def fget(self):
return self.editor.is_modified
def fset(self, val):
self.editor.is_modified = val
return property(fget=fget, fset=fset)
def create_toolbars(self):
self.action_bar = b = self.addToolBar(_('File actions tool bar'))
示例4: Editor
# 需要导入模块: from calibre.gui2.tweak_book.editor.text import TextEdit [as 别名]
# 或者: from calibre.gui2.tweak_book.editor.text.TextEdit import mark_selected_text [as 别名]
class Editor(QMainWindow):
has_line_numbers = True
modification_state_changed = pyqtSignal(object)
undo_redo_state_changed = pyqtSignal(object, object)
copy_available_state_changed = pyqtSignal(object)
data_changed = pyqtSignal(object)
cursor_position_changed = pyqtSignal()
def __init__(self, syntax, parent=None):
QMainWindow.__init__(self, parent)
if parent is None:
self.setWindowFlags(Qt.Widget)
self.is_synced_to_container = False
self.syntax = syntax
self.editor = TextEdit(self)
self.setCentralWidget(self.editor)
self.create_toolbars()
self.undo_available = False
self.redo_available = False
self.copy_available = self.cut_available = False
self.editor.modificationChanged.connect(self._modification_state_changed)
self.editor.undoAvailable.connect(self._undo_available)
self.editor.redoAvailable.connect(self._redo_available)
self.editor.textChanged.connect(self._data_changed)
self.editor.copyAvailable.connect(self._copy_available)
self.editor.cursorPositionChanged.connect(self._cursor_position_changed)
@dynamic_property
def current_line(self):
def fget(self):
return self.editor.textCursor().blockNumber()
def fset(self, val):
self.editor.go_to_line(val)
return property(fget=fget, fset=fset)
@property
def number_of_lines(self):
return self.editor.blockCount()
@dynamic_property
def data(self):
def fget(self):
ans = self.get_raw_data()
return ans.encode('utf-8')
def fset(self, val):
self.editor.load_text(val, syntax=self.syntax)
return property(fget=fget, fset=fset)
def init_from_template(self, template):
self.editor.load_text(template, syntax=self.syntax, process_template=True)
def get_raw_data(self):
return unicodedata.normalize('NFC', unicode(self.editor.toPlainText()))
def replace_data(self, raw, only_if_different=True):
if isinstance(raw, bytes):
raw = raw.decode('utf-8')
current = self.get_raw_data() if only_if_different else False
if current != raw:
self.editor.replace_text(raw)
def apply_settings(self, prefs=None):
self.editor.apply_settings(prefs=None)
def set_focus(self):
self.editor.setFocus(Qt.OtherFocusReason)
def undo(self):
self.editor.undo()
def redo(self):
self.editor.redo()
@property
def selected_text(self):
return self.editor.selected_text
# Search and replace {{{
def mark_selected_text(self):
self.editor.mark_selected_text()
def find(self, *args, **kwargs):
return self.editor.find(*args, **kwargs)
def replace(self, *args, **kwargs):
return self.editor.replace(*args, **kwargs)
def all_in_marked(self, *args, **kwargs):
return self.editor.all_in_marked(*args, **kwargs)
def go_to_anchor(self, *args, **kwargs):
return self.editor.go_to_anchor(*args, **kwargs)
# }}}
@property
def has_marked_text(self):
return self.editor.current_search_mark is not None
#.........这里部分代码省略.........
示例5: Editor
# 需要导入模块: from calibre.gui2.tweak_book.editor.text import TextEdit [as 别名]
# 或者: from calibre.gui2.tweak_book.editor.text.TextEdit import mark_selected_text [as 别名]
class Editor(QMainWindow):
has_line_numbers = True
modification_state_changed = pyqtSignal(object)
undo_redo_state_changed = pyqtSignal(object, object)
copy_available_state_changed = pyqtSignal(object)
data_changed = pyqtSignal(object)
cursor_position_changed = pyqtSignal()
def __init__(self, syntax, parent=None):
QMainWindow.__init__(self, parent)
if parent is None:
self.setWindowFlags(Qt.Widget)
self.syntax = syntax
self.editor = TextEdit(self)
self.setCentralWidget(self.editor)
self.editor.modificationChanged.connect(self.modification_state_changed.emit)
self.create_toolbars()
self.undo_available = False
self.redo_available = False
self.copy_available = self.cut_available = False
self.editor.undoAvailable.connect(self._undo_available)
self.editor.redoAvailable.connect(self._redo_available)
self.editor.textChanged.connect(self._data_changed)
self.editor.copyAvailable.connect(self._copy_available)
self.editor.cursorPositionChanged.connect(self._cursor_position_changed)
@dynamic_property
def current_line(self):
def fget(self):
return self.editor.textCursor().blockNumber()
def fset(self, val):
self.editor.go_to_line(val)
return property(fget=fget, fset=fset)
@property
def number_of_lines(self):
return self.editor.blockCount()
@dynamic_property
def data(self):
def fget(self):
ans = unicode(self.editor.toPlainText())
if self.syntax == 'html':
ans = xml_replace_entities(ans)
return ans.encode('utf-8')
def fset(self, val):
self.editor.load_text(val, syntax=self.syntax)
return property(fget=fget, fset=fset)
def init_from_template(self, template):
self.editor.load_text(template, syntax=self.syntax, process_template=True)
def get_raw_data(self):
return unicode(self.editor.toPlainText())
def replace_data(self, raw, only_if_different=True):
if isinstance(raw, bytes):
raw = raw.decode('utf-8')
current = self.get_raw_data() if only_if_different else False
if current != raw:
self.editor.replace_text(raw)
def set_focus(self):
self.editor.setFocus(Qt.OtherFocusReason)
def undo(self):
self.editor.undo()
def redo(self):
self.editor.redo()
# Search and replace {{{
def mark_selected_text(self):
self.editor.mark_selected_text()
def find(self, *args, **kwargs):
return self.editor.find(*args, **kwargs)
def replace(self, *args, **kwargs):
return self.editor.replace(*args, **kwargs)
def all_in_marked(self, *args, **kwargs):
return self.editor.all_in_marked(*args, **kwargs)
# }}}
@property
def has_marked_text(self):
return self.editor.current_search_mark is not None
@dynamic_property
def is_modified(self):
def fget(self):
return self.editor.is_modified
def fset(self, val):
self.editor.is_modified = val
return property(fget=fget, fset=fset)
def create_toolbars(self):
#.........这里部分代码省略.........