[OT?] Pymacs in ruby?

This is probably way, way OT, but has anyone considered something along the
lines of pymacs, but in ruby? (http://www.iro.umontreal.ca/~pinard/pymacs/)

I’m half again dangerous enough with lisp to hack out an emacs function when and
if I need it, but being able to do that in ruby would be so, so cool.

I’m half again dangerous enough with lisp to hack out an emacs function when and
if I need it, but being able to do that in ruby would be so, so cool.

I don’t know about emacs, but vim has had the ability to be scripted
with ruby for quite some time now.

-Michael

“Mike Campbell” michael_s_campbell@yahoo.com writes:

This is probably way, way OT, but has anyone considered something
along the lines of pymacs, but in ruby?
(http://www.iro.umontreal.ca/~pinard/pymacs/)

I’m half again dangerous enough with lisp to hack out an emacs
function when and if I need it, but being able to do that in ruby
would be so, so cool.

Agreed. This would be extreemly bad-ass. Perhaps some weekend when I
have some free time! :wink:

···


Josh Huber

Well, I use emacs for more than just an editor. currently and in the past, it’s
been my multi-windowing “os”, ftp client, mail reader, news reader, remote-file
editor, shell handler, IDE, etc.

I like the idea of VIM for an editor based on the beauty of vi’s paradigm, but
it just can’t do what I use emacs for.

···

-----Original Message-----
From: Michael Brailsford [mailto:brailsmt@yahoo.com]
Sent: Tuesday, December 10, 2002 1:01 PM
To: ruby-talk ML
Subject: Re: [OT?] Pymacs in ruby?

I’m half again dangerous enough with lisp to hack out an emacs
function when and
if I need it, but being able to do that in ruby would be so, so cool.

I don’t know about emacs, but vim has had the ability to be scripted
with ruby for quite some time now.

-Michael

I’m half again dangerous enough with lisp to hack out an emacs function
when and
if I need it, but being able to do that in ruby would be so, so cool.

I don’t know about emacs, but vim has had the ability to be scripted
with ruby for quite some time now.

I remember something about that, but no details.
Can you point to something on the web? Is there
a tutorial or at least some good examples?

Hal

···

----- Original Message -----
From: “Michael Brailsford” brailsmt@yahoo.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, December 10, 2002 12:00 PM
Subject: Re: [OT?] Pymacs in ruby?

I’m attempting to create a vertical, single-column
list of text items to match up with a vertical
single-column FXHeader. Is there any way to change
the height of individual items within a list?

If I can’t get this to work, I’ll just go ahead and
use an FXTable.

Jason

I remember something about that, but no details.
Can you point to something on the web? Is there
a tutorial or at least some good examples?

Sure, “:he ruby”. Check the output to “:version” and look for a
“+ruby”, if you see +ruby, as opposed to -ruby, then you have ruby
support already compiled in, otherwise you will need to recompile and
provide ‘–with-rubyinterp’ to ./configure. I think that is the right
option, but it has been awhile, so you may want to check that.

-Michael

Jason Persampieri wrote:

I’m attempting to create a vertical, single-column
list of text items to match up with a vertical
single-column FXHeader. Is there any way to change
the height of individual items within a list?

By default, the height of a list item is determined by the greater of
the height of its font or the height of its icon, plus some extra
inter-item padding, i.e.

 class FXListItem
   def getHeight(aList)
     textHeight = 0
     iconHeight = 0
     unless text.empty?
       textHeight = aList.font.fontHeight
     end
     unless icon.nil?
       iconHeight = icon.height
     end
     LINE_SPACING + [textHeight, iconHeight].max
   end
 end

So if you want to fix the list items’ height at some particular value,
one way would be to subclass FXListItem and override the getHeight() method:

 class FixedHeightListItem < FXListItem
   def initialize(theHeight, theText, theIcon=nil, theData=nil)
     super(theText, theIcon, theData)
     @myFixedHeight = theFixedHeight
   end
   def getHeight(aList)
     @myFixedHeight
   end
 end

And then to add items of this class to your list:

 myList = FXList.new(...)
 myList.appendItem(FixedHeightListItem.new(20, "Tall Item"))
 myList.appendItem(FixedHeightListItem.new(50, "Really Tall Item"))

Hope this helps,

Lyle

Hmm, I didn’t compile gvim. On Windows, we tend
to use precompiled binaries… :slight_smile:

So what should I do? I do have gcc (or rather djgpp).

Don’t worry, my New Year’s Resolution for 2003 will
be to dump Windows forever. And finish the novel.

Hal

···

----- Original Message -----
From: “Michael Brailsford” brailsmt@yahoo.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, December 10, 2002 6:27 PM
Subject: Re: [OT?] Pymacs in ruby?

I remember something about that, but no details.
Can you point to something on the web? Is there
a tutorial or at least some good examples?

Sure, “:he ruby”. Check the output to “:version” and look for a
“+ruby”, if you see +ruby, as opposed to -ruby, then you have ruby
support already compiled in, otherwise you will need to recompile and
provide ‘–with-rubyinterp’ to ./configure. I think that is the right
option, but it has been awhile, so you may want to check that.

ok, that worked (although I ended up using a slightly
different approach). I really need to get my brain
latched on to the idea of modifying classes so easily
:wink:

Now, I need to be able to add widgets at runtime.
This ‘seems’ to work ok as parentFrame.numChildren
returns the correct value, but the widgets just aren’t
appearing.

I’ve tried all sorts of stuff like recalc, resize,
hide then show, raise, etc on all widgets involved
(parents and children). What the heck am I missing?

On a side note, you show FXListItem as being written
in Ruby… I’ve been trying to look through the FXRuby
source to find where all of these classes are defined
but I can’t seem to find them…

Jason Persampieri
Tools Programmer
Kush Games

···

— Lyle Johnson lyle@users.sourceforge.net wrote:

Jason Persampieri wrote:

I’m attempting to create a vertical, single-column
list of text items to match up with a vertical
single-column FXHeader. Is there any way to
change
the height of individual items within a list?

By default, the height of a list item is determined
by the greater of
the height of its font or the height of its icon,
plus some extra
inter-item padding, i.e.

 class FXListItem
   def getHeight(aList)
     textHeight = 0
     iconHeight = 0
     unless text.empty?
       textHeight = aList.font.fontHeight
     end
     unless icon.nil?
       iconHeight = icon.height
     end
     LINE_SPACING + [textHeight, iconHeight].max
   end
 end

So if you want to fix the list items’ height at some
particular value,
one way would be to subclass FXListItem and override
the getHeight() method:

 class FixedHeightListItem < FXListItem
   def initialize(theHeight, theText,

theIcon=nil, theData=nil)
super(theText, theIcon, theData)
@myFixedHeight = theFixedHeight
end
def getHeight(aList)
@myFixedHeight
end
end

And then to add items of this class to your list:

 myList = FXList.new(...)
 myList.appendItem(FixedHeightListItem.new(20,

“Tall Item”))
myList.appendItem(FixedHeightListItem.new(50,
“Really Tall Item”))

Hope this helps,

Lyle

Hmm, I didn’t compile gvim. On Windows, we tend
to use precompiled binaries… :slight_smile:

So what should I do? I do have gcc (or rather djgpp).

Don’t worry, my New Year’s Resolution for 2003 will
be to dump Windows forever. And finish the novel.

You got me there. I am about as clueless as one can be when it comes
to windows. I remember seeing something about compiling win32 vim for
ruby support on a rubygarden wiki. I searched for vim and it brought
up 3 wikis with vim in the title. I know vim has been successfully
compiled with Borland’s bcc and with msvc++ 6.0, as well as with mingw
and cygwin. If you still have troubles getting it working then,
I am sure that someone on the vim or vim-dev ML could give you far
better info than I.

-Michael

Jason Persampieri wrote:

Now, I need to be able to add widgets at runtime.
This ‘seems’ to work ok as parentFrame.numChildren
returns the correct value, but the widgets just aren’t
appearing.

I’ve tried all sorts of stuff like recalc, resize,
hide then show, raise, etc on all widgets involved
(parents and children). What the heck am I missing?

You need to call create() on widgets that you add after the program’s
running, e.g.

 aNewList = FXList.new(parentFrame, ...)
 aNewList.create

On a side note, you show FXListItem as being written
in Ruby…

Yes, that was me lying. I mean distorting reality.

I’ve been trying to look through the FXRuby
source to find where all of these classes are defined
but I can’t seem to find them…

The code for FXListItem isn’t written in Ruby, and this is true for
almost all of FXRuby. FXRuby is a wrapper around the FOX library, which
is C++ code. The (fake) Ruby code that I showed for FXListItem#getHeight
is a “translation” of the corresponding C++ function into Ruby.

Hmm, I didn’t compile gvim. On Windows, we tend
to use precompiled binaries… :slight_smile:

So what should I do? I do have gcc (or rather djgpp).

Don’t worry, my New Year’s Resolution for 2003 will
be to dump Windows forever. And finish the novel.

You got me there. I am about as clueless as one can be when it comes
to windows. I remember seeing something about compiling win32 vim for
ruby support on a rubygarden wiki. I searched for vim and it brought
up 3 wikis with vim in the title. I know vim has been successfully
compiled with Borland’s bcc and with msvc++ 6.0, as well as with mingw
and cygwin. If you still have troubles getting it working then,
I am sure that someone on the vim or vim-dev ML could give you far
better info than I.

-Michael

The wiki page that contains information about compiling Win32 Vim with Ruby
support is

http://www.rubygarden.org/ruby?VimExtensions

The instructions use MinGW. Funny, since I compiled it, I haven’t used the
Ruby interface at all.

http://www.rubygarden.org/ruby?VimExtensions

contains Tim Hammerquist’s excellent hack to control xmms (music player) via
Vim shortcuts through the Ruby interface!

Cheers,
Gavin

···

From: “Michael Brailsford” brailsmt@yahoo.com

Gah… this [small] problem is really starting to
irritate me. Thank you so much for your help Lyle…
I wouldv’e given up by now if you weren’t here :wink:

Here’s my latest issue:

I’m attempting to wipe everything from one area and
replace it with some other widgets. I have two
strategies.

(1) delete and recreate the parent
newParent = FXVerticalFrame.new(parent.parent, …)
parent.destroy
parent = newParent
parent.create

this is sloppy, but I figured it’d work.
Unfortunately, the parent disappears, but the new one
doesn’t take it’s place (although it DOES exist out
there)

(2) delete all the child widgets of parent
0.upto(parent.numChildren-1) do |childNum|
parent.childAt(childNum).destroy
end

Now, this ALMOST works… the problem here is that the
parent widget still counts the old children towards
the total child height (which seems like a bug to me)
and places the next new widget urther down. And
parent.setHeight(0) doesn’t seem to have an effect.

Whew… have at it!

Jason Persampieri
Tools Programmer
Kush Games

Jason Persampieri wrote:

I’m attempting to wipe everything from one area and
replace it with some other widgets. I have two
strategies.

(1) delete and recreate the parent
newParent = FXVerticalFrame.new(parent.parent, …)
parent.destroy
parent = newParent
parent.create

this is sloppy, but I figured it’d work.
Unfortunately, the parent disappears, but the new one
doesn’t take it’s place (although it DOES exist out
there)

Calling FXWindow#destroy destroys the server-side resources (e.g. the X
window associated with the parent widget) but it doesn’t make the
underlying object go away. Another way to look at it is that
FXWindow#destroy is the opposite of FXWindow#create. What you want to do
is blow away the parent window object altogether, and to do that you
want to call FXWindow#removeChild:

 grandParent = parent.parent
 grandParent.removeChild(parent)
 parent = FXVerticalFrame.new(grandParent, ...)

(2) delete all the child widgets of parent
0.upto(parent.numChildren-1) do |childNum|
parent.childAt(childNum).destroy
end

This would also work, if you replace the calls to FXWindow#destroy with
a removeChild from the parent, i.e.

 (numChildren - 1).downto(0) do |childNum|
   parent.removeChild(parent.childAt(childNum))
 end

Note that I also changed it from “count up from zero” to “count down
from numChildren-1”. The reason is that each time you call
removeChild(i) you’ve shifted all of the child widgets with index > i
down a slot.