<p>Hello!</p>
<p>Is it possible to use readline with a termbox?</p>
<p>I need to have one line command prompt from where i can insert text and catch it with termbox event. Or perhaps there is a better solution...</p>
<hr/>**评论:**<br/><br/>qcoh: <pre><p>You could use <a href="https://github.com/gizak/termui" rel="nofollow">termui</a>, <a href="https://github.com/jroimartin/gocui" rel="nofollow">gocui</a> or do it yourself. It's not very difficult if you use a <a href="https://en.wikipedia.org/wiki/Gap_buffer" rel="nofollow">gap buffer</a>: Basically whenever PollEvent returns a printable character (or termbox.KeySpace), add it to your gap buffer in the right place and draw everything. Printing double-width characters is a minor annoyance (use go-runewidth!).</p>
<p>I've done this <a href="https://github.com/qcoh/mondrian/blob/master/prompt.go" rel="nofollow">here</a>. You can try the demo, it shows off the prompt at the bottom. It's not very good or even complete code but feel free to copy what you need.</p>
<p>Also look at <a href="https://github.com/nsf/termbox-go" rel="nofollow">other termbox projects</a> how they handle this.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传