annotate src/if_ruby.c @ 2083:24eb7921b8f0 v7.2.367

updated for version 7.2.367 Problem: "xxd -r -p" doesn't work as documented. Solution: Skip white space. (James Vega)
author Bram Moolenaar <bram@zimbu.org>
date Wed, 17 Feb 2010 18:28:41 +0100
parents d8983769c9dd
children 4bac7ed34007
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
4 *
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
5 * Ruby interface by Shugo Maeda
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
6 * with improvements by SegPhault (Ryan Paul)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 #include <stdio.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include <string.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #ifdef _WIN32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 # if !defined(DYNAMIC_RUBY_VER) || (DYNAMIC_RUBY_VER < 18)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 # define NT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 # ifndef DYNAMIC_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 # define IMPORT /* For static dll usage __declspec(dllimport) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 # define RUBYEXTERN __declspec(dllimport)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 #ifndef RUBYEXTERN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 # define RUBYEXTERN extern
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 * This is tricky. In ruby.h there is (inline) function rb_class_of()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 * definition. This function use these variables. But we want function to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 * use dll_* variables.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 #ifdef DYNAMIC_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 # define rb_cFalseClass (*dll_rb_cFalseClass)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 # define rb_cFixnum (*dll_rb_cFixnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 # define rb_cNilClass (*dll_rb_cNilClass)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 # define rb_cSymbol (*dll_rb_cSymbol)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 # define rb_cTrueClass (*dll_rb_cTrueClass)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 * On ver 1.8, all Ruby functions are exported with "__declspce(dllimport)"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 * in ruby.h. But it cause trouble for these variables, because it is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 * defined in this file. When defined this RUBY_EXPORT it modified to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 * "extern" and be able to avoid this problem.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 # define RUBY_EXPORT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
2076
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
51 /* suggested by Ariya Mizutani */
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
52 #if (_MSC_VER == 1200)
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
53 # undef _WIN32_WINNT
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
54 #endif
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
55
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 #include <ruby.h>
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
57 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
58 # include <ruby/encoding.h>
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
59 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 #undef EXTERN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 #undef _
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 /* T_DATA defined both by Ruby and Mac header files, hack around it... */
1233
57dc6ad793e6 updated for version 7.1
vimboss
parents: 1188
diff changeset
65 #if defined(MACOS_X_UNIX) || defined(macintosh)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 # define __OPENTRANSPORT__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 # define __OPENTRANSPORTPROTOCOL__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 # define __OPENTRANSPORTPROVIDERS__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
71 /*
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
72 * Backward compatiblity for Ruby 1.8 and earlier.
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
73 * Ruby 1.9 does not provide STR2CSTR, instead StringValuePtr is provided.
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
74 * Ruby 1.9 does not provide RXXX(s)->len and RXXX(s)->ptr, instead
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
75 * RXXX_LEN(s) and RXXX_PTR(s) are provided.
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
76 */
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
77 #ifndef StringValuePtr
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
78 # define StringValuePtr(s) STR2CSTR(s)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
79 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
80 #ifndef RARRAY_LEN
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
81 # define RARRAY_LEN(s) RARRAY(s)->len
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
82 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
83 #ifndef RARRAY_PTR
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
84 # define RARRAY_PTR(s) RARRAY(s)->ptr
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
85 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
86 #ifndef RSTRING_LEN
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
87 # define RSTRING_LEN(s) RSTRING(s)->len
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
88 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
89 #ifndef RSTRING_PTR
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
90 # define RSTRING_PTR(s) RSTRING(s)->ptr
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
91 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
92
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 #include "version.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 #if defined(PROTO) && !defined(FEAT_RUBY)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 /* Define these to be able to generate the function prototypes. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 # define VALUE int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 # define RUBY_DATA_FUNC int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 static int ruby_initialized = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 static VALUE objtbl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 static VALUE mVIM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 static VALUE cBuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 static VALUE cVimWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 static VALUE eDeletedBufferError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 static VALUE eDeletedWindowError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 static int ensure_ruby_initialized(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 static void error_print(int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 static void ruby_io_init(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 static void ruby_vim_init(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 #if defined(DYNAMIC_RUBY) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 #ifdef PROTO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 # define HINSTANCE int /* for generating prototypes */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 * Wrapper defines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 #define rb_assoc_new dll_rb_assoc_new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 #define rb_cObject (*dll_rb_cObject)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 #define rb_check_type dll_rb_check_type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 #define rb_class_path dll_rb_class_path
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 #define rb_data_object_alloc dll_rb_data_object_alloc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 #define rb_define_class_under dll_rb_define_class_under
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 #define rb_define_const dll_rb_define_const
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 #define rb_define_global_function dll_rb_define_global_function
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 #define rb_define_method dll_rb_define_method
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 #define rb_define_module dll_rb_define_module
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 #define rb_define_module_function dll_rb_define_module_function
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 #define rb_define_singleton_method dll_rb_define_singleton_method
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 #define rb_define_virtual_variable dll_rb_define_virtual_variable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 #define rb_stdout (*dll_rb_stdout)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 #define rb_eArgError (*dll_rb_eArgError)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 #define rb_eIndexError (*dll_rb_eIndexError)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 #define rb_eRuntimeError (*dll_rb_eRuntimeError)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 #define rb_eStandardError (*dll_rb_eStandardError)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 #define rb_eval_string_protect dll_rb_eval_string_protect
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 #define rb_global_variable dll_rb_global_variable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 #define rb_hash_aset dll_rb_hash_aset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 #define rb_hash_new dll_rb_hash_new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 #define rb_inspect dll_rb_inspect
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 #define rb_int2inum dll_rb_int2inum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 #define rb_lastline_get dll_rb_lastline_get
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 #define rb_lastline_set dll_rb_lastline_set
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 #define rb_load_protect dll_rb_load_protect
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 #define rb_num2long dll_rb_num2long
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 #define rb_num2ulong dll_rb_num2ulong
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 #define rb_obj_alloc dll_rb_obj_alloc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 #define rb_obj_as_string dll_rb_obj_as_string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 #define rb_obj_id dll_rb_obj_id
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 #define rb_raise dll_rb_raise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 #define rb_str2cstr dll_rb_str2cstr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 #define rb_str_cat dll_rb_str_cat
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 #define rb_str_concat dll_rb_str_concat
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 #define rb_str_new dll_rb_str_new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 #define rb_str_new2 dll_rb_str_new2
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
162 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
163 # define rb_errinfo dll_rb_errinfo
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
164 #else
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
165 # define ruby_errinfo (*dll_ruby_errinfo)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
166 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 #define ruby_init dll_ruby_init
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 #define ruby_init_loadpath dll_ruby_init_loadpath
2076
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
169 #define NtInitialize dll_NtInitialize
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 # define rb_w32_snprintf dll_rb_w32_snprintf
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
174 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
175 # define ruby_script dll_ruby_script
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
176 # define rb_enc_find_index dll_rb_enc_find_index
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
177 # define rb_enc_find dll_rb_enc_find
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
178 # define rb_enc_str_new dll_rb_enc_str_new
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
179 # define rb_sprintf dll_rb_sprintf
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
180 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
181
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 * Pointers for dynamic link
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 static VALUE (*dll_rb_assoc_new) (VALUE, VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 static VALUE *dll_rb_cFalseClass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 static VALUE *dll_rb_cFixnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 static VALUE *dll_rb_cNilClass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 static VALUE *dll_rb_cObject;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 static VALUE *dll_rb_cSymbol;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 static VALUE *dll_rb_cTrueClass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 static void (*dll_rb_check_type) (VALUE,int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 static VALUE (*dll_rb_class_path) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 static VALUE (*dll_rb_data_object_alloc) (VALUE, void*, RUBY_DATA_FUNC, RUBY_DATA_FUNC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 static VALUE (*dll_rb_define_class_under) (VALUE, const char*, VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 static void (*dll_rb_define_const) (VALUE,const char*,VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 static void (*dll_rb_define_global_function) (const char*,VALUE(*)(),int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 static void (*dll_rb_define_method) (VALUE,const char*,VALUE(*)(),int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 static VALUE (*dll_rb_define_module) (const char*);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 static void (*dll_rb_define_module_function) (VALUE,const char*,VALUE(*)(),int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 static void (*dll_rb_define_singleton_method) (VALUE,const char*,VALUE(*)(),int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 static void (*dll_rb_define_virtual_variable) (const char*,VALUE(*)(),void(*)());
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 static VALUE *dll_rb_stdout;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 static VALUE *dll_rb_eArgError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 static VALUE *dll_rb_eIndexError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 static VALUE *dll_rb_eRuntimeError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 static VALUE *dll_rb_eStandardError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 static VALUE (*dll_rb_eval_string_protect) (const char*, int*);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 static void (*dll_rb_global_variable) (VALUE*);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 static VALUE (*dll_rb_hash_aset) (VALUE, VALUE, VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 static VALUE (*dll_rb_hash_new) (void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 static VALUE (*dll_rb_inspect) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 static VALUE (*dll_rb_int2inum) (long);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 static VALUE (*dll_rb_int2inum) (long);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 static VALUE (*dll_rb_lastline_get) (void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 static void (*dll_rb_lastline_set) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 static void (*dll_rb_load_protect) (VALUE, int, int*);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 static long (*dll_rb_num2long) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 static unsigned long (*dll_rb_num2ulong) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 static VALUE (*dll_rb_obj_alloc) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 static VALUE (*dll_rb_obj_as_string) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 static VALUE (*dll_rb_obj_id) (VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 static void (*dll_rb_raise) (VALUE, const char*, ...);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 static char *(*dll_rb_str2cstr) (VALUE,int*);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 static VALUE (*dll_rb_str_cat) (VALUE, const char*, long);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 static VALUE (*dll_rb_str_concat) (VALUE, VALUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 static VALUE (*dll_rb_str_new) (const char*, long);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 static VALUE (*dll_rb_str_new2) (const char*);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
229 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
230 static VALUE (*dll_rb_errinfo) (void);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
231 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 static VALUE *dll_ruby_errinfo;
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
233 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 static void (*dll_ruby_init) (void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 static void (*dll_ruby_init_loadpath) (void);
2076
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
236 static void (*dll_NtInitialize) (int*, char***);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
241 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
242 static void (*dll_ruby_script) (const char*);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
243 static int (*dll_rb_enc_find_index) (const char*);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
244 static rb_encoding* (*dll_rb_enc_find) (const char*);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
245 static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
246 static VALUE (*dll_rb_sprintf) (const char*, ...);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
247 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
248
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 static HINSTANCE hinstRuby = 0; /* Instance of ruby.dll */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 /*
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
252 * Table of name to function pointer of ruby.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 #define RUBY_PROC FARPROC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 static struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 char *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 RUBY_PROC *ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 } ruby_funcname_table[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 {"rb_assoc_new", (RUBY_PROC*)&dll_rb_assoc_new},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 {"rb_cFalseClass", (RUBY_PROC*)&dll_rb_cFalseClass},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 {"rb_cFixnum", (RUBY_PROC*)&dll_rb_cFixnum},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 {"rb_cNilClass", (RUBY_PROC*)&dll_rb_cNilClass},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 {"rb_cObject", (RUBY_PROC*)&dll_rb_cObject},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 {"rb_cSymbol", (RUBY_PROC*)&dll_rb_cSymbol},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 {"rb_cTrueClass", (RUBY_PROC*)&dll_rb_cTrueClass},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 {"rb_check_type", (RUBY_PROC*)&dll_rb_check_type},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 {"rb_class_path", (RUBY_PROC*)&dll_rb_class_path},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 {"rb_data_object_alloc", (RUBY_PROC*)&dll_rb_data_object_alloc},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 {"rb_define_class_under", (RUBY_PROC*)&dll_rb_define_class_under},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 {"rb_define_const", (RUBY_PROC*)&dll_rb_define_const},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 {"rb_define_global_function", (RUBY_PROC*)&dll_rb_define_global_function},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 {"rb_define_method", (RUBY_PROC*)&dll_rb_define_method},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 {"rb_define_module", (RUBY_PROC*)&dll_rb_define_module},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 {"rb_define_module_function", (RUBY_PROC*)&dll_rb_define_module_function},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 {"rb_define_singleton_method", (RUBY_PROC*)&dll_rb_define_singleton_method},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 {"rb_define_virtual_variable", (RUBY_PROC*)&dll_rb_define_virtual_variable},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 {"rb_stdout", (RUBY_PROC*)&dll_rb_stdout},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 {"rb_eArgError", (RUBY_PROC*)&dll_rb_eArgError},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 {"rb_eIndexError", (RUBY_PROC*)&dll_rb_eIndexError},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 {"rb_eRuntimeError", (RUBY_PROC*)&dll_rb_eRuntimeError},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 {"rb_eStandardError", (RUBY_PROC*)&dll_rb_eStandardError},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 {"rb_eval_string_protect", (RUBY_PROC*)&dll_rb_eval_string_protect},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 {"rb_global_variable", (RUBY_PROC*)&dll_rb_global_variable},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 {"rb_hash_aset", (RUBY_PROC*)&dll_rb_hash_aset},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 {"rb_hash_new", (RUBY_PROC*)&dll_rb_hash_new},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 {"rb_inspect", (RUBY_PROC*)&dll_rb_inspect},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 {"rb_int2inum", (RUBY_PROC*)&dll_rb_int2inum},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 {"rb_lastline_get", (RUBY_PROC*)&dll_rb_lastline_get},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 {"rb_lastline_set", (RUBY_PROC*)&dll_rb_lastline_set},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 {"rb_load_protect", (RUBY_PROC*)&dll_rb_load_protect},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 {"rb_num2long", (RUBY_PROC*)&dll_rb_num2long},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 {"rb_num2ulong", (RUBY_PROC*)&dll_rb_num2ulong},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 {"rb_obj_alloc", (RUBY_PROC*)&dll_rb_obj_alloc},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 {"rb_obj_as_string", (RUBY_PROC*)&dll_rb_obj_as_string},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 {"rb_obj_id", (RUBY_PROC*)&dll_rb_obj_id},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 {"rb_raise", (RUBY_PROC*)&dll_rb_raise},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 {"rb_str2cstr", (RUBY_PROC*)&dll_rb_str2cstr},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 {"rb_str_cat", (RUBY_PROC*)&dll_rb_str_cat},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2},
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
304 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
305 {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo},
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
306 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo},
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
308 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 {"ruby_init", (RUBY_PROC*)&dll_ruby_init},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 {"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath},
2076
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
311 {"NtInitialize", (RUBY_PROC*)&dll_NtInitialize},
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 #endif
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
315 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
316 {"ruby_script", (RUBY_PROC*)&dll_ruby_script},
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
317 {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index},
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
318 {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find},
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
319 {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new},
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
320 {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
321 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 {"", NULL},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 * Free ruby.dll
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 end_dynamic_ruby()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 if (hinstRuby)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 FreeLibrary(hinstRuby);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 hinstRuby = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 * Load library and get all pointers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 * Parameter 'libname' provides name of DLL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 * Return OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 ruby_runtime_link_init(char *libname, int verbose)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 if (hinstRuby)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 hinstRuby = LoadLibrary(libname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 if (!hinstRuby)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 if (verbose)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 EMSG2(_(e_loadlib), libname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 for (i = 0; ruby_funcname_table[i].ptr; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 if (!(*ruby_funcname_table[i].ptr = GetProcAddress(hinstRuby,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 ruby_funcname_table[i].name)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 FreeLibrary(hinstRuby);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 hinstRuby = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 if (verbose)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 EMSG2(_(e_loadfunc), ruby_funcname_table[i].name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 * If ruby is enabled (there is installed ruby on Windows system) return TRUE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 * else FALSE.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 ruby_enabled(verbose)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 int verbose;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 return ruby_runtime_link_init(DYNAMIC_RUBY_DLL, verbose) == OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 #endif /* defined(DYNAMIC_RUBY) || defined(PROTO) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 ruby_end()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 #ifdef DYNAMIC_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 end_dynamic_ruby();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 void ex_ruby(exarg_T *eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 int state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 char *script = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397
750
e2f45cbe2b8a updated for version 7.0223
vimboss
parents: 714
diff changeset
398 script = (char *)script_get(eap, eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 if (!eap->skip && ensure_ruby_initialized())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 if (script == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 rb_eval_string_protect((char *)eap->arg, &state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 rb_eval_string_protect(script, &state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 if (state)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 error_print(state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 vim_free(script);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
411 /*
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
412 * In Ruby 1.9 or later, ruby String object has encoding.
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
413 * conversion buffer string of vim to ruby String object using
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
414 * VIM encoding option.
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
415 */
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
416 static VALUE
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
417 vim_str2rb_enc_str(const char *s)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
418 {
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
419 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
420 int isnum;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
421 long lval;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
422 char_u *sval;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
423 rb_encoding *enc;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
424
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
425 isnum = get_option_value((char_u *)"enc", &lval, &sval, 0);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
426 if (isnum == 0)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
427 {
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
428 enc = rb_enc_find((char *)sval);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
429 vim_free(sval);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
430 if (enc) {
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
431 return rb_enc_str_new(s, strlen(s), enc);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
432 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
433 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
434 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
435 return rb_str_new2(s);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
436 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
437
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
438 static VALUE
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
439 eval_enc_string_protect(const char *str, int *state)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
440 {
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
441 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
442 int isnum;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
443 long lval;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
444 char_u *sval;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
445 rb_encoding *enc;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
446 VALUE v;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
447
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
448 isnum = get_option_value((char_u *)"enc", &lval, &sval, 0);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
449 if (isnum == 0)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
450 {
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
451 enc = rb_enc_find((char *)sval);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
452 vim_free(sval);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
453 if (enc)
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
454 {
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
455 v = rb_sprintf("#-*- coding:%s -*-\n%s", rb_enc_name(enc), str);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
456 return rb_eval_string_protect(StringValuePtr(v), state);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
457 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
458 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
459 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
460 return rb_eval_string_protect(str, state);
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
461 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
462
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 void ex_rubydo(exarg_T *eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 int state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 linenr_T i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 if (ensure_ruby_initialized())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 if (u_save(eap->line1 - 1, eap->line2 + 1) != OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 for (i = eap->line1; i <= eap->line2; i++) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 VALUE line, oldline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
475 line = oldline = vim_str2rb_enc_str((char *)ml_get(i));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 rb_lastline_set(line);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
477 eval_enc_string_protect((char *) eap->arg, &state);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 if (state) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 error_print(state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 line = rb_lastline_get();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 if (!NIL_P(line)) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 if (TYPE(line) != T_STRING) {
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
485 EMSG(_("E265: $_ must be an instance of String"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 }
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
488 ml_replace(i, (char_u *) StringValuePtr(line), 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 changed();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 #ifdef SYNTAX_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 syn_changed(i); /* recompute syntax hl. for this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 check_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 update_curbuf(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 void ex_rubyfile(exarg_T *eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 int state;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 if (ensure_ruby_initialized())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 rb_load_protect(rb_str_new2((char *) eap->arg), 0, &state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 if (state) error_print(state);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 void ruby_buffer_free(buf_T *buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
513 if (buf->b_ruby_ref)
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
514 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
515 rb_hash_aset(objtbl, rb_obj_id((VALUE) buf->b_ruby_ref), Qnil);
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
516 RDATA(buf->b_ruby_ref)->data = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 void ruby_window_free(win_T *win)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
522 if (win->w_ruby_ref)
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
523 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
524 rb_hash_aset(objtbl, rb_obj_id((VALUE) win->w_ruby_ref), Qnil);
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
525 RDATA(win->w_ruby_ref)->data = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 static int ensure_ruby_initialized(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 if (!ruby_initialized)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 #ifdef DYNAMIC_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 if (ruby_enabled(TRUE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 #endif
2076
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
537 #ifdef _WIN32
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
538 /* suggested by Ariya Mizutani */
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
539 int argc = 1;
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
540 char *argv[] = {"gvim.exe"};
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
541 NtInitialize(&argc, &argv);
1c7a66d820e4 updated for version 7.2.360
Bram Moolenaar <bram@zimbu.org>
parents: 1888
diff changeset
542 #endif
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
543 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
544 RUBY_INIT_STACK;
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
545 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 ruby_init();
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
547 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
548 ruby_script("vim-ruby");
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
549 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 ruby_init_loadpath();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 ruby_io_init();
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
552 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
553 rb_enc_find_index("encdb");
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
554 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 ruby_vim_init();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 ruby_initialized = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 #ifdef DYNAMIC_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 EMSG(_("E266: Sorry, this command is disabled, the Ruby library could not be loaded."));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 return ruby_initialized;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 static void error_print(int state)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 #ifndef DYNAMIC_RUBY
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
572 #if !(defined(RUBY_VERSION) && RUBY_VERSION >= 19)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 RUBYEXTERN VALUE ruby_errinfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 #endif
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
575 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 VALUE eclass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 VALUE einfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 char buff[BUFSIZ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 #define TAG_RETURN 0x1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 #define TAG_BREAK 0x2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 #define TAG_NEXT 0x3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 #define TAG_RETRY 0x4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 #define TAG_REDO 0x5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 #define TAG_RAISE 0x6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 #define TAG_THROW 0x7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 #define TAG_FATAL 0x8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 #define TAG_MASK 0xf
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 switch (state) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 case TAG_RETURN:
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
592 EMSG(_("E267: unexpected return"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 case TAG_NEXT:
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
595 EMSG(_("E268: unexpected next"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 case TAG_BREAK:
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
598 EMSG(_("E269: unexpected break"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 case TAG_REDO:
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
601 EMSG(_("E270: unexpected redo"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 case TAG_RETRY:
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
604 EMSG(_("E271: retry outside of rescue clause"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 case TAG_RAISE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 case TAG_FATAL:
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
608 #if defined(RUBY_VERSION) && RUBY_VERSION >= 19
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
609 eclass = CLASS_OF(rb_errinfo());
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
610 einfo = rb_obj_as_string(rb_errinfo());
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
611 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 eclass = CLASS_OF(ruby_errinfo);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 einfo = rb_obj_as_string(ruby_errinfo);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
614 #endif
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
615 if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 779
diff changeset
616 EMSG(_("E272: unhandled exception"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 VALUE epath;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 epath = rb_class_path(eclass);
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
623 vim_snprintf(buff, BUFSIZ, "%s: %s",
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
624 RSTRING_PTR(epath), RSTRING_PTR(einfo));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 p = strchr(buff, '\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 if (p) *p = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 EMSG(buff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 default:
272
ddada568db54 updated for version 7.0073
vimboss
parents: 7
diff changeset
631 vim_snprintf(buff, BUFSIZ, _("E273: unknown longjmp status %d"), state);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 EMSG(buff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
637 static VALUE vim_message(VALUE self UNUSED, VALUE str)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 char *buff, *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 str = rb_obj_as_string(str);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
642 buff = ALLOCA_N(char, RSTRING_LEN(str));
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
643 strcpy(buff, RSTRING_PTR(str));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 p = strchr(buff, '\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 if (p) *p = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 MSG(buff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
650 static VALUE vim_set_option(VALUE self UNUSED, VALUE str)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
652 do_set((char_u *)StringValuePtr(str), 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 update_screen(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
657 static VALUE vim_command(VALUE self UNUSED, VALUE str)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
659 do_cmdline_cmd((char_u *)StringValuePtr(str));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
663 static VALUE vim_evaluate(VALUE self UNUSED, VALUE str)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 #ifdef FEAT_EVAL
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
666 char_u *value = eval_to_string((char_u *)StringValuePtr(str), NULL, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667
750
e2f45cbe2b8a updated for version 7.0223
vimboss
parents: 714
diff changeset
668 if (value != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 {
750
e2f45cbe2b8a updated for version 7.0223
vimboss
parents: 714
diff changeset
670 VALUE val = rb_str_new2((char *)value);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 vim_free(value);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 return val;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 static VALUE buffer_new(buf_T *buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
681 if (buf->b_ruby_ref)
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
682 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
683 return (VALUE) buf->b_ruby_ref;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 }
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
685 else
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
686 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 VALUE obj = Data_Wrap_Struct(cBuffer, 0, 0, buf);
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
688 buf->b_ruby_ref = (void *) obj;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 rb_hash_aset(objtbl, rb_obj_id(obj), obj);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 return obj;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 static buf_T *get_buf(VALUE obj)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 Data_Get_Struct(obj, buf_T, buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 if (buf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 rb_raise(eDeletedBufferError, "attempt to refer to deleted buffer");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 static VALUE buffer_s_current()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 return buffer_new(curbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 static VALUE buffer_s_count()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 buf_T *b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 int n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
714 for (b = firstbuf; b != NULL; b = b->b_next)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
715 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
716 /* Deleted buffers should not be counted
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
717 * SegPhault - 01/07/05 */
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
718 if (b->b_p_bl)
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
719 n++;
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
720 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
721
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 return INT2NUM(n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
725 static VALUE buffer_s_aref(VALUE self UNUSED, VALUE num)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 buf_T *b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 int n = NUM2INT(num);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
730 for (b = firstbuf; b != NULL; b = b->b_next)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
731 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
732 /* Deleted buffers should not be counted
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
733 * SegPhault - 01/07/05 */
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
734 if (!b->b_p_bl)
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
735 continue;
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
736
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
737 if (n == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 return buffer_new(b);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
739
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
740 n--;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 static VALUE buffer_name(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 buf_T *buf = get_buf(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748
750
e2f45cbe2b8a updated for version 7.0223
vimboss
parents: 714
diff changeset
749 return buf->b_ffname ? rb_str_new2((char *)buf->b_ffname) : Qnil;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 static VALUE buffer_number(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 buf_T *buf = get_buf(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 return INT2NUM(buf->b_fnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 static VALUE buffer_count(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 buf_T *buf = get_buf(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 return INT2NUM(buf->b_ml.ml_line_count);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
766 static VALUE get_buffer_line(buf_T *buf, linenr_T n)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 {
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
768 if (n > 0 && n <= buf->b_ml.ml_line_count)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
769 {
750
e2f45cbe2b8a updated for version 7.0223
vimboss
parents: 714
diff changeset
770 char *line = (char *)ml_get_buf(buf, n, FALSE);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
771 return line ? vim_str2rb_enc_str(line) : Qnil;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 }
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
773 rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
774 #ifndef __GNUC__
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
775 return Qnil; /* For stop warning */
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
776 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
779 static VALUE buffer_aref(VALUE self, VALUE num)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 buf_T *buf = get_buf(self);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
782
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
783 if (buf != NULL)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
784 return get_buffer_line(buf, (linenr_T)NUM2LONG(num));
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
785 return Qnil; /* For stop warning */
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
786 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
787
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
788 static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
789 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
790 char *line = StringValuePtr(str);
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
791 aco_save_T aco;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
793 if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL)
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
794 {
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
795 /* set curwin/curbuf for "buf" and save some things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
796 aucmd_prepbuf(&aco, buf);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
797
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 if (u_savesub(n) == OK) {
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
799 ml_replace(n, (char_u *)line, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 changed();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 #ifdef SYNTAX_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 syn_changed(n); /* recompute syntax hl. for this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 }
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
805
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
806 /* restore curwin/curbuf and a few other things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
807 aucmd_restbuf(&aco);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
808 /* Careful: autocommands may have made "buf" invalid! */
934
e44efb3af0d5 updated for version 7.0-060
vimboss
parents: 896
diff changeset
809
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 update_curbuf(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 }
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
812 else
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
813 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
814 rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
815 #ifndef __GNUC__
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 return Qnil; /* For stop warning */
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
817 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 return str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
822 static VALUE buffer_aset(VALUE self, VALUE num, VALUE str)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
823 {
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
824 buf_T *buf = get_buf(self);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
825
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
826 if (buf != NULL)
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
827 return set_buffer_line(buf, (linenr_T)NUM2LONG(num), str);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
828 return str;
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
829 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
830
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 static VALUE buffer_delete(VALUE self, VALUE num)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 {
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
833 buf_T *buf = get_buf(self);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
834 long n = NUM2LONG(num);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
835 aco_save_T aco;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
837 if (n > 0 && n <= buf->b_ml.ml_line_count)
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
838 {
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
839 /* set curwin/curbuf for "buf" and save some things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
840 aucmd_prepbuf(&aco, buf);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
841
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 if (u_savedel(n, 1) == OK) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 ml_delete(n, 0);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
844
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
845 /* Changes to non-active buffers should properly refresh
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
846 * SegPhault - 01/09/05 */
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
847 deleted_lines_mark(n, 1L);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
848
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 changed();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 }
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
851
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
852 /* restore curwin/curbuf and a few other things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
853 aucmd_restbuf(&aco);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
854 /* Careful: autocommands may have made "buf" invalid! */
934
e44efb3af0d5 updated for version 7.0-060
vimboss
parents: 896
diff changeset
855
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 update_curbuf(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 }
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
858 else
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
859 {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
860 rb_raise(rb_eIndexError, "line number %ld out of range", n);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 static VALUE buffer_append(VALUE self, VALUE num, VALUE str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 {
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
867 buf_T *buf = get_buf(self);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
868 char *line = StringValuePtr(str);
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
869 long n = NUM2LONG(num);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
870 aco_save_T aco;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
872 if (line != NULL) {
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
873 rb_raise(rb_eIndexError, "NULL line");
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
874 }
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
875 else if (n >= 0 && n <= buf->b_ml.ml_line_count)
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
876 {
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
877 /* set curwin/curbuf for "buf" and save some things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
878 aucmd_prepbuf(&aco, buf);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
879
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 if (u_inssub(n + 1) == OK) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 ml_append(n, (char_u *) line, (colnr_T) 0, FALSE);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
882
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
883 /* Changes to non-active buffers should properly refresh screen
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
884 * SegPhault - 12/20/04 */
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
885 appended_lines_mark(n, 1L);
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
886
856
8cd729851562 updated for version 7.0g
vimboss
parents: 835
diff changeset
887 changed();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 }
896
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
889
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
890 /* restore curwin/curbuf and a few other things */
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
891 aucmd_restbuf(&aco);
354ea37841d1 updated for version 7.0-022
vimboss
parents: 856
diff changeset
892 /* Careful: autocommands may have made "buf" invalid! */
934
e44efb3af0d5 updated for version 7.0-060
vimboss
parents: 896
diff changeset
893
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 update_curbuf(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 else {
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
897 rb_raise(rb_eIndexError, "line number %ld out of range", n);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 return str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 static VALUE window_new(win_T *win)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
904 if (win->w_ruby_ref)
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
905 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
906 return (VALUE) win->w_ruby_ref;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 }
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
908 else
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
909 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 VALUE obj = Data_Wrap_Struct(cVimWindow, 0, 0, win);
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
911 win->w_ruby_ref = (void *) obj;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 rb_hash_aset(objtbl, rb_obj_id(obj), obj);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 return obj;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 static win_T *get_win(VALUE obj)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 Data_Get_Struct(obj, win_T, win);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 if (win == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 rb_raise(eDeletedWindowError, "attempt to refer to deleted window");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 return win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 static VALUE window_s_current()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 return window_new(curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
932 /*
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
933 * Added line manipulation functions
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
934 * SegPhault - 03/07/05
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
935 */
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
936 static VALUE line_s_current()
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
937 {
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
938 return get_buffer_line(curbuf, curwin->w_cursor.lnum);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
939 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
940
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
941 static VALUE set_current_line(VALUE self UNUSED, VALUE str)
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
942 {
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
943 return set_buffer_line(curbuf, curwin->w_cursor.lnum, str);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
944 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
945
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
946 static VALUE current_line_number()
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
947 {
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
948 return INT2FIX((int)curwin->w_cursor.lnum);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
949 }
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
950
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
951
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
952
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 static VALUE window_s_count()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 win_T *w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 int n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958
671
83a006f81bac updated for version 7.0199
vimboss
parents: 502
diff changeset
959 for (w = firstwin; w != NULL; w = w->w_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 n++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 return INT2NUM(n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 return INT2NUM(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
967 static VALUE window_s_aref(VALUE self UNUSED, VALUE num)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 win_T *w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 int n = NUM2INT(num);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 #ifndef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 w = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 for (w = firstwin; w != NULL; w = w->w_next, --n)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 if (n == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 return window_new(w);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 static VALUE window_buffer(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 win_T *win = get_win(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 return buffer_new(win->w_buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 static VALUE window_height(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 win_T *win = get_win(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 return INT2NUM(win->w_height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 static VALUE window_set_height(VALUE self, VALUE height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 win_T *win = get_win(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 win_T *savewin = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 curwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 win_setheight(NUM2INT(height));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 curwin = savewin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 return height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1007 static VALUE window_width(VALUE self)
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1008 {
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1009 win_T *win = get_win(self);
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1010
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1011 return INT2NUM(win->w_width);
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1012 }
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1013
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1014 static VALUE window_set_width(VALUE self, VALUE width)
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1015 {
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1016 win_T *win = get_win(self);
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1017 win_T *savewin = curwin;
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1018
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1019 curwin = win;
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1020 win_setwidth(NUM2INT(width));
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1021 curwin = savewin;
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1022 return width;
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1023 }
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1024
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 static VALUE window_cursor(VALUE self)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1026 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 win_T *win = get_win(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 return rb_assoc_new(INT2NUM(win->w_cursor.lnum), INT2NUM(win->w_cursor.col));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 static VALUE window_set_cursor(VALUE self, VALUE pos)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 VALUE lnum, col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 win_T *win = get_win(self);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 Check_Type(pos, T_ARRAY);
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1038 if (RARRAY_LEN(pos) != 2)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 rb_raise(rb_eArgError, "array length must be 2");
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1040 lnum = RARRAY_PTR(pos)[0];
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1041 col = RARRAY_PTR(pos)[1];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 win->w_cursor.lnum = NUM2LONG(lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 win->w_cursor.col = NUM2UINT(col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 check_cursor(); /* put cursor on an existing line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 update_screen(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048
1888
ae2251be41f9 updated for version 7.2-185
vimboss
parents: 1386
diff changeset
1049 static VALUE f_p(int argc, VALUE *argv, VALUE self UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 VALUE str = rb_str_new("", 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 for (i = 0; i < argc; i++) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 if (i > 0) rb_str_cat(str, ", ", 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 rb_str_concat(str, rb_inspect(argv[i]));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 }
2077
d8983769c9dd updated for version 7.2.361
Bram Moolenaar <bram@zimbu.org>
parents: 2076
diff changeset
1058 MSG(RSTRING_PTR(str));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 return Qnil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 static void ruby_io_init(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 #ifndef DYNAMIC_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 RUBYEXTERN VALUE rb_stdout;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 rb_stdout = rb_obj_alloc(rb_cObject);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 rb_define_singleton_method(rb_stdout, "write", vim_message, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 rb_define_global_function("p", f_p, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 static void ruby_vim_init(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 objtbl = rb_hash_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 rb_global_variable(&objtbl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077
1188
2a276274c592 updated for version 7.1b
vimboss
parents: 1131
diff changeset
1078 /* The Vim module used to be called "VIM", but "Vim" is better. Make an
2a276274c592 updated for version 7.1b
vimboss
parents: 1131
diff changeset
1079 * alias "VIM" for backwards compatiblity. */
2a276274c592 updated for version 7.1b
vimboss
parents: 1131
diff changeset
1080 mVIM = rb_define_module("Vim");
2a276274c592 updated for version 7.1b
vimboss
parents: 1131
diff changeset
1081 rb_define_const(rb_cObject, "VIM", mVIM);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082 rb_define_const(mVIM, "VERSION_MAJOR", INT2NUM(VIM_VERSION_MAJOR));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 rb_define_const(mVIM, "VERSION_MINOR", INT2NUM(VIM_VERSION_MINOR));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 rb_define_const(mVIM, "VERSION_BUILD", INT2NUM(VIM_VERSION_BUILD));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 rb_define_const(mVIM, "VERSION_PATCHLEVEL", INT2NUM(VIM_VERSION_PATCHLEVEL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 rb_define_const(mVIM, "VERSION_SHORT", rb_str_new2(VIM_VERSION_SHORT));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 rb_define_const(mVIM, "VERSION_MEDIUM", rb_str_new2(VIM_VERSION_MEDIUM));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 rb_define_const(mVIM, "VERSION_LONG", rb_str_new2(VIM_VERSION_LONG));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 rb_define_const(mVIM, "VERSION_LONG_DATE", rb_str_new2(VIM_VERSION_LONG_DATE));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 rb_define_module_function(mVIM, "message", vim_message, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 rb_define_module_function(mVIM, "set_option", vim_set_option, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 rb_define_module_function(mVIM, "command", vim_command, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 rb_define_module_function(mVIM, "evaluate", vim_evaluate, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 eDeletedBufferError = rb_define_class_under(mVIM, "DeletedBufferError",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 rb_eStandardError);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 eDeletedWindowError = rb_define_class_under(mVIM, "DeletedWindowError",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 rb_eStandardError);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 cBuffer = rb_define_class_under(mVIM, "Buffer", rb_cObject);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 rb_define_singleton_method(cBuffer, "current", buffer_s_current, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 rb_define_singleton_method(cBuffer, "count", buffer_s_count, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 rb_define_singleton_method(cBuffer, "[]", buffer_s_aref, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 rb_define_method(cBuffer, "name", buffer_name, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 rb_define_method(cBuffer, "number", buffer_number, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 rb_define_method(cBuffer, "count", buffer_count, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 rb_define_method(cBuffer, "length", buffer_count, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 rb_define_method(cBuffer, "[]", buffer_aref, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 rb_define_method(cBuffer, "[]=", buffer_aset, 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 rb_define_method(cBuffer, "delete", buffer_delete, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 rb_define_method(cBuffer, "append", buffer_append, 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112
779
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1113 /* Added line manipulation functions
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1114 * SegPhault - 03/07/05 */
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1115 rb_define_method(cBuffer, "line_number", current_line_number, 0);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1116 rb_define_method(cBuffer, "line", line_s_current, 0);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1117 rb_define_method(cBuffer, "line=", set_current_line, 1);
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1118
fb913578cbf5 updated for version 7.0228
vimboss
parents: 750
diff changeset
1119
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 cVimWindow = rb_define_class_under(mVIM, "Window", rb_cObject);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 rb_define_singleton_method(cVimWindow, "current", window_s_current, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 rb_define_singleton_method(cVimWindow, "count", window_s_count, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 rb_define_singleton_method(cVimWindow, "[]", window_s_aref, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 rb_define_method(cVimWindow, "buffer", window_buffer, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 rb_define_method(cVimWindow, "height", window_height, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 rb_define_method(cVimWindow, "height=", window_set_height, 1);
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1127 rb_define_method(cVimWindow, "width", window_width, 0);
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 272
diff changeset
1128 rb_define_method(cVimWindow, "width=", window_set_width, 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 rb_define_method(cVimWindow, "cursor", window_cursor, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 rb_define_method(cVimWindow, "cursor=", window_set_cursor, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 rb_define_virtual_variable("$curbuf", buffer_s_current, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 rb_define_virtual_variable("$curwin", window_s_current, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 }