ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtperl.xs
(Generate patch)

Comparing rxvt-unicode/src/rxvtperl.xs (file contents):
Revision 1.109 by root, Thu Dec 14 15:19:31 2006 UTC vs.
Revision 1.119 by ayin, Fri Jan 4 17:57:28 2008 UTC

31#include <cstddef> 31#include <cstddef>
32#include <cstdarg> 32#include <cstdarg>
33 33
34#include "unistd.h" 34#include "unistd.h"
35 35
36#include "iom.h" 36#include "ev_cpp.h"
37#include "rxvt.h" 37#include "rxvt.h"
38#include "keyboard.h" 38#include "keyboard.h"
39#include "rxvtutil.h" 39#include "rxvtutil.h"
40#include "rxvtperl.h" 40#include "rxvtperl.h"
41 41
42#include "perlxsi.c" 42#include "perlxsi.c"
43 43
44#ifdef HAVE_SCROLLBARS 44#ifdef HAVE_SCROLLBARS
45# define GRAB_CURSOR THIS->leftptr_cursor 45# define GRAB_CURSOR THIS->scrollBar.leftptr_cursor
46#else 46#else
47# define GRAB_CURSOR None 47# define GRAB_CURSOR None
48#endif 48#endif
49 49
50#undef LINENO 50#undef LINENO
51#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) 51#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows)
52#undef ROW 52#undef ROW
53#define ROW(n) THIS->row_buf [LINENO (n)] 53#define ROW(n) THIS->row_buf [LINENO (n)]
54 54
55typedef int CHAINED UNUSED;
56
57///////////////////////////////////////////////////////////////////////////// 55/////////////////////////////////////////////////////////////////////////////
58 56
59static wchar_t * 57static wchar_t *
60sv2wcs (SV *sv) 58sv2wcs (SV *sv)
61{ 59{
72 SV *sv = newSVpv (str, 0); 70 SV *sv = newSVpv (str, 0);
73 SvUTF8_on (sv); 71 SvUTF8_on (sv);
74 free (str); 72 free (str);
75 73
76 return sv; 74 return sv;
77}
78
79static SV *
80new_ref (HV *hv, const char *klass)
81{
82 return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1));
83} 75}
84 76
85static SV * 77static SV *
86newSVptr (void *ptr, const char *klass) 78newSVptr (void *ptr, const char *klass)
87{ 79{
222 *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) 214 *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)
223 )); 215 ));
224 av_push (overlay_av, newSViv ((long)this)); 216 av_push (overlay_av, newSViv ((long)this));
225 217
226 THIS->want_refresh = 1; 218 THIS->want_refresh = 1;
219 THIS->refresh_check ();
227} 220}
228 221
229void 222void
230overlay::hide () 223overlay::hide ()
231{ 224{
245 238
246 SvREFCNT_dec (overlay_av); 239 SvREFCNT_dec (overlay_av);
247 overlay_av = 0; 240 overlay_av = 0;
248 241
249 THIS->want_refresh = 1; 242 THIS->want_refresh = 1;
243 THIS->refresh_check ();
250} 244}
251 245
252void overlay::swap () 246void overlay::swap ()
253{ 247{
254 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); 248 int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w));
299 for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) 293 for (int col = min (AvFILL (av) + 1, w - x - border); col--; )
300 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); 294 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1));
301 } 295 }
302 296
303 THIS->want_refresh = 1; 297 THIS->want_refresh = 1;
298 THIS->refresh_check ();
304} 299}
305 300
306///////////////////////////////////////////////////////////////////////////// 301/////////////////////////////////////////////////////////////////////////////
307 302
308#define IOM_CLASS "urxvt" 303#define IOM_CLASS "urxvt"
304#define IOM_WARN rxvt_warn
309#include <iom_perl.h> 305#include "iom_perl.h"
310 306
311///////////////////////////////////////////////////////////////////////////// 307/////////////////////////////////////////////////////////////////////////////
312 308
313struct rxvt_perl_interp rxvt_perl; 309struct rxvt_perl_interp rxvt_perl;
314 310
389 385
390 // pre-handling of some events 386 // pre-handling of some events
391 if (htype == HOOK_REFRESH_END) 387 if (htype == HOOK_REFRESH_END)
392 { 388 {
393 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 389 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
394 390
395 for (int i = 0; i <= AvFILL (av); i++) 391 for (int i = 0; i <= AvFILL (av); i++)
396 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 392 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
397 } 393 }
398 394
399 swap (perl_environ, environ); 395 swap (perl_environ, environ);
598 594
599 // post-handling of some events 595 // post-handling of some events
600 if (htype == HOOK_REFRESH_BEGIN) 596 if (htype == HOOK_REFRESH_BEGIN)
601 { 597 {
602 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 598 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
603 599
604 for (int i = AvFILL (av); i >= 0; i--) 600 for (int i = AvFILL (av); i >= 0; i--)
605 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 601 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
606 } 602 }
607 else if (htype == HOOK_DESTROY) 603 else if (htype == HOOK_DESTROY)
608 { 604 {
609 clearSVptr ((SV *)term->perl.self); 605 clearSVptr ((SV *)term->perl.self);
610 SvREFCNT_dec ((SV *)term->perl.self); 606 SvREFCNT_dec ((SV *)term->perl.self);
611 607
612 // don't allow further calls 608 // don't allow further calls
613 term->perl.self = 0; 609 term->perl.self = 0;
614 } 610 }
615 611
616 swap (perl_environ, environ); 612 swap (perl_environ, environ);
674 const_iv (AnyModifier), 670 const_iv (AnyModifier),
675 671
676 const_iv (NoSymbol), 672 const_iv (NoSymbol),
677 const_iv (GrabModeSync), 673 const_iv (GrabModeSync),
678 const_iv (GrabModeAsync), 674 const_iv (GrabModeAsync),
679
680 const_iv (EVENT_NONE),
681 const_iv (EVENT_READ),
682 const_iv (EVENT_WRITE),
683 675
684 const_iv (NoEventMask), 676 const_iv (NoEventMask),
685 const_iv (KeyPressMask), 677 const_iv (KeyPressMask),
686 const_iv (KeyReleaseMask), 678 const_iv (KeyReleaseMask),
687 const_iv (ButtonPressMask), 679 const_iv (ButtonPressMask),
786_exit (int status) 778_exit (int status)
787 779
788NV 780NV
789NOW () 781NOW ()
790 CODE: 782 CODE:
791 RETVAL = NOW; 783 RETVAL = ev::now ();
792 OUTPUT: 784 OUTPUT:
793 RETVAL 785 RETVAL
794 786
795int 787int
796GET_BASEFG (int rend) 788GET_BASEFG (int rend)
868 for (int i = AvFILL (env) + 1; i--; ) 860 for (int i = AvFILL (env) + 1; i--; )
869 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 861 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
870 862
871 envv->push_back (0); 863 envv->push_back (0);
872 864
873 bool success;
874
875 try 865 try
876 { 866 {
877 success = term->init (argv, envv); 867 term->init (argv, envv);
878 } 868 }
879 catch (const class rxvt_failure_exception &e) 869 catch (const class rxvt_failure_exception &e)
880 {
881 success = false;
882 }
883
884 if (!success)
885 { 870 {
886 term->destroy (); 871 term->destroy ();
887 croak ("error while initializing new terminal instance"); 872 croak ("error while initializing new terminal instance");
888 } 873 }
889 874
1150 if (*i) 1135 if (*i)
1151 PUSHs (sv_2mortal (newSVpv (*i, 0))); 1136 PUSHs (sv_2mortal (newSVpv (*i, 0)));
1152} 1137}
1153 1138
1154int 1139int
1155rxvt_term::pty_ev_events (int events = EVENT_UNDEF) 1140rxvt_term::pty_ev_events (int events = ev::UNDEF)
1156 CODE: 1141 CODE:
1157 RETVAL = THIS->pty_ev.events; 1142 RETVAL = THIS->pty_ev.events;
1158 if (events != EVENT_UNDEF) 1143 if (events != ev::UNDEF)
1159 THIS->pty_ev.set (events); 1144 THIS->pty_ev.set (events);
1160 OUTPUT: 1145 OUTPUT:
1161 RETVAL 1146 RETVAL
1162 1147
1163int 1148int
1242 1227
1243void 1228void
1244rxvt_term::want_refresh () 1229rxvt_term::want_refresh ()
1245 CODE: 1230 CODE:
1246 THIS->want_refresh = 1; 1231 THIS->want_refresh = 1;
1232 THIS->refresh_check ();
1247 1233
1248void 1234void
1249rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) 1235rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
1250 PPCODE: 1236 PPCODE:
1251{ 1237{
1406SV * 1392SV *
1407rxvt_term::special_decode (SV *text) 1393rxvt_term::special_decode (SV *text)
1408 CODE: 1394 CODE:
1409{ 1395{
1410 wchar_t *wstr = sv2wcs (text); 1396 wchar_t *wstr = sv2wcs (text);
1411 int wlen = wcslen (wstr);
1412 int dlen = 0; 1397 int dlen = 0;
1413 1398
1414 // find length 1399 // find length
1415 for (wchar_t *s = wstr; *s; s++) 1400 for (wchar_t *s = wstr; *s; s++)
1416 if (*s == NOCHAR) 1401 if (*s == NOCHAR)
1479 1464
1480const char * 1465const char *
1481rxvt_term::x_resource (const char *name) 1466rxvt_term::x_resource (const char *name)
1482 1467
1483bool 1468bool
1484rxvt_term::option (U32 optval, int set = -1) 1469rxvt_term::option (U8 optval, int set = -1)
1485 CODE: 1470 CODE:
1486{ 1471{
1487 RETVAL = THIS->options & optval; 1472 RETVAL = THIS->option (optval);
1488 1473
1489 if (set >= 0) 1474 if (set >= 0)
1490 { 1475 {
1491 if (set)
1492 THIS->options |= optval; 1476 THIS->set_option (optval, set);
1493 else
1494 THIS->options &= ~optval;
1495 1477
1496 if (THIS->check_ev.is_active ()) // avoid doing this before START 1478 if (THIS->env_colorfgbg [0]) // avoid doing this before START
1497 switch (optval) 1479 switch (optval)
1498 { 1480 {
1499 case Opt_skipBuiltinGlyphs: 1481 case Opt_skipBuiltinGlyphs:
1500 THIS->set_fonts (); 1482 THIS->set_fonts ();
1501 THIS->scr_remap_chars (); 1483 THIS->scr_remap_chars ();
1502 THIS->scr_touch (true); 1484 THIS->scr_touch (true);
1503 THIS->want_refresh = 1; 1485 THIS->want_refresh = 1;
1486 THIS->refresh_check ();
1504 break; 1487 break;
1505 1488
1506 case Opt_cursorUnderline: 1489 case Opt_cursorUnderline:
1507 THIS->want_refresh = 1; 1490 THIS->want_refresh = 1;
1491 THIS->refresh_check ();
1508 break; 1492 break;
1509 1493
1510# case Opt_scrollBar_floating: 1494# case Opt_scrollBar_floating:
1511# case Opt_scrollBar_right: 1495# case Opt_scrollBar_right:
1512# THIS->resize_all_windows (THIS->width, THIS->height, 1); 1496# THIS->resize_all_windows (THIS->width, THIS->height, 1);
1570 1554
1571 clamp_it (rc.col, 0, THIS->ncol); 1555 clamp_it (rc.col, 0, THIS->ncol);
1572 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); 1556 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1573 1557
1574 if (ix) 1558 if (ix)
1559 {
1575 THIS->want_refresh = 1; 1560 THIS->want_refresh = 1;
1561 THIS->refresh_check ();
1562 }
1576 } 1563 }
1577} 1564}
1578 1565
1579char 1566char
1580rxvt_term::cur_charset () 1567rxvt_term::cur_charset ()
1687 Atom *props = XListProperties (THIS->dpy, window, &count); 1674 Atom *props = XListProperties (THIS->dpy, window, &count);
1688 1675
1689 EXTEND (SP, count); 1676 EXTEND (SP, count);
1690 while (count--) 1677 while (count--)
1691 PUSHs (newSVuv ((U32)props [count])); 1678 PUSHs (newSVuv ((U32)props [count]));
1692 1679
1693 XFree (props); 1680 XFree (props);
1694} 1681}
1695 1682
1696void 1683void
1697rxvt_term::XGetWindowProperty (Window window, Atom property) 1684rxvt_term::XGetWindowProperty (Window window, Atom property)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines