# Path: meld/matchers.py
# def init_worker():
# def matcher_worker(text1, textn):
# def find_common_prefix(a, b):
# def find_common_suffix(a, b):
#     def __init__(self, isjunk=None, a="", b=""):
#     def get_matching_blocks(self):
#     def get_opcodes(self):
#     def get_difference_opcodes(self):
#     def preprocess_remove_prefix_suffix(self, a, b):
#     def preprocess_discard_nonmatching_lines(self, a, b):
#         def index_matching(a, b):
#     def preprocess(self):
#     def postprocess(self):
#     def build_matching_blocks(self, lastsnake):
#     def initialise(self):
#     def preprocess_discard_nonmatching_lines(self, a, b):
#         def index_matching_kmers(a, b):
#     def __init__(self, isjunk=None, a="", b="", syncpoints=None):
#     def initialise(self):
# class MyersSequenceMatcher(difflib.SequenceMatcher):
# class InlineMyersSequenceMatcher(MyersSequenceMatcher):
# class SyncPointMyersSequenceMatcher(MyersSequenceMatcher):


import gobject
from .matchers import DiffChunk, MyersSequenceMatcher, \
    SyncPointMyersSequenceMatcher

    def _find_blank_lines(txt, lo, hi):
        while lo < hi and not txt[lo]:
            lo += 1
        while lo < hi and not txt[hi - 1]:
            hi -= 1
        return lo, hi

    tag = chunk.tag
    c1, c2 = _find_blank_lines(texts[pane1], chunk[1], chunk[2])
    c3, c4 = _find_blank_lines(texts[pane2], chunk[3], chunk[4])

    if c1 == c2 and c3 == c4:
        return None
    if c1 == c2 and tag == "replace":
        tag = "insert"
    elif c3 == c4 and tag == "replace":
        tag = "delete"
    return DiffChunk._make((tag, c1, c2, c3, c4))


class Differ(gobject.GObject):
    """Utility class to hold diff2 or diff3 chunks"""

    __gsignals__ = {
        'diffs-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
                                                    (object,)),
    }

    _matcher = MyersSequenceMatcher

# Path: meld/matchers.py
# def init_worker():
# def matcher_worker(text1, textn):
# def find_common_prefix(a, b):
# def find_common_suffix(a, b):
#     def __init__(self, isjunk=None, a="", b=""):
#     def get_matching_blocks(self):
#     def get_opcodes(self):
#     def get_difference_opcodes(self):
#     def preprocess_remove_prefix_suffix(self, a, b):
#     def preprocess_discard_nonmatching_lines(self, a, b):
#         def index_matching(a, b):
#     def preprocess(self):
#     def postprocess(self):
#     def build_matching_blocks(self, lastsnake):
#     def initialise(self):
#     def preprocess_discard_nonmatching_lines(self, a, b):
#         def index_matching_kmers(a, b):
#     def __init__(self, isjunk=None, a="", b="", syncpoints=None):
#     def initialise(self):
# class MyersSequenceMatcher(difflib.SequenceMatcher):
# class InlineMyersSequenceMatcher(MyersSequenceMatcher):
# class SyncPointMyersSequenceMatcher(MyersSequenceMatcher):


# Path: meld/diffutil.py
import gobject
from .matchers import DiffChunk, MyersSequenceMatcher, \
    SyncPointMyersSequenceMatcher


    def _find_blank_lines(txt, lo, hi):
        while lo < hi and not txt[lo]:
            lo += 1
        while lo < hi and not txt[hi - 1]:
            hi -= 1
        return lo, hi

    tag = chunk.tag
    c1, c2 = _find_blank_lines(texts[pane1], chunk[1], chunk[2])
    c3, c4 = _find_blank_lines(texts[pane2], chunk[3], chunk[4])

    if c1 == c2 and c3 == c4:
        return None
    if c1 == c2 and tag == "replace":
        tag = "insert"
    elif c3 == c4 and tag == "replace":
        tag = "delete"
    return DiffChunk._make((tag, c1, c2, c3, c4))


class Differ(gobject.GObject):
    """Utility class to hold diff2 or diff3 chunks"""

    __gsignals__ = {
        'diffs-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
                                                    (object,)),
    }

    _matcher = MyersSequenceMatcher

    _sync_matcher = SyncPointMyersSequenceMatcher