示例#1
0
文件: output.py 项目: CHANTXU64/.vim
    def _CreateBuffer(self,
                      category,
                      file_name=None,
                      cmd=None,
                      completion_handler=None,
                      syntax=None):

        buf_to_delete = None
        if (not self._buffers and self._window is not None
                and self._window.valid and not self._window.buffer.name):
            # If there's an empty buffer in the current window that we're not using,
            # delete it. We could try and use it, but that complicates the call to
            # SetUpCommandBuffer
            buf_to_delete = self._window.buffer

        if file_name is not None:
            assert cmd is None
            if install.GetOS() == "windows":
                # FIXME: Can't display fiels in windows (yet?)
                return

            cmd = ['tail', '-F', '-n', '+1', '--', file_name]

        if cmd is not None:
            out = utils.SetUpCommandBuffer(
                cmd,
                category,
                self._api_prefix,
                completion_handler=completion_handler)

            self._buffers[category] = TabBuffer(out, len(self._buffers))
            self._buffers[category].is_job = True
            self._RenderWinBar(category)
        else:
            if category == 'Console':
                name = 'vimspector.Console'
            else:
                name = 'vimspector.Output:{0}'.format(category)

            tab_buffer = TabBuffer(utils.NewEmptyBuffer(), len(self._buffers))

            self._buffers[category] = tab_buffer

            if category == 'Console':
                utils.SetUpPromptBuffer(tab_buffer.buf, name, '> ',
                                        'vimspector#EvaluateConsole',
                                        'vimspector#OmniFuncConsole')
            else:
                utils.SetUpHiddenBuffer(tab_buffer.buf, name)

            self._RenderWinBar(category)

        self._buffers[category].syntax = utils.SetSyntax(
            self._buffers[category].syntax, syntax,
            self._buffers[category].buf)

        if buf_to_delete:
            with utils.RestoreCurrentWindow():
                self._ShowOutput(category)
            utils.CleanUpHiddenBuffer(buf_to_delete)
示例#2
0
    def _CreateBuffer(self, category, file_name=None, cmd=None):
        with utils.LetCurrentWindow(self._window):
            with utils.RestoreCurrentBuffer(self._window):

                if file_name is not None:
                    assert cmd is None
                    cmd = ['tail', '-F', '-n', '+1', '--', file_name]

                if cmd is not None:
                    out, err = utils.SetUpCommandBuffer(cmd, category)
                    self._buffers[category + '-out'] = TabBuffer(
                        out, len(self._buffers))
                    self._buffers[category + '-out'].is_job = True
                    self._buffers[category + '-err'] = TabBuffer(
                        err, len(self._buffers))
                    self._buffers[category + '-err'].is_job = False
                    self._RenderWinBar(category + '-out')
                    self._RenderWinBar(category + '-err')
                else:
                    vim.command('enew')
                    tab_buffer = TabBuffer(vim.current.buffer,
                                           len(self._buffers))
                    self._buffers[category] = tab_buffer
                    if category == 'Console':
                        utils.SetUpPromptBuffer(tab_buffer.buf,
                                                'vimspector.Console',
                                                '> ',
                                                'vimspector#EvaluateConsole',
                                                hidden=True)
                    else:
                        utils.SetUpHiddenBuffer(
                            tab_buffer.buf,
                            'vimspector.Output:{0}'.format(category))

                    self._RenderWinBar(category)
示例#3
0
  def _CreateBuffer( self,
                     category,
                     file_name = None,
                     cmd = None,
                     completion_handler = None,
                     syntax = None ):
    if file_name is not None:
      assert cmd is None
      if install.GetOS() == "windows":
        # FIXME: Can't display fiels in windows (yet?)
        return

      cmd = [ 'tail', '-F', '-n', '+1', '--', file_name ]

    if cmd is not None:
      out = utils.SetUpCommandBuffer(
        cmd,
        category,
        self._api_prefix,
        completion_handler = completion_handler )
      self._buffers[ category ] = TabBuffer( out, len( self._buffers ) )
      self._buffers[ category ].is_job = True
      self._RenderWinBar( category )
    else:
      if category == 'Console':
        name = 'vimspector.Console'
      else:
        name = 'vimspector.Output:{0}'.format( category )

      tab_buffer = TabBuffer( utils.NewEmptyBuffer(), len( self._buffers ) )
      self._buffers[ category ] = tab_buffer

      if category == 'Console':
        utils.SetUpPromptBuffer( tab_buffer.buf,
                                 name,
                                 '> ',
                                 'vimspector#EvaluateConsole' )
      else:
        utils.SetUpHiddenBuffer( tab_buffer.buf, name )

      self._RenderWinBar( category )

    self._buffers[ category ].syntax = utils.SetSyntax(
      self._buffers[ category ].syntax,
      syntax,
      self._buffers[ category ].buf )
示例#4
0
    def _CreateBuffer(self, category, file_name=None, cmd=None):
        win = self._window
        if not win.valid:
            # We need to borrow the current window
            win = vim.current.window

        with utils.LetCurrentWindow(win):
            with utils.RestoreCurrentBuffer(win):

                if file_name is not None:
                    assert cmd is None
                    if install.GetOS() == "windows":
                        # FIXME: Can't display fiels in windows (yet?)
                        return

                    cmd = ['tail', '-F', '-n', '+1', '--', file_name]

                if cmd is not None:
                    out, err = utils.SetUpCommandBuffer(
                        cmd, category, self._api_prefix)
                    self._buffers[category + '-out'] = TabBuffer(
                        out, len(self._buffers))
                    self._buffers[category + '-out'].is_job = True
                    self._buffers[category + '-out'].job_category = category
                    self._buffers[category + '-err'] = TabBuffer(
                        err, len(self._buffers))
                    self._buffers[category + '-err'].is_job = False
                    self._RenderWinBar(category + '-out')
                    self._RenderWinBar(category + '-err')
                else:
                    vim.command('enew')
                    tab_buffer = TabBuffer(vim.current.buffer,
                                           len(self._buffers))
                    self._buffers[category] = tab_buffer
                    if category == 'Console':
                        utils.SetUpPromptBuffer(tab_buffer.buf,
                                                'vimspector.Console', '> ',
                                                'vimspector#EvaluateConsole')
                    else:
                        utils.SetUpHiddenBuffer(
                            tab_buffer.buf,
                            'vimspector.Output:{0}'.format(category))

                    self._RenderWinBar(category)