# Path: terminology.py
# class Term():
#   def __init__(self, word = "", meaning = "", section = ""):
#     self.word    = word
#     self.meaning = meaning
#     self.section = section


from PyQt4 import QtGui, QtCore
from PyQt4.QtGui import QTextCharFormat, QColor
from terminology import Term as Keyword
import re
import common
### If not, see <http://www.gnu.org/licenses/>.
################################################################################



# lol

def allindices(string, sub, listindex=[], offset=0):
  i = string.find(sub, offset)
  while i >= 0:
    listindex.append(i)
    i = string.find(sub, i + 1)
  return listindex

class KeywordHighlighter(QtGui.QSyntaxHighlighter):
  def __init__(self, parent = None):
    super(KeywordHighlighter, self).__init__(parent)
    
    self.format = QTextCharFormat()
    self.format.setForeground(QColor(255, 0, 0))
    
    self.keywords = []
    self.matches  = []
    
    self.re_flags = re.IGNORECASE | re.UNICODE
  
  def highlightBlock(self, text):
    
    # If there is no previous state, then it's -1, which makes the first line 0.
    # And every line after that increases as expected.

# Path: terminology.py
# class Term():
#   def __init__(self, word = "", meaning = "", section = ""):
#     self.word    = word
#     self.meaning = meaning
#     self.section = section


# Path: keyword_highlighter.py
from PyQt4 import QtGui, QtCore
from PyQt4.QtGui import QTextCharFormat, QColor
from terminology import Term as Keyword
import re
import common

### If not, see <http://www.gnu.org/licenses/>.
################################################################################



# lol

def allindices(string, sub, listindex=[], offset=0):
  i = string.find(sub, offset)
  while i >= 0:
    listindex.append(i)
    i = string.find(sub, i + 1)
  return listindex

class KeywordHighlighter(QtGui.QSyntaxHighlighter):
  def __init__(self, parent = None):
    super(KeywordHighlighter, self).__init__(parent)
    
    self.format = QTextCharFormat()
    self.format.setForeground(QColor(255, 0, 0))
    
    self.keywords = []
    self.matches  = []
    
    self.re_flags = re.IGNORECASE | re.UNICODE
  
  def highlightBlock(self, text):
    
    # If there is no previous state, then it's -1, which makes the first line 0.
    # And every line after that increases as expected.

    line = self.previousBlockState() + 1