FXRuby: Creating a terminal window

I am using an FXText control as my main terminal window. I have a couple of
problems:

  1. How do I get it to auto-scroll? Seems like it should be easy, but so far
    I haven’t figured it out.

  2. I want the window to act like a terminal window where input is only
    appended to the existing window. Can I stop the user from repositioning the
    cursor with the mouse. I have already taken care of the arrow keys by
    capturing SEL_KEYPRESS. Do I just do something similar when capturing mouse
    events?

  3. What is the best way to simulate a backspace or delete? Since I capture
    SEL_KEYPRESS, I know when it happens, but what do I do to the FXText control
    to make it update correctly?

Dale Martenson wrote:

I am using an FXText control as my main terminal window. I have a couple
of problems:

Sorry for the delayed response; I’ve been spending time with Judy :wink:

  1. How do I get it to auto-scroll? Seems like it should be easy, but so
    far I haven’t figured it out.

I just posted an answer to this on the FOX Community FAQ list:

 http://www.fifthplanet.net/cgi-bin/wiki.pl?FAQ

Look near the bottom of the list.

  1. I want the window to act like a terminal window where input is only
    appended to the existing window. Can I stop the user from repositioning
    the cursor with the mouse. I have already taken care of the arrow keys
    by capturing SEL_KEYPRESS. Do I just do something similar when capturing
    mouse events?

Yes, I think you’ll need to intercept the SEL_LEFTBUTTONPRESS (and
possibly SEL_LEFTBUTTONRELEASE) messages for that window so that
"clicking" at a certain position doesn’t move the text caret.

  1. What is the best way to simulate a backspace or delete? Since I
    capture SEL_KEYPRESS, I know when it happens, but what do I do to the
    FXText control to make it update correctly?

You should probably just mimic what FXText normally does when the user
presses those keys. The final word is to actually look at the C++ source
code for the FXText widget’s onKeyPress() member function; but for
starters, you can send the FXText::ID_DELETE message to an FXText widget
to tell it to delete the character at the current cursor position, i.e.

 text.handle(self, MKUINT(FXText::ID_DELETE, SEL_COMMAND), nil)

or to do a “backspace” at the current cursor position, send ID_BACKSPACE:

 text.handle(self, MKUINT(FXText::ID_BACKSPACE, SEL_COMMAND), nil)

Hope this helps,

Lyle