在C中创建文本编辑器 [英] Creating a text editor in C

查看:75
本文介绍了在C中创建文本编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用C创建一个文本编辑器。

我希望用户可以自由地输入文本而不必担心里面有什么gonig



我尝试了fgets的一些组合,fgetc与realloc和stdin一起作为

poniter.Bute不能成功。

什么可以是一种方式?

如何正常创建编辑器?

如果C中有一些功能,欢迎使用。

谢谢。

I want to create a text editor using C.
I want user to enter text freely without worring about what''s gonig
inside.
I tried some combinations of fgets,fgetc with realloc and stdin as
poniter.Bute can''t do it successfully.
What can be a way?
How are editors created normally?
If there are some functions in C ,welcomed.
thanks.

推荐答案

也许您想阅读Richard Stallman的

<< EMACS:可扩展,可自定义的显示编辑器> ;>

at:
http://www.gnu.org/software/emacs/emacs-paper.html

Maybe you''d like to read Richard Stallman''s
<<EMACS: The Extensible, Customizable Display Editor>>
at:
http://www.gnu.org/software/emacs/emacs-paper.html


silwafer说:
siliconwafer said:
我想用C创建一个文本编辑器。
我希望用户自由输入文本而不必担心什么'内部的gonig。
我尝试了fgets的一些组合,fgetc与realloc和stdin作为poniter.Bute不能成功。
有什么方法可以?
如何正常创建编辑器?
如果C中有一些功能,欢迎。
谢谢。
I want to create a text editor using C.
I want user to enter text freely without worring about what''s gonig
inside.
I tried some combinations of fgets,fgetc with realloc and stdin as
poniter.Bute can''t do it successfully.
What can be a way?
How are editors created normally?
If there are some functions in C ,welcomed.
thanks.




仅使用ISO C,你可以很容易地编写一个行编辑器。但是如果你想要完全可寻址的屏幕I / O,花哨的图形等等,你需要使用

来使用特定于你的实现的库(尽管两个或者存在三个
跨平台库,它们至少可以使您的代码在更受欢迎的桌面操作系统中可移植。


我建议你先决定你希望如何在内部代表文本

- 一个链接的行缓冲区列表是一种可能的选择,但是由

否意味着唯一的。然后,您应该能够编写一套

函数来管理和操作此存储。到目前为止,你可以完全在ISO C的范围内保持

。然后,如果你重视华丽的图形超过

便携性,我建议你把你的查询转移到新闻组处理使用

为您的平台编程。如果你重视华丽的图片,那可能是一个更好的新闻组。


去吧,看你能走多远,问一下你会被卡住,并准备发布你的尽力代码。


-

Richard Heathfield
Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然放弃了www)



Using only ISO C, you can write a line editor reasonably easily. But if you
want fully-addressable screen I/O, fancy graphics, and so on, you''ll need
to use libraries specific to your implementation (although two or three
cross-platform libraries do exist which can, at least, make your code
portable across the more popular desktop OSs).

I suggest you start off by deciding how you wish to represent the text
internally - a linked list of line buffers is one possible option, but by
no means the only one. You should then be able to write a suite of
functions to manage and manipulate this storage. So far, you can stay
entirely within the remit of ISO C. Then, if you value flashy graphics over
portability, I suggest you move your enquiries to a newsgroup dealing with
programming for your platform. If you value portability over flashy
graphics, this is probably a better newsgroup for your questions.

Have a go, see how far you get, ask if you get stuck, and be ready to post
your best-effort code.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)


如何创建1行编辑器动态分配?

说,如果用户只输入3个字符,我想只保留3个位置



静态分配,我可以使用640个字符的数组,但是如果用户每行只输入3个字符,那么
将是低效的



任何提示?

Richard Heathfield写道:
How does one create a 1 line editor with dynamic allocationi?
Say,If user types only 3 characters,I want to reserve only 3 locations
for it.
With static allocation,I can take an array of 640 characters,but it
would be inefficient
if user types only 3 characters per line.
Any hints?
Richard Heathfield wrote:
silwafer说:
siliconwafer said:
我想用C创建一个文本编辑器。
我希望用户能够自由地输入文本,而不必担心里面的内容。
我尝试了一些fgets,fgetc和realloc以及stdin的组合作为poniter.Bute不能这样做成功。
什么是方式?
编辑如何创造d通常?
如果C中有一些功能,欢迎。
谢谢。
I want to create a text editor using C.
I want user to enter text freely without worring about what''s gonig
inside.
I tried some combinations of fgets,fgetc with realloc and stdin as
poniter.Bute can''t do it successfully.
What can be a way?
How are editors created normally?
If there are some functions in C ,welcomed.
thanks.



只使用ISO C,你可以很容易地编写一个行编辑器。但是,如果您想要完全可寻址的屏幕I / O,花哨的图形等,您将需要使用特定于您的实现的库(尽管两个或三个交叉 - 平台库确实存在,至少可以让你的代码在更流行的桌面操作系统上移植。

我建议你先决定你希望如何表示文本。内部 - 行缓冲区的链接列表是一种可能的选择,但是
并不是唯一的选择。然后,您应该能够编写一套
函数来管理和操作此存储。到目前为止,您可以完全保持在ISO C的范围内。然后,如果您重视浮华图形的可移植性,我建议您将查询移至处理
编程的新闻组。平台。如果你重视华丽的图形可移植性,这对你的问题可能是一个更好的新闻组。

有一个去,看你有多远,问你是否卡住了,并准备好发布
你最努力的代码。

-
理查德希思菲尔德
Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk
电子邮件:rjh在上面的域名(但显然放弃了www)



Using only ISO C, you can write a line editor reasonably easily. But if you
want fully-addressable screen I/O, fancy graphics, and so on, you''ll need
to use libraries specific to your implementation (although two or three
cross-platform libraries do exist which can, at least, make your code
portable across the more popular desktop OSs).

I suggest you start off by deciding how you wish to represent the text
internally - a linked list of line buffers is one possible option, but by
no means the only one. You should then be able to write a suite of
functions to manage and manipulate this storage. So far, you can stay
entirely within the remit of ISO C. Then, if you value flashy graphics over
portability, I suggest you move your enquiries to a newsgroup dealing with
programming for your platform. If you value portability over flashy
graphics, this is probably a better newsgroup for your questions.

Have a go, see how far you get, ask if you get stuck, and be ready to post
your best-effort code.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)






这篇关于在C中创建文本编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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