# Path: keyword_highlighter.py
# def allindices(string, sub, listindex=[], offset=0):
#   def __init__(self, parent = None):
#   def highlightBlock(self, text):
#   def add_keyword(self, word):
#   def add_keywords(self, words):
#   def set_keyword(self, word):
#   def set_keywords(self, words):
#   def clear_keywords(self):
# class KeywordHighlighter(QtGui.QSyntaxHighlighter):


from PyQt4 import Qt, QtGui, QtCore
from PyQt4.QtCore import QRect, QSignalMapper
from PyQt4.QtGui import QTextCursor, QApplication
from keyword_highlighter import KeywordHighlighter, Keyword
  import cPickle as pickle
  import pickle
import terminology
import time
    
    match_start = 0
    match_len   = 0
    
    matches     = 0
    
    #for word in self.highlighter.matches[line]:
      #if col >= word[1] and col < word[2]:
    for word in self.words_at_pos(line, col):
      keyword     = word[0]
      
      # Go for the smallest region possible so we can update
      # as soon as the mouse falls out of range of one of the words.
      if word[1] > match_start:
        match_start = word[1]
      
      if word[2] - word[1] < match_len:
        match_len = word[2] - word[1]
      
      if matches > 0:
        tooltip += u"\n"
      
      if not keyword.section == "":
        tooltip += u"【%s】 " % keyword.section
      
      tooltip += u"%s ― %s" % (keyword.word, keyword.meaning)
      
      matches += 1
    
    # Highlight our word, so we can get the rect.

# Path: keyword_highlighter.py
# def allindices(string, sub, listindex=[], offset=0):
#   def __init__(self, parent = None):
#   def highlightBlock(self, text):
#   def add_keyword(self, word):
#   def add_keywords(self, words):
#   def set_keyword(self, word):
#   def set_keywords(self, words):
#   def clear_keywords(self):
# class KeywordHighlighter(QtGui.QSyntaxHighlighter):


# Path: keywordedit.py
from PyQt4 import Qt, QtGui, QtCore
from PyQt4.QtCore import QRect, QSignalMapper
from PyQt4.QtGui import QTextCursor, QApplication
from keyword_highlighter import KeywordHighlighter, Keyword
  import cPickle as pickle
  import pickle
import terminology
import time

    
    match_start = 0
    match_len   = 0
    
    matches     = 0
    
    #for word in self.highlighter.matches[line]:
      #if col >= word[1] and col < word[2]:
    for word in self.words_at_pos(line, col):
      keyword     = word[0]
      
      # Go for the smallest region possible so we can update
      # as soon as the mouse falls out of range of one of the words.
      if word[1] > match_start:
        match_start = word[1]
      
      if word[2] - word[1] < match_len:
        match_len = word[2] - word[1]
      
      if matches > 0:
        tooltip += u"\n"
      
      if not keyword.section == "":
        tooltip += u"【%s】 " % keyword.section
      
      tooltip += u"%s ― %s" % (keyword.word, keyword.meaning)
      
      matches += 1
    
    # Highlight our word, so we can get the rect.

    cursor.movePosition(QTextCursor.Start)