def replace_in_range(self, rng, text):
        """
        Replace the text in the given range
        :param rng: range to replace (start, length)
        :type rng: tuple of (int, int)
        :param text: text to insert
        :type text: iterable of str or ShChar
        """
        rstart, length = rng
        start, end = self._rel_cursor_pos_to_abs_pos(rstart), self._rel_cursor_pos_to_abs_pos(rstart + length)
        tkstart, tkend = self._tuple_to_tk_index(start), self._tuple_to_tk_index(end)
        saved = self.selected_range
        self._txt.delete(tkstart, tkend)
        cp = rstart
        for c in text:
            a = 1
            ctkp = self._tuple_to_tk_index(self._rel_cursor_pos_to_abs_pos(cp))
            if isinstance(c, (six.binary_type, six.text_type)):
                self._txt.insert(ctkp, c)
            elif isinstance(c, ShChar):
                if not self._colors_initialized:
                    self._add_color_tags()
                ch = c.data
                if c.strikethrough:
                    ch = u"\u0336" + ch
                    a += 1
                self._txt.insert(ctkp, ch, self._tag_for_char(c))
            else:
                raise TypeError("Unknown character type {!r}!".format(type(c)))
            cp += a
        self.selected_range = saved  # restore cursor position

        Replace the text in the given range
        :param rng: range to replace (start, length)
        :type rng: tuple of (int, int)
        :param text: text to insert
        :type text: iterable of str or ShChar
        
system/shui/tkui.py