1
2
3
4
5
6
7
8
9
10
11 from PyQt4.QtCore import *
12 from PyQt4.QtGui import *
13
15
16 - def __init__(self, editor, plugin, textArea):
17 '''
18 Editörün oluşturulması ile ilgili temel şeyleri hazırlar.
19 '''
20 QTextEdit.__init__(self, editor.viewport())
21
22 self._editor = editor
23 self._plugin = plugin
24 self._textArea = textArea
25
26
27 self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
28 self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
29 self.setWordWrapMode(QTextOption.NoWrap)
30 self.setLineWrapMode(QTextEdit.NoWrap)
31
32
33 self.setContentsMargins(0, 0, 0, 0)
34 self.setViewportMargins(0, 0, 0, 0)
35 self.setLineWidth(0)
36 self.setMidLineWidth(0)
37
39 '''
40 Editörün font ayarlarını yapar.
41 '''
42 self.setFontFamily(font.family())
43 self.setFontItalic(font.italic())
44 self.setFontPointSize(font.pointSize())
45 self.setFontUnderline(font.underline())
46 self.setFontWeight(font.weight())
47
49 '''
50 Yazısını değiştirdiği alanı verir.
51 '''
52 return self._textArea
53
55 '''
56 Bazı kontrolleri ekliyoruz.
57 '''
58 key = e.key()
59
60 if key in (Qt.Key_Return, Qt.Key_Enter) and e.modifiers() == Qt.NoModifier:
61 self._editor.endTextAreaEditing()
62
63 elif key == Qt.Key_Escape:
64 self._editor.cancelTextAreaEditing()
65
66 else:
67 QTextEdit.keyPressEvent(self, e)
68
76