Skip to content

Commit ab1080d

Browse files
committed
Move EmacsBehavior out of CodeInput
1 parent 23ebb75 commit ab1080d

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

examples/widgets/codeinput.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
from kivy.uix.spinner import Spinner, SpinnerOption
44
from kivy.uix.boxlayout import BoxLayout
55
from kivy.uix.codeinput import CodeInput
6+
from kivy.uix.behaviors import EmacsBehavior
67
from kivy.uix.popup import Popup
78
from kivy.properties import ListProperty
89
from kivy.core.window import Window
910
from kivy.core.text import LabelBase
1011
from pygments import lexers
11-
12+
from pygame import font as fonts
1213
import codecs
1314
import glob
1415
import os
@@ -109,6 +110,13 @@ def cancel(self):
109110
self.dismiss()
110111

111112

113+
class CodeInputWithBindings(EmacsBehavior, CodeInput):
114+
'''CodeInput with keybindings.
115+
To add more bindings, add behavior before CodeInput in class definition
116+
'''
117+
pass
118+
119+
112120
class CodeInputTest(App):
113121

114122
files = ListProperty([None, ])
@@ -154,11 +162,12 @@ def build(self):
154162
menu.add_widget(key_bindings)
155163
b.add_widget(menu)
156164

157-
self.codeinput = CodeInput(
158-
165+
self.codeinput = CodeInputWithBindings(
159166
lexer=KivyLexer(),
160167
font_size=12,
161-
text=example_text)
168+
text=example_text,
169+
active_key_bindings='default',
170+
)
162171

163172
b.add_widget(self.codeinput)
164173

kivy/uix/codeinput.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@
4444
from kivy.cache import Cache
4545
from kivy.properties import ObjectProperty, OptionProperty, StringProperty
4646
from kivy.utils import get_hex_from_color, get_color_from_hex
47-
from kivy.uix.behaviors import CodeNavigationBehavior, EmacsBehavior
47+
from kivy.uix.behaviors import CodeNavigationBehavior
4848

4949
Cache_get = Cache.get
5050
Cache_append = Cache.append
5151

5252
# TODO: color chooser for keywords/strings/...
5353

5454

55-
class CodeInput(CodeNavigationBehavior, EmacsBehavior, TextInput):
55+
class CodeInput(CodeNavigationBehavior, TextInput):
5656
'''CodeInput class, used for displaying highlighted code.
5757
'''
5858

0 commit comments

Comments
 (0)