我在JRuby中开发了一些工具。这两个工具都向用户提示了几个问题。在回答这些问题时,如果用户想要更正错误的条目并按backspace
键删除整行(包括问题)而不是仅删除一个字符。
以下是提示问题的代码:
require highline/import
def prompt
begin
input=ask("\t\tEnter user name: ") do |ch|
ch=true
end
input
rescue => e
print "Error -"+e
end
end
我想知道你们之前是否有人见过这种问题,可以解决这个问题的原因是什么?非常感谢您的时间和帮助。
提前致谢。
答案 0 :(得分:1)
以下是代码的工作部分。我删除了\t
并将ch=true
更改为ch.readline=true
。感谢您的所有帮助和指导。
require highline/import
def prompt
begin
input=ask("Enter user name: ") do |ch|
ch.readline=true
end
input
rescue => e
print "Error -"+e
end
end
答案 1 :(得分:0)
如果您使用的是highline gem,那么在阅读输入而不是
时,
"syntax": "Packages/Text/Plain text.tmLanguage"
使用
// standard sublime view settings that will be overwritten on each repl view
// this has to be customized as a whole dictionary
"repl_view_settings": {
"translate_tabs_to_spaces": false,
"auto_indent": false,
"smart_indent": false,
"spell_check": false,
"indent_subsequent_lines": false,
"detect_indentation": false,
"auto_complete": true,
"line_numbers": false,
"gutter": false,
"syntax": "Packages/Text/Plain text.tmLanguage"
},