… | |
… | |
5 | #ifndef RXVTPERL_H_ |
5 | #ifndef RXVTPERL_H_ |
6 | #define RXVTPERL_H_ |
6 | #define RXVTPERL_H_ |
7 | |
7 | |
8 | #if ENABLE_PERL |
8 | #if ENABLE_PERL |
9 | |
9 | |
10 | #include "rxvt.h" |
10 | #define SHOULD_INVOKE(htype) \ |
11 | |
11 | ( (htype) == HOOK_INIT \ |
|
|
12 | || (htype) == HOOK_DESTROY \ |
|
|
13 | || (htype) == HOOK_REFRESH_BEGIN \ |
|
|
14 | || (htype) == HOOK_REFRESH_END \ |
|
|
15 | || perl.should_invoke [htype]) |
12 | #define PERL_INVOKE(args) rxvt_perl.invoke args |
16 | #define HOOK_INVOKE(args) rxvt_perl.invoke args |
13 | |
17 | |
14 | enum data_type { |
18 | enum data_type { |
15 | DT_END, |
19 | DT_END, // no further arguments |
16 | DT_INT, |
20 | DT_INT, |
17 | DT_LONG, |
21 | DT_LONG, |
|
|
22 | DT_STR, // 0-terminated string |
|
|
23 | DT_STR_LEN, // string + length |
|
|
24 | DT_WCS_LEN, // wchar_t* + length |
|
|
25 | DT_LCS_LEN, // long* + length |
|
|
26 | DT_XEVENT, |
18 | }; |
27 | }; |
19 | |
28 | |
20 | enum hook_type { |
29 | enum hook_type { |
21 | HOOK_LOAD, |
30 | # define def(sym) HOOK_ ## sym, |
|
|
31 | # include "hookinc.h" |
|
|
32 | # undef def |
|
|
33 | HOOK_NUM, |
|
|
34 | }; |
22 | |
35 | |
23 | HOOK_INIT, |
36 | struct rxvt_perl_term |
24 | HOOK_RESET, |
37 | { |
25 | HOOK_START, |
38 | void *self; |
26 | HOOK_DESTROY, |
39 | unsigned long grabtime; |
|
|
40 | uint8_t should_invoke[HOOK_NUM]; |
27 | |
41 | |
28 | HOOK_SEL_BEGIN, |
42 | // this object must be zero-initialised |
29 | HOOK_SEL_EXTEND, |
43 | rxvt_perl_term () |
30 | HOOK_SEL_MAKE, |
44 | { |
31 | HOOK_SEL_GRAB, |
45 | should_invoke [HOOK_INIT] = |
32 | |
46 | should_invoke [HOOK_DESTROY] = 1; |
33 | HOOK_FOCUS_IN, |
47 | } |
34 | HOOK_FOCUS_OUT, |
|
|
35 | |
|
|
36 | HOOK_VIEW_CHANGE, |
|
|
37 | HOOK_SCROLL_BACK, |
|
|
38 | HOOK_TTY_ACTIVITY, |
|
|
39 | |
|
|
40 | HOOK_REFRESH_BEGIN, |
|
|
41 | HOOK_REFRESH_END, |
|
|
42 | |
|
|
43 | HOOK_NUM, |
|
|
44 | }; |
48 | }; |
45 | |
49 | |
46 | struct rxvt_perl_interp |
50 | struct rxvt_perl_interp |
47 | { |
51 | { |
48 | rxvt_perl_interp (); |
52 | char **perl_environ; |
|
|
53 | |
|
|
54 | #if 0 // see rxvtperl.xs |
49 | ~rxvt_perl_interp (); |
55 | ~rxvt_perl_interp (); |
50 | |
56 | #endif |
51 | bool should_invoke[HOOK_NUM]; |
|
|
52 | |
57 | |
53 | void init (); |
58 | void init (); |
|
|
59 | void init (rxvt_term *term); |
|
|
60 | void eval (const char *str); |
54 | bool invoke (rxvt_term *term, hook_type htype, ...); |
61 | bool invoke (rxvt_term *term, hook_type htype, ...); |
|
|
62 | void line_update (rxvt_term *term); |
|
|
63 | void selection_finish (rxvt_selection *sel, char *data, unsigned int len); |
|
|
64 | void usage (rxvt_term *term, int type); |
|
|
65 | |
|
|
66 | enum |
|
|
67 | { |
|
|
68 | RESOURCE_AVAILABLE = 1, // whether the option is valid |
|
|
69 | RESOURCE_ARG = 2 // whether the option eats the next arg |
|
|
70 | }; |
|
|
71 | uint8_t parse_resource (rxvt_term *term, const char *name, bool arg, bool longopt, bool flag, const char *value); |
55 | }; |
72 | }; |
56 | |
73 | |
57 | extern struct rxvt_perl_interp rxvt_perl; |
74 | extern struct rxvt_perl_interp rxvt_perl; |
58 | |
75 | |
59 | #else |
76 | #else |
60 | #define PERL_INVOKE(args) (void)0 |
77 | |
|
|
78 | #define SHOULD_INVOKE(htype) false |
|
|
79 | #define HOOK_INVOKE(args) false |
|
|
80 | |
61 | #endif |
81 | #endif |
62 | |
82 | |
63 | #endif |
83 | #endif |
64 | |
84 | |