class CulebraView(gtksourceview.SourceView): def __init__(self, action_group): gtksourceview.SourceView.__init__(self) self.set_auto_indent(True) self.set_show_line_numbers(True) self.set_show_line_markers(True) self.set_tabs_width(4) self.set_margin(80) self.set_show_margin(True) self.set_smart_home_end(True) self.set_highlight_current_line(True) font_desc = pango.FontDescription('monospace 10') if font_desc is not None: self.modify_font(font_desc) self.search_bar = SearchBar(self, action_group) self.replace_bar = ReplaceBar(self, self.search_bar, action_group) action_group.get_action(ACTION_FIND_FORWARD).connect( "activate", self.on_find_forward) action_group.get_action(ACTION_FIND_BACKWARD).connect( "activate", self.on_find_backwards) def set_buffer(self, buff): self.replace_bar.set_buffer(buff) super(CulebraView, self).set_buffer(buff) def find(self, find_forward): buff = self.get_buffer() found = buff.search(find_forward=find_forward) if not found and len(buff.get_selection_bounds()) == 0: found = buff.search(find_forward=not find_forward) if not found: return mark = buff.get_insert() line_iter = buff.get_iter_at_mark(mark) self.scroll_to_iter(line_iter, 0.25) def on_find_forward(self, action): self.find(True) def on_find_backwards(self, action): self.find(False)
class CulebraView(gtksourceview.SourceView): def __init__(self, action_group): gtksourceview.SourceView.__init__(self) self.set_auto_indent(True) self.set_show_line_numbers(True) self.set_show_line_markers(True) self.set_tabs_width(4) self.set_margin(80) self.set_show_margin(True) self.set_smart_home_end(True) self.set_highlight_current_line(True) font_desc = pango.FontDescription('monospace 10') if font_desc is not None: self.modify_font(font_desc) self.search_bar = SearchBar(self, action_group) self.replace_bar = ReplaceBar(self, self.search_bar, action_group) action_group.get_action(ACTION_FIND_FORWARD).connect("activate", self.on_find_forward) action_group.get_action(ACTION_FIND_BACKWARD).connect("activate", self.on_find_backwards) def set_buffer(self, buff): self.replace_bar.set_buffer(buff) super(CulebraView, self).set_buffer(buff) def find(self, find_forward): buff = self.get_buffer() found = buff.search(find_forward=find_forward) if not found and len(buff.get_selection_bounds()) == 0: found = buff.search(find_forward=not find_forward) if not found: return mark = buff.get_insert() line_iter = buff.get_iter_at_mark(mark) self.scroll_to_iter(line_iter, 0.25) def on_find_forward(self, action): self.find(True) def on_find_backwards(self, action): self.find(False)
def __init__(self, action_group): gtksourceview.SourceView.__init__(self) self.set_auto_indent(True) self.set_show_line_numbers(True) self.set_show_line_markers(True) self.set_tabs_width(4) self.set_margin(80) self.set_show_margin(True) self.set_smart_home_end(True) self.set_highlight_current_line(True) self.set_insert_spaces_instead_of_tabs(True) font_desc = pango.FontDescription('monospace 10') if font_desc is not None: self.modify_font(font_desc) self.search_bar = SearchBar(self, action_group) self.replace_bar = ReplaceBar(self, self.search_bar, action_group) self.set_action_group(action_group) make_source_view_indentable(self)
def __init__(self): gtksourceview.SourceView.__init__(self) self.set_auto_indent(True) self.set_show_line_numbers(True) self.set_show_line_markers(True) self.set_tabs_width(4) self.set_margin(80) self.set_show_margin(True) self.set_smart_home_end(True) self.set_highlight_current_line(True) font_desc = pango.FontDescription('monospace 10') if font_desc is not None: self.modify_font(font_desc) show_find = gtk.ToggleAction("FindToggle", "Find...", "Finds a string in current document", gtk.STOCK_FIND) self.find_toggle = show_find self.find_fw = gtk.Action("FindForward", "Find next", "Finds the string forward", gtk.STOCK_FIND) self.find_bw = gtk.Action("FindBackwards", "Find back", "Finds the string backwards", gtk.STOCK_FIND) self.replace_fw = gtk.Action("ReplaceForward", "Replace next", "Replaces the string forward", gtk.STOCK_FIND_AND_REPLACE) self.replace_toggle = gtk.ToggleAction("ReplaceToggle", "Replace...", "Replaces the string forward", gtk.STOCK_FIND_AND_REPLACE) self.replace_all = gtk.Action("ReplaceAll", "Replace all", "Replaces all the occurrences", gtk.STOCK_FIND_AND_REPLACE) self.search_bar = SearchBar(self, self.find_fw, self.find_bw, show_find) actions = (self.find_toggle, self.replace_toggle, self.replace_fw, self.replace_all) self.replace_bar = ReplaceBar(self, self.search_bar, *actions) self.find_fw.connect("activate", self.on_find_forward) self.find_bw.connect("activate", self.on_find_backwards)
def __init__(self, action_group): gtksourceview.SourceView.__init__(self) self.set_auto_indent(True) self.set_show_line_numbers(True) self.set_show_line_markers(True) self.set_tabs_width(4) self.set_margin(80) self.set_show_margin(True) self.set_smart_home_end(True) self.set_highlight_current_line(True) font_desc = pango.FontDescription('monospace 10') if font_desc is not None: self.modify_font(font_desc) self.search_bar = SearchBar(self, action_group) self.replace_bar = ReplaceBar(self, self.search_bar, action_group) action_group.get_action(ACTION_FIND_FORWARD).connect( "activate", self.on_find_forward) action_group.get_action(ACTION_FIND_BACKWARD).connect( "activate", self.on_find_backwards)
def __init__(self, action_group): gtksourceview.SourceView.__init__(self) self.set_auto_indent(True) self.set_show_line_numbers(True) self.set_show_line_markers(True) self.set_tabs_width(4) self.set_margin(80) self.set_show_margin(True) self.set_smart_home_end(True) self.set_highlight_current_line(True) font_desc = pango.FontDescription('monospace 10') if font_desc is not None: self.modify_font(font_desc) self.search_bar = SearchBar(self, action_group) self.replace_bar = ReplaceBar(self, self.search_bar, action_group) action_group.get_action(ACTION_FIND_FORWARD).connect("activate", self.on_find_forward) action_group.get_action(ACTION_FIND_BACKWARD).connect("activate", self.on_find_backwards)
def __init__(self): gtksourceview.SourceView.__init__(self) self.set_auto_indent(True) self.set_show_line_numbers(True) self.set_show_line_markers(True) self.set_tabs_width(4) self.set_margin(80) self.set_show_margin(True) self.set_smart_home_end(True) self.set_highlight_current_line(True) font_desc = pango.FontDescription('monospace 10') if font_desc is not None: self.modify_font(font_desc) show_find = gtk.ToggleAction( "FindToggle", "Find...", "Finds a string in current document", gtk.STOCK_FIND ) self.find_toggle = show_find self.find_fw = gtk.Action("FindForward", "Find next", "Finds the string forward", gtk.STOCK_FIND) self.find_bw = gtk.Action("FindBackwards", "Find back", "Finds the string backwards", gtk.STOCK_FIND) self.replace_fw = gtk.Action("ReplaceForward", "Replace next", "Replaces the string forward", gtk.STOCK_FIND_AND_REPLACE) self.replace_toggle = gtk.ToggleAction("ReplaceToggle", "Replace...", "Replaces the string forward", gtk.STOCK_FIND_AND_REPLACE) self.replace_all = gtk.Action("ReplaceAll", "Replace all", "Replaces all the occurrences", gtk.STOCK_FIND_AND_REPLACE) self.search_bar = SearchBar(self, self.find_fw, self.find_bw, show_find) actions =( self.find_toggle, self.replace_toggle, self.replace_fw, self.replace_all ) self.replace_bar = ReplaceBar(self, self.search_bar, *actions) self.find_fw.connect("activate", self.on_find_forward) self.find_bw.connect("activate", self.on_find_backwards)
class CulebraView(gtksourceview.SourceView): def __init__(self): gtksourceview.SourceView.__init__(self) self.set_auto_indent(True) self.set_show_line_numbers(True) self.set_show_line_markers(True) self.set_tabs_width(4) self.set_margin(80) self.set_show_margin(True) self.set_smart_home_end(True) self.set_highlight_current_line(True) font_desc = pango.FontDescription('monospace 10') if font_desc is not None: self.modify_font(font_desc) show_find = gtk.ToggleAction( "FindToggle", "Find...", "Finds a string in current document", gtk.STOCK_FIND ) self.find_toggle = show_find self.find_fw = gtk.Action("FindForward", "Find next", "Finds the string forward", gtk.STOCK_FIND) self.find_bw = gtk.Action("FindBackwards", "Find back", "Finds the string backwards", gtk.STOCK_FIND) self.replace_fw = gtk.Action("ReplaceForward", "Replace next", "Replaces the string forward", gtk.STOCK_FIND_AND_REPLACE) self.replace_toggle = gtk.ToggleAction("ReplaceToggle", "Replace...", "Replaces the string forward", gtk.STOCK_FIND_AND_REPLACE) self.replace_all = gtk.Action("ReplaceAll", "Replace all", "Replaces all the occurrences", gtk.STOCK_FIND_AND_REPLACE) self.search_bar = SearchBar(self, self.find_fw, self.find_bw, show_find) actions =( self.find_toggle, self.replace_toggle, self.replace_fw, self.replace_all ) self.replace_bar = ReplaceBar(self, self.search_bar, *actions) self.find_fw.connect("activate", self.on_find_forward) self.find_bw.connect("activate", self.on_find_backwards) def set_buffer(self, buff): self.replace_bar.set_buffer(buff) super(CulebraView, self).set_buffer(buff) def find(self, find_forward): buff = self.get_buffer() found = buff.search(find_forward=find_forward) if not found and len(buff.get_selection_bounds()) == 0: found = buff.search(find_forward=not find_forward) if not found: return mark = buff.get_insert() line_iter = buff.get_iter_at_mark(mark) self.scroll_to_iter(line_iter, 0.25) def on_find_forward(self, action): self.find(True) def on_find_backwards(self, action): self.find(False)
class CulebraView(gtksourceview.SourceView): def __init__(self, action_group): gtksourceview.SourceView.__init__(self) self.set_auto_indent(True) self.set_show_line_numbers(True) self.set_show_line_markers(True) self.set_tabs_width(4) self.set_margin(80) self.set_show_margin(True) self.set_smart_home_end(True) self.set_highlight_current_line(True) self.set_insert_spaces_instead_of_tabs(True) font_desc = pango.FontDescription('monospace 10') if font_desc is not None: self.modify_font(font_desc) self.search_bar = SearchBar(self, action_group) self.replace_bar = ReplaceBar(self, self.search_bar, action_group) action_group.get_action(ACTION_FIND_FORWARD).connect( "activate", self.on_find_forward) action_group.get_action(ACTION_FIND_BACKWARD).connect( "activate", self.on_find_backwards) make_source_view_indentable(self) def set_background_color(self, color): self.modify_base(gtk.STATE_NORMAL, color) def set_font_color(self, color): self.modify_text(gtk.STATE_NORMAL, color) def set_buffer(self, buff): self.replace_bar.set_buffer(buff) self.search_bar.set_buffer(buff) super(CulebraView, self).set_buffer(buff) def find(self, find_forward): buff = self.get_buffer() found = buff.search(find_forward=find_forward) if not found and len(buff.get_selection_bounds()) == 0: found = buff.search(find_forward=not find_forward) if not found: return mark = buff.get_insert() line_iter = buff.get_iter_at_mark(mark) self.scroll_to_iter(line_iter, 0.25) def on_find_forward(self, action): self.find(True) def on_find_backwards(self, action): self.find(False) def on_key_pressed(self, search_text, event): global KEY_ESCAPE if event.keyval == KEY_ESCAPE: self.toggle_action.set_active(False) def get_widget(self): if self._widget is None: self._widget = self.create_widget() self._widget.connect("key-release-event", self.on_key_pressed) return self._widget widget = property(get_widget)
class CulebraView(gtksourceview.SourceView): def __init__(self): gtksourceview.SourceView.__init__(self) self.set_auto_indent(True) self.set_show_line_numbers(True) self.set_show_line_markers(True) self.set_tabs_width(4) self.set_margin(80) self.set_show_margin(True) self.set_smart_home_end(True) self.set_highlight_current_line(True) font_desc = pango.FontDescription('monospace 10') if font_desc is not None: self.modify_font(font_desc) show_find = gtk.ToggleAction("FindToggle", "Find...", "Finds a string in current document", gtk.STOCK_FIND) self.find_toggle = show_find self.find_fw = gtk.Action("FindForward", "Find next", "Finds the string forward", gtk.STOCK_FIND) self.find_bw = gtk.Action("FindBackwards", "Find back", "Finds the string backwards", gtk.STOCK_FIND) self.replace_fw = gtk.Action("ReplaceForward", "Replace next", "Replaces the string forward", gtk.STOCK_FIND_AND_REPLACE) self.replace_toggle = gtk.ToggleAction("ReplaceToggle", "Replace...", "Replaces the string forward", gtk.STOCK_FIND_AND_REPLACE) self.replace_all = gtk.Action("ReplaceAll", "Replace all", "Replaces all the occurrences", gtk.STOCK_FIND_AND_REPLACE) self.search_bar = SearchBar(self, self.find_fw, self.find_bw, show_find) actions = (self.find_toggle, self.replace_toggle, self.replace_fw, self.replace_all) self.replace_bar = ReplaceBar(self, self.search_bar, *actions) self.find_fw.connect("activate", self.on_find_forward) self.find_bw.connect("activate", self.on_find_backwards) def set_buffer(self, buff): self.replace_bar.set_buffer(buff) super(CulebraView, self).set_buffer(buff) def find(self, find_forward): buff = self.get_buffer() found = buff.search(find_forward=find_forward) if not found and len(buff.get_selection_bounds()) == 0: found = buff.search(find_forward=not find_forward) if not found: return mark = buff.get_insert() line_iter = buff.get_iter_at_mark(mark) self.scroll_to_iter(line_iter, 0.25) def on_find_forward(self, action): self.find(True) def on_find_backwards(self, action): self.find(False)
class CulebraView(gtksourceview.SourceView): def __init__(self, action_group): gtksourceview.SourceView.__init__(self) self.set_auto_indent(True) self.set_show_line_numbers(True) self.set_show_line_markers(True) self.set_tabs_width(4) self.set_margin(80) self.set_show_margin(True) self.set_smart_home_end(True) self.set_highlight_current_line(True) self.set_insert_spaces_instead_of_tabs(True) font_desc = pango.FontDescription('monospace 10') if font_desc is not None: self.modify_font(font_desc) self.search_bar = SearchBar(self, action_group) self.replace_bar = ReplaceBar(self, self.search_bar, action_group) self.set_action_group(action_group) make_source_view_indentable(self) def set_action_group(self, action_group): self.search_bar.set_action_group(action_group) self.replace_bar.set_action_group(action_group) if action_group is None: self.find_forward_source = None self.find_backward_source = None return find_forward = action_group.get_action(ACTION_FIND_FORWARD) holder = SignalHolder(find_forward, "activate", self.on_find_forward) self.find_forward_source = holder find_backward = action_group.get_action(ACTION_FIND_BACKWARD) holder = SignalHolder(find_backward, "activate", self.on_find_backwards) self.find_backward_source = holder def set_background_color(self, color): self.modify_base(gtk.STATE_NORMAL, color) def set_font_color(self, color): self.modify_text(gtk.STATE_NORMAL, color) def set_buffer(self, buff): self.replace_bar.set_buffer(buff) self.search_bar.set_buffer(buff) super(CulebraView, self).set_buffer(buff) def find(self, find_forward): buff = self.get_buffer() found = buff.search(find_forward=find_forward) if not found and len(buff.get_selection_bounds()) == 0: found = buff.search(find_forward=not find_forward) if not found: return self.focus_carret() def on_find_forward(self, action): self.find(True) def on_find_backwards(self, action): self.find(False) def _on_key_pressed(self, search_text, event): global KEY_ESCAPE if event.keyval == KEY_ESCAPE: self.toggle_action.set_active(False) def get_widget(self): if self._widget is None: self._widget = self.create_widget() self._widget.connect("key-release-event", self._on_key_pressed) return self._widget widget = property(get_widget) def focus_carret(self): buff = self.get_buffer() mark = buff.get_insert() line_iter = buff.get_iter_at_mark(mark) self.scroll_to_iter(line_iter, 0.25)