def keypress_enter(): if TixMode.current == TixMode.LIST and len(self.stored_items) > 0: curses_view.end_curses() note_before = self.stored_items.get_visible(Control.list_visible_index) note_after = note_before.edit() curses_view.init_curses() if note_before.text != note_after.text: Control.reload_notes = True Control.list_visible_index = 0 h = History(note_after.fullpath()) Control.file_history.append(h) h.append_to_file(utils.get_file_history_path()) else: Control.reload_notes = False elif TixMode.current == TixMode.TAGS: Control.reload_notes = False TixMode.current = TixMode.LIST if UserMode.current == Control.tags_visible_index: return else: UserMode.current = Control.tags_visible_index Control.list_visible_index = 0 list_modes = self.stored_items.modes() for note in self.stored_items: if list_modes[UserMode.current] == UserMode.ALL or list_modes[UserMode.current] in note.modes: note.visible(True) elif list_modes[UserMode.current] == UserMode.NOTAG and not note.modes: note.visible(True) else: note.visible(False)
def event_save(self, widget, event, data=None): if TixMode.current == TixMode.EDIT: if event.state == gtk.gdk.CONTROL_MASK: Control.reload_notes = True n = self.editor.save() self.status_bar.update('"%s"' % n.fullpath()) h = History(n.fullpath()) Control.file_history.append(h) h.append_to_file(utils.get_file_history_path())
def event_save(self, widget, event, data=None): if TixMode.current == TixMode.EDIT: if event.state == gtk.gdk.CONTROL_MASK: Control.reload_notes = True n = self.editor.save() self.status_bar.update('"%s"' % n.fullpath()) h = History(n.fullpath()) Control.file_history.append(h) h.append_to_file(utils.get_file_history_path())
def event_execute_command(self, widget, event, data=None): regex = self.commandline.get_text() if len(regex) > 0: # Notice we're not striping '#' if regex[0] in ('/', '?'): regex = regex[1:] #if regex.strip(): h = History("/" + regex) h.append_to_file(utils.get_search_history_path()) Control.regex_patterns.append(h) Control.current_regex_index = len(Control.regex_patterns) nbr_visible = self.stored_items.filter() if nbr_visible == 1: curr_note = self.stored_items.get_visible(0) self.show_note_in_edit_mode(curr_note) else: # repopulate tree_view: self.vbox.remove(self.tree_view.get_parent()) self.create_list() Control.reload_notes = False self.event_switch_to_list_view(None, None) self.tree_view.grab_focus()
def event_execute_command(self, widget, event, data=None): regex = self.commandline.get_text() if len(regex) > 0: # Notice we're not striping '#' if regex[0] in ('/', '?'): regex = regex[1:] #if regex.strip(): h = History("/" + regex) h.append_to_file(utils.get_search_history_path()) Control.regex_patterns.append(h) Control.current_regex_index = len(Control.regex_patterns) nbr_visible = self.stored_items.filter() if nbr_visible == 1: curr_note = self.stored_items.get_visible(0) self.show_note_in_edit_mode(curr_note) else: # repopulate tree_view: self.vbox.remove(self.tree_view.get_parent()) self.create_list() Control.reload_notes = False self.event_switch_to_list_view(None, None) self.tree_view.grab_focus()
def pressed_slash(): Control.reload_notes = False if TixMode.current == TixMode.LIST: Control.reload_thread_lock.acquire() def validator(c): if c == 27: # ctrl A >then> ctrl K # regex = None return 7 elif c == 10: return 7 # RETURN key -- CTRL-g = 7 and CTRL-j = 10 else: curses_view.search_textbox.do_command(c) if c == curses.KEY_UP and Control.current_regex_index > 0: Control.current_regex_index -= 1 curses_view.footer_pad.clear() CursesView.add_str(curses_view.footer_pad, Control.regex_patterns[Control.current_regex_index].value) elif c == curses.KEY_DOWN and Control.current_regex_index < len(Control.regex_patterns) - 1: Control.current_regex_index += 1 curses_view.footer_pad.clear() CursesView.add_str(curses_view.footer_pad, Control.regex_patterns[Control.current_regex_index].value) elif c == curses.KEY_DOWN and Control.current_regex_index == len(Control.regex_patterns) - 1: Control.current_regex_index += 1 curses_view.footer_pad.clear() CursesView.add_str(curses_view.footer_pad, curses_view.search_prompt) if curses_view.search_textbox.gather() is '': return 7 regex = "" try: curses.curs_set(1) except curses.error: # iphone pass Control.current_regex_index = len(Control.regex_patterns) curses_view.footer_pad.clear() CursesView.add_str(curses_view.footer_pad, curses_view.search_prompt) self.is_searching = True regex = curses_view.search_textbox.edit(validator) self.is_searching = False try: curses.curs_set(0) except curses.error: # iphone pass if regex != None: regex = regex[len(curses_view.search_prompt):] if regex.strip(): h = History(curses_view.search_prompt + regex) h.append_to_file(utils.get_search_history_path()) Control.regex_patterns.append(h) Control.list_visible_index = 0 curses_view.adjust_scroll(len(self.stored_items)) list_modes = self.stored_items.modes() current_mode = list_modes[UserMode.current] for note in self.stored_items: if note.is_search_match(regex): if (current_mode == UserMode.ALL or current_mode in note.modes): note.visible(True) elif (current_mode == UserMode.NOTAG and not note.modes): note.visible(True) else: note.visible(False) Control.reload_thread_lock.release()