Esempio n. 1
0
    def _base_findit(self, do_find, optionals, get_kwds):
        self._check_project()
        self._save_buffers()
        resource, offset = self._get_location()

        action, values = dialog.show_dialog(
            lisputils.askdata, ['search', 'cancel'], optionals=optionals)
        if action == 'search':
            kwds = get_kwds(values)
            def calculate(handle):
                resources = refactor._resources(self.project,
                                                values.get('resources'))
                return do_find(self.project, resource, offset,
                               resources=resources, task_handle=handle, **kwds)
            result = lisputils.runtask(calculate, 'Find Occurrences')
            text = []
            for occurrence in result:
                line = '%s : %s' % (occurrence.resource.path, occurrence.offset)
                if occurrence.unsure:
                    line += ' ?'
                text.append(line)
            text = '\n'.join(text) + '\n'
            buffer = lisputils.make_buffer('*rope-occurrences*',
                                           text, switch=True)
            lisp.set_buffer(buffer)
            lisp.local_set_key('\r', lisp.rope_occurrences_goto_occurrence)
            lisp.local_set_key('q', lisp.rope_occurrences_quit)
Esempio n. 2
0
 def show_occurrences(self, locations):
     text = []
     for location in locations:
         line = '%s : %s   %s %s' % (location.filename, location.lineno,
                                     location.note, location.offset)
         text.append(line)
     text = '\n'.join(text) + '\n'
     buffer = self._make_buffer('*rope-occurrences*', text, switch=True)
     lisp.set_buffer(buffer)
     lisp.local_set_key('\r', lisp.rope_occurrences_goto_occurrence)
     lisp.local_set_key('q', lisp.delete_window)
Esempio n. 3
0
 def show_doc(self, docs, altview=False):
     use_minibuffer = not altview
     if self.get('separate_doc_buffer'):
         use_minibuffer = not use_minibuffer
     if not use_minibuffer:
         fit_lines = self.get('max_doc_buffer_height')
         buffer = self._make_buffer('*rope-pydoc*', docs,
                                    empty_goto=False,
                                    fit_lines=fit_lines)
         lisp.local_set_key('q', lisp.bury_buffer)
     elif docs:
         docs = '\n'.join(docs.split('\n')[:7])
         self.message(docs)
Esempio n. 4
0
 def show_occurrences(self, locations):
     text = ['List of occurrences:', '']
     for location in locations:
         line = '%s : %s   %s %s' % (location.filename, location.lineno,
                                     location.note, location.offset)
         text.append(line)
     text = '\n'.join(text) + '\n'
     buffer = self._make_buffer('*rope-occurrences*', text, switch=False)
     lisp.set_buffer(buffer)
     lisp.toggle_read_only(1)
     lisp.set(lisp["next-error-function"], lisp.rope_occurrences_next)
     lisp.local_set_key('\r', lisp.rope_occurrences_goto)
     lisp.local_set_key('q', lisp.delete_window)
Esempio n. 5
0
 def show_occurrences(self, locations):
     text = ['List of occurrences:', '']
     for location in locations:
         line = '%s : %s   %s %s' % (location.filename, location.lineno,
                                     location.note, location.offset)
         text.append(line)
     text = '\n'.join(text) + '\n'
     buffer = self._make_buffer('*rope-occurrences*', text, switch=False)
     lisp.set_buffer(buffer)
     lisp.toggle_read_only(1)
     lisp.set(lisp["next-error-function"], lisp.rope_occurrences_next)
     lisp.local_set_key('\r', lisp.rope_occurrences_goto)
     lisp.local_set_key('q', lisp.delete_window)
Esempio n. 6
0
 def show_doc(self, docs, altview=False):
     use_minibuffer = not altview
     if self.get('separate_doc_buffer'):
         use_minibuffer = not use_minibuffer
     if not use_minibuffer:
         fit_lines = self.get('max_doc_buffer_height')
         buffer = self._make_buffer('*rope-pydoc*', docs,
                                    empty_goto=False,
                                    fit_lines=fit_lines)
         lisp.local_set_key('q', lisp.bury_buffer)
     elif docs:
         docs = '\n'.join(docs.split('\n')[:7])
         self.message(docs)
Esempio n. 7
0
    def _base_show_doc(self, prefix, get_doc):
        maxfixes = lisp['ropemacs-codeassist-maxfixes'].value()
        text = self._get_text()
        offset = self._get_offset()
        docs = get_doc(self.project, text, offset,
                       self._get_resource(), maxfixes)

        use_minibuffer = not prefix
        if lisp['ropemacs-separate-doc-buffer'].value():
            use_minibuffer = not use_minibuffer
        if use_minibuffer and docs:
            docs = '\n'.join(docs.split('\n')[:7])
            lisputils.message(docs)
        else:
            fit_lines = lisp["ropemacs-max-doc-buffer-height"].value()
            buffer = lisputils.make_buffer('*rope-pydoc*', docs,
                                           empty_goto=False,
                                           fit_lines=fit_lines)
            lisp.local_set_key('q', lisp.bury_buffer)
        if docs is None:
            lisputils.message('No docs avilable!')
Esempio n. 8
0
    def show_occurrences(self, locations):
        buffer = self._make_buffer('*rope-occurrences*', "", switch=False)
        lisp.set_buffer(buffer)
        lisp.toggle_read_only(0)

        trunc_length = len(lisp.rope_get_project_root())

        lisp.insert('List of occurrences:\n')
        for location in locations:
            code_line = self.read_line_from_file(location.filename, location.lineno).rstrip()
            filename = location.filename[trunc_length:]
            lineno = str(location.lineno)
            offset = str(location.offset)

            lisp.insert(filename + ":" + lineno + ":" + code_line + " " + offset)

            beginning = lisp.line_beginning_position()
            end = beginning + len(filename)

            lisp.add_text_properties(beginning, end, [lisp.face, lisp.button])
            lisp.add_text_properties(beginning, end, [lisp.mouse_face, lisp.highlight,
                                                      lisp.help_echo, "mouse-2: visit this file in other window"])

            lisp.insert("\n")

        lisp.toggle_read_only(1)

        lisp.set(lisp["next-error-function"], lisp.rope_occurrences_next)
        lisp.local_set_key('\r', lisp.rope_occurrences_goto)
        lisp.local_set_key((lisp.mouse_1,), lisp.rope_occurrences_goto)
        lisp.local_set_key('q', lisp.delete_window)