'Generate a list of text chunks of the given language content.
For a single-language buffer this is trivial: 1 chunk of the whole
buffer. For multi-language buffers, less so.
Generates 2-tuples:
(POSITION-OFFSET, TEXT-CHUNK)'

def text_chunks_from_lang(self, lang):

    udl_family_from_lang = self.udl_family_from_lang
    if (len(udl_family_from_lang) == 1):
        (yield (0, self.accessor.text))
    elif (lang not in udl_family_from_lang):
        pass
    elif hasattr(self.accessor, 'udl_family_chunk_ranges'):
        udl_family = self.udl_family_from_lang[lang]
        text = self.accessor.text
        for (u, start, end) in self.accessor.udl_family_chunk_ranges:
            if (u == udl_family):
                (yield (start, text[start:end]))
    else:
        (min_style, max_style) = {self.m_lang: (ScintillaConstants.SCE_UDL_M_DEFAULT, ScintillaConstants.SCE_UDL_M_COMMENT), self.css_lang: (ScintillaConstants.SCE_UDL_CSS_DEFAULT, ScintillaConstants.SCE_UDL_CSS_OPERATOR), self.csl_lang: (ScintillaConstants.SCE_UDL_CSL_DEFAULT, ScintillaConstants.SCE_UDL_CSL_REGEX), self.ssl_lang: (ScintillaConstants.SCE_UDL_SSL_DEFAULT, ScintillaConstants.SCE_UDL_SSL_VARIABLE), self.tpl_lang: (ScintillaConstants.SCE_UDL_TPL_DEFAULT, ScintillaConstants.SCE_UDL_TPL_VARIABLE)}[lang]
        in_chunk = False
        pos_offset = None
        text = self.accessor.text
        for token in self.accessor.gen_tokens():
            if in_chunk:
                if (not (min_style <= token['style'] <= max_style)):
                    end_index = (token['end_index'] + 1)
                    (yield (pos_offset, text[pos_offset:end_index]))
                    in_chunk = False
            elif (min_style <= token['style'] <= max_style):
                in_chunk = True
                pos_offset = token['start_index']
        if in_chunk:
            (yield (pos_offset, text[pos_offset:]))
