是否有用于将光标位置放置在cosole中的库函数? [英] Is there a library function for placing cursor position in the cosole?

查看:46
本文介绍了是否有用于将光标位置放置在cosole中的库函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

老实说,我为此搜索了comp.lang.c.faq,却一无所获。 :)


是否有用于将光标位置放在

控制台中的库函数?或者它是否只能通过平台API进行

调用?


我能够在具有Windows.h功能的Windows中执行此操作,但是我想在Linux / Unix上也可以使用



我不会要求定位光标的Linux API调用,因为那是超出comp.lang.c组范围的
。但如果有人知道这件事,他们不会阻止你在一篇文章中写下它! ;)

;)


无论如何,如果有一个标准的C库

函数,那将是非常理想的光标在控制台中。这样,我就可以保证我的代码更便携了。

Honest, I scoured the comp.lang.c.faq for this but found nothing. :)

Is there a library function for placing the cursor position in the
console? Or is it something that can only be done with a platform API
call?

I was able to do this in Windows with a Windows.h function, but I want
to also do it on Linux/Unix as well.

I won''t ask for a Linux API call that positions the cursor, as that is
beyond the scope of the comp.lang.c group. But if someone knew it off
the top of their head, I won''t stop you from writing it in a post! ;)
;)

Anyway, it would be really ideal if there were a standard C library
function that postitions the cursor in the console. This way, I can
keep my code more portable.

推荐答案



" JeffS" < JA **** @ yahoo.com>在消息中写道

news:11 ********************* @ f14g2000cwb.googlegro ups.com ...

"JeffS" <ja****@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
老实说,我为此搜索了comp.lang.c.faq,却一无所获。 :)


那是因为标准C不支持直接设备

访问。所有i / o都被抽象为'字符串''。

C根本不需要存在视频显示。

是否有库函数将光标位置放在
控制台中?


有许多,但都依赖于平台。此外,许多实现

为此类事物提供库扩展(如果适用)。

您可能需要检查文档。

或者它是否只能通过平台API
调用?


基本上是的。但是也有一些第三方''便携式''

库。

我能够在Windows中使用Windows.h函数执行此操作,但我想要
也可以在Linux / Unix上进行。


听起来你想要一些(相对)便携式方法。 ''curses''

是可能的。


我不会要求定位光标的Linux API调用,因为它是;)

无论如何,如果有一个标准的C库
函数将光标寄存在控制台中,那将是非常理想的。


没有。

这样,我可以保持我的代码更便携。
Honest, I scoured the comp.lang.c.faq for this but found nothing. :)
That''s because standard C does not support direct device
access. All i/o is abstracted as ''streams of characters''.
C does not require the existence of a video display at all.

Is there a library function for placing the cursor position in the
console?
There are many, but all all platform-dependent. Also many implementations
provide library ''extensions'' for this sort of thing, when applicable.
You might want to check your documentation for that.
Or is it something that can only be done with a platform API
call?
Essentially yes. But there are some third-party ''portable''
libraries available too.

I was able to do this in Windows with a Windows.h function, but I want
to also do it on Linux/Unix as well.
Sounds like you want some (relatively) ''portable'' method. ''curses''
is one possiblity.


I won''t ask for a Linux API call that positions the cursor, as that is
beyond the scope of the comp.lang.c group. But if someone knew it off
the top of their head, I won''t stop you from writing it in a post! ;)
;)

Anyway, it would be really ideal if there were a standard C library
function that postitions the cursor in the console.
There is not.
This way, I can
keep my code more portable.



好​​吧,我希望你发现我的评论很有帮助。


-Mike



Well, I hope you find my comments helpful anyway.

-Mike


>有没有用于将光标位置放在
>Is there a library function for placing the cursor position in the
控制台中的库函数?


哪个控制台?什么光标? ASR33电传打字机没有

光标。 (我怀疑C最初是在这种

终端上开发的,虽然它可能比ASR33更早。)


还记得许多操作系统提供的方法指示

stdin和stdout到别的东西,比如文件或管道。

或者它是否只能通过平台API
调用?


有些硬件没有光标(打印终端,用于

示例)。有些硬件也没有硬币返回插槽。

我能在Windows中使用Windows.h函数执行此操作,但我希望
也可以在Linux上执行此操作/ Unix也是如此。


如果您知道CRT终端的类型(或它模拟的内容)

,例如VT100,您可以发送一个特定的字符序列

它定位光标(通常,独立于操作系统,但

取决于字符集。)。但你不知道。它可能

在两个不同的终端上甚至不是相同的终端类型

连接到同一个Linux机器。并且由于拨号端口

和网络连接,可能无法通过查看机器本身的硬件来解决这个问题



我不会要求定位光标的Linux API调用,因为这超出了comp.lang.c组的范围。但是,如果有人知道它的头顶,我不会阻止你在帖子中写它! ;)
;)

无论如何,如果有一个标准的C库
函数将光标寄存在控制台中,那将是非常理想的。通过这种方式,我可以保持我的代码更加便携。
console?
Which console? What cursor? An ASR33 teletype doesn''t have a
cursor. (I suspect C was originally developed on this kind of
terminal, although maybe something older than the ASR33.)

Remember also that many operating systems provide ways to direct
stdin and stdout to something else, like files or pipes.
Or is it something that can only be done with a platform API
call?
Some hardware doesn''t HAVE a cursor (printing terminals, for
example). Some hardware doesn''t HAVE a coin return slot, either.
I was able to do this in Windows with a Windows.h function, but I want
to also do it on Linux/Unix as well.
If you know what the type of CRT terminal is (or what it emulates)
such as VT100, there is a specific character sequence you can send
it to position the cursor (generally, independent of the OS, but
dependent on the character set.). But you don''t know that. It may
not even be the same terminal type on two different terminals
connected to the same Linux machine. And thanks to dialup ports
and network connections, there may not be a way to figure this out
by looking at the hardware of the machine itself.
I won''t ask for a Linux API call that positions the cursor, as that is
beyond the scope of the comp.lang.c group. But if someone knew it off
the top of their head, I won''t stop you from writing it in a post! ;)
;)

Anyway, it would be really ideal if there were a standard C library
function that postitions the cursor in the console. This way, I can
keep my code more portable.




如果预期连接到
$ b,您的代码不是非常便携$ ba console。


Gordon L. Burditt



Your code is not very portable if it expects to be connected to
a console.

Gordon L. Burditt


JeffS写道:
JeffS wrote:
老实说,我为此搜索了comp.lang.c.faq,却一无所获。 :)

是否有用于将光标位置放在
控制台中的库函数?或者它是否只能通过平台API
调用?

我能够在具有Windows.h功能的Windows中执行此操作,但我想要
也可以在Linux / Unix上进行。

我不会要求定位光标的Linux API调用,因为它超出了comp.lang的范围。 c组。但是,如果有人知道它的头顶,我不会阻止你在帖子中写它! ;)
;)

无论如何,如果有一个标准的C库
函数将光标放在控制台中,那将是非常理想的。
这样,我可以保持我的代码更便携。
man ncurses
Honest, I scoured the comp.lang.c.faq for this but found nothing. :)

Is there a library function for placing the cursor position in the
console? Or is it something that can only be done with a platform API
call?

I was able to do this in Windows with a Windows.h function, but I want
to also do it on Linux/Unix as well.

I won''t ask for a Linux API call that positions the cursor, as that is
beyond the scope of the comp.lang.c group. But if someone knew it off
the top of their head, I won''t stop you from writing it in a post! ;)
;)

Anyway, it would be really ideal if there were a standard C library
function that postitions the cursor in the console.
This way, I can keep my code more portable. man ncurses




ncurses(3X)ncurses(3X)


名称

ncurses - CRT屏幕处理和优化包


概要

#include< curses.h>


描述

ncurses库例程为用户提供了一个

独立于终端的方法来更新字符屏幕

并进行合理的优化。

这个实现是新的curses ?? (ncurses)并且是

4.4BSD经典诅咒的批准替代品,

已停止使用。



ncurses(3X) ncurses(3X)

NAME
ncurses - CRT screen handling and optimization package

SYNOPSIS
#include <curses.h>

DESCRIPTION
The ncurses library routines give the user a
terminal-independent method of updating character screens
with reasonable optimization.
This implementation is ??new curses?? (ncurses) and is
the approved replacement for 4.4BSD classic curses,
which has been discontinued.


这篇关于是否有用于将光标位置放置在cosole中的库函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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