#NEWLINE# def jump( dir ) : #NEWLINE# #INDENT# w = vim . current . window #NEWLINE# check_history ( w ) #NEWLINE# history = list ( w . vars [ VHIST ] ) #NEWLINE# bufnr = vim . current . buffer . number #NEWLINE# now = time ( ) #NEWLINE# lastbuf = w . vars . get ( VLAST , None ) #NEWLINE# if ( ( not lastbuf ) or ( ( bufnr == lastbuf [ 0 ] ) and ( ( now - lastbuf [ 1 ] ) > vim . vars [ 'vial_bufhist_timeout' ] ) ) ) : #NEWLINE# #INDENT# history = add_to_history ( w , bufnr ) #NEWLINE# #UNINDENT# if ( bufnr not in history ) : #NEWLINE# #INDENT# history = add_to_history ( w , bufnr ) #NEWLINE# #UNINDENT# names = { r . number : ( split ( r . name ) if r . name else [ '' , '[buf-{}]' . format ( r . number ) ] ) for r in vim . buffers if vfunc . buflisted ( r . number ) } #NEWLINE# history [ : ] = filter ( ( lambda r : ( r in names ) ) , history ) #NEWLINE# dups = True #NEWLINE# while dups : #NEWLINE# #INDENT# dups = False #NEWLINE# for ( name , g ) in groupby ( sorted ( names . iteritems ( ) , key = skey ) , skey ) : #NEWLINE# #INDENT# g = list ( g ) #NEWLINE# if ( len ( g ) > 1 ) : #NEWLINE# #INDENT# dups = True #NEWLINE# for ( nr , ( path , _ ) ) in g : #NEWLINE# #INDENT# ( p , n ) = split ( path ) #NEWLINE# names [ nr ] = ( p , ( ( n + '/' ) + name ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# width = vim . vars [ 'vial_bufhist_width' ] #NEWLINE# if ( width < 0 ) : #NEWLINE# #INDENT# width += ( int ( vim . eval ( '&columns' ) ) - 1 ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# idx = history . index ( bufnr ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# idx += dir #NEWLINE# if ( idx < 0 ) : #NEWLINE# #INDENT# idx = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( idx >= len ( history ) ) : #NEWLINE# #INDENT# idx = ( len ( history ) - 1 ) #NEWLINE# #UNINDENT# #UNINDENT# anr = history [ idx ] #NEWLINE# active = names [ anr ] [ 1 ] #NEWLINE# before = '  ' . join ( ( names [ r ] [ 1 ] for r in history [ : idx ] ) ) #NEWLINE# after = '  ' . join ( ( names [ r ] [ 1 ] for r in history [ ( idx + 1 ) : ] ) ) #NEWLINE# half = ( ( ( width - len ( active ) ) - 4 ) / 2 ) #NEWLINE# if ( len ( before ) < len ( after ) ) : #NEWLINE# #INDENT# blen = min ( half , len ( before ) ) #NEWLINE# alen = ( ( ( width - len ( active ) ) - blen ) - 4 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# alen = min ( half , len ( after ) ) #NEWLINE# blen = ( ( ( width - len ( active ) ) - alen ) - 4 ) #NEWLINE# #UNINDENT# if ( len ( before ) > blen ) : #NEWLINE# #INDENT# before = ( '...' + before [ ( 3 - blen ) : ] ) #NEWLINE# #UNINDENT# if ( len ( after ) > alen ) : #NEWLINE# #INDENT# after = ( after [ : ( alen - 3 ) ] + '...' ) #NEWLINE# #UNINDENT# if before : #NEWLINE# #INDENT# before += '  ' #NEWLINE# #UNINDENT# if after : #NEWLINE# #INDENT# after = ( '  ' + after ) #NEWLINE# #UNINDENT# vim . command ( 'let x=&ruler | let y=&showcmd' ) #NEWLINE# vim . command ( 'set noruler noshowcmd' ) #NEWLINE# redraw ( ) #NEWLINE# echon ( before ) #NEWLINE# vim . command ( 'echohl CursorLine' ) #NEWLINE# echon ( active ) #NEWLINE# vim . command ( 'echohl None' ) #NEWLINE# echon ( after ) #NEWLINE# vim . command ( 'let &ruler=x | let &showcmd=y' ) #NEWLINE# if ( anr != bufnr ) : #NEWLINE# #INDENT# w . vars [ 'vial_bufhist_switch' ] = 1 #NEWLINE# vim . command ( 'silent b {}' . format ( anr ) ) #NEWLINE# w . vars [ 'vial_bufhist_switch' ] = 0 #NEWLINE# #UNINDENT# vim . command ( 'augroup vial_bufhist_wait_action' ) #NEWLINE# vim . command ( 'au!' ) #NEWLINE# vim . command ( ( 'au CursorMoved,CursorHold <buffer> python %s()' % moved . ref ) ) #NEWLINE# vim . command ( 'augroup END' )