def EchoTextVimWidth( text ): vim_width = GetIntValue( '&columns' ) truncated_text = ToUnicode( text )[ : int( vim_width * 0.9 ) ] truncated_text.replace( '\n', ' ' ) old_ruler = GetIntValue( '&ruler' ) old_showcmd = GetIntValue( '&showcmd' ) vim.command( 'set noruler noshowcmd' ) vim.command( 'redraw' ) EchoText( truncated_text, False ) SetVariableValue( '&ruler', old_ruler ) SetVariableValue( '&showcmd', old_showcmd )
def EchoTextVimWidth( text ): vim_width = GetIntValue( '&columns' ) truncated_text = ToUnicode( text )[ : int( vim_width * 0.9 ) ] truncated_text.replace( '\n', ' ' ) old_ruler = GetIntValue( '&ruler' ) old_showcmd = GetIntValue( '&showcmd' ) vim.command( 'set noruler noshowcmd' ) vim.command( 'redraw' ) EchoText( truncated_text, False ) vim.command( 'let &ruler = {0}'.format( old_ruler ) ) vim.command( 'let &showcmd = {0}'.format( old_showcmd ) )
def EchoTextVimWidth(text): vim_width = GetIntValue("&columns") truncated_text = ToUnicode(text)[: int(vim_width * 0.9)] truncated_text.replace("\n", " ") old_ruler = GetIntValue("&ruler") old_showcmd = GetIntValue("&showcmd") vim.command("set noruler noshowcmd") vim.command("redraw") EchoText(truncated_text, False) SetVariableValue("&ruler", old_ruler) SetVariableValue("&showcmd", old_showcmd)
def PostVimMessage( message, warning = True, truncate = False ): """Display a message on the Vim status line. By default, the message is highlighted and logged to Vim command-line history (see :h history). Unset the |warning| parameter to disable this behavior. Set the |truncate| parameter to avoid hit-enter prompts (see :h hit-enter) when the message is longer than the window width.""" echo_command = 'echom' if warning else 'echo' # Displaying a new message while previous ones are still on the status line # might lead to a hit-enter prompt or the message appearing without a # newline so we do a redraw first. vim.command( 'redraw' ) if warning: vim.command( 'echohl WarningMsg' ) message = ToUnicode( message ) if truncate: vim_width = GetIntValue( '&columns' ) message = message.replace( '\n', ' ' ) if len( message ) > vim_width: message = message[ : vim_width - 4 ] + '...' old_ruler = GetIntValue( '&ruler' ) old_showcmd = GetIntValue( '&showcmd' ) vim.command( 'set noruler noshowcmd' ) vim.command( "{0} '{1}'".format( echo_command, EscapeForVim( message ) ) ) SetVariableValue( '&ruler', old_ruler ) SetVariableValue( '&showcmd', old_showcmd ) else: for line in message.split( '\n' ): vim.command( "{0} '{1}'".format( echo_command, EscapeForVim( line ) ) ) if warning: vim.command( 'echohl None' )