mirror of https://github.com/kivy/kivy.git
Clean textinput/codeinput.
This commit is contained in:
parent
a1cb8167fa
commit
13a7814e98
|
@ -94,7 +94,7 @@ class CodeInput(TextInput):
|
||||||
cid = '%s\0%s' % (ntext, str(kw))
|
cid = '%s\0%s' % (ntext, str(kw))
|
||||||
texture = Cache_get('textinput.label', cid)
|
texture = Cache_get('textinput.label', cid)
|
||||||
|
|
||||||
if not texture:
|
if texture is None:
|
||||||
# FIXME right now, we can't render very long line...
|
# FIXME right now, we can't render very long line...
|
||||||
# if we move on "VBO" version as fallback, we won't need to
|
# if we move on "VBO" version as fallback, we won't need to
|
||||||
# do this.
|
# do this.
|
||||||
|
@ -104,10 +104,7 @@ class CodeInput(TextInput):
|
||||||
label.text = u''
|
label.text = u''
|
||||||
else:
|
else:
|
||||||
label.text = ntext
|
label.text = ntext
|
||||||
try:
|
label.refresh()
|
||||||
label.refresh()
|
|
||||||
except ValueError:
|
|
||||||
return
|
|
||||||
|
|
||||||
# ok, we found it.
|
# ok, we found it.
|
||||||
texture = label.texture
|
texture = label.texture
|
||||||
|
@ -129,7 +126,7 @@ class CodeInput(TextInput):
|
||||||
if width:
|
if width:
|
||||||
return width
|
return width
|
||||||
lbl = self._create_line_label(text)
|
lbl = self._create_line_label(text)
|
||||||
width = lbl.width if lbl else 0
|
width = lbl.width
|
||||||
Cache_append(
|
Cache_append(
|
||||||
'textinput.width',
|
'textinput.width',
|
||||||
text + u'_' + repr(self._get_line_options()), width)
|
text + u'_' + repr(self._get_line_options()), width)
|
||||||
|
|
|
@ -1508,9 +1508,7 @@ class TextInput(Widget):
|
||||||
for x in _lines:
|
for x in _lines:
|
||||||
lbl = _create_label(x)
|
lbl = _create_label(x)
|
||||||
_lines_labels.append(lbl)
|
_lines_labels.append(lbl)
|
||||||
_line_rects.append(
|
_line_rects.append(Rectangle(size=lbl.size))
|
||||||
Rectangle(size=(lbl.size if lbl else (0, 0))))
|
|
||||||
lbl = None
|
|
||||||
|
|
||||||
if mode == 'all':
|
if mode == 'all':
|
||||||
self._lines_labels = _lines_labels
|
self._lines_labels = _lines_labels
|
||||||
|
@ -1530,13 +1528,9 @@ class TextInput(Widget):
|
||||||
len_lines, _lines_flags, _lines, _lines_labels,
|
len_lines, _lines_flags, _lines, _lines_labels,
|
||||||
_line_rects)
|
_line_rects)
|
||||||
|
|
||||||
line_label = _lines_labels[0]
|
|
||||||
min_line_ht = self._label_cached.get_extents('_')[1]
|
min_line_ht = self._label_cached.get_extents('_')[1]
|
||||||
if line_label is None:
|
# with markup texture can be of height `1`
|
||||||
self.line_height = max(1, min_line_ht)
|
self.line_height = max(_lines_labels[0].height, min_line_ht)
|
||||||
else:
|
|
||||||
# with markup texture can be of height `1`
|
|
||||||
self.line_height = max(line_label.height, min_line_ht)
|
|
||||||
#self.line_spacing = 2
|
#self.line_spacing = 2
|
||||||
# now, if the text change, maybe the cursor is not at the same place as
|
# now, if the text change, maybe the cursor is not at the same place as
|
||||||
# before. so, try to set the cursor on the good place
|
# before. so, try to set the cursor on the good place
|
||||||
|
@ -1628,9 +1622,6 @@ class TextInput(Widget):
|
||||||
for line_num, value in enumerate(lines):
|
for line_num, value in enumerate(lines):
|
||||||
if miny <= y <= maxy + dy:
|
if miny <= y <= maxy + dy:
|
||||||
texture = labels[line_num]
|
texture = labels[line_num]
|
||||||
if not texture:
|
|
||||||
y -= dy
|
|
||||||
continue
|
|
||||||
size = list(texture.size)
|
size = list(texture.size)
|
||||||
texc = texture.tex_coords[:]
|
texc = texture.tex_coords[:]
|
||||||
|
|
||||||
|
@ -1815,7 +1806,7 @@ class TextInput(Widget):
|
||||||
cid = '%s\0%s' % (ntext, str(kw))
|
cid = '%s\0%s' % (ntext, str(kw))
|
||||||
texture = Cache_get('textinput.label', cid)
|
texture = Cache_get('textinput.label', cid)
|
||||||
|
|
||||||
if not texture:
|
if texture is None:
|
||||||
# FIXME right now, we can't render very long line...
|
# FIXME right now, we can't render very long line...
|
||||||
# if we move on "VBO" version as fallback, we won't need to
|
# if we move on "VBO" version as fallback, we won't need to
|
||||||
# do this. try to found the maximum text we can handle
|
# do this. try to found the maximum text we can handle
|
||||||
|
@ -2039,9 +2030,7 @@ class TextInput(Widget):
|
||||||
for x in _lines:
|
for x in _lines:
|
||||||
lbl = _create_label(x, hint=True)
|
lbl = _create_label(x, hint=True)
|
||||||
_hint_text_labels.append(lbl)
|
_hint_text_labels.append(lbl)
|
||||||
_hint_text_rects.append(
|
_hint_text_rects.append(Rectangle(size=lbl.size))
|
||||||
Rectangle(size=(lbl.size if lbl else (0, 0))))
|
|
||||||
lbl = None
|
|
||||||
|
|
||||||
self._hint_text_lines = _lines
|
self._hint_text_lines = _lines
|
||||||
self._hint_text_labels = _hint_text_labels
|
self._hint_text_labels = _hint_text_labels
|
||||||
|
|
Loading…
Reference in New Issue