Scriptable text editor with Ruby?

Discussion in 'Ruby' started by Dolazy, Jan 3, 2007.

  1. Dolazy

    Dolazy Guest

    Hi all!

    Vim and emacs are text editor that can be scripted using internal
    script languages. I'm thinking of writing a platform independent text
    editor myself that uses the ruby language for executing scripts. The
    host application would be written in C++ (+Qt) and it would somehow be
    able to interact with ruby.

    I think there are basically two ways of implementing this interaction:
    - using IPC
    - command line interaction (host executes the ruby script with
    parameters and catches the output)

    IPC is the most powerful I think, but then again I have various options
    to achieve this communication:
    - TCP
    - XmlRpc
    - shared memory

    I'm very new to the concept of inter-process-communication and I would
    greatly appreciate your insights on how I would best proceed to achieve
    this interaction.

    Or maybe there is a more obvious and straightforward approach that I
    overlooked?

    Best regards,
    Francis
     
    Dolazy, Jan 3, 2007
    #1
    1. Advertising

  2. On 1/3/07, Dolazy <> wrote:
    > Hi all!
    >
    > Vim and emacs are text editor that can be scripted using internal
    > script languages. I'm thinking of writing a platform independent text
    > editor myself that uses the ruby language for executing scripts. The
    > host application would be written in C++ (+Qt) and it would somehow be
    > able to interact with ruby.


    Vim runs everywhere. Are you sure that this is necessary?

    Mike
    --
    Michael P. Soulier <>
    "Any intelligent fool can make things bigger and more complex... It takes a
    touch of genius - and a lot of courage to move in the opposite direction."
    --Albert Einstein
     
    Michael P. Soulier, Jan 3, 2007
    #2
    1. Advertising

  3. Dolazy

    Dolazy Guest

    Michael P. Soulier schreef:

    > Vim runs everywhere. Are you sure that this is necessary?
    >
    > Mike


    Are you sure Vim was necessary? Emacs runs everywhere... :p
     
    Dolazy, Jan 3, 2007
    #3
  4. On 1/3/07, Dolazy <> wrote:
    >
    > Michael P. Soulier schreef:
    >
    > > Vim runs everywhere. Are you sure that this is necessary?
    > >
    > > Mike

    >
    > Are you sure Vim was necessary? Emacs runs everywhere... :p


    but vi *must* run everywhere (According to POSIX). :)

    To the OP:

    Both editors run everywhere and in my opinion, if you're not planning
    on building a cross platform TextMate clone that is at least 95% as
    good, you won't pry anyone from vim, emacs, *or* TextMate.

    But if you're looking to try something different, or build the perfect
    editor for you, have fun. I know I'd at least play around with yet
    another Ruby enabled editor. (Though QT is yucky)
     
    Gregory Brown, Jan 3, 2007
    #4
  5. Dolazy

    James Britt Guest

    Dolazy wrote:
    > Hi all!
    >
    > Vim and emacs are text editor that can be scripted using internal
    > script languages. I'm thinking of writing a platform independent text
    > editor myself that uses the ruby language for executing scripts.


    Vim can do that now. Build it with Ruby support and you can drive the
    editor with Ruby.


    --
    James Britt

    "I was born not knowing and have had only a little
    time to change that here and there."
    - Richard P. Feynman
     
    James Britt, Jan 3, 2007
    #5
  6. Dolazy

    Dolazy Guest

    Gregory Brown schreef:

    > On 1/3/07, Dolazy <> wrote:
    > >
    > > Michael P. Soulier schreef:
    > >
    > > > Vim runs everywhere. Are you sure that this is necessary?
    > > >
    > > > Mike

    > >
    > > Are you sure Vim was necessary? Emacs runs everywhere... :p

    >
    > but vi *must* run everywhere (According to POSIX). :)
    >
    > To the OP:
    >
    > Both editors run everywhere and in my opinion, if you're not planning
    > on building a cross platform TextMate clone that is at least 95% as
    > good, you won't pry anyone from vim, emacs, *or* TextMate.
    >
    > But if you're looking to try something different, or build the perfect
    > editor for you, have fun. I know I'd at least play around with yet
    > another Ruby enabled editor. (Though QT is yucky)


    Thanks :)

    This is really a pet project and I develop it in the first place to
    deal with some of my specific needs (gdb integration). And also because
    I want to learn Qt.

    Btw I use Vim as primary editor.
     
    Dolazy, Jan 3, 2007
    #6
  7. Dolazy

    Dolazy Guest


    > Embed the Ruby interpreter in the text editor itself? Then just make certain
    > functions available to Ruby and script away.
    >
    > Jason


    That would be one of those obvious approaches that I couldn't think of
    myself.. Thanks!
     
    Dolazy, Jan 3, 2007
    #7
  8. Dolazy wrote:
    > Hi all!
    >
    > Vim and emacs are text editor that can be scripted using internal
    > script languages. I'm thinking of writing a platform independent text
    > editor myself that uses the ruby language for executing scripts. The
    > host application would be written in C++ (+Qt) and it would somehow be
    > able to interact with ruby.
    >

    Well, given QtRuby, you probably don't really need C++ at all -- you
    could do it all in Ruby. But I'm not sure what the most recent status of
    QtRuby is, and there is always the licensing gotcha -- you have to use
    Qt 4 for open source Windows projects. If you use another GUI toolkit,
    there are a number with Ruby bindings. For that matter, most of them
    have some kind of text editor widget built in, which makes life even easier.
    > I think there are basically two ways of implementing this interaction:
    > - using IPC
    > - command line interaction (host executes the ruby script with
    > parameters and catches the output)
    >
    > IPC is the most powerful I think, but then again I have various options
    > to achieve this communication:
    > - TCP
    > - XmlRpc
    > - shared memory
    >
    > I'm very new to the concept of inter-process-communication and I would
    > greatly appreciate your insights on how I would best proceed to achieve
    > this interaction.
    >
    > Or maybe there is a more obvious and straightforward approach that I
    > overlooked?
    >

    Two comments:

    1. As a number of folks have pointed out, "vim" has an excellent Ruby
    scripting facility already.
    2. Rather than delving into issues of low-level implementation,
    interprocess communication vs. shelling out to a command like vs.
    whatever, I'd recommend a more agile and pragmatic approach. Pick a
    toolkit, find a Windows user, a Mac user and a Linux user, set up a
    project on RubyForge and start building the thing!


    --
    M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)
    http://borasky-research.blogspot.com/

    If God had meant for carrots to be eaten cooked, He would have given rabbits fire.
     
    M. Edward (Ed) Borasky, Jan 3, 2007
    #8
  9. On 1/3/07, Dolazy <> wrote:
    [snip stuff about ruby/c++]
    > Or maybe there is a more obvious and straightforward approach that I
    > overlooked?


    have you considered writing the entire editor in ruby and
    then use ruby qt.. so you don't use any c++?

    Ruby is good at string manipulation, so its possible
    to do the entire syntax coloring in ruby. I think
    this task is pretty big in c++.

    --
    Simon Strandgaard
    http://opcoders.com/
     
    Simon Strandgaard, Jan 3, 2007
    #9
  10. Hi,

    You might want to have a look at Java 6. I have just installed that
    yesterday and haven't played around with it at all yet, but from what
    I read on the website it's integration with scripting languages might
    make it relatively easy to include Ruby scripting in your text editor.

    I realise there would be quite a few disadvantages to this approach
    (need the runtime, need a brand new runtime, cannot code it in
    Ruby...) but it might be worth looking into this.

    Thomas


    2007/1/4, Simon Strandgaard <>:
    > On 1/3/07, Dolazy <> wrote:
    > [snip stuff about ruby/c++]
    > > Or maybe there is a more obvious and straightforward approach that I
    > > overlooked?

    >
    > have you considered writing the entire editor in ruby and
    > then use ruby qt.. so you don't use any c++?
    >
    > Ruby is good at string manipulation, so its possible
    > to do the entire syntax coloring in ruby. I think
    > this task is pretty big in c++.
    >
    > --
    > Simon Strandgaard
    > http://opcoders.com/
    >
    >
     
    Thomas Mueller, Jan 3, 2007
    #10
  11. M. Edward (Ed) Borasky wrote:
    > Dolazy wrote:
    >> Hi all!
    >>
    >> Vim and emacs are text editor that can be scripted using internal
    >> script languages. I'm thinking of writing a platform independent text
    >> editor myself that uses the ruby language for executing scripts. The
    >> host application would be written in C++ (+Qt) and it would somehow be
    >> able to interact with ruby.
    >>

    > Well, given QtRuby, you probably don't really need C++ at all -- you
    > could do it all in Ruby.


    I can only agree to that. For what I experience, Qt4 1.4.7 is pretty
    stable, much more than its predecessors. But I think you'll need a bit
    of practice with the C++ classes before coding direcly with Qt/Ruby.

    Well, have fun !

    Vince

    --
    Vincent Fourmond, PhD student
    http://vincent.fourmond.neuf.fr/
     
    Vincent Fourmond, Jan 3, 2007
    #11
  12. Dolazy

    Jeroen Budts Guest

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    On 2007-01-03 23:15, Thomas Mueller wrote:
    > You might want to have a look at Java 6. I have just installed that
    > yesterday and haven't played around with it at all yet, but from what
    > I read on the website it's integration with scripting languages might
    > make it relatively easy to include Ruby scripting in your text editor.


    I would suggest to have a look at jEdit: http://jedit.org

    It's a very nice and open source editor, written in java and has
    powerful support for macro's (amongst other nice features such as
    plugins etc). By default macro's are written in BeanShell (one of the
    scripting languages for the JVM), but if you install the
    SuperScript-plugin and combine it with JRuby you can write macro's in Ruby.

    You might also want to have a look at the Ruby plugin for jEdit:
    http://rubyjedit.org/

    greetz,
    Jeroen


    - --
    <TeRanEX/>
    --- e-mail: - jid:
    --- blog: http://budts.be/weblog/ - cv: http://budts.be/jeroen/
    --- projects: http://lightyear.be - pgp: 0x8B7B774A

    ___________________________________
    GetFirefox.com - rediscover the web

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.5 (MingW32)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFFnDXuH04wF4t7d0oRAhLUAJ9DfzWru8CXazwTQsulNfG6uy0PbwCffTZz
    uL40zRVH3jPItSgRtYOPY4s=
    =cISC
    -----END PGP SIGNATURE-----
     
    Jeroen Budts, Jan 3, 2007
    #12
  13. Dolazy

    Guest

    On Thu, 4 Jan 2007, Dolazy wrote:

    > Hi all!
    >
    > Vim and emacs are text editor that can be scripted using internal
    > script languages. I'm thinking of writing a platform independent text
    > editor myself that uses the ruby language for executing scripts. The
    > host application would be written in C++ (+Qt) and it would somehow be
    > able to interact with ruby.
    >
    > I think there are basically two ways of implementing this interaction:
    > - using IPC
    > - command line interaction (host executes the ruby script with
    > parameters and catches the output)


    - using vim

    it already does all this! check out the man pages.

    regards.

    -a
    --
    if you find yourself slandering anybody, first imagine that your mouth is
    filled with excrement. it will break you of the habit quickly enough. - the
    dalai lama
     
    , Jan 3, 2007
    #13
  14. Vincent Fourmond wrote:
    > M. Edward (Ed) Borasky wrote:
    >
    >> Dolazy wrote:
    >>
    >>> Hi all!
    >>>
    >>> Vim and emacs are text editor that can be scripted using internal
    >>> script languages. I'm thinking of writing a platform independent text
    >>> editor myself that uses the ruby language for executing scripts. The
    >>> host application would be written in C++ (+Qt) and it would somehow be
    >>> able to interact with ruby.
    >>>
    >>>

    >> Well, given QtRuby, you probably don't really need C++ at all -- you
    >> could do it all in Ruby.
    >>

    >
    > I can only agree to that. For what I experience, Qt4 1.4.7 is pretty
    > stable, much more than its predecessors. But I think you'll need a bit
    > of practice with the C++ classes before coding direcly with Qt/Ruby.
    >
    > Well, have fun !
    >
    > Vince
    >
    >

    I jumped right into QtRuby (3, though, on Linux) using Caleb Tennis'
    book from Pragmatic. I can't begin to even *read* C++, much less write
    it! :) If QT4/QT4-Ruby are "upward compatible", it shouldn't be too
    difficult. I just wish the bigger brothers of QTRuby, Korundum and
    Kommander, were available on Macs and Windows. It's *almost* worth
    putting up with "KDE bloat" for them. :)

    --
    M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)
    http://borasky-research.blogspot.com/

    If God had meant for carrots to be eaten cooked, He would have given rabbits fire.
     
    M. Edward (Ed) Borasky, Jan 4, 2007
    #14
  15. >>> sender: "Dolazy" date: "Thu, Jan 04, 2007 at 02:30:10AM +0900" <<<EOQ
    > [..]
    >
    > This is really a pet project and I develop it in the first place to
    > deal with some of my specific needs (gdb integration). And also because
    > I want to learn Qt.
    >
    > Btw I use Vim as primary editor.

    For vim+gdb integration, you can check out:
    http://clewn.sourceforge.net/

    Cheers,
    Alex
     
    Alexandru E. Ungur, Jan 4, 2007
    #15
  16. On Jan 3, 2007, at 10:30 PM, Tim X wrote:

    > What I think would be really good is semantic highlighting rather
    > than syntax highlighting - this may sound crazy, but I find syntax
    > problems to be the more trivial bugs to squash. Highlighting which
    > gave more information on the "meaning" of what you are coding would
    > probably provide more valuable information.


    This is pretty much how TextMate works.

    Language grammars divide the document you are editing into "scopes,"
    which might be something like "entity.name.type.class.ruby." Themes
    then color these elements for syntax highlighting.

    But they are used in many other places by the editor. You can write
    commands that work only inside certain scopes, change editor
    behaviors when working with certain scopes, etc.

    It's quite powerful.

    James Edward Gray II
     
    James Edward Gray II, Jan 4, 2007
    #16
  17. On 1/3/07, Dolazy <> wrote:
    [snip out of context]
    > I'm thinking of writing a platform independent text
    > editor myself that uses the ruby language for executing scripts.

    [snip]

    I don't know what exactly your goal is for this editor,
    but if you want it to be great then take a look at
    what other great editors is doing.

    IMO TextMate is the best editor I have ever tried,
    and was the reason I abandoned my own editor
    project: http://aeditor.rubyforge.org/


    btw: Know your enemy (maybe I should this one day)
    http://en.wikipedia.org/wiki/The_Art_of_War


    --
    Simon Strandgaard
    http://opcoders.com/
     
    Simon Strandgaard, Jan 4, 2007
    #17
  18. Dolazy

    Dolazy Guest

    Simon Strandgaard wrote:

    > have you considered writing the entire editor in ruby and
    > then use ruby qt.. so you don't use any c++?
    >
    > Ruby is good at string manipulation, so its possible
    > to do the entire syntax coloring in ruby. I think
    > this task is pretty big in c++.


    :) Syntax coloring could be implemented as a ruby plugin.
    And all these advanced concepts I will try to delegate to libraries as
    much as I can.
     
    Dolazy, Jan 4, 2007
    #18
  19. Dolazy

    Dolazy Guest

    Thanks for your suggestions Edward, Vince (+others).

    However, running a complete text editor application as a ruby script;
    wouldn't that be slow?

    The idea of having a C++ skeleton application with lot's of ruby
    plugins seems more appealing to me. It would be faster and still
    strongly customizable. However, if you think differently then please
    share your insights on this..
     
    Dolazy, Jan 4, 2007
    #19
  20. Dolazy wrote:
    > I'm thinking of writing a platform independent text
    > editor myself that uses the ruby language for executing scripts. The
    > host application would be written in C++ (+Qt) and it would somehow be
    > able to interact with ruby.


    Why start from scratch? Take over an existing, defunct open source
    project:

    http://aeditor.rubyforge.org/

    --
    Posted via http://www.ruby-forum.com/.
     
    Suraj Kurapati, Jan 4, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    721
    Stylus Studio
    Aug 3, 2004
  2. Heiko =?ISO-8859-15?Q?K=F6hler?=

    ANN: scintilla based, scriptable code editor CUTE 0.1.6 released

    Heiko =?ISO-8859-15?Q?K=F6hler?=, Jul 27, 2003, in forum: Python
    Replies:
    0
    Views:
    369
    Heiko =?ISO-8859-15?Q?K=F6hler?=
    Jul 27, 2003
  3. Basile STARYNKEVITCH
    Replies:
    0
    Views:
    334
    Basile STARYNKEVITCH
    Sep 2, 2003
  4. Basile STARYNKEVITCH
    Replies:
    0
    Views:
    115
    Basile STARYNKEVITCH
    Sep 2, 2003
  5. Zed A. Shaw
    Replies:
    2
    Views:
    126
    Wilson Bilkovich
    Sep 9, 2005
Loading...

Share This Page