Basically took the xcb_image_text... call and wrapped it in an argc,args[] call. Noe how I handle the argument index in the set up.
// This version of Xchars keeps the window_t and grahic context in the loist
// xchar_win, a list of open windows. Any subsystem may open a windows, but the Xchar keeps only only one X server connection.
/// OutStr ID str x y str
int OutStr(int * argc,void * args[] ){
int argi= *argc +1; // skip command
int id = atoi(args[argi]);
xcb_gcontext_t gc = xchar_win[id].gc;
xcb_window_t window = xchar_win[id].window;
har * label= args[argi+1];
int16_t x1=atoiargs[argi+2];
int16_t y1=atoi(args[argi+3]);
*argc +=5;
/* draw the text */
xcb_void_cookie_t textCookie = xcb_image_text_8_checked (connection,
strlen (label),
window,
gc,
x1, y1,
label );
testCookie(textCookie, connection, "can't paste text");
}
//
//Now here is the Xchars entry point:
int Entry(int *argc, void * args[] {
if(!strcmp(args[0],"Init")) Init(argc,args);
else if(!strcmp(args[0],"OutStr")) OutStr(argc,args);
else if(!strcmp(args[0],"NewScr")) NewScr(argc,args);
else if(!strcmp(args[0],"DelScr")) DelScr(argc,args);
}
It is the Xchars command loop and it is found by ConsoleLoop when Xchar is loaded:
LoadModule xchars;
Then ConsoleLoop will automatically call:
Init;
Stepping into the entry point before continuing to loop.
This whole module comes in at 200 lines, but it gves me a simple two dimensional screen for strings. My ConsoleLoop is all of 75 lines of code. So, right away I am light years ahead of any terminal emulations.
Any subsystem called can throw up an xchars window for output, using a separate args list of its own, if it is signaled to do so. The scripter also can take standard strings back from a sub system call and present them on a window quite easily. The scripter is loaded like any other module.
We can see that making a two dimensional adapter for gdb is quite easy once we decide on a simple, low foot print scripter.
No comments:
Post a Comment