テキスト文書があるとします。行があります。その行のテキストを削除して、別のテキストに置き換えたいです。どうすればいいですか?ドキュメントにはこれについて何もありません。事前に感謝します!
2 に答える
2
QScintilla の行を置き換えるには、まず次のように行を選択する必要があります。
# as an example, get the current line
line, pos = editor.getCursorPosition()
# then select it
editor.setSelection(line, 0, line, editor.lineLength(line))
行が選択されたら、次のものに置き換えることができます。
editor.replaceSelectedText(text)
行を別の行に置き換えたい場合 (プロセスで削除されます):
# get the text of the other line
text = editor.text(line)
# select it, so it can be removed
editor.setSelection(line, 0, line, editor.lineLength(line))
# remove it
editor.removeSelectedText()
# now select the target line and replace its text
editor.setSelection(target, 0, target, editor.lineLength(target))
editor.replaceSelectedText(text)
于 2014-03-16T17:34:37.383 に答える