gtksourceview3 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +29 -0
- data/Rakefile +16 -0
- data/ext/gtksourceview3/depend +6 -0
- data/ext/gtksourceview3/extconf.rb +76 -0
- data/ext/gtksourceview3/gtksourceview3.def +2 -0
- data/ext/gtksourceview3/rbgtksource.c +53 -0
- data/ext/gtksourceview3/rbgtksourcebuffer.c +318 -0
- data/ext/gtksourceview3/rbgtksourcegutter.c +82 -0
- data/ext/gtksourceview3/rbgtksourcegutterrenderer.c +143 -0
- data/ext/gtksourceview3/rbgtksourcegutterrendererpixbuf.c +42 -0
- data/ext/gtksourceview3/rbgtksourcegutterrenderertext.c +64 -0
- data/ext/gtksourceview3/rbgtksourcelanguage.c +124 -0
- data/ext/gtksourceview3/rbgtksourcelanguagemanager.c +114 -0
- data/ext/gtksourceview3/rbgtksourcemark.c +85 -0
- data/ext/gtksourceview3/rbgtksourcemarkattributes.c +77 -0
- data/ext/gtksourceview3/rbgtksourceprintcompositor.c +171 -0
- data/ext/gtksourceview3/rbgtksourcestyle.c +42 -0
- data/ext/gtksourceview3/rbgtksourcestylescheme.c +72 -0
- data/ext/gtksourceview3/rbgtksourcestyleschememanager.c +140 -0
- data/ext/gtksourceview3/rbgtksourceundomanager.c +83 -0
- data/ext/gtksourceview3/rbgtksourceview.c +94 -0
- data/ext/gtksourceview3/rbgtksourceview3conversions.h +43 -0
- data/ext/gtksourceview3/rbgtksourceview3private.h +54 -0
- data/extconf.rb +49 -0
- data/lib/gtksourceview3/deprecated.rb +47 -0
- data/lib/gtksourceview3.rb +20 -0
- data/sample/sourcelanguagemanager.rb +21 -0
- data/sample/test.rb +32 -0
- data/test/run-test.rb +33 -0
- data/test/test_source_view.rb +17 -0
- metadata +111 -0
data/README
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Ruby/GtkSourceView2
|
2
|
+
===================
|
3
|
+
Ruby/GtkSourceView2 is a Ruby binding of gtksourceview-2.x.
|
4
|
+
|
5
|
+
Requirements
|
6
|
+
------------
|
7
|
+
Ruby: http://www.ruby-lang.org/
|
8
|
+
Ruby-GNOME2: http://ruby-gnome2.sourceforge.jp/
|
9
|
+
GtkSourceView: ftp://ftp.gnome.org/pub/GNOME/sources/gtksourceview
|
10
|
+
|
11
|
+
Install
|
12
|
+
-------
|
13
|
+
0. install ruby 1.8.0 or newer, GtkSourceView 2.0.0 or newer, Ruby/GTK2.
|
14
|
+
1. ruby extconf.rb
|
15
|
+
2. make
|
16
|
+
3. su
|
17
|
+
4. make install
|
18
|
+
|
19
|
+
Copying
|
20
|
+
-------
|
21
|
+
Copyright (c) 2008 Ruby-GNOME2 Project Team
|
22
|
+
|
23
|
+
This program is free software.
|
24
|
+
You can distribute/modify this program under the terms of
|
25
|
+
the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
|
26
|
+
|
27
|
+
Project Website
|
28
|
+
---------------
|
29
|
+
http://ruby-gnome2.sourceforge.jp/
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift("./../glib2/lib")
|
4
|
+
require 'gnome2-raketask'
|
5
|
+
|
6
|
+
package = GNOME2Package.new do |_package|
|
7
|
+
_package.summary = "Ruby/GtkSourceView3 is a Ruby binding of gtksourceview-3.x."
|
8
|
+
_package.description = "Ruby/GtkSourceView3 is a Ruby binding of gtksourceview-3.x."
|
9
|
+
_package.dependency.gem.runtime = ["gtk3"]
|
10
|
+
_package.win32.packages = ["gtksourceview"]
|
11
|
+
_package.win32.dependencies = ["libxml2"]
|
12
|
+
_package.required_ruby_version = ">= 1.9.2"
|
13
|
+
_package.post_install_message = "This library is experimental."
|
14
|
+
end
|
15
|
+
package.define_tasks
|
16
|
+
|
@@ -0,0 +1,76 @@
|
|
1
|
+
=begin
|
2
|
+
extconf.rb for Ruby/GtkSourceView3 extension library
|
3
|
+
=end
|
4
|
+
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
base_dir = Pathname(__FILE__).dirname.parent.parent.expand_path
|
8
|
+
top_dir = base_dir.parent
|
9
|
+
top_build_dir = Pathname(".").parent.parent.parent.expand_path
|
10
|
+
|
11
|
+
mkmf_gnome2_dir = top_dir + "glib2" + 'lib'
|
12
|
+
version_suffix = ""
|
13
|
+
unless mkmf_gnome2_dir.exist?
|
14
|
+
if /(-\d+\.\d+\.\d+)\z/ =~ base_dir.basename.to_s
|
15
|
+
version_suffix = $1
|
16
|
+
mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + 'lib'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
$LOAD_PATH.unshift(mkmf_gnome2_dir.to_s)
|
21
|
+
|
22
|
+
module_name = "gtksourceview3"
|
23
|
+
package_id = "gtksourceview-3.0"
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'mkmf-gnome2'
|
27
|
+
rescue LoadError
|
28
|
+
require 'rubygems'
|
29
|
+
gem 'glib2'
|
30
|
+
require 'mkmf-gnome2'
|
31
|
+
end
|
32
|
+
|
33
|
+
["glib2", "atk", "pango", "gdk_pixbuf2", "gdk3", "gtk3"].each do |package|
|
34
|
+
directory = "#{package}#{version_suffix}"
|
35
|
+
build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}"
|
36
|
+
add_depend_package(package, "#{directory}/ext/#{package}",
|
37
|
+
top_dir.to_s,
|
38
|
+
:top_build_dir => top_build_dir.to_s,
|
39
|
+
:target_build_dir => build_dir)
|
40
|
+
end
|
41
|
+
|
42
|
+
rcairo_options = {}
|
43
|
+
rcairo_source_dir_names = ["rcairo"]
|
44
|
+
if /mingw|cygwin|mswin32/ =~ RUBY_PLATFORM
|
45
|
+
rcairo_source_dir_names.unshift("rcairo.win32")
|
46
|
+
end
|
47
|
+
rcairo_source_dir_names.each do |rcairo_source_dir_name|
|
48
|
+
rcairo_source_dir = top_dir.parent.expand_path + rcairo_source_dir_name
|
49
|
+
if rcairo_source_dir.exist?
|
50
|
+
rcairo_options[:rcairo_source_dir] = rcairo_source_dir.to_s
|
51
|
+
break
|
52
|
+
end
|
53
|
+
end
|
54
|
+
check_cairo(rcairo_options)
|
55
|
+
|
56
|
+
setup_win32(module_name, base_dir)
|
57
|
+
|
58
|
+
unless required_pkg_config_package(package_id,
|
59
|
+
:debian => "libgtksourceview3.0-dev",
|
60
|
+
:fedora => "gtksourceview3-devel")
|
61
|
+
exit(false)
|
62
|
+
end
|
63
|
+
|
64
|
+
make_version_header("GTKSOURCEVIEW3", package_id, ".")
|
65
|
+
|
66
|
+
create_pkg_config_file("Ruby/GtkSourceView3", package_id)
|
67
|
+
$defs << "-DRUBY_GTKSOURCEVIEW3_COMPILATION"
|
68
|
+
create_makefile(module_name)
|
69
|
+
pkg_config_dir = with_config("pkg-config-dir")
|
70
|
+
if pkg_config_dir.is_a?(String)
|
71
|
+
File.open("Makefile", "ab") do |makefile|
|
72
|
+
makefile.puts
|
73
|
+
makefile.puts("pkgconfigdir=#{pkg_config_dir}")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2004,2005 Ruby-GNOME2 Project Team
|
5
|
+
* Copyright (C) 2003 Geoff Youngs, based on gtktextview.c by Masao Mutoh
|
6
|
+
*
|
7
|
+
* This library is free software; you can redistribute it and/or
|
8
|
+
* modify it under the terms of the GNU Lesser General Public
|
9
|
+
* License as published by the Free Software Foundation; either
|
10
|
+
* version 2.1 of the License, or (at your option) any later version.
|
11
|
+
*
|
12
|
+
* This library is distributed in the hope that it will be useful,
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
* Lesser General Public License for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public
|
18
|
+
* License along with this library; if not, write to the Free Software
|
19
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
20
|
+
* MA 02110-1301 USA
|
21
|
+
*/
|
22
|
+
|
23
|
+
#include "rbgtksourceview3private.h"
|
24
|
+
|
25
|
+
#define RG_TARGET_NAMESPACE mGtkSource
|
26
|
+
|
27
|
+
void
|
28
|
+
Init_gtksourceview3 (void)
|
29
|
+
{
|
30
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module("GtkSource");
|
31
|
+
|
32
|
+
rb_define_const(RG_TARGET_NAMESPACE, "BUILD_VERSION",
|
33
|
+
rb_ary_new3(3,
|
34
|
+
INT2FIX(GTKSOURCEVIEW3_MAJOR_VERSION),
|
35
|
+
INT2FIX(GTKSOURCEVIEW3_MINOR_VERSION),
|
36
|
+
INT2FIX(GTKSOURCEVIEW3_MICRO_VERSION)));
|
37
|
+
|
38
|
+
Init_gtksource_view (RG_TARGET_NAMESPACE);
|
39
|
+
Init_gtksource_buffer (RG_TARGET_NAMESPACE);
|
40
|
+
Init_gtksource_language (RG_TARGET_NAMESPACE);
|
41
|
+
Init_gtksource_languagemanager (RG_TARGET_NAMESPACE);
|
42
|
+
Init_gtksource_mark (RG_TARGET_NAMESPACE);
|
43
|
+
Init_gtksource_printcompositor (RG_TARGET_NAMESPACE);
|
44
|
+
Init_gtksource_style (RG_TARGET_NAMESPACE);
|
45
|
+
Init_gtksource_stylescheme (RG_TARGET_NAMESPACE);
|
46
|
+
Init_gtksource_styleschememanager (RG_TARGET_NAMESPACE);
|
47
|
+
Init_gtksource_gutter(RG_TARGET_NAMESPACE);
|
48
|
+
Init_gtksource_gutterrenderer(RG_TARGET_NAMESPACE);
|
49
|
+
Init_gtksource_gutterrendererpixbuf(RG_TARGET_NAMESPACE);
|
50
|
+
Init_gtksource_gutterrenderertext(RG_TARGET_NAMESPACE);
|
51
|
+
Init_gtksource_markattributes(RG_TARGET_NAMESPACE);
|
52
|
+
Init_gtksource_undomanager(RG_TARGET_NAMESPACE);
|
53
|
+
}
|
@@ -0,0 +1,318 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2004,2005 Ruby-GNOME2 Project Team
|
5
|
+
* Copyright (C) 2003 Geoff Youngs, based on gtktextview.c by Masao Mutoh
|
6
|
+
*
|
7
|
+
* This library is free software; you can redistribute it and/or
|
8
|
+
* modify it under the terms of the GNU Lesser General Public
|
9
|
+
* License as published by the Free Software Foundation; either
|
10
|
+
* version 2.1 of the License, or (at your option) any later version.
|
11
|
+
*
|
12
|
+
* This library is distributed in the hope that it will be useful,
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
* Lesser General Public License for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public
|
18
|
+
* License along with this library; if not, write to the Free Software
|
19
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
20
|
+
* MA 02110-1301 USA
|
21
|
+
*/
|
22
|
+
|
23
|
+
#include "rbgtksourceview3private.h"
|
24
|
+
|
25
|
+
/* Class: Gtk::SourceBuffer
|
26
|
+
* Text buffer object for Gtk::SourceView.
|
27
|
+
*/
|
28
|
+
|
29
|
+
#define RG_TARGET_NAMESPACE cBuffer
|
30
|
+
#define _SELF(self) (RVAL2GTKSOURCEBUFFER(self))
|
31
|
+
|
32
|
+
#define RVAL2ITER(self, position) rval2iter(self, position)
|
33
|
+
#define RVAL2STARTITER(self, iter, out) \
|
34
|
+
rval2iter_with_default(&(self), &(iter), &(out), gtk_text_buffer_get_start_iter)
|
35
|
+
#define RVAL2ENDITER(self, iter, out) \
|
36
|
+
rval2iter_with_default(&(self), &(iter), &(out), gtk_text_buffer_get_end_iter)
|
37
|
+
|
38
|
+
static GtkTextIter *
|
39
|
+
rval2iter(VALUE self, VALUE position)
|
40
|
+
{
|
41
|
+
if (!g_type_is_a(RVAL2GTYPE(position), GTK_TYPE_TEXT_ITER))
|
42
|
+
position = rb_funcall(self, rb_intern("get_iter_at"), 1, position);
|
43
|
+
return RVAL2GTKTEXTITER(position);
|
44
|
+
}
|
45
|
+
|
46
|
+
static GtkTextIter *
|
47
|
+
rval2iter_with_default(VALUE *self, VALUE *iter, GtkTextIter *out,
|
48
|
+
void (*default_func)(GtkTextBuffer *, GtkTextIter *))
|
49
|
+
{
|
50
|
+
if (NIL_P(*iter)) {
|
51
|
+
default_func(RVAL2GTKTEXTBUFFER(*self), out);
|
52
|
+
return out;
|
53
|
+
} else {
|
54
|
+
return RVAL2ITER(*self, *iter);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
/*
|
59
|
+
* Class method: new(obj=nil)
|
60
|
+
* obj: either a Gtk::TextTagTable, a Gtk::SourceLanguage, or nil.
|
61
|
+
*
|
62
|
+
* Creates a new source buffer. If a Gtk::SourceTagTable is provided, the
|
63
|
+
* buffer will use it, otherwise it will create a new one.
|
64
|
+
*
|
65
|
+
* If a Gtk::SourceLanguage object is given, the buffer will be created
|
66
|
+
* using highlightings patterns in this language. This is equivalent to
|
67
|
+
* creating a new source buffer with the default tag table and then setting
|
68
|
+
* the 'language' property.
|
69
|
+
*
|
70
|
+
* Returns: a newly created Gtk::SourceBuffer object.
|
71
|
+
*/
|
72
|
+
static VALUE
|
73
|
+
rg_initialize(int argc, VALUE *argv, VALUE self)
|
74
|
+
{
|
75
|
+
VALUE val;
|
76
|
+
|
77
|
+
rb_scan_args (argc, argv, "01", &val);
|
78
|
+
if (NIL_P (val)) {
|
79
|
+
G_INITIALIZE (self, gtk_source_buffer_new (NULL));
|
80
|
+
} else
|
81
|
+
if (rb_obj_is_kind_of
|
82
|
+
(val, GTYPE2CLASS (GTK_TYPE_TEXT_TAG_TABLE))) {
|
83
|
+
G_INITIALIZE (self,
|
84
|
+
gtk_source_buffer_new(RVAL2GTKTEXTTAGTABLE(val)));
|
85
|
+
} else
|
86
|
+
if (rb_obj_is_kind_of
|
87
|
+
(val, GTYPE2CLASS (GTK_SOURCE_TYPE_LANGUAGE))) {
|
88
|
+
G_INITIALIZE (self,
|
89
|
+
gtk_source_buffer_new_with_language(RVAL2GTKSOURCELANGUAGE(val)));
|
90
|
+
} else {
|
91
|
+
rb_raise (rb_eArgError,
|
92
|
+
"invalid argument %s (expect nil, Gtk::TextTagTable or Gtk::SourceLanguage)",
|
93
|
+
rb_class2name (CLASS_OF (val)));
|
94
|
+
}
|
95
|
+
return Qnil;
|
96
|
+
}
|
97
|
+
|
98
|
+
/*
|
99
|
+
* Method: redo!
|
100
|
+
*
|
101
|
+
* Redoes the last undo operation. Use Gtk::SourceBuffer#can_redo? to check
|
102
|
+
* whether a call to this function will have any effect.
|
103
|
+
*
|
104
|
+
* Returns: self.
|
105
|
+
*/
|
106
|
+
static VALUE
|
107
|
+
rg_redo_bang(VALUE self)
|
108
|
+
{
|
109
|
+
gtk_source_buffer_redo (_SELF (self));
|
110
|
+
return self;
|
111
|
+
}
|
112
|
+
|
113
|
+
/*
|
114
|
+
* Method: undo!
|
115
|
+
*
|
116
|
+
* Undoes the last user action which modified the buffer.
|
117
|
+
* Use Gtk::SourceBuffer#can_undo? to check whether a call to this function
|
118
|
+
* will have any effect.
|
119
|
+
*
|
120
|
+
* Actions are defined as groups of operations between a call to
|
121
|
+
* Gtk::TextBuffer#begin_user_action and Gtk::TextBuffer#end_user_action,
|
122
|
+
* or sequences of similar edits (inserts or deletes) on the same line.
|
123
|
+
*
|
124
|
+
* Returns: self.
|
125
|
+
*/
|
126
|
+
static VALUE
|
127
|
+
rg_undo_bang(VALUE self)
|
128
|
+
{
|
129
|
+
gtk_source_buffer_undo (_SELF (self));
|
130
|
+
return self;
|
131
|
+
}
|
132
|
+
|
133
|
+
/*
|
134
|
+
* Method: begin_not_undoable_action
|
135
|
+
* Method: begin_not_undoable_action { ... }
|
136
|
+
*
|
137
|
+
* Marks the beginning of a not undoable action on the buffer, disabling the
|
138
|
+
* undo manager.
|
139
|
+
*
|
140
|
+
* If a block is given, the block is called after marking the beginning
|
141
|
+
* of a not undoable action on the buffer.
|
142
|
+
* At the end of the block, marks the end of a not undoable action on the
|
143
|
+
* buffer. When the last not undoable block is finished, the list of undo
|
144
|
+
* actions is cleared and the undo manager is re-enabled.
|
145
|
+
*
|
146
|
+
* Returns: self
|
147
|
+
*/
|
148
|
+
static VALUE
|
149
|
+
rg_begin_not_undoable_action(VALUE self)
|
150
|
+
{
|
151
|
+
gtk_source_buffer_begin_not_undoable_action (_SELF (self));
|
152
|
+
|
153
|
+
if (rb_block_given_p()) {
|
154
|
+
VALUE block = rb_block_proc ();
|
155
|
+
rb_funcall (block, rb_intern ("call"), 0);
|
156
|
+
gtk_source_buffer_end_not_undoable_action (_SELF (self));
|
157
|
+
}
|
158
|
+
return self;
|
159
|
+
}
|
160
|
+
|
161
|
+
/*
|
162
|
+
* Method: end_not_undoable_action
|
163
|
+
*
|
164
|
+
* Marks the end of a not undoable action on the buffer.
|
165
|
+
* When the last not undoable block is finished, the list of undo
|
166
|
+
* actions is cleared and the undo manager is re-enabled.
|
167
|
+
*
|
168
|
+
* Returns: self
|
169
|
+
*/
|
170
|
+
static VALUE
|
171
|
+
rg_end_not_undoable_action(VALUE self)
|
172
|
+
{
|
173
|
+
gtk_source_buffer_end_not_undoable_action (_SELF (self));
|
174
|
+
return self;
|
175
|
+
}
|
176
|
+
|
177
|
+
/*
|
178
|
+
* Method: create_source_mark(name=nil, category, where)
|
179
|
+
* name: the name of the mark.
|
180
|
+
* type: a string defining the mark type.
|
181
|
+
* where: a location to place the mark, as a Gtk::TreeIter object.
|
182
|
+
*
|
183
|
+
* Creates a mark in the buffer of the given type. A mark is semantically
|
184
|
+
* very similar to a Gtk::TextMark, except it has a type which is used by the
|
185
|
+
* Gtk::SourceView object displaying the buffer to show a pixmap on the left
|
186
|
+
* margin, at the line the mark is in. Because of this, a mark is generally
|
187
|
+
* associated to a line and not a character position. Marks are also
|
188
|
+
* accessible through a position or range in the buffer.
|
189
|
+
*
|
190
|
+
* Marks are implemented using Gtk::TextMark, so all characteristics and
|
191
|
+
* restrictions to marks apply to marks too. These includes life cycle issues
|
192
|
+
* and "mark-set" and "mark-deleted" signal emissions.
|
193
|
+
*
|
194
|
+
* Like a Gtk::TextMark, a Gtk::SourceMark can be anonymous if the passed
|
195
|
+
* name is nil.
|
196
|
+
*
|
197
|
+
* Marks always have left gravity and are moved to the beginning of the line
|
198
|
+
* when the user deletes the line they were in. Also, if the user deletes a
|
199
|
+
* region of text which contained lines with marks, those are deleted.
|
200
|
+
*
|
201
|
+
* Typical uses for a mark are bookmarks, breakpoints, current executing
|
202
|
+
* instruction indication in a source file, etc..
|
203
|
+
*
|
204
|
+
* Returns: a new Gtk::SourceMark object, owned by the buffer.
|
205
|
+
*/
|
206
|
+
static VALUE
|
207
|
+
rg_create_source_mark(int argc, VALUE *argv, VALUE self)
|
208
|
+
{
|
209
|
+
VALUE name, category, where;
|
210
|
+
|
211
|
+
if (argc == 2)
|
212
|
+
rb_scan_args (argc, argv, "21", &where, &category, &name);
|
213
|
+
else
|
214
|
+
rb_scan_args (argc, argv, "30", &name, &category, &where);
|
215
|
+
|
216
|
+
return GOBJ2RVAL (gtk_source_buffer_create_source_mark (_SELF (self),
|
217
|
+
RVAL2CSTR (name),
|
218
|
+
RVAL2CSTR_ACCEPT_SYMBOL (category),
|
219
|
+
RVAL2ITER (self, where)));
|
220
|
+
}
|
221
|
+
|
222
|
+
static VALUE
|
223
|
+
rg_get_source_marks_at_line(int argc, VALUE *argv, VALUE self)
|
224
|
+
{
|
225
|
+
VALUE line, category;
|
226
|
+
|
227
|
+
rb_scan_args (argc, argv, "11", &line, &category);
|
228
|
+
|
229
|
+
/* TODO: need free? */
|
230
|
+
return GOBJGSLIST2RVAL_FREE(gtk_source_buffer_get_source_marks_at_line(_SELF(self),
|
231
|
+
NUM2INT(line),
|
232
|
+
RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL(category)),
|
233
|
+
g_slist_free, NULL);
|
234
|
+
}
|
235
|
+
|
236
|
+
static VALUE
|
237
|
+
rg_get_source_marks_at_iter(int argc, VALUE *argv, VALUE self)
|
238
|
+
{
|
239
|
+
VALUE iter, category;
|
240
|
+
|
241
|
+
rb_scan_args (argc, argv, "11", &iter, &category);
|
242
|
+
|
243
|
+
/* TODO: need free? */
|
244
|
+
return GOBJGSLIST2RVAL_FREE(gtk_source_buffer_get_source_marks_at_iter(_SELF(self),
|
245
|
+
RVAL2ITER(self, iter),
|
246
|
+
RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL(category)),
|
247
|
+
g_slist_free, NULL);
|
248
|
+
}
|
249
|
+
|
250
|
+
static VALUE
|
251
|
+
rg_remove_source_marks(int argc, VALUE *argv, VALUE self)
|
252
|
+
{
|
253
|
+
VALUE start, end, category;
|
254
|
+
GtkTextIter start_iter, end_iter;
|
255
|
+
|
256
|
+
rb_scan_args (argc, argv, "03", &start, &end, &category);
|
257
|
+
|
258
|
+
gtk_source_buffer_remove_source_marks (_SELF (self),
|
259
|
+
RVAL2STARTITER(self, start, start_iter),
|
260
|
+
RVAL2ENDITER(self, end, end_iter),
|
261
|
+
RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL (category));
|
262
|
+
|
263
|
+
return self;
|
264
|
+
}
|
265
|
+
|
266
|
+
static VALUE
|
267
|
+
rg_forward_iter_to_source_mark(int argc, VALUE *argv, VALUE self)
|
268
|
+
{
|
269
|
+
VALUE iter, category;
|
270
|
+
|
271
|
+
rb_scan_args (argc, argv, "11", &iter, &category);
|
272
|
+
|
273
|
+
return
|
274
|
+
CBOOL2RVAL (gtk_source_buffer_forward_iter_to_source_mark
|
275
|
+
(_SELF (self), RVAL2ITER (self, iter),
|
276
|
+
RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL (category)));
|
277
|
+
}
|
278
|
+
|
279
|
+
static VALUE
|
280
|
+
rg_backward_iter_to_source_mark(int argc, VALUE *argv, VALUE self)
|
281
|
+
{
|
282
|
+
VALUE iter, category;
|
283
|
+
|
284
|
+
rb_scan_args (argc, argv, "11", &iter, &category);
|
285
|
+
|
286
|
+
return
|
287
|
+
CBOOL2RVAL (gtk_source_buffer_backward_iter_to_source_mark
|
288
|
+
(_SELF (self), RVAL2ITER (self, iter),
|
289
|
+
RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL (category)));
|
290
|
+
}
|
291
|
+
|
292
|
+
static VALUE
|
293
|
+
rg_ensure_highlight(VALUE self, VALUE start, VALUE end)
|
294
|
+
{
|
295
|
+
gtk_source_buffer_ensure_highlight (_SELF (self), RVAL2ITER (self, start), RVAL2ITER (self, end));
|
296
|
+
|
297
|
+
return self;
|
298
|
+
}
|
299
|
+
|
300
|
+
void
|
301
|
+
Init_gtksource_buffer (VALUE mGtkSource)
|
302
|
+
{
|
303
|
+
VALUE RG_TARGET_NAMESPACE =
|
304
|
+
G_DEF_CLASS (GTK_SOURCE_TYPE_BUFFER, "Buffer", mGtkSource);
|
305
|
+
|
306
|
+
RG_DEF_METHOD(initialize, -1);
|
307
|
+
RG_DEF_METHOD_BANG(redo, 0);
|
308
|
+
RG_DEF_METHOD_BANG(undo, 0);
|
309
|
+
RG_DEF_METHOD(begin_not_undoable_action, 0);
|
310
|
+
RG_DEF_METHOD(end_not_undoable_action, 0);
|
311
|
+
RG_DEF_METHOD(create_source_mark, -1);
|
312
|
+
RG_DEF_METHOD(get_source_marks_at_line, -1);
|
313
|
+
RG_DEF_METHOD(get_source_marks_at_iter, -1);
|
314
|
+
RG_DEF_METHOD(remove_source_marks, -1);
|
315
|
+
RG_DEF_METHOD(forward_iter_to_source_mark, -1);
|
316
|
+
RG_DEF_METHOD(backward_iter_to_source_mark, -1);
|
317
|
+
RG_DEF_METHOD(ensure_highlight, 2);
|
318
|
+
}
|
@@ -0,0 +1,82 @@
|
|
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 "rbgtksourceview3private.h"
|
22
|
+
|
23
|
+
#define RG_TARGET_NAMESPACE cGutter
|
24
|
+
#define _SELF(self) (RVAL2GTKSOURCEGUTTER(self))
|
25
|
+
|
26
|
+
static VALUE
|
27
|
+
rg_window(VALUE self)
|
28
|
+
{
|
29
|
+
return GOBJ2RVAL(gtk_source_gutter_get_window(_SELF(self)));
|
30
|
+
}
|
31
|
+
|
32
|
+
static VALUE
|
33
|
+
rg_insert(VALUE self, VALUE renderer, VALUE position)
|
34
|
+
{
|
35
|
+
gboolean result;
|
36
|
+
|
37
|
+
result = gtk_source_gutter_insert(_SELF(self),
|
38
|
+
RVAL2GTKSOURCEGUTTERRENDERER(renderer),
|
39
|
+
NUM2INT(position));
|
40
|
+
G_CHILD_ADD(self, renderer);
|
41
|
+
|
42
|
+
return CBOOL2RVAL(result);
|
43
|
+
}
|
44
|
+
|
45
|
+
static VALUE
|
46
|
+
rg_queue_draw(VALUE self)
|
47
|
+
{
|
48
|
+
gtk_source_gutter_queue_draw(_SELF(self));
|
49
|
+
|
50
|
+
return self;
|
51
|
+
}
|
52
|
+
|
53
|
+
static VALUE
|
54
|
+
rg_remove(VALUE self, VALUE renderer)
|
55
|
+
{
|
56
|
+
gtk_source_gutter_remove(_SELF(self), RVAL2GTKSOURCEGUTTERRENDERER(renderer));
|
57
|
+
G_CHILD_REMOVE(self, renderer);
|
58
|
+
|
59
|
+
return self;
|
60
|
+
}
|
61
|
+
|
62
|
+
static VALUE
|
63
|
+
rg_reorder(VALUE self, VALUE renderer, VALUE position)
|
64
|
+
{
|
65
|
+
gtk_source_gutter_reorder(_SELF(self),
|
66
|
+
RVAL2GTKSOURCEGUTTERRENDERER(renderer),
|
67
|
+
NUM2INT(position));
|
68
|
+
|
69
|
+
return self;
|
70
|
+
}
|
71
|
+
|
72
|
+
void
|
73
|
+
Init_gtksource_gutter(VALUE mGtkSource)
|
74
|
+
{
|
75
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_SOURCE_TYPE_GUTTER, "Gutter", mGtkSource);
|
76
|
+
|
77
|
+
RG_DEF_METHOD(window, 0);
|
78
|
+
RG_DEF_METHOD(insert, 2);
|
79
|
+
RG_DEF_METHOD(queue_draw, 0);
|
80
|
+
RG_DEF_METHOD(remove, 1);
|
81
|
+
RG_DEF_METHOD(reorder, 2);
|
82
|
+
}
|