仅当命令输出不可用时才隐藏liberator-bottombar。 (Vimperator的)

时间:2015-03-25 18:58:02

标签: javascript css vimperator

我尝试做的是this,但如果我执行某个命令,并且该命令有输出,我也希望能够看到命令'输出,所以,这就是我所做的:

"javascript to hide statusbar
noremap <silent> <F8> :js toggle_bottombar()<CR>
noremap : :js toggle_bottombar('on', true)<CR>:
noremap b :js toggle_bottombar('on')<CR>b
noremap o :js toggle_bottombar('on')<CR>o
noremap O :js toggle_bottombar('on')<CR>O
noremap t :js toggle_bottombar('on')<CR>t
noremap T :js toggle_bottombar('on')<CR>T
noremap / :js toggle_bottombar('on')<CR>/
cnoremap <CR> <CR>:js toggle_bottombar('off')<CR>
cnoremap <Esc> <Esc>:js toggle_bottombar('off')<CR>

:js << EOF 

var executing_command = false;

function toggle_bottombar(p, command) {
  var bb = document.getElementById('liberator-bottombar');
  if (!bb)
    return;
if (p == 'on'){
    executing_command = (command === true) ? true : false; 
    bb.style.height = ''; 
    bb.style.overflow = ''; 
    return;
}   
if (p == 'off'){
    if (!executing_command){
        bb.style.height = '0px';
        bb.style.overflow = 'hidden';
    } else {
        toggle_bottombar('on');             
    }  
    return;
}   

bb.style.height = (bb.style.height == '') ? '0px' : ''; 
bb.style.overflow = (bb.style.height == '') ? '' : 'hidden';
}
toggle_bottombar();
EOF

那个半工作因为当我输入一个命令时它按下回车后仍然显示状态栏但输出丢失了,你有什么想法达到这个目的吗?

我尝试使用:help style,但这并没有太多帮助......那里没有足够的文档。

1 个答案:

答案 0 :(得分:1)

我终于达到了我想要的目标。通过这些小改动你可以看到命令&#39;输出并保持自动隐藏功能。

noremap <silent> <F8> :js toggle_bottombar()<CR>
noremap : :js toggle_bottombar('on')<CR>:
noremap b :js toggle_bottombar('on')<CR>b
noremap o :js toggle_bottombar('on')<CR>o
noremap O :js toggle_bottombar('on')<CR>O
noremap t :js toggle_bottombar('on')<CR>t
noremap T :js toggle_bottombar('on')<CR>T
noremap / :js toggle_bottombar('on')<CR>/
noremap <Esc> <Esc>:js toggle_bottombar('off')<CR>
cnoremap <CR> <CR>:js toggle_bottombar('off')<CR>
cnoremap ` <CR> g<

:js << EOF
function toggle_bottombar(p) {
     var bb = document.getElementById('liberator-bottombar');
     if (!bb)
         return;
    if (p == 'on'){
        bb.style.height = '';
        bb.style.overflow = '';
        return;
    }   
    if (p == 'off'){
        bb.style.height = '0px';
        bb.style.overflow = 'hidden';
        return;
      }

     bb.style.height = (bb.style.height == '') ? '0px' : '';
     bb.style.overflow = (bb.style.height == '') ? '' : 'hidden';
}       
toggle_bottombar();
EOF 

这个vimperator的文档引导我回答:liberator:// help / message #more-prompt,如果你在vimperator的控制台中使用解放器组件,它几乎是自我解释的。

这样做的唯一缺点是,无论何时想要查看命令的输出,都需要使用&#34;`&#34; (蒂尔达),但我无法找到更好的方法。

注意:必须按<Esc>两次才能完全隐藏 bottombar 命令的输出,第一次隐藏命令行显示 bottombar ,第二次显示所需内容。我想这不是最干净的方法,但这并不属于原始问题。