xforms-development
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XForms] drawing into a foreign window


From: Jens Thoms Toerring
Subject: Re: [XForms] drawing into a foreign window
Date: Wed, 28 Dec 2016 21:16:29 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

On Wed, Dec 28, 2016 at 01:37:21PM -0500, Patrick wrote:
> I am doing something weird.

Indeed;-)

> I want to mix ncurses and xforms.

For what purpose? XForms is for dealing with graphic
windows, ncurses for terminals (which may not even
have to be windows, it could be simple consoles),
i.e. completely text-based stuff.

> I can obtain the window ID that the ncurses program is running in. I
> wanted to override the FL_FORM struct so that the window ID is the
> terminal window's ID.

ou simply can't. And the ncurses library can do nothing
useful with any of the windows managed by X via XForms,
it's completely unaware of them. It detects the terminal
type from an environment variable (TERM) and then sends
escape sequences to that terminal (which sequences that
are deoends on the terminal type) to e.g. position the
cursor and do other things. That's nothing that would
make any sense with an X11 window. So I'm still at a
complete loss of what you want to achieve, sorry.

> I tracked Window in the FL_FORMS struct on line 896 to
> window(lowercase) and then this back to line 96 in X.h
> 
> Window is a typedef of XID on line 66 of X.h
> 
> XID is type unsigned long.

Yup, that's an XLib window ID. It has nothing at all
to do with a 'WINDOW' structure used by ncurses. These
are completely different concepts. One is the ID of
a window on a graphical screen, managed by Xlib, the
other represents properties of some area in a ter-
minal. The later may be displayed in an Xlib window
- but then it's the purpose of the terminal program
(like xterm) to interpret the escape sequences
ncurses sends into Xlib commands - or could be a
simple, text-only console (as will you get when you
press Alt-Ctrl-F1 on a linux PC).

> I tried to hack arrows.c from demos like this:
> 
> int
> main( int    argc,
>       char * argv[ ] )
> {
>     FL_FORM *form;
>     FL_OBJECT *obj;
> 
>     fl_initialize( &argc, argv, "FormDemo", 0, 0 );
> 
>     form = fl_bgn_form( FL_FLAT_BOX, 400, 400 );
>     form->window = 83886089;
> printf("first time, window is is %lu \n", form->window) ;
> 
>     obj = fl_add_button( FL_NORMAL_BUTTON, 50, 250, 100, 100, "@1" );
>     fl_set_object_lcolor( obj, FL_BLUE );
> 
>     obj = fl_add_button( FL_NORMAL_BUTTON, 150, 150, 100, 100, "@square" );
>     fl_set_object_lcolor( obj, FL_GREEN );
> 
>     fl_end_form( );
> 
>     fl_show_form( form, FL_PLACE_ASPECT, FL_TRANSIENT, "Buttons" );
> 
>     while ( fl_do_forms( ) != obj )
>         /* empty */ ;
> 
> 
> printf("second time, window is is %lu \n", form->window) ;
> 
>     fl_finish( );
>     return 0;
> }
> 
> The window ID in the second printf statement does not match the one
> I assigned to it but the first one does.
> 
> Am I close? Is there a better way to do this?

Not even in any reasonable distance, sorry;-) First of
all, changing the window ID before the window has been
created (which only happens here in fl_show_form()) has
no effect at all, the value simply gets overwritten. If
you did it afterwards, the XForms genertated window would
pop up, but then I'd expect some XError very soon and the
ensuing termination of the program. And ncurses still would
have no idea what to do with that window ID since it doesn't
work with windows in the sense of the Xlib library XForms
is based on.

It may look a bit as if you're planning to write a terminal
emulator (i.e. something like xterm), using XForms. Then
you have to take a completely different approach. First of
all, you'll have to decide which type of terminal to emulate
(there are many). Next you'll have to write a program that
reads what ncurses sends, extract the escaoe sequences
(typically starting with 0x1b) and draw the rest as text
at the appropriate position (and with the selected color/
font/whatsoever) into the window using some of XForms func-
tions. It's not that complicated once you get the hang of
it, I did something like that when porting vim to my ebook
reader recently (though it doesn't use X11, so I couldn't
use XForms for that;-)
                            Regards, Jens
-- 
  \   Jens Thoms Toerring  ________      address@hidden
   \_______________________________      http://toerring.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]