11 Replies - 3013 Views - Last Post: 23 May 2012 - 04:45 PM Rate Topic: -----

#1 smoothedatol412  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 78
  • Joined: 22-May 12

question: Ruby Text Editer

Posted 22 May 2012 - 06:21 PM

Hello All,
I have been playing around with Ruby now for about a few weeks now and I was wondering how hard
it would be to write a simple text editor in Ruby to be run in terminal; not having any GUI components
but maybe after it was build as an update to the program.
I think it would be fun to write a Ruby program within a Ruby.

**Happy Coding**
Is This A Good Question/Topic? 0
  • +

Replies To: question: Ruby Text Editer

#2 dorknexus  Icon User is offline

  • or something bad...real bad.
  • member icon

Reputation: 1255
  • View blog
  • Posts: 4,618
  • Joined: 02-May 04

Re: question: Ruby Text Editer

Posted 22 May 2012 - 06:48 PM

Hello! Awesome to hear you're experimenting with ruby!

You could utilize rbcurse which is described as "a comprehensive widget library written in ruby for creating ncurses applications."

If you don't know anything about ncurses it is described as "a programming library that provides an API which allows the programmer to write text-based user interfaces in a terminal-independent manner."

This would be a good place to start learning about how to create terminal-based user interfaces.

Hope that helps!
Was This Post Helpful? 1
  • +
  • -

#3 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2100
  • View blog
  • Posts: 3,197
  • Joined: 21-June 11

Re: question: Ruby Text Editer

Posted 22 May 2012 - 06:57 PM

I'm not sure that writing a terminal text-editor (unless it's a simple command-based one) would actually be easier than writing a GUI text-editor. ncurses isn't really easier to work with than most GUI libraries.
Was This Post Helpful? 0
  • +
  • -

#4 smoothedatol412  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 78
  • Joined: 22-May 12

Re: question: Ruby Text Editer

Posted 22 May 2012 - 07:06 PM

A text editer like nano is what i mean.
Also, is there a site what would show me how to code one
with out the heavy use of GEMS or library.. Coding the
whole thing from the ground up?
Was This Post Helpful? 0
  • +
  • -

#5 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1359
  • View blog
  • Posts: 3,425
  • Joined: 28-November 09

Re: question: Ruby Text Editer

Posted 22 May 2012 - 07:12 PM

For the most part, if you have to ask how, it's time to either break out the paper and start thinking, or find another project.

Depending on your skill level currently, this could either be a valid exercise, or something completely overkill. What you CAN do is look at the source code of say nano, vim, or emacs. It's written primarily in C, so translation won't be horrid and it's not a far transfer for most things.
Was This Post Helpful? 0
  • +
  • -

#6 smoothedatol412  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 78
  • Joined: 22-May 12

Re: question: Ruby Text Editer

Posted 22 May 2012 - 07:15 PM

How would I find the source code of such an application??
Was This Post Helpful? 0
  • +
  • -

#7 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2100
  • View blog
  • Posts: 3,197
  • Joined: 21-June 11

Re: question: Ruby Text Editer

Posted 22 May 2012 - 07:24 PM

View Postsmoothedatol412, on 23 May 2012 - 04:06 AM, said:

A text editer like nano is what i mean.


So not command-based. Then what I said stands and you could just as well write a GUI text editor.

Quote

Also, is there a site what would show me how to code one
with out the heavy use of GEMS or library.. Coding the
whole thing from the ground up?


Not using gems would mean you have to write your own C extension to use the (n)curses library1. Not using (n)curses would mean, you'll have to write your own C library to replace ncurses (in platform specific C code). Not using any libraries (including the ones provided by the OS) would mean you can't. The functionality you need just isn't available in plain ruby1 (or standard C for that matter).

1 Actually ruby includes curses binding in the standard library, so you could use those if you don't count that as cheating.

This post has been edited by sepp2k: 22 May 2012 - 07:28 PM

Was This Post Helpful? 0
  • +
  • -

#8 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1152
  • View blog
  • Posts: 2,530
  • Joined: 05-May 05

Re: question: Ruby Text Editer

Posted 22 May 2012 - 07:36 PM

sepp2k: Wouldn't rbcurses be exactly what you need to write something like nano?
Was This Post Helpful? 0
  • +
  • -

#9 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2100
  • View blog
  • Posts: 3,197
  • Joined: 21-June 11

Re: question: Ruby Text Editer

Posted 22 May 2012 - 07:38 PM

View Postblackcompe, on 23 May 2012 - 04:36 AM, said:

sepp2k: Wouldn't rbcurses be exactly what you need to write something like nano?


Yes. Did I say something that makes you think that would not be the case?
Was This Post Helpful? 0
  • +
  • -

#10 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1152
  • View blog
  • Posts: 2,530
  • Joined: 05-May 05

Re: question: Ruby Text Editer

Posted 22 May 2012 - 07:43 PM

Quote

Yes. Did I say something that makes you think that would not be the case?


When you said, "So not command-based," I thought you were advising against it. Everything is clear now.
Was This Post Helpful? 0
  • +
  • -

#11 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2100
  • View blog
  • Posts: 3,197
  • Joined: 21-June 11

Re: question: Ruby Text Editer

Posted 22 May 2012 - 07:45 PM

I just meant that if it had been command-based, you could implement that just by using gets and puts. But if you want to implement a visual text editor like nano, you need something like ncurses/rbcurses or a GUI library.
Was This Post Helpful? 0
  • +
  • -

#12 smoothedatol412  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 78
  • Joined: 22-May 12

Re: question: Ruby Text Editer

Posted 23 May 2012 - 04:45 PM

Thank you all for the replies I have a lot of reading and code testing
thanks to all of your wonderful ideas. I will be sure to do a blog entry
about my results with the application in ruby.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1