MCPcopy Index your code
hub / github.com/python/cpython / insert

Method insert

Lib/idlelib/idle_test/mock_tk.py:186–199  ·  view source on GitHub ↗

Insert chars before the character at index.

(self, index, chars)

Source from the content-addressed store, hash-verified

184 return n, len(self.data[n]) + endflag
185
186 def insert(self, index, chars):
187 "Insert chars before the character at index."
188
189 if not chars: # ''.splitlines() is [], not ['']
190 return
191 chars = chars.splitlines(True)
192 if chars[-1][-1] == '\n':
193 chars.append('')
194 line, char = self._decode(index, -1)
195 before = self.data[line][:char]
196 after = self.data[line][char:]
197 self.data[line] = before + chars[0]
198 self.data[line+1:line+1] = chars[1:]
199 self.data[line+len(chars)-1] += after
200
201 def get(self, index1, index2=None):
202 "Return slice from index1 to index2 (default is 'index1+1')."

Callers 15

_calltip_windowFunction · 0.95
_color_delegatorFunction · 0.95
_grep_dialogFunction · 0.95
_replace_dialogFunction · 0.95
_search_dialogFunction · 0.95
setUpMethod · 0.45
test_initMethod · 0.45
test_insertMethod · 0.45
test_deleteMethod · 0.45
test_recolorize_mainMethod · 0.45
_assert_highlightingMethod · 0.45

Calls 3

_decodeMethod · 0.95
splitlinesMethod · 0.45
appendMethod · 0.45

Tested by 15

setUpMethod · 0.36
test_initMethod · 0.36
test_insertMethod · 0.36
test_deleteMethod · 0.36
test_recolorize_mainMethod · 0.36
_assert_highlightingMethod · 0.36
test_removecolorsMethod · 0.36
next_testFunction · 0.36
runcaseMethod · 0.36
test_short_lineMethod · 0.36
test_long_lineMethod · 0.36