D7: editor multi-cursor support
Add secondary_cursors field to Editor with insert_char_multi, delete_back_multi, delete_forward_multi methods. Right-to-left processing ensures position shifts don't corrupt earlier insertions. 7 new tests: add/clear, all_positions, insert, delete_back, delete_forward, unicode, duplicate-add.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# SPDX-FileCopyrightText: 2025 Nicolas Fella <nicolas.fella@gmx.de>
|
||||
# SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
|
||||
import sys
|
||||
from PySide6 import QtCore, QtWidgets, QtGui
|
||||
from KGuiAddons import KDateValidator
|
||||
|
||||
class MyWidget(QtWidgets.QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.input = QtWidgets.QLineEdit()
|
||||
self.input.editingFinished.connect(self.onEditFinished)
|
||||
|
||||
validator = KDateValidator()
|
||||
self.input.setValidator(validator)
|
||||
|
||||
self.layout = QtWidgets.QVBoxLayout(self)
|
||||
self.layout.addWidget(self.input)
|
||||
|
||||
@QtCore.Slot()
|
||||
def onEditFinished(self):
|
||||
print("Got valid input")
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QtWidgets.QApplication([])
|
||||
|
||||
widget = MyWidget()
|
||||
widget.resize(800, 600)
|
||||
widget.show()
|
||||
|
||||
sys.exit(app.exec())
|
||||
Reference in New Issue
Block a user