1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/*
* Copyright (C) 2011 Ruby-GNOME2 Project Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
#include "rbvte3private.h"
#define RG_TARGET_NAMESPACE cPty
#define _SELF(s) (RVAL2VTEPTY(s))
static VALUE
rg_initialize(VALUE self, VALUE flags_or_fd)
{
VtePty *pty = NULL;
GError *error = NULL;
if (TYPE(flags_or_fd) == T_FIXNUM) {
pty = vte_pty_new_foreign(NUM2INT(flags_or_fd), &error);
} else {
pty = vte_pty_new(RVAL2VTEPTYFLAGS(flags_or_fd), &error);
}
if (error)
RAISE_GERROR(error);
G_INITIALIZE(self, pty);
return Qnil;
}
static VALUE
rg_child_setup(VALUE self)
{
vte_pty_child_setup(_SELF(self));
return self;
}
static VALUE
rg_close(VALUE self)
{
vte_pty_close(_SELF(self));
return self;
}
static VALUE
rg_size(VALUE self)
{
int rows, columns;
gboolean result;
GError *error = NULL;
result = vte_pty_get_size(_SELF(self), &rows, &columns, &error);
if (error)
RAISE_GERROR(error);
return rb_ary_new3(2, INT2NUM(rows), INT2NUM(columns));
}
static VALUE
rg_set_size(VALUE self, VALUE rows, VALUE columns)
{
gboolean result;
GError *error = NULL;
result = vte_pty_set_size(_SELF(self), NUM2INT(rows), NUM2INT(columns), &error);
if (error)
RAISE_GERROR(error);
return self;
}
static VALUE
rg_set_utf8(VALUE self, VALUE utf8)
{
gboolean result;
GError *error = NULL;
result = vte_pty_set_utf8(_SELF(self), RVAL2CBOOL(utf8), &error);
if (error)
RAISE_GERROR(error);
return self;
}
void
Init_vte_pty(VALUE mVte)
{
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(VTE_TYPE_PTY, "Pty", mVte);
G_DEF_CLASS(VTE_TYPE_PTY_ERROR, "Error", RG_TARGET_NAMESPACE);
G_DEF_CLASS(VTE_TYPE_PTY_FLAGS, "Flags", RG_TARGET_NAMESPACE);
RG_DEF_METHOD(initialize, 1);
RG_DEF_METHOD(child_setup, 0);
RG_DEF_METHOD(close, 0);
RG_DEF_METHOD(size, 0);
RG_DEF_METHOD(set_size, 2);
RG_DEF_METHOD(set_utf8, 1);
}
|