用于显示文本模式菜单的库? [英] Libraries for displaying a text-mode menu?

查看:133
本文介绍了用于显示文本模式菜单的库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我正在进行的游戏项目中,我被严重放慢了 - 放弃了 - 看起来似乎没有任何库可以简化在文本模式下显示菜单的过程(即80x25文本框,command.com/cmd.exe的本地界面)。



我需要一个可以给出选项列表的选项,最好包括多个页面,要输入的值以选择其中一个;提示用户;当所述用户未能输入有效的东西时轻轻地叮嘱用户(可能敲响铃声并重新绘制选择一个:提示)并返回可以用于确定传递哪个选项的内容。



这比起听起来更多的工作;现在,同样的问题,使我在家里慢慢下降,在工作中出现了(或即将上来)。有没有人知道任何非copyleft库的函数,可以传递一个存储容器的选项,显示在屏幕上,并获得用户的选择?



回答:Ncurses非常适合此目的,包括显式提供菜单驱动程序。它有一个MIT风格的许可证,使其与商业使用兼容。但是,它不适用于MS-DOS或Windows。 (我参考上面的command.com,但没有想到明确说明这是关于Microsoft架构的问题。)



但是,它看起来像在过去的DOS和Windows上已经成功编译,我相信我将能够得到它,或至少它需要的部分,工作,特别是考虑到它的菜单逻辑,而不是行绘画等,我后。问题为Windows编写控制台样式应用程序的良好资源?

:Windows提供了大量的显示功能开箱即用,如这里所示 - 虽然这不会 包括菜单显示系统,与ncurses相反。一个不道德的混合ncurses菜单逻辑和Windows API?

:ncurses和pdcurses在Windows上运行起来非常顺利,甚至可以使用。而不使用Windows API来创建和调整显示器大小。我决定使用pdcurses,并学会构建自己的菜单 - 允许回调,轻松扩展的屏幕消息队列,使用C ++字符串类和其他这样的功能。



进一步更新:Curses的菜单库用C语言编写,因此按照char *序列工作。

解决方案

尝试 ncurses ,它位于 MIT 许可证上,这比GPL更容许许可。它是非常容易使用:菜单,对话框,复选框 - 它是所有。它是大多数GUI库的事件驱动。


In a game project I was working on, I was seriously slowed down -- to the point of giving up -- by how there don't seem to be any libraries that can simplify the process of displaying a menu in text mode (i.e., 80x25 textbox, command.com/cmd.exe's native interface).

I need something that can give a list of choices, ideally including multiple pages, and including values to be entered to choose one of these; prompt the user; gently chide the user (perhaps ringing a bell and redrawing the "choose one:" prompt) when said user fails to enter something valid; and returning something that can be used to determine which option was passed.

This turns out to be a lot more work than it sounds like; and now, the exact same question that slowed me down so badly at home has come up (or is about to come up) at work. Does anyone know of any non-copyleft libraries with a function that can be passed a storage container of options, display them on screen, and get the user's choice?

Answer: Ncurses is very suitable for this purpose, including explicitly providing a menu driver. It has an MIT-style license, making it compatible with commercial use. However, it's not available for MS-DOS or Windows. (I'd referenced command.com above, but hadn't thought to explicitly spell out that this was a question regarding Microsoft architectures.)

However, it looks like it's been compiled successfully on DOS and Windows in the past, and I'm confident that I'll be able to get it, or at least the parts of it that I need, to work, especially given that it's the menu logic rather than line-drawing and the like that I'm after. The question Good resources for writing console style applications for Windows? should also be useful in this regard.

Later, additional answer: Windows provides a fair amount of display functionality out of the box, as depicted here -- although this does not include a menu-display system, in contrast to ncurses. An unholy hybrid of ncurses menu logic and Windows APIs? It might be as viable a choice as cygwin...

Much later additional answer: Both ncurses and pdcurses work very smoothly with Windows, even without using the Windows API for anything more than creating and sizing the display. I settled on using pdcurses, and learned to build my own menus -- allowing for callbacks, an easily expanded on-screen message queue, use of the C++ string class, and other such functionality.

Further update: Curses' menu libraries are written in C, and so work in terms of char* sequences. I gave up on trying to use them, and wrote my own menus instead, using low-level curses functions for screen display.

解决方案

Try ncurses, it is on MIT license, which is much more permissive than GPL. It is very easy to use: menus, dialog boxes, checkboxes - it is all there. It is event-driven like most GUI libraries.

这篇关于用于显示文本模式菜单的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆