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.112 by root, Thu Dec 14 17:40:03 2006 UTC vs.
Revision 1.120 by root, Fri Jan 25 16:04:57 2008 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: rxvtperl.xs 2 * File: rxvtperl.xs
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
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
70 SV *sv = newSVpv (str, 0); 70 SV *sv = newSVpv (str, 0);
71 SvUTF8_on (sv); 71 SvUTF8_on (sv);
72 free (str); 72 free (str);
73 73
74 return sv; 74 return sv;
75}
76
77static SV *
78new_ref (HV *hv, const char *klass)
79{
80 return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1));
81} 75}
82 76
83static SV * 77static SV *
84newSVptr (void *ptr, const char *klass) 78newSVptr (void *ptr, const char *klass)
85{ 79{
220 *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) 214 *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)
221 )); 215 ));
222 av_push (overlay_av, newSViv ((long)this)); 216 av_push (overlay_av, newSViv ((long)this));
223 217
224 THIS->want_refresh = 1; 218 THIS->want_refresh = 1;
219 THIS->refresh_check ();
225} 220}
226 221
227void 222void
228overlay::hide () 223overlay::hide ()
229{ 224{
243 238
244 SvREFCNT_dec (overlay_av); 239 SvREFCNT_dec (overlay_av);
245 overlay_av = 0; 240 overlay_av = 0;
246 241
247 THIS->want_refresh = 1; 242 THIS->want_refresh = 1;
243 THIS->refresh_check ();
248} 244}
249 245
250void overlay::swap () 246void overlay::swap ()
251{ 247{
252 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));
297 for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) 293 for (int col = min (AvFILL (av) + 1, w - x - border); col--; )
298 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); 294 this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1));
299 } 295 }
300 296
301 THIS->want_refresh = 1; 297 THIS->want_refresh = 1;
298 THIS->refresh_check ();
302} 299}
303 300
304///////////////////////////////////////////////////////////////////////////// 301/////////////////////////////////////////////////////////////////////////////
305 302
306#define IOM_CLASS "urxvt" 303#define IOM_CLASS "urxvt"
307#define IOM_WARN rxvt_warn 304#define IOM_WARN rxvt_warn
308#include <iom_perl.h> 305#include "iom_perl.h"
309 306
310///////////////////////////////////////////////////////////////////////////// 307/////////////////////////////////////////////////////////////////////////////
311 308
312struct rxvt_perl_interp rxvt_perl; 309struct rxvt_perl_interp rxvt_perl;
313 310
388 385
389 // pre-handling of some events 386 // pre-handling of some events
390 if (htype == HOOK_REFRESH_END) 387 if (htype == HOOK_REFRESH_END)
391 { 388 {
392 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));
393 390
394 for (int i = 0; i <= AvFILL (av); i++) 391 for (int i = 0; i <= AvFILL (av); i++)
395 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 392 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
396 } 393 }
397 394
398 swap (perl_environ, environ); 395 swap (perl_environ, environ);
597 594
598 // post-handling of some events 595 // post-handling of some events
599 if (htype == HOOK_REFRESH_BEGIN) 596 if (htype == HOOK_REFRESH_BEGIN)
600 { 597 {
601 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));
602 599
603 for (int i = AvFILL (av); i >= 0; i--) 600 for (int i = AvFILL (av); i >= 0; i--)
604 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 601 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
605 } 602 }
606 else if (htype == HOOK_DESTROY) 603 else if (htype == HOOK_DESTROY)
607 { 604 {
608 clearSVptr ((SV *)term->perl.self); 605 clearSVptr ((SV *)term->perl.self);
609 SvREFCNT_dec ((SV *)term->perl.self); 606 SvREFCNT_dec ((SV *)term->perl.self);
610 607
611 // don't allow further calls 608 // don't allow further calls
612 term->perl.self = 0; 609 term->perl.self = 0;
613 } 610 }
614 611
615 swap (perl_environ, environ); 612 swap (perl_environ, environ);
781_exit (int status) 778_exit (int status)
782 779
783NV 780NV
784NOW () 781NOW ()
785 CODE: 782 CODE:
786 RETVAL = NOW; 783 RETVAL = ev::now ();
787 OUTPUT: 784 OUTPUT:
788 RETVAL 785 RETVAL
789 786
790int 787int
791GET_BASEFG (int rend) 788GET_BASEFG (int rend)
863 for (int i = AvFILL (env) + 1; i--; ) 860 for (int i = AvFILL (env) + 1; i--; )
864 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 861 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
865 862
866 envv->push_back (0); 863 envv->push_back (0);
867 864
868 bool success;
869
870 try 865 try
871 { 866 {
872 success = term->init (argv, envv); 867 term->init (argv, envv);
873 } 868 }
874 catch (const class rxvt_failure_exception &e) 869 catch (const class rxvt_failure_exception &e)
875 {
876 success = false;
877 }
878
879 if (!success)
880 { 870 {
881 term->destroy (); 871 term->destroy ();
882 croak ("error while initializing new terminal instance"); 872 croak ("error while initializing new terminal instance");
883 } 873 }
884 874
1145 if (*i) 1135 if (*i)
1146 PUSHs (sv_2mortal (newSVpv (*i, 0))); 1136 PUSHs (sv_2mortal (newSVpv (*i, 0)));
1147} 1137}
1148 1138
1149int 1139int
1150rxvt_term::pty_ev_events (int events = EVENT_UNDEF) 1140rxvt_term::pty_ev_events (int events = ev::UNDEF)
1151 CODE: 1141 CODE:
1152 RETVAL = THIS->pty_ev.events; 1142 RETVAL = THIS->pty_ev.events;
1153 if (events != EVENT_UNDEF) 1143 if (events != ev::UNDEF)
1154 THIS->pty_ev.set (events); 1144 THIS->pty_ev.set (events);
1155 OUTPUT: 1145 OUTPUT:
1156 RETVAL 1146 RETVAL
1157 1147
1158int 1148int
1237 1227
1238void 1228void
1239rxvt_term::want_refresh () 1229rxvt_term::want_refresh ()
1240 CODE: 1230 CODE:
1241 THIS->want_refresh = 1; 1231 THIS->want_refresh = 1;
1232 THIS->refresh_check ();
1242 1233
1243void 1234void
1244rxvt_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)
1245 PPCODE: 1236 PPCODE:
1246{ 1237{
1401SV * 1392SV *
1402rxvt_term::special_decode (SV *text) 1393rxvt_term::special_decode (SV *text)
1403 CODE: 1394 CODE:
1404{ 1395{
1405 wchar_t *wstr = sv2wcs (text); 1396 wchar_t *wstr = sv2wcs (text);
1406 int wlen = wcslen (wstr);
1407 int dlen = 0; 1397 int dlen = 0;
1408 1398
1409 // find length 1399 // find length
1410 for (wchar_t *s = wstr; *s; s++) 1400 for (wchar_t *s = wstr; *s; s++)
1411 if (*s == NOCHAR) 1401 if (*s == NOCHAR)
1474 1464
1475const char * 1465const char *
1476rxvt_term::x_resource (const char *name) 1466rxvt_term::x_resource (const char *name)
1477 1467
1478bool 1468bool
1479rxvt_term::option (U32 optval, int set = -1) 1469rxvt_term::option (U8 optval, int set = -1)
1480 CODE: 1470 CODE:
1481{ 1471{
1482 RETVAL = THIS->options & optval; 1472 RETVAL = THIS->option (optval);
1483 1473
1484 if (set >= 0) 1474 if (set >= 0)
1485 { 1475 {
1486 if (set)
1487 THIS->options |= optval; 1476 THIS->set_option (optval, set);
1488 else
1489 THIS->options &= ~optval;
1490 1477
1491 if (THIS->check_ev.is_active ()) // avoid doing this before START 1478 if (THIS->env_colorfgbg [0]) // avoid doing this before START
1492 switch (optval) 1479 switch (optval)
1493 { 1480 {
1494 case Opt_skipBuiltinGlyphs: 1481 case Opt_skipBuiltinGlyphs:
1495 THIS->set_fonts (); 1482 THIS->set_fonts ();
1496 THIS->scr_remap_chars (); 1483 THIS->scr_remap_chars ();
1497 THIS->scr_touch (true); 1484 THIS->scr_touch (true);
1498 THIS->want_refresh = 1; 1485 THIS->want_refresh = 1;
1486 THIS->refresh_check ();
1499 break; 1487 break;
1500 1488
1501 case Opt_cursorUnderline: 1489 case Opt_cursorUnderline:
1502 THIS->want_refresh = 1; 1490 THIS->want_refresh = 1;
1491 THIS->refresh_check ();
1503 break; 1492 break;
1504 1493
1505# case Opt_scrollBar_floating: 1494# case Opt_scrollBar_floating:
1506# case Opt_scrollBar_right: 1495# case Opt_scrollBar_right:
1507# THIS->resize_all_windows (THIS->width, THIS->height, 1); 1496# THIS->resize_all_windows (THIS->width, THIS->height, 1);
1565 1554
1566 clamp_it (rc.col, 0, THIS->ncol); 1555 clamp_it (rc.col, 0, THIS->ncol);
1567 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); 1556 clamp_it (rc.row, THIS->top_row, THIS->nrow - 1);
1568 1557
1569 if (ix) 1558 if (ix)
1559 {
1570 THIS->want_refresh = 1; 1560 THIS->want_refresh = 1;
1561 THIS->refresh_check ();
1562 }
1571 } 1563 }
1572} 1564}
1573 1565
1574char 1566char
1575rxvt_term::cur_charset () 1567rxvt_term::cur_charset ()
1682 Atom *props = XListProperties (THIS->dpy, window, &count); 1674 Atom *props = XListProperties (THIS->dpy, window, &count);
1683 1675
1684 EXTEND (SP, count); 1676 EXTEND (SP, count);
1685 while (count--) 1677 while (count--)
1686 PUSHs (newSVuv ((U32)props [count])); 1678 PUSHs (newSVuv ((U32)props [count]));
1687 1679
1688 XFree (props); 1680 XFree (props);
1689} 1681}
1690 1682
1691void 1683void
1692rxvt_term::XGetWindowProperty (Window window, Atom property) 1684rxvt_term::XGetWindowProperty (Window window, Atom property)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines