如何在流中移动箭头键 [英] how to move arrow keys in streams

查看:121
本文介绍了如何在流中移动箭头键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Assalam-o-Alikum!



这可能是一个愚蠢的问题,但它突然出现在我脑海中。 3个星期前,我正在用C语言进行文件处理。在测试我的编程时,我故意错过键入的内容并点击输入。但当我试图向上移动箭头键转到上面的行,并纠正我无法做到的事情。比如在一些基于文本的编辑nano,vi等中。



我的问题是它在顶部:D ​​...



我的其他问题是..



1)什么是溪流,什么是缓冲区?



2)完全缓冲区,行缓冲区和无缓冲区意味着什么?



3)运行nano编辑器时打开的窗口。我们输入的区域是完全缓冲的?



我的意思是当我输入内容并按回车键在第二行写东西但我可以按向上箭头键进入第一行。



希望您理解我的问题:)

解决方案

请参阅我对该问题的评论。提出这样的问题并不是最有效的学习方法。



让我试试:

  1. 简而言之:流是编程中的重要抽象缓冲区是其技术实现的细节,用于在某些条件下提高某些流的性能。这个想法是:您可以进行快速操作(使用RAM)和较慢的操作(例如,寻址硬盘)。您可以通过减少使用较慢操作的次数来提高平均性能。



    这是您最好向Google,维基百科或其他来源提出的问题之一。他们可以在一个快速答案中更好地解释这个问题:

    http:// en.wikipedia.org/wiki/Stream_%28computing%29 [ ^ ],

    http://en.wikipedia.org/wiki/ Standard_streams [ ^ ],

    http://en.wikipedia.org/wiki/Data_buffer [ ^ ]。
  2. Streams可以缓冲或不缓存。您可以使用没有任何缓冲区的流。就这么简单。



    完全缓冲在这里解释: http://www.cplusplus.com/reference/cstdio/setvbuf [ ^ ]。



    行缓冲是与字符I / O相关的概念,而不是块I / O.差异有点人为,主要源于字符表示为单个字节的时间。这里解释了这些概念: http://www.gnu.org/software/libc/ manual / html_node / Buffering-Concepts.html [ ^ ]。
  3. 区域无法缓冲。这是演示概念(UI)。一些编辑器(实际上很多)在内存中完全读取文档并关闭文件。从那时起,文档保存在内存中并进行编辑,文件可以独立编辑或删除。在无法用于真正的大文件中,因为它们可能太大而无法适应虚拟内存的可寻址空间。然后文件保持打开状态,并根据请求加载或修改文件存储单元上的数据。这样做的算法相对复杂。





祝你好运。

-SA

Assalam-o-Alikum!

this is maybe a stupid question but it pops in my head. 3 weeks ago i was doing file handling in C. While testing my prog i deliberately miss typed something and hit enter. but when i tried to move up arrow key to goto the line above and correct thing i can't. like in some text based editors "nano" ,"vi" etc.

My question is well its on the top :D...

My other questions are..

1) what are streams, what are buffers?

2) what do they means by full buffer, line buffer and unbuffered ?

3) the window which opens when we run nano editor. the area where we type is fully buffered ?

what i mean is when i type something and press enter write something in second line but i can go to first line by pressing up arrow key.

Hope you understand my questions :)

解决方案

Please see my comment to the question. Asking such question is not the most efficient way to learn things.

Let me try:

  1. In a nutshell: stream is the important abstraction in programming, and buffer is the detail of its technical implementation used to improve performance of some streams under certain condition. The idea is: you can have fast operations (working with RAM) and slower operations (for example, addressing hard drive). You can improve average performance by reducing number of the use of slower operations.

    This is one of the questions which you would better address to Google, Wikipedia or other source. They explain this matter better than one could do in one Quick Answer:
    http://en.wikipedia.org/wiki/Stream_%28computing%29[^],
    http://en.wikipedia.org/wiki/Standard_streams[^],
    http://en.wikipedia.org/wiki/Data_buffer[^].
  2. Streams can be buffered or not. You can use a stream without any buffer. As simple as that.

    "Fully-buffered" is explained here: http://www.cplusplus.com/reference/cstdio/setvbuf[^].

    "Line buffering" is the concept related to character I/O, as opposed to block I/O. The difference is somewhat artificial, mostly originated from the time when "characters" were represented as single bytes. The concepts are explained here: http://www.gnu.org/software/libc/manual/html_node/Buffering-Concepts.html[^].
  3. "Area" cannot be buffered or not. This is the presentation concept (UI). Some editors (many, in fact) read the document fully in the memory and close the file. Since then, the document is kept in memory and edited, and the file can be independently edited or removed. In cannot work for really big files, because they may be too big to fit even in the addressable space of the virtual memory. Then the file is kept open and the data on the file storage unit is loaded or modified on request. The algorithms for doing that are relatively complex.



Good luck.

—SA


这篇关于如何在流中移动箭头键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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