BASIC Developer & Support Resources > Scripting Languages

iCALL

<< < (2/12) > >>

JRS:
I wanted to first get positioning working and then worry about color.


--- Code: ---DECLARE SUB DLL ALIAS "_gtk" LIB "gtk-server"

DLL("gtk_server_cfg " & "curses.cfg")

main_win = DLL("initscr")
DLL("wmove " & main_win & " 5 5")
DLL("printw %s \"ScriptBasic iCALL color demo\"")
DLL("refresh")
DLL("getch")
DLL("endwin")

--- End code ---

Even using wmove and passing the stdscr, the position still defaults to the top left corner of the screen.  >:(

AIR:

--- Quote ---@AIR - I would be interested to know if your example on the BCX forum would work calling libcurses.so rather than just static linking.
--- End quote ---

My example isn't statically linked. Run ldd on it and you'll see.....

A.

JRS:
I'm using the curses calls that were made in the SB extension module and I'm close to getting this working. I just need to find out how to pass the value of stdscr between the GTK-Server wrapped functions. Hopefully Peter will chime in and clear up the mystery. The following code is where I left things with just trying to do a position and print text. (color will come later)


--- Code: ---DECLARE SUB DLL ALIAS "_gtk" LIB "gtk-server"

DLL("gtk_server_cfg " & "curses.cfg")

main_win = DLL("initscr")
DLL("wmove " & main_win & " 5 5")
DLL("waddstr " & main_win & " \"ScriptBasic iCALL color demo\"")
DLL("wrefresh " & main_win)
DLL("getch")
DLL("endwin")

--- End code ---


--- Code: ---LIB_NAME = libcurses.so

FUNCTION_NAME = gtk_server_cfg,NONE,STRING,1,STRING

# extern NCURSES_EXPORT(WINDOW *) initscr (void);
FUNCTION_NAME = initscr,NONE,POINTER,0

# extern NCURSES_EXPORT(int) noecho (void);
FUNCTION_NAME = noecho,NONE,INT,0

# extern NCURSES_EXPORT(int) cbreak (void);
FUNCTION_NAME = cbreak,NONE,INT,0

# extern NCURSES_EXPORT(int) start_color (void);
FUNCTION_NAME = start_color,NONE,INT,0

# extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int);
FUNCTION_NAME = wresize,NONE,INT,3,POINTER,INT,INT

# extern NCURSES_EXPORT(int) curs_set (int);
FUNCTION_NAME = curs_set,NONE,INT,1,INT

# extern NCURSES_EXPORT(int) move (int, int);
FUNCTION_NAME = move,NONE,INT,2,INT,INT

# extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int);
FUNCTION_NAME = wmove,NONE,INT,3,POINTER,INT,INT

# extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *);
FUNCTION_NAME = waddstr,NONE,INT,2,POINTER,STRING

# extern NCURSES_EXPORT(int) printw (const char *,...)
FUNCTION_NAME = printw,NONE,INT,2,STRING,STRING

# extern NCURSES_EXPORT(int) init_pair (short,short,short);
FUNCTION_NAME = init_pair,NONE,INT,3,SHORT,SHORT,SHORT

# extern NCURSES_EXPORT(int) COLOR_PAIR (int);
FUNCTION_NAME = COLOR_PAIR,NONE,INT,1,INT

# extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T);
FUNCTION_NAME = attrset,NONE,INT,1,INT

# extern NCURSES_EXPORT(int) getch (void);
FUNCTION_NAME = getch,NONE,INT,0

# extern NCURSES_EXPORT(int) endwin (void);
FUNCTION_NAME = endwin,NONE,INT,0

# extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool);
FUNCTION_NAME = nodelay,NONE,INT,2,POINTER,BOOL

# extern NCURSES_EXPORT(int) refresh (void);
FUNCTION_NAME = refresh,NONE,INT,0

# extern NCURSES_EXPORT(int) wrefresh (WINDOW *);
FUNCTION_NAME = wrefresh,NONE,INT,1,POINTER

--- End code ---

AIR:
You need to look at the gtk-server.cfg file more closely.  It already includes the following (which might help resolve your issue):


--- Code: ---#---------------------------------------------------------------------------
#
# Some ncurses calls
#
FUNCTION_NAME = filter, NONE, NONE, 0
FUNCTION_NAME = use_env, NONE, NONE, 1, BOOL
FUNCTION_NAME = initscr, NONE, WIDGET, 0
FUNCTION_NAME = newwin, NONE, WIDGET, 4, INT, INT, INT, INT
FUNCTION_NAME = delwin, NONE, INT, 1, WIDGET
FUNCTION_NAME = box, NONE, INT, 3, WIDGET, INT, INT
FUNCTION_NAME = endwin, NONE, INT, 0
FUNCTION_NAME = isendwin, NONE, BOOL, 0
FUNCTION_NAME = refresh, NONE, INT, 0
FUNCTION_NAME = wrefresh, NONE, INT, 1, WIDGET
FUNCTION_NAME = redrawwin, NONE, INT, 1, WIDGET
FUNCTION_NAME = getch, NONE, INT, 0
FUNCTION_NAME = wgetch, NONE, INT, 1, WIDGET
FUNCTION_NAME = printw, NONE, INT, 2, STRING, STRING
FUNCTION_NAME = mvwprintw, NONE, INT, 5, WIDGET, INT, INT, STRING, STRING
#
#---------------------------------------------------------------------------
--- End code ---

Notice the use of WIDGET instead of POINTER.

A.

Pjot:
AIR is right about that. By default GTK-server will take its definitions from the configuration file at the standard location. Therefore it will igonore the configuration file you created yourself, unless you tell it to use some other configfile.

Now, if you want to tell this you can use "gtk_server_cfg" which you are actually using in your code. However, your usage of this function is wrong:


--- Code: ---DLL("gtk_server_cfg " & "curses.cfg")

--- End code ---

What is this? The GTK-server does not know what to do with this and probably that is the reason of the errors you see at the prompt. The correct usage can be seen in the Scriptbasic 'gtk.bas' file. The way this function must be used is as if you are passing commandline arguments. Therefore you should do like this:


--- Code: ---DLL("gtk_server_cfg -cfg=curses.cfg")

--- End code ---

There is another way - just rename the 'curses.cfg' to 'gtk-server.cfg' and leave this file in the same directory as your client program. The GTK-server automatically will take this local configfile instead of the global one.

BR,
Peter

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version