Ejemplo n.º 1
0
    def GetMatch(self, ptrn, d):
        """ Find citation key and save completion lines in temporary file """
        for b in self.D[d]:
            if os.path.isfile(b):
                if b not in self.E or os.path.getmtime(b) > self.M[b]:
                    self._parse_bib(b)
            else:
                self.D[d].remove(b)

        # priority level
        p1 = []
        p2 = []
        p3 = []
        p4 = []
        p5 = []
        p6 = []
        for b in self.D[d]:
            for k in self.E[b]:
                if self.E[b][k]['citekey'].lower().find(ptrn) == 0:
                    p1.append(self._get_compl_line(k, self.E[b][k]))
                elif self.E[b][k]['author'].lower().find(ptrn) == 0:
                    p2.append(self._get_compl_line(k, self.E[b][k]))
                elif self.E[b][k]['title'].lower().find(ptrn) == 0:
                    p3.append(self._get_compl_line(k, self.E[b][k]))
                elif self.E[b][k]['citekey'].lower().find(ptrn) > 0:
                    p4.append(self._get_compl_line(k, self.E[b][k]))
                elif self.E[b][k]['author'].lower().find(ptrn) > 0:
                    p5.append(self._get_compl_line(k, self.E[b][k]))
                elif self.E[b][k]['title'].lower().find(ptrn) > 0:
                    p6.append(self._get_compl_line(k, self.E[b][k]))
        resp = p1 + p2 + p3 + p4 + p5 + p6
        with open(os.environ['NVIMR_TMPDIR'] + '/bibcompl', 'w') as f:
            if resp:
                f.write('\n'.join(resp) + '\n')
        nvimr_cmd('let g:rplugin.bib_finished = 1')
Ejemplo n.º 2
0
    def GetMatch(self, ptrn, d):
        """ Find citation key and save completion lines in temporary file """
        for b in self.D[d]:
            if os.path.isfile(b):
                if b not in self.E or os.path.getmtime(b) > self.M[b]:
                    self._parse_bib(b)
            else:
                self.D[d].remove(b)

        # priority level
        p1 = []
        p2 = []
        p3 = []
        p4 = []
        p5 = []
        p6 = []
        for b in self.D[d]:
            for k in self.E[b]:
                if self.E[b][k]['citekey'].lower().find(ptrn) == 0:
                    p1.append(self._get_compl_line(k, self.E[b][k]))
                elif self.E[b][k]['author'].lower().find(ptrn) == 0:
                    p2.append(self._get_compl_line(k, self.E[b][k]))
                elif self.E[b][k]['title'].lower().find(ptrn) == 0:
                    p3.append(self._get_compl_line(k, self.E[b][k]))
                elif self.E[b][k]['citekey'].lower().find(ptrn) > 0:
                    p4.append(self._get_compl_line(k, self.E[b][k]))
                elif self.E[b][k]['author'].lower().find(ptrn) > 0:
                    p5.append(self._get_compl_line(k, self.E[b][k]))
                elif self.E[b][k]['title'].lower().find(ptrn) > 0:
                    p6.append(self._get_compl_line(k, self.E[b][k]))
        resp = p1 + p2 + p3 + p4 + p5 + p6
        with open(os.environ['NVIMR_TMPDIR'] + '/bibcompl', 'w') as f:
            if resp:
                f.write('\n'.join(resp) + '\n')
        nvimr_cmd('let g:rplugin.bib_finished = 1')
Ejemplo n.º 3
0
 def SyncView(self, input_file, data):
     if self.status == CLOSED:
         if self.spawn:
             self._tmp_syncview = [input_file, data, 0]
             self._handler = self._syncview_handler
             self._get_dbus_name(True)
             nvimr_cmd("call Evince_Again()")
     else:
         self.window.SyncView(input_file, data, 0,  dbus_interface = "org.gnome.evince.Window")
         nvimr_cmd("let g:rplugin.evince_loop = 0")
Ejemplo n.º 4
0
    def GetAttachment(self, d, citekey):
        """ Tell Vim what attachment is associated with the citation key """

        for b in self.D[d]:
            if os.path.isfile(b):
                if b not in self.E or os.path.getmtime(b) > self.M[b]:
                    self._parse_bib(b)
            else:
                self.D[d].remove(b)
                nvimr_cmd('let g:rplugin.last_attach = "nObIb:' + b + '"')
                return

        for b in self.D[d]:
            for k in self.E[b]:
                if self.E[b][k]['citekey'] == citekey:
                    if 'file' in self.E[b][k]:
                        nvimr_cmd('let g:rplugin.last_attach = "' + self.E[b][k]['file'] + '"')
                        return
                    nvimr_cmd('let g:rplugin.last_attach = "nOaTtAChMeNt"')
                    return
        nvimr_cmd('let g:rplugin.last_attach = "nOcItEkEy"')
Ejemplo n.º 5
0
    def GetAttachment(self, d, citekey):
        """ Tell Vim what attachment is associated with the citation key """

        for b in self.D[d]:
            if os.path.isfile(b):
                if b not in self.E or os.path.getmtime(b) > self.M[b]:
                    self._parse_bib(b)
            else:
                self.D[d].remove(b)
                nvimr_cmd('let g:rplugin.last_attach = "nObIb:' + b + '"')
                return

        for b in self.D[d]:
            for k in self.E[b]:
                if self.E[b][k]['citekey'] == citekey:
                    if 'file' in self.E[b][k]:
                        nvimr_cmd('let g:rplugin.last_attach = "' +
                                  self.E[b][k]['file'] + '"')
                        return
                    nvimr_cmd('let g:rplugin.last_attach = "nOaTtAChMeNt"')
                    return
        nvimr_cmd('let g:rplugin.last_attach = "nOcItEkEy"')
Ejemplo n.º 6
0
 def on_sync_source(self, input_file, source_link, timestamp):
     input_file = input_file.replace("file://", "")
     input_file = input_file.replace("%20", " ")
     nvimr_cmd("call SyncTeX_backward('" + input_file + "', " +
               str(source_link[0]) + ")\n")