6 Replies - 12373 Views - Last Post: 15 September 2008 - 02:36 AM Rate Topic: -----

#1 breekbot  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 01-August 08

How to write a simple text editor in C (linux)

Post icon  Posted 12 September 2008 - 04:50 PM

Hello everyone :^:

I am pretty new at C programming but i want to try to write a simple text editor anyway.
but i'm not shore where to begin.

Is there someone who can provide some hints (no code!) on how to structure the program
and perhaps a good starting point to get me on track?

Thanks in advance ,
Breekbot

BTW altough this is not a homework assignment i wouldn't dream of opposing forum rules
So this is my best effort!
its not much but im proud of it :P



#include <stdio.h>

int main()
{
	printf("Hello editor\n");
	return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: How to write a simple text editor in C (linux)

#2 GWatt  Icon User is offline

  • member icon

Reputation: 257
  • View blog
  • Posts: 3,035
  • Joined: 01-December 05

Re: How to write a simple text editor in C (linux)

Posted 13 September 2008 - 12:00 AM

What desktop environment are you using? If you're using gnome, then I would look into learning gtk, but if you're using kde, then qt is probably the way to go. As far as I know, gtk is mostly C while QT is C++. I'd imagine that there are C++ wrappers for gtk, and C wrappers for QT, but don't hold me to that.

After you know a particular widget set, a text editor is simply a large textbox with the ability to save its contents.

I hope that helps.
Was This Post Helpful? 0
  • +
  • -

#3 breekbot  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 01-August 08

Re: How to write a simple text editor in C (linux)

Posted 13 September 2008 - 12:34 AM

View PostGWatt, on 13 Sep, 2008 - 12:00 AM, said:

What desktop environment are you using


Fore the sake of simplicicity i want to keep it a console program. like nano.

And my long term higher goals are system progamming anyway so GUI `s are not my top priority at this mpment.

Regards

Breekbot,
Was This Post Helpful? 0
  • +
  • -

#4 MorphiusFaydal  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 43
  • View blog
  • Posts: 1,376
  • Joined: 12-May 05

Re: How to write a simple text editor in C (linux)

Posted 13 September 2008 - 03:01 PM

View PostGWatt, on 13 Sep, 2008 - 02:00 AM, said:

As far as I know, gtk is mostly C while QT is C++. I'd imagine that there are C++ wrappers for gtk, and C wrappers for QT, but don't hold me to that.

gtkmm for Gtk+. :) There's apparently C bindings for Qt, but damned if I can find them. For all I know, they may well be provided with the base Qt package.

And to the OP; you'll want to look into ncurses, for creation of an app. Beyond that... I can only recommend tearing down the source code for nano or pico and seeing how they do things, then write your own version.
Was This Post Helpful? 0
  • +
  • -

#5 breekbot  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 01-August 08

Re: How to write a simple text editor in C (linux)

Posted 13 September 2008 - 04:04 PM

View PostMorphiusFaydal, on 13 Sep, 2008 - 03:01 PM, said:

And to the OP; you'll want to look into ncurses, for creation of an app. Beyond that... I can only recommend tearing down the source code for nano or pico and seeing how they do things, then write your own version.



I am looking at the source code of nano.
And altough i get the individual lines of code its hard to see the big picture
maybe its a litle too early and should i stick to smaller exercises for now ;)

ill keep trying though

thanx anyway :)
Was This Post Helpful? 0
  • +
  • -

#6 ruslan40  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 34
  • Joined: 13-September 08

Re: How to write a simple text editor in C (linux)

Posted 14 September 2008 - 11:23 PM

View Postbreekbot, on 13 Sep, 2008 - 04:04 PM, said:

View PostMorphiusFaydal, on 13 Sep, 2008 - 03:01 PM, said:

And to the OP; you'll want to look into ncurses, for creation of an app. Beyond that... I can only recommend tearing down the source code for nano or pico and seeing how they do things, then write your own version.



I am looking at the source code of nano.
And altough i get the individual lines of code its hard to see the big picture
maybe its a litle too early and should i stick to smaller exercises for now ;)

ill keep trying though

thanx anyway :)



Hi.

If you want to write a console app, you should definitely learn ncurses. Not only it will serve this purpose, it will be especially useful to you if u want to get into systems programming (since you'll be working with the console a lot and almost all gui apps for it use ncurses). It is not very hard to learn, and there are VERY good tutorials for it. All of the console functionality is pretty much included in it (creating menus, input/output, colors, etc).
There is also another library for console manipulation, called slang. But I don't know too much about it. Besides, ncurses is the tried and true method for these tasks. Another advantage of it is that it supports all terminal types (once again, might be useful in your field. Depending on the kind of systems programming u are planning on doing).

Good luck!

Rus
Was This Post Helpful? 0
  • +
  • -

#7 breekbot  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 01-August 08

Re: How to write a simple text editor in C (linux)

Posted 15 September 2008 - 02:36 AM

View Postruslan40, on 14 Sep, 2008 - 11:23 PM, said:

If you want to write a console app, you should definitely learn ncurses. Not only it will serve this purpose, it will be especially useful to you if u want to get into systems programming



Yes now that you mention it i rememeber a few programs that use ncurses.

I stand corrected and get on it right now. :)

thanks for the heads up ruslan40 ! :^:

Breekbot
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1