parameters: (stc, start, end)
docstring: Style the text
      @param stc: Styled text control instance
      @param start: Start position
      @param end: end position
docstring_summary: Style the text
      @param stc: Styled text control instance
      @param start: Start position
      @param end: end position
docstring_tokens: Style the text @param stc : Styled text control instance @param start : Start position @param end : end position
function: def StyleText(stc, start, end):
      """Style the text
      @param stc: Styled text control instance
      @param start: Start position
      @param end: end position
  
      """
      cpos = 0
      stc.StartStyling(cpos, 0x1f)
      lexer = get_lexer_by_name("html+django")
      doctxt = stc.GetTextRange(0, end)
      wineol = stc.GetEOLChar() == "\r\n"
  
      # Need to convert to UTF-8 in order to calculate
      # correct positions in STC.
      try:
          doctxt = doctxt.encode('utf-8')
      except:
          pass
  
      for token, txt in lexer.get_tokens(doctxt):
  #        print token, txt
          style = TOKEN_MAP.get(token, STC_DJANGO_DEFAULT)
          if style == STC_DJANGO_PREPROCESSOR and txt.startswith(u'#'):
              style = STC_DJANGO_COMMENT
  #        elif style == STC_DJANGO_STRING and txt[-1] not in '"\'':
  #            style = STC_DJANGO_STRINGEOL
  
          tlen = len(txt)
          if wineol and "\n" in txt:
              tlen += txt.count("\n")
  
          if tlen:
              stc.SetStyling(tlen, style)
          cpos += tlen
          stc.StartStyling(cpos, 0x1f)
function_tokens: def StyleText ( stc , start , end ) : cpos = 0 stc . StartStyling ( cpos , 0x1f ) lexer = get_lexer_by_name ( "html+django" ) doctxt = stc . GetTextRange ( 0 , end ) wineol = stc . GetEOLChar ( ) == "\r\n" # Need to convert to UTF-8 in order to calculate # correct positions in STC. try : doctxt = doctxt . encode ( 'utf-8' ) except : pass for token , txt in lexer . get_tokens ( doctxt ) : #        print token, txt style = TOKEN_MAP . get ( token , STC_DJANGO_DEFAULT ) if style == STC_DJANGO_PREPROCESSOR and txt . startswith ( u'#' ) : style = STC_DJANGO_COMMENT #        elif style == STC_DJANGO_STRING and txt[-1] not in '"\'': #            style = STC_DJANGO_STRINGEOL tlen = len ( txt ) if wineol and "\n" in txt : tlen += txt . count ( "\n" ) if tlen : stc . SetStyling ( tlen , style ) cpos += tlen stc . StartStyling ( cpos , 0x1f )