# Path: meld/misc.py
#     def select(rlist, wlist, xlist, timeout):
# def shelljoin( command ):
#     def quote(s):
# def run_dialog( text, parent=None, messagetype=gtk.MESSAGE_WARNING, buttonstype=gtk.BUTTONS_OK, extrabuttons=()):
# def open_uri(uri, timestamp=0):
# def position_menu_under_widget(menu, widget):
# def make_tool_button_widget(label):
# def gdk_to_cairo_color(color):
# def all_equal(alist):
# def shorten_names(*names):
#             def firstpart(alist):
# def read_pipe_iter(command, errorstream, yield_interval=0.1, workdir=None):
#         def __init__(self):
#         def __del__(self):
#         def __call__(self):
# def write_pipe(command, text, error=None):
# def commonprefix(dirs):
# def copy2(src, dst):
# def copytree(src, dst):
# def shell_escape(glob_pat):
# def shell_to_regex(pat):
#     class sentinel(object):
# 
# Path: meld/paths.py
# def locale_dir(*args): # i18n files
# def help_dir(*args): # help
# def share_dir(*args):
# def ui_dir(*args):
# def icon_dir(*args):


import gtk
import re
from meld import misc
from meld import paths
from . import gnomeglade
from gettext import gettext as _
            buf.insert_at_cursor( self.replace_entry.get_text() )
        buf.end_user_action()
        if not saved_insert.get_deleted():
            buf.place_cursor( buf.get_iter_at_mark(saved_insert) )
            self.textview.scroll_to_mark(buf.get_insert(), 0.25)

    def on_find_entry__changed(self, entry):
        entry.modify_base( gtk.STATE_NORMAL, self.orig_base_color )

        #
        # find/replace buffer
        #
    def _find_text(self, start_offset=1, backwards=False, wrap=True):
        match_case = self.match_case.get_active()
        whole_word = self.whole_word.get_active()
        regex = self.regex.get_active()
        assert self.textview
        buf = self.textview.get_buffer()
        insert = buf.get_iter_at_mark( buf.get_insert() )
        tofind_utf8 = self.find_entry.get_text()
        tofind = tofind_utf8.decode("utf-8") # tofind is utf-8 encoded
        start, end = buf.get_bounds()
        text = buf.get_text(start, end, False).decode("utf-8") # as is buffer
        if not regex:
            tofind = re.escape(tofind)
        if whole_word:
            tofind = r'\b' + tofind + r'\b'
        try:
            pattern = re.compile( tofind, (match_case and re.M or (re.M|re.I)) )
        except re.error as e:

# Path: meld/misc.py
#     def select(rlist, wlist, xlist, timeout):
# def shelljoin( command ):
#     def quote(s):
# def run_dialog( text, parent=None, messagetype=gtk.MESSAGE_WARNING, buttonstype=gtk.BUTTONS_OK, extrabuttons=()):
# def open_uri(uri, timestamp=0):
# def position_menu_under_widget(menu, widget):
# def make_tool_button_widget(label):
# def gdk_to_cairo_color(color):
# def all_equal(alist):
# def shorten_names(*names):
#             def firstpart(alist):
# def read_pipe_iter(command, errorstream, yield_interval=0.1, workdir=None):
#         def __init__(self):
#         def __del__(self):
#         def __call__(self):
# def write_pipe(command, text, error=None):
# def commonprefix(dirs):
# def copy2(src, dst):
# def copytree(src, dst):
# def shell_escape(glob_pat):
# def shell_to_regex(pat):
#     class sentinel(object):
# 
# Path: meld/paths.py
# def locale_dir(*args): # i18n files
# def help_dir(*args): # help
# def share_dir(*args):
# def ui_dir(*args):
# def icon_dir(*args):


# Path: meld/ui/findbar.py
import gtk
import re
from meld import misc
from meld import paths
from . import gnomeglade
from gettext import gettext as _

            buf.insert_at_cursor( self.replace_entry.get_text() )
        buf.end_user_action()
        if not saved_insert.get_deleted():
            buf.place_cursor( buf.get_iter_at_mark(saved_insert) )
            self.textview.scroll_to_mark(buf.get_insert(), 0.25)

    def on_find_entry__changed(self, entry):
        entry.modify_base( gtk.STATE_NORMAL, self.orig_base_color )

        #
        # find/replace buffer
        #
    def _find_text(self, start_offset=1, backwards=False, wrap=True):
        match_case = self.match_case.get_active()
        whole_word = self.whole_word.get_active()
        regex = self.regex.get_active()
        assert self.textview
        buf = self.textview.get_buffer()
        insert = buf.get_iter_at_mark( buf.get_insert() )
        tofind_utf8 = self.find_entry.get_text()
        tofind = tofind_utf8.decode("utf-8") # tofind is utf-8 encoded
        start, end = buf.get_bounds()
        text = buf.get_text(start, end, False).decode("utf-8") # as is buffer
        if not regex:
            tofind = re.escape(tofind)
        if whole_word:
            tofind = r'\b' + tofind + r'\b'
        try:
            pattern = re.compile( tofind, (match_case and re.M or (re.M|re.I)) )
        except re.error as e:

            misc.run_dialog( _("Regular expression error\n'%s'") % e, self, messagetype=gtk.MESSAGE_ERROR)