# Path: meld/util/sourceviewer.py
# class _srcviewer(object):
# class _gtksourceview2(_srcviewer):
# class gtksourceview24(_gtksourceview2):
#         class SourceView(viewClass):
# class gtksourceview210(_gtksourceview2):
# class nullsourceview(_srcviewer):
#         class NullTextView(gtk.TextView):
# class MeldSourceView(srcviewer.GtkTextView):
#     def __init__(self):
#     def version_check(self):
#     def overrides(self):
#     def GtkLanguageManager(self):
#     def set_highlight_syntax(self, buf, enabled):
#     def set_tab_width(self, tab, tab_size):
#     def get_language_from_file(self, filename):
#     def get_language_from_mime_type(self, mimetype):
#     def get_language_manager(self):
#     def set_language(self, buf, lang):
#     def version_check(self):
#     def overrides(self):
#     def GtkLanguageManager(self):
#     def set_tab_width(self, tab, tab_size):
#     def set_highlight_syntax(self, buf, enabled):
#     def get_language_from_file(self, filename):
#     def get_language_from_mime_type(self, mime_type):
#     def set_language(self, buf, lang):
#     def version_check(self):
#     def overrides(self):
#             def do_key_press_event(self, event):
#     def version_check(self):
#     def overrides(self):
#     def overrides(self):
#     def version_check(self):
# def _get_srcviewer():
#     def get_y_for_line_num(self, line):
#     def get_line_num_for_y(self, y):
# 
# Path: meld/util/compat.py



import sys
from gettext import gettext as _
from .util import sourceviewer
from .util.compat import text_type
    label = property(get_label, set_label)


class BufferLines(object):
    """gtk.TextBuffer shim with line-based access and optional filtering

    This class allows a gtk.TextBuffer to be treated as a list of lines of
    possibly-filtered text. If no filter is given, the raw output from the
    gtk.TextBuffer is used.

    The logic here (and in places in FileDiff) requires that Python's
    unicode splitlines() implementation and gtk.TextBuffer agree on where
    linebreaks occur. Happily, this is usually the case.
    """

    def __init__(self, buf, textfilter=None):
        self.buf = buf
        if textfilter is not None:
            self.textfilter = textfilter
        else:
            self.textfilter = lambda x: x

    def __getitem__(self, key):
        if isinstance(key, slice):
            lo, hi, _ = key.indices(self.buf.get_line_count())

            # FIXME: If we ask for arbitrary slices past the end of the buffer,
            # this will return the last line.
            start = self.buf.get_iter_at_line_or_eof(lo)
            end = self.buf.get_iter_at_line_or_eof(hi)

# Path: meld/util/sourceviewer.py
# class _srcviewer(object):
# class _gtksourceview2(_srcviewer):
# class gtksourceview24(_gtksourceview2):
#         class SourceView(viewClass):
# class gtksourceview210(_gtksourceview2):
# class nullsourceview(_srcviewer):
#         class NullTextView(gtk.TextView):
# class MeldSourceView(srcviewer.GtkTextView):
#     def __init__(self):
#     def version_check(self):
#     def overrides(self):
#     def GtkLanguageManager(self):
#     def set_highlight_syntax(self, buf, enabled):
#     def set_tab_width(self, tab, tab_size):
#     def get_language_from_file(self, filename):
#     def get_language_from_mime_type(self, mimetype):
#     def get_language_manager(self):
#     def set_language(self, buf, lang):
#     def version_check(self):
#     def overrides(self):
#     def GtkLanguageManager(self):
#     def set_tab_width(self, tab, tab_size):
#     def set_highlight_syntax(self, buf, enabled):
#     def get_language_from_file(self, filename):
#     def get_language_from_mime_type(self, mime_type):
#     def set_language(self, buf, lang):
#     def version_check(self):
#     def overrides(self):
#             def do_key_press_event(self, event):
#     def version_check(self):
#     def overrides(self):
#     def overrides(self):
#     def version_check(self):
# def _get_srcviewer():
#     def get_y_for_line_num(self, line):
#     def get_line_num_for_y(self, y):
# 
# Path: meld/util/compat.py



# Path: meld/meldbuffer.py
import sys
from gettext import gettext as _
from .util import sourceviewer
from .util.compat import text_type

    label = property(get_label, set_label)


class BufferLines(object):
    """gtk.TextBuffer shim with line-based access and optional filtering

    This class allows a gtk.TextBuffer to be treated as a list of lines of
    possibly-filtered text. If no filter is given, the raw output from the
    gtk.TextBuffer is used.

    The logic here (and in places in FileDiff) requires that Python's
    unicode splitlines() implementation and gtk.TextBuffer agree on where
    linebreaks occur. Happily, this is usually the case.
    """

    def __init__(self, buf, textfilter=None):
        self.buf = buf
        if textfilter is not None:
            self.textfilter = textfilter
        else:
            self.textfilter = lambda x: x

    def __getitem__(self, key):
        if isinstance(key, slice):
            lo, hi, _ = key.indices(self.buf.get_line_count())

            # FIXME: If we ask for arbitrary slices past the end of the buffer,
            # this will return the last line.
            start = self.buf.get_iter_at_line_or_eof(lo)
            end = self.buf.get_iter_at_line_or_eof(hi)

            txt = text_type(self.buf.get_text(start, end, False), 'utf8')