Skip to content
Browse files

Updated advancedfind to 3.3.7

  • Loading branch information...
1 parent 1650b71 commit 78c488deaa90b5c461cfd1f97674d77ffb4ce8fd @nengxu committed Feb 27, 2012
View
6 plugins3/advancedfind/__init__.py
@@ -1,12 +1,12 @@
# -*- encoding:utf-8 -*-
-# __init__.py
+# __init__.py is part of advancedfind-gedit
#
#
-# Copyright 2010 swatch
+# Copyright 2010-2012 swatch
#
-# This program is free software; you can redistribute it and/or modify
+# advancedfind-gedit is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
View
39 plugins3/advancedfind/advancedfind.py
@@ -1,12 +1,12 @@
# -*- encoding:utf-8 -*-
-# findadvance.py
+# advancedfind.py is part of advancedfind-gedit.
#
#
-# Copyright 2010 swatch
+# Copyright 2010-2012 swatch
#
-# This program is free software; you can redistribute it and/or modify
+# advancedfind-gedit is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@@ -98,7 +98,11 @@ def __init__(self, plugin, window):
self.result_highlight_tag.set_property('style', pango.STYLE_ITALIC)
#'''
- configfile = os.path.join(os.path.dirname(__file__), "config.xml")
+ user_configfile = os.path.join(os.path.expanduser('~/.local/share/gedit/plugins/' + APP_NAME), 'config.xml')
+ if os.path.exists(user_configfile):
+ configfile = user_configfile
+ else:
+ configfile = os.path.join(os.path.dirname(__file__), "config.xml")
self.config_manager = config_manager.ConfigManager(configfile)
self.find_options = self.config_manager.load_configure('FindOption')
self.config_manager.to_bool(self.find_options)
@@ -155,7 +159,7 @@ def deactivate(self):
self.replace_history = None
self.file_type_history = None
self.file_path_history = None
- self._result_view = None
+ self._results_view = None
'''
self.config_manager.update_config_file(self.config_manager.config_file, 'search_option', self.find_options)
@@ -483,25 +487,36 @@ def advanced_find_all_in_doc(self, parent_it, doc, search_pattern, find_options,
self._results_view.append_find_result(tree_it, str(line_num+1), line_text, result[0], result[1], "", line_start_pos, True)
self.result_highlight_on(tree_it)
-
+
+ '''
def check_file_pattern(self, path, pattern_text):
pattern_list = re.split('\s*\|\s*', pattern_text)
#print os.path.basename(path).strip()
for pattern in pattern_list:
if fnmatch.fnmatch(os.path.basename(path).strip(), pattern):
return True
return False
+ #'''
def find_all_in_dir(self, parent_it, dir_path, file_pattern, search_pattern, find_options, replace_flg = False):
#start_time = time.time()
if search_pattern == "":
return
-
+
#d_list = []
file_list = []
grep_cmd = ['grep', '-l']
+ if find_options['MATCH_WHOLE_WORD'] == True:
+ grep_cmd.append('-w')
+ if find_options['MATCH_CASE'] == False:
+ grep_cmd.append('-i')
if find_options['INCLUDE_SUBFOLDER'] == True:
grep_cmd.append('-R')
+
+ pattern_list = re.split('\s*\|\s*', file_pattern)
+ for f_pattern in pattern_list:
+ grep_cmd.append('--include=' + f_pattern)
+
if find_options['REGEX_SEARCH'] == True:
grep_cmd = grep_cmd + ['-E', search_pattern, dir_path]
else:
@@ -518,8 +533,12 @@ def find_all_in_dir(self, parent_it, dir_path, file_pattern, search_pattern, fin
output = p2.communicate()[0]
if output:
continue
+ file_list.append(f[:-1])
+ '''
if self.check_file_pattern(f, unicode(file_pattern, 'utf-8')):
file_list.append(f[:-1])
+ #'''
+
'''
for root, dirs, files in os.walk(unicode(dir_path, 'utf-8')):
@@ -584,10 +603,16 @@ def result_highlight_on(self, file_it):
doc.apply_tag_by_name('result_highlight', doc.get_iter_at_offset(result_start), doc.get_iter_at_offset(result_start + result_len))
def result_highlight_off(self, doc):
+ if doc.get_tag_table().lookup('result_highlight'):
+ start, end = doc.get_bounds()
+ doc.remove_tag_by_name('result_highlight', start, end)
+
+ '''
start, end = doc.get_bounds()
if doc.get_tag_table().lookup('result_highlight') == None:
tag = doc.create_tag("result_highlight", foreground=self.result_highlight['FOREGROUND_COLOR'], background=self.result_highlight['BACKGROUND_COLOR'])
doc.remove_tag_by_name('result_highlight', start, end)
+ #'''
def show_bottom_panel(self):
panel = self._window.get_bottom_panel()
View
6 plugins3/advancedfind/advancedfind_ui.py
@@ -1,12 +1,12 @@
# -*- encoding:utf-8 -*-
-# findadvance_ui.py
+# advancedfind_ui.py is part of advancedfind-gedit.
#
#
-# Copyright 2010 swatch
+# Copyright 2010-2012 swatch
#
-# This program is free software; you can redistribute it and/or modify
+# advancedfind-gedit is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
View
6 plugins3/advancedfind/config_manager.py
@@ -1,12 +1,12 @@
# -*- encoding:utf-8 -*-
-# config_manager.py
+# config_manager.py is part of advancedfind-gedit
#
#
-# Copyright 2010 swatch
+# Copyright 2010-2012 swatch
#
-# This program is free software; you can redistribute it and/or modify
+# advancedfind-gedit is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
View
6 plugins3/advancedfind/config_ui.py
@@ -1,12 +1,12 @@
# -*- encoding:utf-8 -*-
-# config_ui.py
+# config_ui.py is part of advancedfind-gedit.
#
#
-# Copyright 2010 swatch
+# Copyright 2010-2012 swatch
#
-# This program is free software; you can redistribute it and/or modify
+# advancedfind-gedit is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
View
18 plugins3/advancedfind/find_result.py
@@ -1,12 +1,12 @@
# -*- encoding:utf-8 -*-
-# find_result.py
+# find_result.py is part of advancedfind-gedit.
#
#
-# Copyright 2010 swatch
+# Copyright 2010-2012 swatch
#
-# This program is free software; you can redistribute it and/or modify
+# advancedfind-gedit is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@@ -188,7 +188,11 @@ def __init__(self, window, show_button_option):
self.show_buttons()
- format_file = os.path.join(os.path.dirname(__file__), "result_format.xml")
+ user_formatfile = os.path.join(os.path.expanduser('~/.local/share/gedit/plugins/' + APP_NAME), 'result_format.xml')
+ if os.path.exists(user_formatfile):
+ format_file = user_formatfile
+ else:
+ format_file = os.path.join(os.path.dirname(__file__), "result_format.xml")
self.result_format = config_manager.ConfigManager(format_file).load_configure('result_format')
def do_events(self):
@@ -224,8 +228,6 @@ def on_findResultTreeview_cursor_changed_action(self, object):
parent_it = model.iter_parent(it)
if parent_it:
- #uri = urllib.quote(model.get_value(parent_it, 6).encode('utf-8')).replace('%3A//', '://')
- #uri = urllib.quote(model.get_value(parent_it, 6)).replace('%3A//', '://')
uri = model.get_value(parent_it, 6)
tab = model.get_value(parent_it, 3)
else:
@@ -240,8 +242,8 @@ def on_findResultTreeview_cursor_changed_action(self, object):
# Still nothing? Open the file then
if not tab:
- #tab = self._window.create_tab_from_uri(uri, None, line_num, False, False)
- if not uri.startswith('smb://'):
+ m = re.search('[a-zA-Z0-9]+\:\/\/.+', uri)
+ if m == None:
tab = self._window.create_tab_from_location(Gio.file_new_for_uri('file://' + uri), None, line_num, 0, False, False)
else:
tab = self._window.create_tab_from_location(Gio.file_new_for_uri(uri), None, line_num, 0, False, False)
View
0 plugins3/advancedfind/result_format.xml 100644 → 100755
File mode changed.

0 comments on commit 78c488d

Please sign in to comment.
Something went wrong with that request. Please try again.