【问题标题】:jquery terminal custom tab completionjquery终端自定义选项卡完成
【发布时间】:2014-10-14 07:00:05
【问题描述】:

是否可以控制 JQuery.Terminal 中的整个制表符补全功能?我想管理显示的自动完成。

例如,我想支持模板/正则表达式,以便我可以执行诸如“可视化活动 CAMPAIGN_NAME 其中 config = SOMETHING”之类的事情。我可以为所有这些编写自己的解析器和处理程序,但我不确定如何/在哪里插入它?

【问题讨论】:

    标签: jquery-terminal


    【解决方案1】:

    在初始化设置中,需要确保没有设置完成属性(默认为false)。

    然后,您需要拦截 keydown 函数并处理您感兴趣的键(在我的例子中是 tab)。

    您可以在其中为自动完成逻辑提供自己的处理程序:

    $('#terminal').terminal(function (command, term) 
            {
                // Command handlers
            },
            {
                keydown: function(event, term) {
    
                if (event.keyCode == 9) //Tab
                {
                    // Call handler to handle your auto-completion logic
    
                    // Sample to print stuff to the console and update the command
                    term.echo("autocompletion commands...");
                    term.set_command(term.get_command() + " completion text");
    
                    // Tells the terminal to not handle the tab key
                    return false;
                }
            }
        });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-07
      • 2012-06-12
      • 1970-01-01
      • 2013-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多