def _postWarning(self, msg): """ Post warnings to the user once """ if ('warn', msg) not in self._posted_notifications: self._posted_notifications += [('warn', msg)] vim_helpers.postVimWarning(msg)
def postQueuedMessages(self): '''Because Vim doesn't allows commands from non-GUI threads, we enqueue messages generated by background threads and post them whenever Vim is ready''' while not self._ui_msg_queue.empty(): msg = self._ui_msg_queue.get() if msg['type'] == 'info': vim_helpers.postVimInfo(msg['text']) elif msg['type'] == 'warning': vim_helpers.postVimWarning(msg['text']) elif msg['type'] == 'error': vim_helpers.postVimError(msg['text'])
def _postQueuedMessages(self): "Empty our queue in a single message" while not self._ui_queue.empty(): messages = self._ui_queue.get() for severity, message in messages.json().get('ui_messages', []): if severity == 'info': vim_helpers.postVimInfo(message) elif severity == 'warning': vim_helpers.postVimWarning(message) elif severity == 'error': vim_helpers.postVimError(message) else: vim_helpers.postVimError( "Unknown severity '%s' for message '%s'" % (severity, message))
def rebuildProject(self): """ Rebuilds the current project """ if vim.eval('&filetype') not in ('vhdl', 'verilog', 'systemverilog'): vim_helpers.postVimWarning("Not a VHDL file, can't rebuild") return vim_helpers.postVimInfo("Rebuilding project...") project_file = vim_helpers.getProjectFile() request = RequestProjectRebuild(project_file=project_file) response = request.sendRequest() if response is None: return "hdlcc server is not running" self._logger.info("Response: %s", repr(response))
def test(): vim_helpers.postVimWarning("Some warning") vim.command.assert_called_with( "redraw | echohl WarningMsg | echom 'Some warning' | echohl None")
def _postError(self, msg): "Post errors to the user once" if ('error', msg) not in self._posted_notifications: self._posted_notifications += [('error', msg)] vim_helpers.postVimWarning(msg)