Hi Brian,

Since my project only has a 160x160 px display (20 char x 20 char with the current font), I need to only display that much of the display buffer. Here is what I am thinking: if I take the display buffer from tn5250 and copy the characters that I want to display into a new 20x20 buffer. Each time I have the cursor move or want the screen to move I can just update the 20x20 buffer. My only real question is where in the code is dbuffer actually pushed to the screen? I need to add a function just like it but pushing my 20x20 buffer to the display.

What you want to do is write your own "terminal object". If your screen is curses based, it would probably make sense to copy cursesterm.c and then change the names, so that the original is still intact.

TN5250 will call the routines in the terminal object that are defined in the Tn5250Terminal structure. There's a whole list of callbacks in that structure for the various routines that need to be called.

For example, in the tn5250_curses_terminal_new() routine in cursesterm.c, you'll see the following code:

   r->conn_fd = -1;
   r->init = curses_terminal_init;
   r->term = curses_terminal_term;
   r->destroy = curses_terminal_destroy;
   r->width = curses_terminal_width;
   r->height = curses_terminal_height;
   r->flags = curses_terminal_flags;
   r->update = curses_terminal_update;
   r->update_indicators = curses_terminal_update_indicators;
   r->waitevent = curses_terminal_waitevent;
   r->getkey = curses_terminal_getkey;
   r->putkey = NULL;
   r->beep = curses_terminal_beep;
   r->enhanced = curses_terminal_enhanced;
   r->config = curses_terminal_config;

This is setting the callbacks. When lib5250 wants the terminal to make a beep noice, it calls curses_terminal_beep(). When lib5250 wants to read a keypress from the terminal, it calls curses_terminal_getkey(), etc.

You can write your own terminal object by creating code that provides these different "events". If your terminal is curses based, it might make sense to just copy the existing cursesterm.c, rename the functions, and modify them to work the way you want. That way, you'll be able to display the screen differently.

As far as how the display buffer gets "pushed" to the screen, the "update" routine is called by lib5250 (in the above example, "update" points to the curses_terminal_update() function, so that function would be called). Also, when the indicators (for message waiting, input inhibited, etc) need to be updated, it called the "update_indicators" routine (which is mapped to curses_terminal_update_indicators) and so on.

Take a look at those routines in cursesterm.c to see how they work...

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].