vte3 2.2.5 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +47 -31
- data/lib/vte3.rb +54 -2
- data/lib/vte3/deprecated.rb +21 -23
- data/lib/vte3/loader.rb +66 -0
- data/lib/vte3/pty.rb +29 -0
- data/lib/vte3/terminal.rb +73 -0
- data/lib/vte3/version.rb +35 -0
- data/test/run-test.rb +63 -0
- data/test/test-pty.rb +47 -0
- data/test/test-terminal-properties.rb +122 -0
- data/test/test-terminal-signals.rb +48 -0
- data/test/test-terminal.rb +44 -0
- data/test/test-version.rb +53 -0
- data/test/vte3-test-utils.rb +27 -0
- metadata +31 -20
- data/ext/vte3/depend +0 -6
- data/ext/vte3/extconf.rb +0 -67
- data/ext/vte3/rbvte.c +0 -51
- data/ext/vte3/rbvte3conversions.h +0 -54
- data/ext/vte3/rbvte3private.h +0 -22
- data/ext/vte3/rbvtecharattributes.c +0 -76
- data/ext/vte3/rbvtepty.c +0 -114
- data/ext/vte3/rbvtereaper.c +0 -39
- data/ext/vte3/rbvteterminal.c +0 -984
- data/ext/vte3/rbvteterminalaccessible.c +0 -41
- data/extconf.rb +0 -49
- data/sample/multiterm.rb +0 -103
- data/sample/terminal.rb +0 -28
data/ext/vte3/rbvte.c
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2006-2011 Ruby-GNOME2 Project Team
|
4
|
-
*
|
5
|
-
* This library is free software; you can redistribute it and/or
|
6
|
-
* modify it under the terms of the GNU Lesser General Public
|
7
|
-
* License as published by the Free Software Foundation; either
|
8
|
-
* version 2.1 of the License, or (at your option) any later version.
|
9
|
-
*
|
10
|
-
* This library is distributed in the hope that it will be useful,
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* Lesser General Public License for more details.
|
14
|
-
*
|
15
|
-
* You should have received a copy of the GNU Lesser General Public
|
16
|
-
* License along with this library; if not, write to the Free Software
|
17
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18
|
-
* MA 02110-1301 USA
|
19
|
-
*/
|
20
|
-
|
21
|
-
#include "rbvte3private.h"
|
22
|
-
|
23
|
-
#define RG_TARGET_NAMESPACE mVte
|
24
|
-
|
25
|
-
void Init_vte3(void);
|
26
|
-
|
27
|
-
void
|
28
|
-
Init_vte3(void)
|
29
|
-
{
|
30
|
-
VALUE RG_TARGET_NAMESPACE;
|
31
|
-
|
32
|
-
RG_TARGET_NAMESPACE = rb_define_module("Vte");
|
33
|
-
|
34
|
-
rb_define_const(RG_TARGET_NAMESPACE, "BUILD_VERSION",
|
35
|
-
rb_ary_new3(3,
|
36
|
-
INT2FIX(VTE_MAJOR_VERSION),
|
37
|
-
INT2FIX(VTE_MINOR_VERSION),
|
38
|
-
INT2FIX(VTE_MICRO_VERSION)));
|
39
|
-
|
40
|
-
G_DEF_CLASS(VTE_TYPE_TERMINAL_ANTI_ALIAS, "TerminalAntiAlias", RG_TARGET_NAMESPACE);
|
41
|
-
G_DEF_CLASS(VTE_TYPE_TERMINAL_ERASE_BINDING, "TerminalEraseBinding", RG_TARGET_NAMESPACE);
|
42
|
-
G_DEF_CLASS(VTE_TYPE_TERMINAL_CURSOR_BLINK_MODE, "TerminalCursorBlinkMode", RG_TARGET_NAMESPACE);
|
43
|
-
G_DEF_CLASS(VTE_TYPE_TERMINAL_CURSOR_SHAPE, "TerminalCursorShape", RG_TARGET_NAMESPACE);
|
44
|
-
G_DEF_CLASS(VTE_TYPE_TERMINAL_WRITE_FLAGS, "TerminalWriteFlags", RG_TARGET_NAMESPACE);
|
45
|
-
|
46
|
-
Init_vte_access(RG_TARGET_NAMESPACE);
|
47
|
-
Init_vte_reaper(RG_TARGET_NAMESPACE);
|
48
|
-
Init_vte_terminal(RG_TARGET_NAMESPACE);
|
49
|
-
Init_vte_charattributes(RG_TARGET_NAMESPACE);
|
50
|
-
Init_vte_pty(RG_TARGET_NAMESPACE);
|
51
|
-
}
|
@@ -1,54 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011-2014 Ruby-GNOME2 Project Team
|
4
|
-
*
|
5
|
-
* This library is free software; you can redistribute it and/or
|
6
|
-
* modify it under the terms of the GNU Lesser General Public
|
7
|
-
* License as published by the Free Software Foundation; either
|
8
|
-
* version 2.1 of the License, or (at your option) any later version.
|
9
|
-
*
|
10
|
-
* This library is distributed in the hope that it will be useful,
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* Lesser General Public License for more details.
|
14
|
-
*
|
15
|
-
* You should have received a copy of the GNU Lesser General Public
|
16
|
-
* License along with this library; if not, write to the Free Software
|
17
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18
|
-
* MA 02110-1301 USA
|
19
|
-
*/
|
20
|
-
|
21
|
-
#ifndef __RBVTE3CONVERSIONS_H__
|
22
|
-
#define __RBVTE3CONVERSIONS_H__
|
23
|
-
|
24
|
-
#define RVAL2VTEPTY(o) (VTE_PTY(RVAL2GOBJ(o)))
|
25
|
-
#define RVAL2VTETERMINAL(o) (VTE_TERMINAL(RVAL2GOBJ(o)))
|
26
|
-
|
27
|
-
#define RVAL2VTETERMINALCURSORBLINKMODE(o) (RVAL2GENUM(o, VTE_TYPE_TERMINAL_CURSOR_BLINK_MODE))
|
28
|
-
#define VTETERMINALCURSORBLINKMODE2RVAL(o) (GENUM2RVAL(o, VTE_TYPE_TERMINAL_CURSOR_BLINK_MODE))
|
29
|
-
#define RVAL2VTETERMINALCURSORSHAPE(o) (RVAL2GENUM(o, VTE_TYPE_TERMINAL_CURSOR_SHAPE))
|
30
|
-
#define VTETERMINALCURSORSHAPE2RVAL(o) (GENUM2RVAL(o, VTE_TYPE_TERMINAL_CURSOR_SHAPE))
|
31
|
-
#define RVAL2VTETERMINALERASEBINDING(o) (RVAL2GENUM(o, VTE_TYPE_TERMINAL_ERASE_BINDING))
|
32
|
-
#define VTETERMINALERASEBINDING2RVAL(o) (GENUM2RVAL(o, VTE_TYPE_TERMINAL_ERASE_BINDING))
|
33
|
-
#define RVAL2VTETERMINALWRITEFLAGS(o) (RVAL2GENUM(o, VTE_TYPE_TERMINAL_WRITE_FLAGS))
|
34
|
-
#define VTETERMINALWRITEFLAGS2RVAL(o) (GENUM2RVAL(o, VTE_TYPE_TERMINAL_WRITE_FLAGS))
|
35
|
-
|
36
|
-
#define RVAL2VTEPTYFLAGS(o) (RVAL2GFLAGS(o, VTE_TYPE_PTY_FLAGS))
|
37
|
-
#define VTEPTYFLAGS2RVAL(o) (GFLAGS2RVAL(o, VTE_TYPE_PTY_FLAGS))
|
38
|
-
|
39
|
-
/* For GIO. They are temporary. They will be needless after Ruby/GDK3
|
40
|
-
* is based on Ruby/GObjectIntrospection.
|
41
|
-
*/
|
42
|
-
#define RVAL2GCANCELLABLE(o) (G_CANCELLABLE(RVAL2GOBJ(o)))
|
43
|
-
#define RVAL2GOUTPUTSTREAM(o) (G_OUTPUT_STREAM(RVAL2GOBJ(o)))
|
44
|
-
|
45
|
-
/* For GDK3. They are temporary. They will be needless after Ruby/GDK3
|
46
|
-
* is based on Ruby/GObjectIntrospection.
|
47
|
-
*/
|
48
|
-
#define RVAL2GDKPIXBUF(o) (GDK_PIXBUF(RVAL2GOBJ(o)))
|
49
|
-
#define RVAL2GDKCOLOR(o) ((GdkColor*)RVAL2BOXED(o, GDK_TYPE_COLOR))
|
50
|
-
#define GDKCOLOR2RVAL(o) (BOXED2RVAL(o, GDK_TYPE_COLOR))
|
51
|
-
#define RVAL2GDKCURSOR(o) ((GdkCursor*)RVAL2BOXED(o, GDK_TYPE_CURSOR))
|
52
|
-
#define RVAL2GDKCURSORTYPE(o) (RVAL2GENUM(o, GDK_TYPE_CURSOR_TYPE))
|
53
|
-
|
54
|
-
#endif /* __RBVTE3CONVERSIONS_H__ */
|
data/ext/vte3/rbvte3private.h
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#ifndef __RBVTE3PRIVATE_H__
|
2
|
-
#define __RBVTE3PRIVATE_H__
|
3
|
-
|
4
|
-
#include <vte/vte.h>
|
5
|
-
#include <vte/vteaccess.h>
|
6
|
-
#include <vte/reaper.h>
|
7
|
-
|
8
|
-
#include <ruby.h>
|
9
|
-
#include <rbpango.h>
|
10
|
-
#include <rbgtk3.h>
|
11
|
-
#include "rbvte3conversions.h"
|
12
|
-
#ifndef VTE_CHECK_VERSION
|
13
|
-
# include "rbvteversion.h"
|
14
|
-
#endif
|
15
|
-
|
16
|
-
G_GNUC_INTERNAL void Init_vte_access(VALUE mVte);
|
17
|
-
G_GNUC_INTERNAL void Init_vte_reaper(VALUE mVte);
|
18
|
-
G_GNUC_INTERNAL void Init_vte_terminal(VALUE mVte);
|
19
|
-
G_GNUC_INTERNAL void Init_vte_charattributes(VALUE mVte);
|
20
|
-
G_GNUC_INTERNAL void Init_vte_pty(VALUE mVte);
|
21
|
-
|
22
|
-
#endif
|
@@ -1,76 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2006-2011 Ruby-GNOME2 Project Team
|
4
|
-
*
|
5
|
-
* This library is free software; you can redistribute it and/or
|
6
|
-
* modify it under the terms of the GNU Lesser General Public
|
7
|
-
* License as published by the Free Software Foundation; either
|
8
|
-
* version 2.1 of the License, or (at your option) any later version.
|
9
|
-
*
|
10
|
-
* This library is distributed in the hope that it will be useful,
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* Lesser General Public License for more details.
|
14
|
-
*
|
15
|
-
* You should have received a copy of the GNU Lesser General Public
|
16
|
-
* License along with this library; if not, write to the Free Software
|
17
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18
|
-
* MA 02110-1301 USA
|
19
|
-
*/
|
20
|
-
|
21
|
-
#include "rbvte3private.h"
|
22
|
-
|
23
|
-
#define RG_TARGET_NAMESPACE cCharAttributes
|
24
|
-
|
25
|
-
static ID id_row, id_column, id_fore, id_back, id_underline, id_strikethrough;
|
26
|
-
|
27
|
-
static VALUE
|
28
|
-
rg_initialize(VALUE self, VALUE row, VALUE column, VALUE fore, VALUE back,
|
29
|
-
VALUE underline, VALUE strikethrough)
|
30
|
-
{
|
31
|
-
rb_ivar_set(self, id_row, row);
|
32
|
-
rb_ivar_set(self, id_column, column);
|
33
|
-
rb_ivar_set(self, id_fore, fore);
|
34
|
-
rb_ivar_set(self, id_back, back);
|
35
|
-
rb_ivar_set(self, id_underline, underline);
|
36
|
-
rb_ivar_set(self, id_strikethrough, strikethrough);
|
37
|
-
return Qnil;
|
38
|
-
}
|
39
|
-
|
40
|
-
static VALUE
|
41
|
-
rg_underline_p(VALUE self)
|
42
|
-
{
|
43
|
-
return rb_ivar_get(self, id_underline);
|
44
|
-
}
|
45
|
-
|
46
|
-
static VALUE
|
47
|
-
rg_strikethrough_p(VALUE self)
|
48
|
-
{
|
49
|
-
return rb_ivar_get(self, id_strikethrough);
|
50
|
-
}
|
51
|
-
|
52
|
-
void
|
53
|
-
Init_vte_charattributes(VALUE mVte)
|
54
|
-
{
|
55
|
-
VALUE RG_TARGET_NAMESPACE;
|
56
|
-
|
57
|
-
id_row = rb_intern("@row");
|
58
|
-
id_column = rb_intern("@column");
|
59
|
-
id_fore = rb_intern("@fore");
|
60
|
-
id_back = rb_intern("@back");
|
61
|
-
id_underline = rb_intern("@underline");
|
62
|
-
id_strikethrough = rb_intern("@strikethrough");
|
63
|
-
|
64
|
-
RG_TARGET_NAMESPACE = rb_define_class_under(mVte, "CharAttributes", rb_cObject);
|
65
|
-
|
66
|
-
RG_DEF_METHOD(initialize, 6);
|
67
|
-
RG_DEF_ATTR("row", TRUE, FALSE, TRUE);
|
68
|
-
RG_DEF_ATTR("column", TRUE, FALSE, TRUE);
|
69
|
-
RG_DEF_ATTR("fore", TRUE, FALSE, TRUE);
|
70
|
-
RG_DEF_ATTR("back", TRUE, FALSE, TRUE);
|
71
|
-
RG_DEF_ALIAS("foreground", "fore");
|
72
|
-
RG_DEF_ALIAS("background", "back");
|
73
|
-
RG_DEF_METHOD_P(underline, 0);
|
74
|
-
RG_DEF_METHOD_P(strikethrough, 0);
|
75
|
-
}
|
76
|
-
|
data/ext/vte3/rbvtepty.c
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
-
*
|
5
|
-
* This library is free software; you can redistribute it and/or
|
6
|
-
* modify it under the terms of the GNU Lesser General Public
|
7
|
-
* License as published by the Free Software Foundation; either
|
8
|
-
* version 2.1 of the License, or (at your option) any later version.
|
9
|
-
*
|
10
|
-
* This library is distributed in the hope that it will be useful,
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* Lesser General Public License for more details.
|
14
|
-
*
|
15
|
-
* You should have received a copy of the GNU Lesser General Public
|
16
|
-
* License along with this library; if not, write to the Free Software
|
17
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18
|
-
* MA 02110-1301 USA
|
19
|
-
*/
|
20
|
-
|
21
|
-
#include "rbvte3private.h"
|
22
|
-
|
23
|
-
#define RG_TARGET_NAMESPACE cPty
|
24
|
-
#define _SELF(s) (RVAL2VTEPTY(s))
|
25
|
-
|
26
|
-
static VALUE
|
27
|
-
rg_initialize(VALUE self, VALUE flags_or_fd)
|
28
|
-
{
|
29
|
-
VtePty *pty = NULL;
|
30
|
-
GError *error = NULL;
|
31
|
-
|
32
|
-
if (TYPE(flags_or_fd) == T_FIXNUM) {
|
33
|
-
pty = vte_pty_new_foreign(NUM2INT(flags_or_fd), &error);
|
34
|
-
} else {
|
35
|
-
pty = vte_pty_new(RVAL2VTEPTYFLAGS(flags_or_fd), &error);
|
36
|
-
}
|
37
|
-
if (error)
|
38
|
-
RAISE_GERROR(error);
|
39
|
-
|
40
|
-
G_INITIALIZE(self, pty);
|
41
|
-
|
42
|
-
return Qnil;
|
43
|
-
}
|
44
|
-
|
45
|
-
static VALUE
|
46
|
-
rg_child_setup(VALUE self)
|
47
|
-
{
|
48
|
-
vte_pty_child_setup(_SELF(self));
|
49
|
-
|
50
|
-
return self;
|
51
|
-
}
|
52
|
-
|
53
|
-
static VALUE
|
54
|
-
rg_close(VALUE self)
|
55
|
-
{
|
56
|
-
vte_pty_close(_SELF(self));
|
57
|
-
|
58
|
-
return self;
|
59
|
-
}
|
60
|
-
|
61
|
-
static VALUE
|
62
|
-
rg_size(VALUE self)
|
63
|
-
{
|
64
|
-
int rows, columns;
|
65
|
-
gboolean result;
|
66
|
-
GError *error = NULL;
|
67
|
-
|
68
|
-
result = vte_pty_get_size(_SELF(self), &rows, &columns, &error);
|
69
|
-
if (error)
|
70
|
-
RAISE_GERROR(error);
|
71
|
-
|
72
|
-
return rb_ary_new3(2, INT2NUM(rows), INT2NUM(columns));
|
73
|
-
}
|
74
|
-
|
75
|
-
static VALUE
|
76
|
-
rg_set_size(VALUE self, VALUE rows, VALUE columns)
|
77
|
-
{
|
78
|
-
gboolean result;
|
79
|
-
GError *error = NULL;
|
80
|
-
|
81
|
-
result = vte_pty_set_size(_SELF(self), NUM2INT(rows), NUM2INT(columns), &error);
|
82
|
-
if (error)
|
83
|
-
RAISE_GERROR(error);
|
84
|
-
|
85
|
-
return self;
|
86
|
-
}
|
87
|
-
|
88
|
-
static VALUE
|
89
|
-
rg_set_utf8(VALUE self, VALUE utf8)
|
90
|
-
{
|
91
|
-
gboolean result;
|
92
|
-
GError *error = NULL;
|
93
|
-
|
94
|
-
result = vte_pty_set_utf8(_SELF(self), RVAL2CBOOL(utf8), &error);
|
95
|
-
if (error)
|
96
|
-
RAISE_GERROR(error);
|
97
|
-
|
98
|
-
return self;
|
99
|
-
}
|
100
|
-
|
101
|
-
void
|
102
|
-
Init_vte_pty(VALUE mVte)
|
103
|
-
{
|
104
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(VTE_TYPE_PTY, "Pty", mVte);
|
105
|
-
G_DEF_CLASS(VTE_TYPE_PTY_ERROR, "Error", RG_TARGET_NAMESPACE);
|
106
|
-
G_DEF_CLASS(VTE_TYPE_PTY_FLAGS, "Flags", RG_TARGET_NAMESPACE);
|
107
|
-
|
108
|
-
RG_DEF_METHOD(initialize, 1);
|
109
|
-
RG_DEF_METHOD(child_setup, 0);
|
110
|
-
RG_DEF_METHOD(close, 0);
|
111
|
-
RG_DEF_METHOD(size, 0);
|
112
|
-
RG_DEF_METHOD(set_size, 2);
|
113
|
-
RG_DEF_METHOD(set_utf8, 1);
|
114
|
-
}
|
data/ext/vte3/rbvtereaper.c
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2006-2011 Ruby-GNOME2 Project Team
|
4
|
-
*
|
5
|
-
* This library is free software; you can redistribute it and/or
|
6
|
-
* modify it under the terms of the GNU Lesser General Public
|
7
|
-
* License as published by the Free Software Foundation; either
|
8
|
-
* version 2.1 of the License, or (at your option) any later version.
|
9
|
-
*
|
10
|
-
* This library is distributed in the hope that it will be useful,
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* Lesser General Public License for more details.
|
14
|
-
*
|
15
|
-
* You should have received a copy of the GNU Lesser General Public
|
16
|
-
* License along with this library; if not, write to the Free Software
|
17
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18
|
-
* MA 02110-1301 USA
|
19
|
-
*/
|
20
|
-
|
21
|
-
#include "rbvte3private.h"
|
22
|
-
|
23
|
-
#define RG_TARGET_NAMESPACE cReaper
|
24
|
-
|
25
|
-
static VALUE
|
26
|
-
rg_s_get(G_GNUC_UNUSED VALUE self)
|
27
|
-
{
|
28
|
-
return GOBJ2RVAL(vte_reaper_get());
|
29
|
-
}
|
30
|
-
|
31
|
-
void
|
32
|
-
Init_vte_reaper(VALUE mVte)
|
33
|
-
{
|
34
|
-
VALUE RG_TARGET_NAMESPACE;
|
35
|
-
|
36
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(VTE_TYPE_REAPER, "Reaper", mVte);
|
37
|
-
|
38
|
-
RG_DEF_SMETHOD(get, 0);
|
39
|
-
}
|
data/ext/vte3/rbvteterminal.c
DELETED
@@ -1,984 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2006-2011 Ruby-GNOME2 Project Team
|
4
|
-
*
|
5
|
-
* This library is free software; you can redistribute it and/or
|
6
|
-
* modify it under the terms of the GNU Lesser General Public
|
7
|
-
* License as published by the Free Software Foundation; either
|
8
|
-
* version 2.1 of the License, or (at your option) any later version.
|
9
|
-
*
|
10
|
-
* This library is distributed in the hope that it will be useful,
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* Lesser General Public License for more details.
|
14
|
-
*
|
15
|
-
* You should have received a copy of the GNU Lesser General Public
|
16
|
-
* License along with this library; if not, write to the Free Software
|
17
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18
|
-
* MA 02110-1301 USA
|
19
|
-
*/
|
20
|
-
|
21
|
-
#include "rbvte3private.h"
|
22
|
-
|
23
|
-
#include <stdarg.h>
|
24
|
-
#include <pwd.h>
|
25
|
-
|
26
|
-
#define RG_TARGET_NAMESPACE cTerminal
|
27
|
-
#define _SELF(s) (RVAL2VTETERMINAL(s))
|
28
|
-
|
29
|
-
static ID id_new, id_call;
|
30
|
-
|
31
|
-
static char **
|
32
|
-
rval2cstrary(VALUE ary)
|
33
|
-
{
|
34
|
-
long i, len;
|
35
|
-
char **result;
|
36
|
-
|
37
|
-
if (NIL_P(ary))
|
38
|
-
return NULL;
|
39
|
-
|
40
|
-
len = RARRAY_LEN(ary);
|
41
|
-
result = ALLOC_N(char *, len + 1);
|
42
|
-
for (i = 0; i < len; i++) {
|
43
|
-
result[i] = g_strdup(RVAL2CSTR(RARRAY_PTR(ary)[i]));
|
44
|
-
}
|
45
|
-
result[i] = NULL;
|
46
|
-
|
47
|
-
return result;
|
48
|
-
}
|
49
|
-
|
50
|
-
static void
|
51
|
-
free_cstrary(char **ary)
|
52
|
-
{
|
53
|
-
long i;
|
54
|
-
|
55
|
-
if (!ary) return;
|
56
|
-
|
57
|
-
for (i = 0; ary[i] != NULL; i++) {
|
58
|
-
g_free(ary[i]);
|
59
|
-
}
|
60
|
-
g_free(ary);
|
61
|
-
}
|
62
|
-
|
63
|
-
static VALUE
|
64
|
-
attrary2rval(GArray *attrs)
|
65
|
-
{
|
66
|
-
long i, len;
|
67
|
-
VALUE rb_attrs, rb_class;
|
68
|
-
|
69
|
-
len = attrs->len;
|
70
|
-
rb_attrs = rb_ary_new2(len);
|
71
|
-
rb_class = rb_const_get(rb_const_get(rb_cObject, rb_intern("Vte")), rb_intern("CharAttributes"));
|
72
|
-
|
73
|
-
for (i = 0; i < len; i++) {
|
74
|
-
VteCharAttributes *attr;
|
75
|
-
attr = &g_array_index(attrs, VteCharAttributes, i);
|
76
|
-
rb_ary_push(rb_attrs, rb_funcall(rb_class, id_new, 6,
|
77
|
-
LONG2NUM(attr->row),
|
78
|
-
LONG2NUM(attr->column),
|
79
|
-
GDKCOLOR2RVAL(&(attr->fore)),
|
80
|
-
GDKCOLOR2RVAL(&(attr->back)),
|
81
|
-
CBOOL2RVAL(attr->underline),
|
82
|
-
CBOOL2RVAL(attr->strikethrough)));
|
83
|
-
}
|
84
|
-
|
85
|
-
return rb_attrs;
|
86
|
-
}
|
87
|
-
|
88
|
-
static VALUE
|
89
|
-
rg_initialize(VALUE self)
|
90
|
-
{
|
91
|
-
RBGTK_INITIALIZE(self, vte_terminal_new());
|
92
|
-
return Qnil;
|
93
|
-
}
|
94
|
-
|
95
|
-
static VALUE
|
96
|
-
fork_command_default_argv(void)
|
97
|
-
{
|
98
|
-
struct passwd *pwd;
|
99
|
-
const char *shell = NULL;
|
100
|
-
|
101
|
-
pwd = getpwuid(getuid());
|
102
|
-
if (pwd != NULL)
|
103
|
-
shell = pwd->pw_shell;
|
104
|
-
if (shell == NULL)
|
105
|
-
shell = g_getenv("SHELL") ? g_getenv("SHELL") : "/bin/sh";
|
106
|
-
|
107
|
-
return rb_ary_new3(1, CSTR2RVAL(shell));
|
108
|
-
}
|
109
|
-
|
110
|
-
static VALUE
|
111
|
-
rg_fork_command(int argc, VALUE *argv, VALUE self)
|
112
|
-
{
|
113
|
-
VALUE options, rb_pty_flags, rb_working_directory, rb_command_argv, rb_envv, rb_spawn_flags;
|
114
|
-
int pty_flags, spawn_flags;
|
115
|
-
char *working_directory;
|
116
|
-
char **command_argv;
|
117
|
-
char **envv;
|
118
|
-
GPid child_pid;
|
119
|
-
gboolean result;
|
120
|
-
GError *error = NULL;
|
121
|
-
|
122
|
-
rb_scan_args(argc, argv, "01", &options);
|
123
|
-
rbg_scan_options(options,
|
124
|
-
"pty_flags", &rb_pty_flags,
|
125
|
-
"working_directory", &rb_working_directory,
|
126
|
-
"argv", &rb_command_argv,
|
127
|
-
"envv", &rb_envv,
|
128
|
-
"spawn_flags", &rb_spawn_flags,
|
129
|
-
NULL);
|
130
|
-
pty_flags = NIL_P(rb_pty_flags) ?
|
131
|
-
VTE_PTY_DEFAULT :
|
132
|
-
RVAL2VTEPTYFLAGS(rb_pty_flags);
|
133
|
-
working_directory = RVAL2CSTR_ACCEPT_NIL(rb_working_directory);
|
134
|
-
command_argv = rval2cstrary(NIL_P(rb_command_argv) ? fork_command_default_argv() : rb_command_argv);
|
135
|
-
envv = rval2cstrary(rb_envv);
|
136
|
-
spawn_flags = NIL_P(rb_spawn_flags) ?
|
137
|
-
G_SPAWN_CHILD_INHERITS_STDIN | G_SPAWN_SEARCH_PATH :
|
138
|
-
NUM2INT(rb_spawn_flags);
|
139
|
-
|
140
|
-
result = vte_terminal_fork_command_full(_SELF(self),
|
141
|
-
pty_flags,
|
142
|
-
working_directory,
|
143
|
-
command_argv,
|
144
|
-
envv,
|
145
|
-
spawn_flags,
|
146
|
-
NULL,
|
147
|
-
NULL,
|
148
|
-
&child_pid,
|
149
|
-
&error);
|
150
|
-
free_cstrary(command_argv);
|
151
|
-
free_cstrary(envv);
|
152
|
-
if (error)
|
153
|
-
RAISE_GERROR(error);
|
154
|
-
|
155
|
-
return INT2NUM(child_pid);
|
156
|
-
}
|
157
|
-
|
158
|
-
static VALUE
|
159
|
-
rg_feed(VALUE self, VALUE data)
|
160
|
-
{
|
161
|
-
glong length;
|
162
|
-
|
163
|
-
length = RSTRING_LEN(data);
|
164
|
-
|
165
|
-
if (length > 0) {
|
166
|
-
vte_terminal_feed(_SELF(self), RSTRING_PTR(data), length);
|
167
|
-
}
|
168
|
-
|
169
|
-
return self;
|
170
|
-
}
|
171
|
-
|
172
|
-
static VALUE
|
173
|
-
rg_feed_child(VALUE self, VALUE data)
|
174
|
-
{
|
175
|
-
glong length;
|
176
|
-
|
177
|
-
length = RSTRING_LEN(data);
|
178
|
-
|
179
|
-
if (length > 0) {
|
180
|
-
vte_terminal_feed_child(_SELF(self), RSTRING_PTR(data), length);
|
181
|
-
}
|
182
|
-
|
183
|
-
return self;
|
184
|
-
}
|
185
|
-
|
186
|
-
static VALUE
|
187
|
-
rg_feed_child_binary(VALUE self, VALUE data)
|
188
|
-
{
|
189
|
-
glong length;
|
190
|
-
|
191
|
-
length = RSTRING_LEN(data);
|
192
|
-
|
193
|
-
if (length > 0) {
|
194
|
-
vte_terminal_feed_child_binary(_SELF(self),
|
195
|
-
RSTRING_PTR(data), length);
|
196
|
-
}
|
197
|
-
|
198
|
-
return self;
|
199
|
-
}
|
200
|
-
|
201
|
-
static VALUE
|
202
|
-
rg_copy_clipboard(VALUE self)
|
203
|
-
{
|
204
|
-
vte_terminal_copy_clipboard(_SELF(self));
|
205
|
-
return self;
|
206
|
-
}
|
207
|
-
|
208
|
-
static VALUE
|
209
|
-
rg_paste_clipboard(VALUE self)
|
210
|
-
{
|
211
|
-
vte_terminal_paste_clipboard(_SELF(self));
|
212
|
-
return self;
|
213
|
-
}
|
214
|
-
|
215
|
-
static VALUE
|
216
|
-
rg_copy_primary(VALUE self)
|
217
|
-
{
|
218
|
-
vte_terminal_copy_primary(_SELF(self));
|
219
|
-
return self;
|
220
|
-
}
|
221
|
-
|
222
|
-
static VALUE
|
223
|
-
rg_paste_primary(VALUE self)
|
224
|
-
{
|
225
|
-
vte_terminal_paste_primary(_SELF(self));
|
226
|
-
return self;
|
227
|
-
}
|
228
|
-
|
229
|
-
static VALUE
|
230
|
-
rg_set_size(VALUE self, VALUE columns, VALUE rows)
|
231
|
-
{
|
232
|
-
vte_terminal_set_size(_SELF(self), NUM2LONG(columns), NUM2LONG(rows));
|
233
|
-
return self;
|
234
|
-
}
|
235
|
-
|
236
|
-
static VALUE
|
237
|
-
rg_set_audible_bell(VALUE self, VALUE is_audible)
|
238
|
-
{
|
239
|
-
vte_terminal_set_audible_bell(_SELF(self), RVAL2CBOOL(is_audible));
|
240
|
-
return self;
|
241
|
-
}
|
242
|
-
|
243
|
-
static VALUE
|
244
|
-
rg_audible_bell_p(VALUE self)
|
245
|
-
{
|
246
|
-
return CBOOL2RVAL(vte_terminal_get_audible_bell(_SELF(self)));
|
247
|
-
}
|
248
|
-
|
249
|
-
static VALUE
|
250
|
-
rg_set_visible_bell(VALUE self, VALUE is_visible)
|
251
|
-
{
|
252
|
-
vte_terminal_set_visible_bell(_SELF(self), RVAL2CBOOL(is_visible));
|
253
|
-
return self;
|
254
|
-
}
|
255
|
-
|
256
|
-
static VALUE
|
257
|
-
rg_visible_bell_p(VALUE self)
|
258
|
-
{
|
259
|
-
return CBOOL2RVAL(vte_terminal_get_visible_bell(_SELF(self)));
|
260
|
-
}
|
261
|
-
|
262
|
-
static VALUE
|
263
|
-
rg_set_scroll_background(VALUE self, VALUE scroll)
|
264
|
-
{
|
265
|
-
vte_terminal_set_scroll_background(_SELF(self), RVAL2CBOOL(scroll));
|
266
|
-
return self;
|
267
|
-
}
|
268
|
-
|
269
|
-
static VALUE
|
270
|
-
rg_set_scroll_on_output(VALUE self, VALUE scroll)
|
271
|
-
{
|
272
|
-
vte_terminal_set_scroll_on_output(_SELF(self), RVAL2CBOOL(scroll));
|
273
|
-
return self;
|
274
|
-
}
|
275
|
-
|
276
|
-
static VALUE
|
277
|
-
rg_set_scroll_on_keystroke(VALUE self, VALUE scroll)
|
278
|
-
{
|
279
|
-
vte_terminal_set_scroll_on_keystroke(_SELF(self), RVAL2CBOOL(scroll));
|
280
|
-
return self;
|
281
|
-
}
|
282
|
-
|
283
|
-
#if VTE_CHECK_VERSION(0, 36, 0)
|
284
|
-
static VALUE
|
285
|
-
rg_rewrap_on_resize_p(VALUE self)
|
286
|
-
{
|
287
|
-
return CBOOL2RVAL(vte_terminal_get_rewrap_on_resize(_SELF(self)));
|
288
|
-
}
|
289
|
-
|
290
|
-
static VALUE
|
291
|
-
rg_set_rewrap_on_resize(VALUE self, VALUE rewrap)
|
292
|
-
{
|
293
|
-
vte_terminal_set_rewrap_on_resize(_SELF(self), RVAL2CBOOL(rewrap));
|
294
|
-
return self;
|
295
|
-
}
|
296
|
-
#endif
|
297
|
-
|
298
|
-
static VALUE
|
299
|
-
rg_set_color_dim(VALUE self, VALUE dim)
|
300
|
-
{
|
301
|
-
vte_terminal_set_color_dim(_SELF(self), RVAL2GDKCOLOR(dim));
|
302
|
-
return self;
|
303
|
-
}
|
304
|
-
|
305
|
-
static VALUE
|
306
|
-
rg_set_color_bold(VALUE self, VALUE bold)
|
307
|
-
{
|
308
|
-
vte_terminal_set_color_bold(_SELF(self), RVAL2GDKCOLOR(bold));
|
309
|
-
return self;
|
310
|
-
}
|
311
|
-
|
312
|
-
static VALUE
|
313
|
-
rg_set_color_foreground(VALUE self, VALUE foreground)
|
314
|
-
{
|
315
|
-
vte_terminal_set_color_foreground(_SELF(self), RVAL2GDKCOLOR(foreground));
|
316
|
-
return self;
|
317
|
-
}
|
318
|
-
|
319
|
-
static VALUE
|
320
|
-
rg_set_color_background(VALUE self, VALUE background)
|
321
|
-
{
|
322
|
-
vte_terminal_set_color_background(_SELF(self), RVAL2GDKCOLOR(background));
|
323
|
-
return self;
|
324
|
-
}
|
325
|
-
|
326
|
-
static VALUE
|
327
|
-
rg_set_color_cursor(VALUE self, VALUE cursor)
|
328
|
-
{
|
329
|
-
vte_terminal_set_color_cursor(_SELF(self),
|
330
|
-
NIL_P(cursor) ? NULL : RVAL2GDKCOLOR(cursor));
|
331
|
-
return self;
|
332
|
-
}
|
333
|
-
|
334
|
-
static VALUE
|
335
|
-
rg_set_color_highlight(VALUE self, VALUE highlight)
|
336
|
-
{
|
337
|
-
vte_terminal_set_color_highlight(_SELF(self),
|
338
|
-
NIL_P(highlight) ?
|
339
|
-
NULL : RVAL2GDKCOLOR(highlight));
|
340
|
-
return self;
|
341
|
-
}
|
342
|
-
|
343
|
-
static VALUE
|
344
|
-
rg_set_colors(VALUE self, VALUE foreground, VALUE background,
|
345
|
-
VALUE rb_palette)
|
346
|
-
{
|
347
|
-
glong i, len;
|
348
|
-
GdkColor *palette;
|
349
|
-
|
350
|
-
len = RARRAY_LEN(rb_palette);
|
351
|
-
|
352
|
-
if (!(len == 0 || len == 8 || len == 16 || len == 24)) {
|
353
|
-
char *inspect;
|
354
|
-
inspect = RVAL2CSTR(rb_palette);
|
355
|
-
rb_raise(rb_eArgError, "palette size must be 0, 8, 16 or 24: %s",
|
356
|
-
inspect);
|
357
|
-
}
|
358
|
-
|
359
|
-
palette = ALLOCA_N(GdkColor, len);
|
360
|
-
for (i = 0; i < len; i++) {
|
361
|
-
GdkColor *color;
|
362
|
-
color = RVAL2GDKCOLOR(RARRAY_PTR(rb_palette)[i]);
|
363
|
-
palette[i] = *color;
|
364
|
-
}
|
365
|
-
|
366
|
-
vte_terminal_set_colors(_SELF(self), RVAL2GDKCOLOR(foreground),
|
367
|
-
RVAL2GDKCOLOR(background), palette, len);
|
368
|
-
return self;
|
369
|
-
}
|
370
|
-
|
371
|
-
static VALUE
|
372
|
-
rg_set_default_colors(VALUE self)
|
373
|
-
{
|
374
|
-
vte_terminal_set_default_colors(_SELF(self));
|
375
|
-
return self;
|
376
|
-
}
|
377
|
-
|
378
|
-
static VALUE
|
379
|
-
rg_set_background_image(VALUE self, VALUE image_or_path)
|
380
|
-
{
|
381
|
-
if (RVAL2CBOOL(rb_obj_is_kind_of(image_or_path, rb_cString))) {
|
382
|
-
vte_terminal_set_background_image_file(_SELF(self),
|
383
|
-
RVAL2CSTR(image_or_path));
|
384
|
-
} else {
|
385
|
-
vte_terminal_set_background_image(_SELF(self),
|
386
|
-
RVAL2GDKPIXBUF(image_or_path));
|
387
|
-
}
|
388
|
-
|
389
|
-
return self;
|
390
|
-
}
|
391
|
-
|
392
|
-
static VALUE
|
393
|
-
rg_set_background_tint_color(VALUE self, VALUE color)
|
394
|
-
{
|
395
|
-
vte_terminal_set_background_tint_color(_SELF(self), RVAL2GDKCOLOR(color));
|
396
|
-
return self;
|
397
|
-
}
|
398
|
-
|
399
|
-
static VALUE
|
400
|
-
rg_set_background_saturation(VALUE self, VALUE saturation)
|
401
|
-
{
|
402
|
-
vte_terminal_set_background_saturation(_SELF(self),
|
403
|
-
NUM2DBL(saturation));
|
404
|
-
return self;
|
405
|
-
}
|
406
|
-
|
407
|
-
static VALUE
|
408
|
-
rg_set_background_transparent(VALUE self, VALUE transparent)
|
409
|
-
{
|
410
|
-
vte_terminal_set_background_transparent(_SELF(self),
|
411
|
-
RVAL2CBOOL(transparent));
|
412
|
-
return self;
|
413
|
-
}
|
414
|
-
|
415
|
-
static VALUE
|
416
|
-
rg_set_cursor_blinks(VALUE self, VALUE blink)
|
417
|
-
{
|
418
|
-
VteTerminalCursorBlinkMode mode;
|
419
|
-
|
420
|
-
mode = RVAL2CBOOL(blink) ? VTE_CURSOR_BLINK_ON : VTE_CURSOR_BLINK_OFF;
|
421
|
-
vte_terminal_set_cursor_blink_mode(_SELF(self), mode);
|
422
|
-
return self;
|
423
|
-
}
|
424
|
-
|
425
|
-
static VALUE
|
426
|
-
rg_set_cursor_blink_mode(VALUE self, VALUE rb_mode)
|
427
|
-
{
|
428
|
-
VteTerminalCursorBlinkMode mode;
|
429
|
-
|
430
|
-
mode = RVAL2VTETERMINALCURSORBLINKMODE(rb_mode);
|
431
|
-
vte_terminal_set_cursor_blink_mode(_SELF(self), mode);
|
432
|
-
return self;
|
433
|
-
}
|
434
|
-
|
435
|
-
static VALUE
|
436
|
-
rg_cursor_blink_mode(VALUE self)
|
437
|
-
{
|
438
|
-
VteTerminalCursorBlinkMode mode;
|
439
|
-
|
440
|
-
mode = vte_terminal_get_cursor_blink_mode(_SELF(self));
|
441
|
-
return VTETERMINALCURSORBLINKMODE2RVAL(mode);
|
442
|
-
}
|
443
|
-
|
444
|
-
static VALUE
|
445
|
-
rg_set_cursor_shape(VALUE self, VALUE rb_shape)
|
446
|
-
{
|
447
|
-
VteTerminalCursorShape shape;
|
448
|
-
|
449
|
-
shape = RVAL2VTETERMINALCURSORSHAPE(rb_shape);
|
450
|
-
vte_terminal_set_cursor_shape(_SELF(self), shape);
|
451
|
-
return self;
|
452
|
-
}
|
453
|
-
|
454
|
-
static VALUE
|
455
|
-
rg_cursor_shape(VALUE self)
|
456
|
-
{
|
457
|
-
VteTerminalCursorShape shape;
|
458
|
-
|
459
|
-
shape = vte_terminal_get_cursor_shape(_SELF(self));
|
460
|
-
return VTETERMINALCURSORSHAPE2RVAL(shape);
|
461
|
-
}
|
462
|
-
|
463
|
-
static VALUE
|
464
|
-
rg_child_exit_status(VALUE self)
|
465
|
-
{
|
466
|
-
return INT2NUM(vte_terminal_get_child_exit_status(_SELF(self)));
|
467
|
-
}
|
468
|
-
|
469
|
-
static VALUE
|
470
|
-
rg_set_scrollback_lines(VALUE self, VALUE lines)
|
471
|
-
{
|
472
|
-
vte_terminal_set_scrollback_lines(_SELF(self), NUM2LONG(lines));
|
473
|
-
return self;
|
474
|
-
}
|
475
|
-
|
476
|
-
static VALUE
|
477
|
-
rg_im_append_menuitems(VALUE self, VALUE menushell)
|
478
|
-
{
|
479
|
-
vte_terminal_im_append_menuitems(_SELF(self), RVAL2GTKMENUSHELL(menushell));
|
480
|
-
return self;
|
481
|
-
}
|
482
|
-
|
483
|
-
static VALUE
|
484
|
-
rg_set_font(VALUE self, VALUE desc_or_name)
|
485
|
-
{
|
486
|
-
if (rb_obj_is_kind_of(desc_or_name, rb_cString)) {
|
487
|
-
vte_terminal_set_font_from_string(_SELF(self), RVAL2CSTR(desc_or_name));
|
488
|
-
} else {
|
489
|
-
vte_terminal_set_font(_SELF(self), RVAL2PANGOFONTDESCRIPTION(desc_or_name));
|
490
|
-
}
|
491
|
-
|
492
|
-
return self;
|
493
|
-
}
|
494
|
-
|
495
|
-
static VALUE
|
496
|
-
rg_font(VALUE self)
|
497
|
-
{
|
498
|
-
PangoFontDescription *font_desc;
|
499
|
-
font_desc = (PangoFontDescription *)vte_terminal_get_font(_SELF(self));
|
500
|
-
return PANGOFONTDESCRIPTION2RVAL(font_desc);
|
501
|
-
}
|
502
|
-
|
503
|
-
static VALUE
|
504
|
-
rg_set_allow_bold(VALUE self, VALUE allow_bold)
|
505
|
-
{
|
506
|
-
vte_terminal_set_allow_bold(_SELF(self), RVAL2CBOOL(allow_bold));
|
507
|
-
return self;
|
508
|
-
}
|
509
|
-
|
510
|
-
static VALUE
|
511
|
-
rg_allow_bold_p(VALUE self)
|
512
|
-
{
|
513
|
-
return CBOOL2RVAL(vte_terminal_get_allow_bold(_SELF(self)));
|
514
|
-
}
|
515
|
-
|
516
|
-
static VALUE
|
517
|
-
rg_has_selection_p(VALUE self)
|
518
|
-
{
|
519
|
-
return CBOOL2RVAL(vte_terminal_get_has_selection(_SELF(self)));
|
520
|
-
}
|
521
|
-
|
522
|
-
static VALUE
|
523
|
-
rg_set_word_chars(VALUE self, VALUE word_chars)
|
524
|
-
{
|
525
|
-
vte_terminal_set_word_chars(_SELF(self), RVAL2CSTR_ACCEPT_NIL(word_chars));
|
526
|
-
return self;
|
527
|
-
}
|
528
|
-
|
529
|
-
static VALUE
|
530
|
-
rg_word_char_p(VALUE self, VALUE c)
|
531
|
-
{
|
532
|
-
return CBOOL2RVAL(vte_terminal_is_word_char(_SELF(self), NUM2UINT(c)));
|
533
|
-
}
|
534
|
-
|
535
|
-
static VALUE
|
536
|
-
rg_set_backspace_binding(VALUE self, VALUE binding)
|
537
|
-
{
|
538
|
-
vte_terminal_set_backspace_binding(_SELF(self), RVAL2VTETERMINALERASEBINDING(binding));
|
539
|
-
return self;
|
540
|
-
}
|
541
|
-
|
542
|
-
static VALUE
|
543
|
-
rg_set_delete_binding(VALUE self, VALUE binding)
|
544
|
-
{
|
545
|
-
vte_terminal_set_delete_binding(_SELF(self), RVAL2VTETERMINALERASEBINDING(binding));
|
546
|
-
return self;
|
547
|
-
}
|
548
|
-
|
549
|
-
static VALUE
|
550
|
-
rg_mouse_autohide_p(VALUE self)
|
551
|
-
{
|
552
|
-
return CBOOL2RVAL(vte_terminal_get_mouse_autohide(_SELF(self)));
|
553
|
-
}
|
554
|
-
|
555
|
-
static VALUE
|
556
|
-
rg_set_mouse_autohide(VALUE self, VALUE setting)
|
557
|
-
{
|
558
|
-
vte_terminal_set_mouse_autohide(_SELF(self), RVAL2CBOOL(setting));
|
559
|
-
return self;
|
560
|
-
}
|
561
|
-
|
562
|
-
static VALUE
|
563
|
-
rg_reset(VALUE self, VALUE full, VALUE clear_history)
|
564
|
-
{
|
565
|
-
vte_terminal_reset(_SELF(self), RVAL2CBOOL(full),
|
566
|
-
RVAL2CBOOL(clear_history));
|
567
|
-
return self;
|
568
|
-
}
|
569
|
-
|
570
|
-
static gboolean
|
571
|
-
term_is_selected_cb(VteTerminal *terminal, glong column, glong row,
|
572
|
-
gpointer data)
|
573
|
-
{
|
574
|
-
gboolean result = TRUE;
|
575
|
-
VALUE callback = (VALUE)data;
|
576
|
-
|
577
|
-
if (!NIL_P(callback)) {
|
578
|
-
VALUE rb_result;
|
579
|
-
rb_result = rb_funcall(callback, id_call, 3, GOBJ2RVAL(terminal),
|
580
|
-
LONG2NUM(column), LONG2NUM(row));
|
581
|
-
result = RVAL2CBOOL(rb_result);
|
582
|
-
}
|
583
|
-
|
584
|
-
return result;
|
585
|
-
}
|
586
|
-
|
587
|
-
static VALUE
|
588
|
-
rg_get_text(int argc, VALUE *argv, VALUE self)
|
589
|
-
{
|
590
|
-
VALUE get_attrs, include_trailing_spaces, proc, rb_text;
|
591
|
-
GArray *attrs = NULL;
|
592
|
-
char *text;
|
593
|
-
|
594
|
-
rb_scan_args(argc, argv, "02&", &get_attrs,
|
595
|
-
&include_trailing_spaces, &proc);
|
596
|
-
|
597
|
-
if (get_attrs != Qfalse)
|
598
|
-
attrs = g_array_new(FALSE, TRUE, sizeof(VteCharAttributes));
|
599
|
-
|
600
|
-
if (RVAL2CBOOL(include_trailing_spaces)) {
|
601
|
-
text = vte_terminal_get_text_include_trailing_spaces(
|
602
|
-
_SELF(self), term_is_selected_cb, (gpointer)proc, attrs);
|
603
|
-
} else {
|
604
|
-
text = vte_terminal_get_text(_SELF(self), term_is_selected_cb,
|
605
|
-
(gpointer)proc, attrs);
|
606
|
-
}
|
607
|
-
rb_text = CSTR2RVAL(text);
|
608
|
-
free(text);
|
609
|
-
|
610
|
-
if (attrs) {
|
611
|
-
VALUE rb_attrs;
|
612
|
-
rb_attrs = attrary2rval(attrs);
|
613
|
-
g_array_free(attrs, TRUE);
|
614
|
-
return rb_ary_new3(2, rb_text, rb_attrs);
|
615
|
-
} else {
|
616
|
-
return rb_text;
|
617
|
-
}
|
618
|
-
}
|
619
|
-
|
620
|
-
static VALUE
|
621
|
-
rg_get_text_range(int argc, VALUE *argv, VALUE self)
|
622
|
-
{
|
623
|
-
VALUE start_row, start_col, end_row, end_col, get_attrs, proc, rb_text;
|
624
|
-
GArray *attrs = NULL;
|
625
|
-
char *text;
|
626
|
-
|
627
|
-
rb_scan_args(argc, argv, "41&", &start_row, &start_col,
|
628
|
-
&end_row, &end_col, &get_attrs, &proc);
|
629
|
-
|
630
|
-
if (get_attrs != Qfalse)
|
631
|
-
attrs = g_array_new(FALSE, TRUE, sizeof(VteCharAttributes));
|
632
|
-
|
633
|
-
text = vte_terminal_get_text_range(_SELF(self),
|
634
|
-
NUM2LONG(start_row),
|
635
|
-
NUM2LONG(start_col),
|
636
|
-
NUM2LONG(end_row),
|
637
|
-
NUM2LONG(end_col),
|
638
|
-
term_is_selected_cb,
|
639
|
-
(gpointer)proc,
|
640
|
-
attrs);
|
641
|
-
rb_text = CSTR2RVAL(text);
|
642
|
-
free(text);
|
643
|
-
|
644
|
-
if (attrs) {
|
645
|
-
VALUE rb_attrs;
|
646
|
-
rb_attrs = attrary2rval(attrs);
|
647
|
-
g_array_free(attrs, TRUE);
|
648
|
-
return rb_ary_new3(2, rb_text, rb_attrs);
|
649
|
-
} else {
|
650
|
-
return rb_text;
|
651
|
-
}
|
652
|
-
}
|
653
|
-
|
654
|
-
static VALUE
|
655
|
-
rg_cursor_position(VALUE self)
|
656
|
-
{
|
657
|
-
glong column, row;
|
658
|
-
vte_terminal_get_cursor_position(_SELF(self), &column, &row);
|
659
|
-
return rb_ary_new3(2, LONG2NUM(column), LONG2NUM(row));
|
660
|
-
}
|
661
|
-
|
662
|
-
static VALUE
|
663
|
-
rg_match_clear_all(VALUE self)
|
664
|
-
{
|
665
|
-
vte_terminal_match_clear_all(_SELF(self));
|
666
|
-
return self;
|
667
|
-
}
|
668
|
-
|
669
|
-
static VALUE
|
670
|
-
rg_match_add(VALUE self, VALUE match)
|
671
|
-
{
|
672
|
-
return INT2NUM(vte_terminal_match_add(_SELF(self), RVAL2CSTR(match)));
|
673
|
-
}
|
674
|
-
|
675
|
-
static VALUE
|
676
|
-
rg_match_set_cursor(VALUE self, VALUE tag, VALUE cursor)
|
677
|
-
{
|
678
|
-
if (NIL_P(cursor) || RVAL2GTYPE(cursor) == GDK_TYPE_CURSOR) {
|
679
|
-
vte_terminal_match_set_cursor(_SELF(self), NUM2INT(tag), RVAL2GDKCURSOR(cursor));
|
680
|
-
} else if (RVAL2GTYPE(cursor) == GDK_TYPE_CURSOR_TYPE) {
|
681
|
-
vte_terminal_match_set_cursor_type(_SELF(self), NUM2INT(tag), RVAL2GDKCURSORTYPE(cursor));
|
682
|
-
} else {
|
683
|
-
vte_terminal_match_set_cursor_name(_SELF(self), NUM2INT(tag), RVAL2CSTR(cursor));
|
684
|
-
}
|
685
|
-
|
686
|
-
return self;
|
687
|
-
}
|
688
|
-
|
689
|
-
static VALUE
|
690
|
-
rg_match_remove(VALUE self, VALUE tag)
|
691
|
-
{
|
692
|
-
vte_terminal_match_remove(_SELF(self), NUM2INT(tag));
|
693
|
-
return self;
|
694
|
-
}
|
695
|
-
|
696
|
-
static VALUE
|
697
|
-
rg_match_check(VALUE self, VALUE column, VALUE row)
|
698
|
-
{
|
699
|
-
char *string;
|
700
|
-
int tag;
|
701
|
-
|
702
|
-
string = vte_terminal_match_check(_SELF(self), NUM2LONG(column),
|
703
|
-
NUM2LONG(row), &tag);
|
704
|
-
if (string) {
|
705
|
-
VALUE rb_string;
|
706
|
-
rb_string = CSTR2RVAL(string);
|
707
|
-
free(string);
|
708
|
-
return rb_ary_new3(2, rb_string, INT2NUM(tag));
|
709
|
-
} else {
|
710
|
-
return Qnil;
|
711
|
-
}
|
712
|
-
}
|
713
|
-
|
714
|
-
static VALUE
|
715
|
-
rg_default_emulation(VALUE self)
|
716
|
-
{
|
717
|
-
return CSTR2RVAL(vte_terminal_get_default_emulation(_SELF(self)));
|
718
|
-
}
|
719
|
-
|
720
|
-
static VALUE
|
721
|
-
rg_status_line(VALUE self)
|
722
|
-
{
|
723
|
-
return CSTR2RVAL(vte_terminal_get_status_line(_SELF(self)));
|
724
|
-
}
|
725
|
-
|
726
|
-
static VALUE
|
727
|
-
rg_adjustment(VALUE self)
|
728
|
-
{
|
729
|
-
return GOBJ2RVAL(vte_terminal_get_adjustment(_SELF(self)));
|
730
|
-
}
|
731
|
-
|
732
|
-
static VALUE
|
733
|
-
rg_char_width(VALUE self)
|
734
|
-
{
|
735
|
-
return LONG2NUM(vte_terminal_get_char_width(_SELF(self)));
|
736
|
-
}
|
737
|
-
|
738
|
-
static VALUE
|
739
|
-
rg_char_height(VALUE self)
|
740
|
-
{
|
741
|
-
return LONG2NUM(vte_terminal_get_char_height(_SELF(self)));
|
742
|
-
}
|
743
|
-
|
744
|
-
static VALUE
|
745
|
-
rg_row_count(VALUE self)
|
746
|
-
{
|
747
|
-
return LONG2NUM(vte_terminal_get_row_count(_SELF(self)));
|
748
|
-
}
|
749
|
-
|
750
|
-
static VALUE
|
751
|
-
rg_column_count(VALUE self)
|
752
|
-
{
|
753
|
-
return LONG2NUM(vte_terminal_get_column_count(_SELF(self)));
|
754
|
-
}
|
755
|
-
|
756
|
-
static VALUE
|
757
|
-
rg_window_title(VALUE self)
|
758
|
-
{
|
759
|
-
return CSTR2RVAL(vte_terminal_get_window_title(_SELF(self)));
|
760
|
-
}
|
761
|
-
|
762
|
-
static VALUE
|
763
|
-
rg_icon_title(VALUE self)
|
764
|
-
{
|
765
|
-
return CSTR2RVAL(vte_terminal_get_icon_title(_SELF(self)));
|
766
|
-
}
|
767
|
-
|
768
|
-
static VALUE
|
769
|
-
rg_pty_new(VALUE self, VALUE flags)
|
770
|
-
{
|
771
|
-
VtePty *result;
|
772
|
-
GError *error = NULL;
|
773
|
-
|
774
|
-
result = vte_terminal_pty_new(_SELF(self), RVAL2VTEPTYFLAGS(flags), &error);
|
775
|
-
if (error)
|
776
|
-
RAISE_GERROR(error);
|
777
|
-
|
778
|
-
return GOBJ2RVAL(result);
|
779
|
-
}
|
780
|
-
|
781
|
-
static VALUE
|
782
|
-
rg_search_find_next(VALUE self)
|
783
|
-
{
|
784
|
-
gboolean result;
|
785
|
-
|
786
|
-
result = vte_terminal_search_find_next(_SELF(self));
|
787
|
-
|
788
|
-
return CBOOL2RVAL(result);
|
789
|
-
}
|
790
|
-
|
791
|
-
static VALUE
|
792
|
-
rg_search_find_previous(VALUE self)
|
793
|
-
{
|
794
|
-
gboolean result;
|
795
|
-
|
796
|
-
result = vte_terminal_search_find_previous(_SELF(self));
|
797
|
-
|
798
|
-
return CBOOL2RVAL(result);
|
799
|
-
}
|
800
|
-
|
801
|
-
static VALUE
|
802
|
-
rg_search_get_wrap_around_p(VALUE self)
|
803
|
-
{
|
804
|
-
gboolean result;
|
805
|
-
|
806
|
-
result = vte_terminal_search_get_wrap_around(_SELF(self));
|
807
|
-
|
808
|
-
return CBOOL2RVAL(result);
|
809
|
-
}
|
810
|
-
|
811
|
-
static VALUE
|
812
|
-
rg_search_set_wrap_around(VALUE self, VALUE wrap_around)
|
813
|
-
{
|
814
|
-
vte_terminal_search_set_wrap_around(_SELF(self), RVAL2CBOOL(wrap_around));
|
815
|
-
|
816
|
-
return self;
|
817
|
-
}
|
818
|
-
|
819
|
-
static VALUE
|
820
|
-
rg_select_all(VALUE self)
|
821
|
-
{
|
822
|
-
vte_terminal_select_all(_SELF(self));
|
823
|
-
|
824
|
-
return self;
|
825
|
-
}
|
826
|
-
|
827
|
-
static VALUE
|
828
|
-
rg_select_none(VALUE self)
|
829
|
-
{
|
830
|
-
vte_terminal_select_none(_SELF(self));
|
831
|
-
|
832
|
-
return self;
|
833
|
-
}
|
834
|
-
|
835
|
-
static VALUE
|
836
|
-
rg_set_opacity(VALUE self, VALUE opacity)
|
837
|
-
{
|
838
|
-
vte_terminal_set_opacity(_SELF(self), NUM2UINT(opacity));
|
839
|
-
|
840
|
-
return self;
|
841
|
-
}
|
842
|
-
|
843
|
-
static VALUE
|
844
|
-
rg_watch_child(VALUE self, VALUE child_pid)
|
845
|
-
{
|
846
|
-
vte_terminal_watch_child(_SELF(self), NUM2INT(child_pid));
|
847
|
-
|
848
|
-
return self;
|
849
|
-
}
|
850
|
-
|
851
|
-
static VALUE
|
852
|
-
rg_write_contents(int argc, VALUE *argv, VALUE self)
|
853
|
-
{
|
854
|
-
VALUE stream, flags, rb_cancellable;
|
855
|
-
GCancellable *cancellable;
|
856
|
-
gboolean result;
|
857
|
-
GError *error = NULL;
|
858
|
-
|
859
|
-
rb_scan_args(argc, argv, "21", &stream, &flags, &rb_cancellable);
|
860
|
-
cancellable = NIL_P(rb_cancellable) ? NULL : RVAL2GCANCELLABLE(rb_cancellable);
|
861
|
-
|
862
|
-
result = vte_terminal_write_contents(_SELF(self),
|
863
|
-
RVAL2GOUTPUTSTREAM(stream),
|
864
|
-
RVAL2VTETERMINALWRITEFLAGS(flags),
|
865
|
-
cancellable,
|
866
|
-
&error);
|
867
|
-
if (error)
|
868
|
-
RAISE_GERROR(error);
|
869
|
-
|
870
|
-
return CBOOL2RVAL(result);
|
871
|
-
}
|
872
|
-
|
873
|
-
void
|
874
|
-
Init_vte_terminal(VALUE mVte)
|
875
|
-
{
|
876
|
-
VALUE RG_TARGET_NAMESPACE;
|
877
|
-
|
878
|
-
id_new = rb_intern("new");
|
879
|
-
id_call = rb_intern("call");
|
880
|
-
|
881
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(VTE_TYPE_TERMINAL, "Terminal", mVte);
|
882
|
-
|
883
|
-
G_DEF_CLASS(VTE_TYPE_TERMINAL_ERASE_BINDING, "EraseBinding", RG_TARGET_NAMESPACE);
|
884
|
-
G_DEF_CLASS(VTE_TYPE_TERMINAL_CURSOR_BLINK_MODE, "CursorBlinkMode", RG_TARGET_NAMESPACE);
|
885
|
-
G_DEF_CLASS(VTE_TYPE_TERMINAL_CURSOR_SHAPE, "CursorShape", RG_TARGET_NAMESPACE);
|
886
|
-
G_DEF_CLASS(VTE_TYPE_TERMINAL_WRITE_FLAGS, "WriteFlags", RG_TARGET_NAMESPACE);
|
887
|
-
|
888
|
-
RG_DEF_METHOD(initialize, 0);
|
889
|
-
|
890
|
-
RG_DEF_METHOD(fork_command, -1);
|
891
|
-
|
892
|
-
RG_DEF_METHOD(feed, 1);
|
893
|
-
RG_DEF_METHOD(feed_child, 1);
|
894
|
-
RG_DEF_METHOD(feed_child_binary, 1);
|
895
|
-
|
896
|
-
RG_DEF_METHOD(copy_clipboard, 0);
|
897
|
-
RG_DEF_METHOD(paste_clipboard, 0);
|
898
|
-
RG_DEF_METHOD(copy_primary, 0);
|
899
|
-
RG_DEF_METHOD(paste_primary, 0);
|
900
|
-
|
901
|
-
RG_DEF_METHOD(set_size, 2);
|
902
|
-
|
903
|
-
RG_DEF_METHOD(set_audible_bell, 1);
|
904
|
-
RG_DEF_METHOD_P(audible_bell, 0);
|
905
|
-
RG_DEF_METHOD(set_visible_bell, 1);
|
906
|
-
RG_DEF_METHOD_P(visible_bell, 0);
|
907
|
-
|
908
|
-
RG_DEF_METHOD(set_scroll_background, 1);
|
909
|
-
RG_DEF_METHOD(set_scroll_on_output, 1);
|
910
|
-
RG_DEF_METHOD(set_scroll_on_keystroke, 1);
|
911
|
-
|
912
|
-
#if VTE_CHECK_VERSION(0, 36, 0)
|
913
|
-
RG_DEF_METHOD_P(rewrap_on_resize, 0);
|
914
|
-
RG_REPLACE_SET_PROPERTY(rewrap_on_resize, 1);
|
915
|
-
#endif
|
916
|
-
|
917
|
-
RG_DEF_METHOD(set_color_dim, 1);
|
918
|
-
RG_DEF_METHOD(set_color_bold, 1);
|
919
|
-
RG_DEF_METHOD(set_color_foreground, 1);
|
920
|
-
RG_DEF_METHOD(set_color_background, 1);
|
921
|
-
RG_DEF_METHOD(set_color_cursor, 1);
|
922
|
-
RG_DEF_METHOD(set_color_highlight, 1);
|
923
|
-
RG_DEF_METHOD(set_colors, 3);
|
924
|
-
RG_DEF_METHOD(set_default_colors, 0);
|
925
|
-
RG_DEF_METHOD(set_background_image, 1);
|
926
|
-
RG_DEF_METHOD(set_background_tint_color, 1);
|
927
|
-
RG_DEF_METHOD(set_background_saturation, 1);
|
928
|
-
RG_DEF_METHOD(set_background_transparent, 1);
|
929
|
-
RG_DEF_METHOD(set_cursor_blinks, 1);
|
930
|
-
RG_DEF_METHOD(set_cursor_blink_mode, 1);
|
931
|
-
RG_DEF_METHOD(cursor_blink_mode, 0);
|
932
|
-
RG_DEF_METHOD(set_cursor_shape, 1);
|
933
|
-
RG_DEF_METHOD(cursor_shape, 0);
|
934
|
-
RG_DEF_METHOD(child_exit_status, 0);
|
935
|
-
RG_DEF_METHOD(set_scrollback_lines, 1);
|
936
|
-
|
937
|
-
RG_DEF_METHOD(im_append_menuitems, 1);
|
938
|
-
|
939
|
-
RG_DEF_METHOD(set_font, 1);
|
940
|
-
RG_DEF_METHOD(font, 0);
|
941
|
-
RG_DEF_METHOD(set_allow_bold, 1);
|
942
|
-
RG_DEF_METHOD_P(allow_bold, 0);
|
943
|
-
RG_DEF_METHOD_P(has_selection, 0);
|
944
|
-
RG_DEF_ALIAS("have_selection?", "has_selection?");
|
945
|
-
RG_DEF_METHOD(set_word_chars, 1);
|
946
|
-
RG_DEF_METHOD_P(word_char, 1);
|
947
|
-
RG_DEF_METHOD(set_backspace_binding, 1);
|
948
|
-
RG_DEF_METHOD(set_delete_binding, 1);
|
949
|
-
RG_DEF_METHOD_P(mouse_autohide, 0);
|
950
|
-
RG_DEF_METHOD(set_mouse_autohide, 1);
|
951
|
-
|
952
|
-
RG_DEF_METHOD(reset, 2);
|
953
|
-
|
954
|
-
RG_DEF_METHOD(get_text, -1);
|
955
|
-
RG_DEF_METHOD(get_text_range, -1);
|
956
|
-
|
957
|
-
RG_DEF_METHOD(cursor_position, 0);
|
958
|
-
|
959
|
-
RG_DEF_METHOD(match_clear_all, 0);
|
960
|
-
RG_DEF_METHOD(match_add, 1);
|
961
|
-
RG_DEF_METHOD(match_set_cursor, 2);
|
962
|
-
RG_DEF_METHOD(match_remove, 1);
|
963
|
-
RG_DEF_METHOD(match_check, 2);
|
964
|
-
RG_DEF_METHOD(default_emulation, 0);
|
965
|
-
RG_DEF_METHOD(status_line, 0);
|
966
|
-
RG_DEF_METHOD(adjustment, 0);
|
967
|
-
RG_DEF_METHOD(char_width, 0);
|
968
|
-
RG_DEF_METHOD(char_height, 0);
|
969
|
-
RG_DEF_METHOD(row_count, 0);
|
970
|
-
RG_DEF_METHOD(column_count, 0);
|
971
|
-
RG_DEF_METHOD(window_title, 0);
|
972
|
-
RG_DEF_METHOD(icon_title, 0);
|
973
|
-
RG_DEF_METHOD(pty_new, 1);
|
974
|
-
RG_DEF_METHOD(search_find_next, 0);
|
975
|
-
RG_DEF_METHOD(search_find_previous, 0);
|
976
|
-
RG_DEF_METHOD_P(search_get_wrap_around, 0);
|
977
|
-
RG_DEF_METHOD(search_set_wrap_around, 1);
|
978
|
-
RG_DEF_ALIAS("search_wrap_around=", "search_set_wrap_around");
|
979
|
-
RG_DEF_METHOD(select_all, 0);
|
980
|
-
RG_DEF_METHOD(select_none, 0);
|
981
|
-
RG_DEF_METHOD(set_opacity, 1);
|
982
|
-
RG_DEF_METHOD(watch_child, 1);
|
983
|
-
RG_DEF_METHOD(write_contents, -1);
|
984
|
-
}
|