[Spiderape-cvs] SF.net SVN: spiderape: [46] plugins/ncurses
Status: Beta
Brought to you by:
sgbeal
|
From: <sg...@us...> - 2007-09-28 11:18:21
|
Revision: 46
http://spiderape.svn.sourceforge.net/spiderape/?rev=46&view=rev
Author: sgbeal
Date: 2007-09-28 04:18:20 -0700 (Fri, 28 Sep 2007)
Log Message:
-----------
minor fixes... moving over to the laptop
Modified Paths:
--------------
plugins/ncurses/ChangeLog
plugins/ncurses/NCursesPanel.js
plugins/ncurses/binder.cpp
plugins/ncurses/ncwrapper.cpp
plugins/ncurses/panel.cpp
plugins/ncurses/quicktests.js
plugins/ncurses/scripts/ripoffline.js
Modified: plugins/ncurses/ChangeLog
===================================================================
--- plugins/ncurses/ChangeLog 2007-09-28 07:11:07 UTC (rev 45)
+++ plugins/ncurses/ChangeLog 2007-09-28 11:18:20 UTC (rev 46)
@@ -1,6 +1,23 @@
This is the informal changelog for the 'nc' plugin for SpiderApe.
+20070928:
+
+- Fundmental rework of the cleanup done during nc_endwin(). i don't think
+it was actually cleaning up before.
+
+- Added several new bound functions. Now we're at 152 funcs.
+
+- NCursesWindow class is working. PANEL support works as an add-on to the
+NCursesWindow class, as opposed to a subclass. (The initial attempt
+was to make a subclass, but it behaved really buggy.)
+
+- Changed the way that WINDOW/PANEL/PAD handles are doled out to JS-space,
+to avoid accidentally re-using the same handle ID from the NCursesWindow
+class and to avoid the special-case ID handling of stdscr (which caused
+a segfault during shutdown/cleanup in some cases).
+
+
20070927:
- A minor bug fix for a broken return value in wbkgd().
@@ -10,7 +27,7 @@
low-level API.
- Removed the older NCurses dir from the svn repository and renamed
-this one to 'ncurses'. svn (suprisingly) choked on the case-sensitive
+this one to 'ncurses'. svn (suprisingly) choked on the case-insensitive
similar names, though, and left my dirs in a bit of a mess. :/
Modified: plugins/ncurses/NCursesPanel.js
===================================================================
--- plugins/ncurses/NCursesPanel.js 2007-09-28 07:11:07 UTC (rev 45)
+++ plugins/ncurses/NCursesPanel.js 2007-09-28 11:18:20 UTC (rev 46)
@@ -1,6 +1,39 @@
assert(open_dll('./ncurses.so'));
+
+var doRipoffLine = 1;
+
+if( doRipoffLine ) { // ripoffline demo...
+ var ripwins = new Array();
+ function ripoffhandler(win,cols) {
+ ripwins[ripwins.length] = win;
+ return 0;
+ }
+
+ function ripoffhandler2(win,cols) {
+ ripwins[ripwins.length] = win;
+ return 0;
+ }
+
+ for( var i = 0; i < 5; ++i ) {
+ var even = (i%2);
+ nc_ripoffline( even ? -1 : 1,
+ even ? ripoffhandler : ripoffhandler2 );
+ }
+}
+//nc_ripoffline
nc_initscr();
+if( doRipoffLine ) {
+ var fgcolors = new Array( 'white', 'yellow', 'red', 'cyan', 'blue' );
+ for( var i = 0; i < ripwins.length; ++i ) {
+ var rw = ripwins[i];
+ nc_wbkgd( rw, nc_color(fgcolors[i%5],'black') );
+ //nc_wattron( rw, ncurses.A_REVERSE );
+ nc_mvwaddstr( rw, 0, 0, "Ripped-off line #"+i );
+ nc_wrefresh( rw );
+ }
+}
+
var root = new NCursesWindow(nc_new_panel(nc_newwin(0,0,0,0)));
root.background( ascii('~') | nc_color('black','yellow'));
nc_curs_set(0);
@@ -12,7 +45,7 @@
var pos = 'blue';
var woffset = {x:5,y:2};
-var wpos = {y:0,x:0,incr:function(){this.x+=woffset.x;this.y+=woffset.y}};
+var wpos = {y:3,x:3,incr:function(){this.x+=woffset.x;this.y+=woffset.y}};
var cpnl = null;
curpnl = wins[pos] = new NCursesWindow( nc_new_panel(nc_newwin(rootgeom.h / 2, rootgeom.w / 2, wpos.y, wpos.x)));
wpos.incr();
Modified: plugins/ncurses/binder.cpp
===================================================================
--- plugins/ncurses/binder.cpp 2007-09-28 07:11:07 UTC (rev 45)
+++ plugins/ncurses/binder.cpp 2007-09-28 11:18:20 UTC (rev 46)
@@ -181,8 +181,8 @@
{
// Kludge: remove stream-to-window redirects:
using namespace Private;
- WindowStreamMap str( captured_streams() );
- captured_streams().clear();
+ WindowStreamMap str;
+ str.swap( captured_streams() );
typedef WindowStreamMap::iterator WIT;
WIT stit = str.begin();
WIT head = stit;
@@ -193,7 +193,6 @@
}
// /KLUDGE
}
-#if 1
/**
We walk the list of all binders and make a deletion
queue for items WITHOUT parents (those with parents
@@ -204,7 +203,6 @@
*/
BinderList them;
BinderList bl( JWBinder::all_binders() );
- //JWBinder::all_binders().clear();
BinderList::reverse_iterator rit = bl.rbegin();
JWBinder * cur = 0;
for( ; bl.rend() != rit; ++rit )
@@ -223,7 +221,6 @@
{
delete *it;
}
-#endif
}
int JWBinder::free_panel()
Modified: plugins/ncurses/ncwrapper.cpp
===================================================================
--- plugins/ncurses/ncwrapper.cpp 2007-09-28 07:11:07 UTC (rev 45)
+++ plugins/ncurses/ncwrapper.cpp 2007-09-28 11:18:20 UTC (rev 46)
@@ -333,13 +333,14 @@
////////////////////////////////////////
// set up the F#'ing key names...
for( int i = KEY_F(1); i <= KEY_F(12); ++i ) {
- os << "this['F"<<(i-KEY_F(0))<<"'] = "<<i<<";\n"
- << "this["<<i<<"] = 'F"<<(i-KEY_F(0))<<"';\n"
+ os << "this['KEY_F"<<(i-KEY_F(0))<<"'] = "<<i<<";\n"
+ << "this["<<i<<"] = 'KEY_F"<<(i-KEY_F(0))<<"';\n"
;
}
+ os << "this.KEY_F = function(n) { return this['KEY_F'+n];};";
// Page/Movement keys:
- os << "this["<<KEY_DOWN<<"] = 'DOWN';\n"
+ os << "this["<<KEY_DOWN<<"] = 'KEY_DOWN';\n"
<< "this['KEY_DOWN'] = "<<KEY_DOWN<<";\n"
<< "this["<<KEY_UP<<"] = 'KEY_UP';\n"
<< "this['KEY_UP'] = "<<KEY_UP<<";\n"
@@ -429,6 +430,8 @@
<< "this['ACS_BSBS'] = "<<ACS_BSBS<<";\n"
<< "this['ACS_SBSB'] = "<<ACS_SBSB<<";\n"
<< "this['ACS_SSSS'] = "<<ACS_SSSS<<";\n"
+
+
<< "this['KEY_MOUSE'] = "<<KEY_MOUSE<<";\n"
<< "this['KEY_RESIZE'] = "<<KEY_RESIZE<<";\n"
<< "this['KEY_EVENT'] = "<<KEY_EVENT<<";\n"
@@ -456,6 +459,13 @@
<< "this['BUTTON3_CLICKED']="<<NCURSES_MOUSE_MASK(3,NCURSES_BUTTON_CLICKED)<<";"
<< "this['BUTTON3_DOUBLE_CLICKED']="<<NCURSES_MOUSE_MASK(3,NCURSES_DOUBLE_CLICKED)<<";"
<< "this['BUTTON3_TRIPLE_CLICKED']="<<NCURSES_MOUSE_MASK(3,NCURSES_TRIPLE_CLICKED)<<";"
+
+ << "this['BUTTON4_RELEASED']="<<NCURSES_MOUSE_MASK(4,NCURSES_BUTTON_RELEASED)<<";"
+ << "this['BUTTON4_PRESSED']="<<NCURSES_MOUSE_MASK(4,NCURSES_BUTTON_PRESSED)<<";"
+ << "this['BUTTON4_CLICKED']="<<NCURSES_MOUSE_MASK(4,NCURSES_BUTTON_CLICKED)<<";"
+ << "this['BUTTON4_DOUBLE_CLICKED']="<<NCURSES_MOUSE_MASK(4,NCURSES_DOUBLE_CLICKED)<<";"
+ << "this['BUTTON4_TRIPLE_CLICKED']="<<NCURSES_MOUSE_MASK(4,NCURSES_TRIPLE_CLICKED)<<";"
+
;
#endif
@@ -591,7 +601,6 @@
{"nc_waddvnstr", nc_waddvnstr, 0},
{"nc_waddvstr", nc_waddvstr, 0},
{"nc_wattroff", nc_wattroff, 0},
- {"nc_wattroff", nc_wattroff, 0},
{"nc_wattron", nc_wattron, 0},
{"nc_wattrset", nc_wattrset, 0},
{"nc_wbegx", nc_wbegx, 0},
@@ -1015,7 +1024,7 @@
JS_FUNC(nc_wprint)
{
- ASSERTARGC("nc_wbkgd",cx,(0<argc));
+ ASSERTARGC("nc_wprint",cx,(0<argc));
WINDOW * w = jsval_to_WINDOW(cx,argv[0]);
if( ! w )
{
@@ -1063,7 +1072,7 @@
if( WIN_IS_PAD(w) )
{
// todo???: prefresh()
- JS_ReportWarning(cx,"nc_wrefresh() was passed a PAD. This is not legal." );
+ //JS_ReportWarning(cx,"nc_wrefresh() was passed a PAD. This is not legal." );
return JS_TRUE;
}
else if( bin->panel() )
@@ -2030,7 +2039,7 @@
JS_FUNC(nc_keypad)
{
ASSERTARGC("nc_mvwinch",cx,(2==argc));
- *rval = int_to_jsval( cx, ::ape::fwd_to_func2<int,WINDOW *,int>( keypad, cx, obj, argc, argv ) );
+ *rval = int_to_jsval( cx, ::ape::fwd_to_func2<int,WINDOW *,bool>( keypad, cx, obj, argc, argv ) );
return JS_TRUE;
}
@@ -2043,7 +2052,7 @@
int n = jsval_to_int(*(argv++));
int attr = jsval_to_int(*(argv++));
short color = jsval_to_short(*(argv++));
- *rval = mvwchgat(w,y,x,n,attr,color,0);
+ *rval = int_to_jsval( mvwchgat(w,y,x,n,attr,color,0) );
return JS_TRUE;
}
JS_FUNC(nc_wchgat)
@@ -2066,7 +2075,7 @@
int attr = av++.to<int>();
short color = av++.to<short>();
#endif
- *rval = wchgat(w,n,attr,color,0);
+ *rval = int_to_jsval( wchgat(w,n,attr,color,0) );
return JS_TRUE;
}
@@ -2076,8 +2085,7 @@
*rval = NCJS_ERR;
if( 2 != argc )
{
- JS_ReportError( cx, "nc_ripoffline() requires 2 arguments: ([1 || -1], Function)" );
- return JS_FALSE;
+ return ape::set_pending_exception( cx, "nc_ripoffline() requires 2 arguments: ([1 || -1], Function)" );
}
int l = jsval_to_int( argv[0] );
if( 0 == l )
Modified: plugins/ncurses/panel.cpp
===================================================================
--- plugins/ncurses/panel.cpp 2007-09-28 07:11:07 UTC (rev 45)
+++ plugins/ncurses/panel.cpp 2007-09-28 11:18:20 UTC (rev 46)
@@ -221,10 +221,9 @@
JS_FUNC(nc_replace_panel)
{
- JS_ReportError(cx,"%s:%d: nc_replace_panel() probably can't be correctly implemented here.",
+ *rval = ::ape::int_to_jsval(-1);
+ return ape::set_pending_exception( cx,"%s:%d: nc_replace_panel() probably can't be correctly implemented here.",
__FILE__, __LINE__ );
- *rval = ::ape::int_to_jsval(-1);
- return JS_FALSE;
ASSERTARGC("nc_replace_panel",cx,(2==argc));
CHECKBINDER("nc_replace_panel",argv[0]);
Modified: plugins/ncurses/quicktests.js
===================================================================
--- plugins/ncurses/quicktests.js 2007-09-28 07:11:07 UTC (rev 45)
+++ plugins/ncurses/quicktests.js 2007-09-28 11:18:20 UTC (rev 46)
@@ -1,35 +1,7 @@
assert(open_dll('./ncurses.so'));
nc_initscr();
-nc_scrollok(stdscr,true);
-nc_noecho();
-var sub = nc_subwin(stdscr,3,4,5,6);
-nc_wbkgd( sub, ncurses["-"] | nc_color("white","red"));
-nc_capture_cout(stdscr);
-nc_wmove(stdscr,12,0);
-print("nc_getparyx(sub) ==",nc_getparyx(sub).toSource());
-print("nc_getparyx(sub).y ==",nc_getparyx(sub).y);
-print("nc_getpary(sub) ==",nc_getpary(sub));
-print("nc_getparx(sub) ==",nc_getparx(sub));
-
-if( 0 ) {
- for( var i = 0; i < 4; ++i ) {
- print("nc_curs_set("+i+") ==",nc_curs_set(i));
- nc_getch();
- }
+for( var k in ncurses ) {
+ cerr( k,'=',ncurses[k] );
}
-if( 1 ) {
- print( "mouse ?? ==",ncurses.MOUSE_VERSION );
- print("Play with the mouse. Tap 'q' to quit.");
- var key = 0;
- while( ascii('q') != (key = nc_wgetch(stdscr)) ) {
- if( key == ncurses.KEY_MOUSE ) {
- var evt = nc_getmouse();
- print( "mouse :",key,evt.toSource() );
- }
- }
-}
-
-print("Tap any key to exit.");
-nc_wgetch(stdscr);
nc_endwin();
Modified: plugins/ncurses/scripts/ripoffline.js
===================================================================
--- plugins/ncurses/scripts/ripoffline.js 2007-09-28 07:11:07 UTC (rev 45)
+++ plugins/ncurses/scripts/ripoffline.js 2007-09-28 11:18:20 UTC (rev 46)
@@ -4,7 +4,7 @@
if( ! is_defined( 'ncurses' ) )
{
- var dll = 'nc';
+ var dll = '../ncurses.so';
if( ! open_dll(dll) ) {
throw new Error("JSWindow could not load plugin from '"+dll+"'");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|