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. 18 30838
siliconwafer said: 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.
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)
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: siliconwafer said:
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.
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)
siliconwafer wrote: 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?
look up malloc()
(that should be a sufficient hint)
HTH,
ed
siliconwafer wrote: 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.
The "pec" multi-line edit control is written in C for Windows. It uses
malloc on each keystroke and connects the blocks with a double link
list. www.ticon.net/~tatimmer/programming.htm
TomT
siliconwafer wrote
(in article
<11************ **********@f14g 2000cwb.googleg roups.com>): 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.
This is 2005. Are you really worried about maximizing memory
information for a single line of text?
If you are, (or if your professor is), then lookup the malloc()
documentation on your system.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw
"Becker" <we*******@devh r.com> writes: 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
First, please provide context when you post a followup.
Read <http://cfaj.freeshell. org/google/>.
Second, I don't think emacs is a good starting point for a C beginner
who wants to write a text editor. Emacs is practically an operating
system. A simpler line-oriented editor like "ed" would be a much
better place to start.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Randy Howard <ra*********@FO OverizonBAR.net > writes: siliconwafer wrote (in article <11************ **********@f14g 2000cwb.googleg roups.com>):
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.
This is 2005. Are you really worried about maximizing memory information for a single line of text?
If you are, (or if your professor is), then lookup the malloc() documentation on your system.
If a 1-line editor is to be the basis for a multi-line editor, it
certainly makes sense to conserve memory, so you can edit large files
without using an order of magnitude more memory than necessary. And
it makes sense to implement the allocation code at an early stage of
the project.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Keith Thompson wrote
(in article <ln************ @nuthaus.mib.or g>): Randy Howard <ra*********@FO OverizonBAR.net > writes: siliconwafer wrote (in article <11************ **********@f14g 2000cwb.googleg roups.com>):
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.
This is 2005. Are you really worried about maximizing memory information for a single line of text?
If you are, (or if your professor is), then lookup the malloc() documentation on your system.
If a 1-line editor is to be the basis for a multi-line editor, it certainly makes sense to conserve memory, so you can edit large files without using an order of magnitude more memory than necessary.
I don't disagree with that, but I was referring to the context
from upthread, wherein this was a (single) line editor, to meet
clc standard conformance, etc.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ed Suominen |
last post by:
I'm thinking of implementing a real-time collaborative text editor in Python
using Twisted. An initial plan is to use a Twisted PB server daemon that
accepts user:password:file connections from text editor clients to make
changes to a specified file on the server, and have the text editor clients
update their local copies of the file based on local user input or input
entered from other users, relayed via the server.
Jabber compatibility...
|
by: IkBenHet |
last post by:
Hello,
I found this script to create a simple rich text form
(http://programmabilities.com/xml/index.php?id=17):
<html>
<head>
<title>Rich Text Editor</title>
</head>
<body>
|
by: m3ckon |
last post by:
Hi there,
I can succesfully create a word doc from my asp.net page, but I have 2
issues I need to resolve in order to use it in my app:
1) Creating a table: I seem unable to create a table, I'm uing the coe
below, but I'm unsure as to what the Range parameter should be for
oWordDoc.Content.Tables.Add ???
|
by: DaWoE |
last post by:
Hi all,
I'm fairly new to ASP.NET. What i want to do is creat a online
registration form. On the first step is getting the users details and
the number of people he wants to register.
Based on the number of people i want to create a form where he can enter
the persons details.
For example he wants to register 3 people. Then the second step of the
registration would have to be like this :
|
by: ValK |
last post by:
Hello All.
I have a windows service, that monitors file directory.
Now I'm trying to create custom install wizard for this service. I added
projectinstaller class to my application, where I specified properties like
ServiceName, DisplayName and so on.
What I like to do, is to add one more dialog screen with the test box and
"Browse" button to the installation wizard and provide user with the ability
to select/change service monitoring...
| |
by: Tarscher |
last post by:
hi all,
I have this seemingly simple problem. I have lost a lot of time on it
though.
When a user selects a value from a dropdownlist (static control) a
dynamic control is generated. I have to create the dynamic controls
in the OnInit stage of the lifecycle. Since data from static controls
is not yet available in the OnInit stage I can't know what dynamic
control I have to create.
|
by: Sean C. |
last post by:
Hey All,
I'm having a little problem here. I have a project that I'm working on
that involves a MySQL server database backend. I'm having no problem
creating the database on the fly if it doesn't already exist and using it
once it's created.
My problem comes into play when I run the program for the first time. I'm
wanting to have some kind of flag that lets me know that the database has
not yet been created, so that I can call my...
|
by: hellboss |
last post by:
Hi every one , iam working wit asp.net vs05,i need to built a editor to view the document. the editor should be similar to that of the message area in your site http://www.thescripts.com/forum/newthread.php?do=newthread&f=131,
if there is a better editor with minimal functional it would serve my purpose
My other question is, Can we use rich text box in asp.net ?
Thanks in advance
|
by: danesh1354 |
last post by:
Hi All,
First I need to construct a text editor by python programming and add this code to a biger code that has been written before, and i would like that by my code for this editor have a capability to save it into special file name and format, for instance if i want to save it to a file with XML extention format like A.xml, wondering if anybody kknows how to do that, if you have any idea please guide me through how to reach to these....
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |