我怎么能写一个ANSI C控制台屏幕缓冲区? [英] how can I write an ANSI C console screen buffer?

查看:129
本文介绍了我怎么能写一个ANSI C控制台屏幕缓冲区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个基于ASCII游戏,到处看人说用从MSDN Console.Write(),这是花花公子,所有如果你使用的是Windows,但我不是。

就这样,我想编写一个函数或函数组C,它可以在两个屏幕缓冲区之间交替,并将其写入到屏幕上,类似于手册页会是什么样子,以及微微, VIM,和emacs。

我有缓冲的工作,并发现了一个使用C和的putchar()在屏幕上的每个字符放在Linux的所谓0verkill一个古老的ASCII比赛,但我所有的尝试重新创建的,导致在连续流动文本,而不是静态文本的窗口尺寸面板。我真的不希望使用任何外部库,例如诅咒(因为这会降低可移植性),并想保持ANSI标准,如果在所有可能的。

谢谢!


解决方案

  

我真的不希望使用任何外部库,例如诅咒(因为这会降低可移植性)


什么?像诅咒和Ncurses库,旨在使这种事情的更多的便携,因为...


  

和想保持ANSI标准,如果在所有可能的。


...有你想要的东西没有ANSI标准(对于C至少)。每个操作系统不同的实现这种行为,所以如果你想要一个可移植的方式来做到这一点,你需要使用一个库。老实说,我讨厌必须开发为的系统没有的有移植到它的ncurses。想象一下,你就不能没有它使用的所有程序。

I'm working on making an ASCII based game, and everywhere I look people are saying to use Console.Write() from MSDN, which is dandy and all if you're using Windows, but I'm not.

And thus, I'm trying to write a function, or group of functions in C that can alternate between two screen buffers, and write them to the screen, similar to what man pages would be like, as well as pico, vim, and emacs.

I have the buffer's working, and found an old ASCII game for linux called 0verkill that uses C and putchar() to place each character on the screen, but all of my attempts to re-create that, result in a continuous flow of text, and not a window sized panel of static text. I really don't want to use any external libraries like curses (because that would reduce portability) and would like to keep to ansi standards if at all possible.

Thanks!

解决方案

I really don't want to use any external libraries like curses (because that would reduce portability)

What? Libraries like curses and ncurses are designed to make this kind of thing more portable, because...

and would like to keep to ansi standards if at all possible.

...there is no ANSI standard (for C at least) for what you want. Each operating system implements this kind of behavior differently, so if you want a portable way to do it, you need to use a library. Honestly, I'd hate to have to develop for a system that didn't have ncurses ported to it. Imagine all the programs you wouldn't be able to use without it.

这篇关于我怎么能写一个ANSI C控制台屏幕缓冲区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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