예제 #1
0
    def SetCurrentFrame(self, frame):
        if self._signs['vimspectorPC']:
            vim.command('sign unplace {} group=VimspectorCode'.format(
                self._signs['vimspectorPC']))
            self._signs['vimspectorPC'] = None

        if not frame or not frame.get('source'):
            return False

        if 'path' not in frame['source']:
            return False

        utils.JumpToWindow(self._window)

        try:
            utils.OpenFileInCurrentWindow(frame['source']['path'])
        except vim.error:
            self._logger.exception(
                'Unexpected vim error opening file {}'.format(
                    frame['source']['path']))
            return False

        # SIC: column is 0-based, line is 1-based in vim. Why? Nobody knows.
        self._window.cursor = (frame['line'], frame['column'] - 1)

        self._signs['vimspectorPC'] = self._next_sign_id
        self._next_sign_id += 1

        vim.command('sign place {0} group=VimspectorCode priority=20 '
                    'line={1} name=vimspectorPC '
                    'file={2}'.format(self._signs['vimspectorPC'],
                                      frame['line'], frame['source']['path']))

        return True
예제 #2
0
파일: output.py 프로젝트: CHANTXU64/.vim
    def _ShowOutput(self, category):
        if not self._window.valid:
            return

        utils.JumpToWindow(self._window)
        vim.current.buffer = self._buffers[category].buf
        vim.command('normal G')
예제 #3
0
  def SetCurrentFrame( self, frame ):
    """Returns True if the code window was updated with the frame, False
    otherwise. False means either the frame is junk, we couldn't find the file
    (or don't have the data) or the code window no longer exits."""

    if self._signs[ 'vimspectorPC' ]:
      vim.command( 'sign unplace {} group=VimspectorCode'.format(
        self._signs[ 'vimspectorPC' ] ) )
      self._signs[ 'vimspectorPC' ] = None

    if not frame or not frame.get( 'source' ):
      return False

    if 'path' not in frame[ 'source' ]:
      return False

    self._signs[ 'vimspectorPC' ] = self._next_sign_id
    self._next_sign_id += 1

    try:
      vim.command( 'sign place {0} group=VimspectorCode priority=20 '
                                   'line={1} name=vimspectorPC '
                                   'file={2}'.format(
                                     self._signs[ 'vimspectorPC' ],
                                     frame[ 'line' ],
                                     frame[ 'source' ][ 'path' ] ) )
    except vim.error as e:
      # Ignore 'invalid buffer name'
      if 'E158' not in str( e ):
        raise

    if not self._window.valid:
      return False

    utils.JumpToWindow( self._window )
    try:
      utils.OpenFileInCurrentWindow( frame[ 'source' ][ 'path' ] )
    except vim.error:
      self._logger.exception( 'Unexpected vim error opening file {}'.format(
        frame[ 'source' ][ 'path' ] ) )
      return False

    # SIC: column is 0-based, line is 1-based in vim. Why? Nobody knows.
    # Note: max() with 0 because some debug adapters (go) return 0 for the
    # column.
    try:
      self._window.cursor = ( frame[ 'line' ], max( frame[ 'column' ] - 1, 0 ) )
    except vim.error:
      self._logger.exception( "Unable to jump to %s:%s in %s, maybe the file "
                              "doesn't exist",
                              frame[ 'line' ],
                              frame[ 'column' ],
                              frame[ 'source' ][ 'path' ] )
      return False

    self.current_syntax = utils.ToUnicode(
      vim.current.buffer.options[ 'syntax' ] )

    return True
예제 #4
0
파일: code.py 프로젝트: yukinjie/vimspector
  def SetCurrentFrame( self, frame ):
    if self._signs[ 'vimspectorPC' ]:
      vim.command( 'sign unplace {} group=VimspectorCode'.format(
        self._signs[ 'vimspectorPC' ] ) )
      self._signs[ 'vimspectorPC' ] = None

    if not frame or not frame.get( 'source' ):
      return False

    if 'path' not in frame[ 'source' ]:
      return False

    utils.JumpToWindow( self._window )

    try:
      utils.OpenFileInCurrentWindow( frame[ 'source' ][ 'path' ] )
    except vim.error:
      self._logger.exception( 'Unexpected vim error opening file {}'.format(
        frame[ 'source' ][ 'path' ] ) )
      return False

    # SIC: column is 0-based, line is 1-based in vim. Why? Nobody knows.
    # Note: max() with 0 because some debug adapters (go) return 0 for the
    # column.
    try:
      self._window.cursor = ( frame[ 'line' ], max( frame[ 'column' ] - 1, 0 ) )
    except vim.error:
      self._logger.exception( "Unable to jump to %s:%s in %s, maybe the file "
                              "doesn't exist",
                              frame[ 'line' ],
                              frame[ 'column' ],
                              frame[ 'source' ][ 'path' ] )
      return False

    self._signs[ 'vimspectorPC' ] = self._next_sign_id
    self._next_sign_id += 1

    vim.command( 'sign place {0} group=VimspectorCode priority=20 '
                                 'line={1} name=vimspectorPC '
                                 'file={2}'.format(
                                   self._signs[ 'vimspectorPC' ],
                                   frame[ 'line' ],
                                   frame[ 'source' ][ 'path' ] ) )

    self.current_syntax = utils.ToUnicode(
      vim.current.buffer.options[ 'syntax' ] )

    return True
예제 #5
0
    def SetCurrentFrame(self, frame):
        """Returns True if the code window was updated with the frame, False
    otherwise. False means either the frame is junk, we couldn't find the file
    (or don't have the data) or the code window no longer exits."""

        if not frame or not frame.get('source'):
            self._UndisplayPC()
            return False

        if 'path' not in frame['source']:
            self._UndisplayPC()
            return False

        self._current_frame = frame

        if not self._window.valid:
            return False

        utils.JumpToWindow(self._window)
        try:
            utils.OpenFileInCurrentWindow(frame['source']['path'])
            vim.command('doautocmd <nomodeline> User VimspectorJumpedToFrame')
        except vim.error:
            self._logger.exception(
                'Unexpected vim error opening file {}'.format(
                    frame['source']['path']))
            return False

        # SIC: column is 0-based, line is 1-based in vim. Why? Nobody knows.
        # Note: max() with 0 because some debug adapters (go) return 0 for the
        # column.
        try:
            utils.SetCursorPosInWindow(self._window, frame['line'],
                                       frame['column'])
        except vim.error:
            self._logger.exception(
                "Unable to jump to %s:%s in %s, maybe the file "
                "doesn't exist", frame['line'], frame['column'],
                frame['source']['path'])
            return False

        self.current_syntax = utils.ToUnicode(
            vim.current.buffer.options['syntax'])

        self._DisplayPC()

        return True
예제 #6
0
    def ShowMemory(self, memoryReference, length, offset, msg):
        if not self._window.valid:
            return False

        buf_name = os.path.join('_vimspector_mem', memoryReference)
        buf = utils.BufferForFile(buf_name)
        self._scratch_buffers.append(buf)
        utils.SetUpHiddenBuffer(buf, buf_name)
        with utils.ModifiableScratchBuffer(buf):
            # TODO: The data is encoded in base64, so we need to convert that to the
            # equivalent output of say xxd
            data = msg.get('body', {}).get('data', '')
            utils.SetBufferContents(buf, [
                f'Memory Dump for Reference {memoryReference} Length: {length} bytes'
                f' Offset: {offset}',
                '-' * 80,
                'Offset    Bytes                                             Text',
                '-' * 80,
            ])
            utils.AppendToBuffer(buf, utils.Base64ToHexDump(data))

        utils.SetSyntax('', 'vimspector-memory', buf)
        utils.JumpToWindow(self._window)
        utils.OpenFileInCurrentWindow(buf_name)
예제 #7
0
 def _ShowOutput(self, category):
     utils.JumpToWindow(self._window)
     vim.command('bu {0}'.format(self._buffers[category].buf.name))
     vim.command('normal G')