rbpad 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,132 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+
4
+ This file is part of GtkSourceView
5
+
6
+ Copyright (C) 2006-2007 GtkSourceView team
7
+ Author: Yevgen Muntyan <muntyan@tamu.edu>
8
+
9
+ GtkSourceView is free software; you can redistribute it and/or
10
+ modify it under the terms of the GNU Lesser General Public
11
+ License as published by the Free Software Foundation; either
12
+ version 2.1 of the License, or (at your option) any later version.
13
+
14
+ GtkSourceView is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ Lesser General Public License for more details.
18
+
19
+ You should have received a copy of the GNU Lesser General Public
20
+ License along with this library; if not, write to the Free Software
21
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
+
23
+ -->
24
+ <style-scheme id="rbpad" _name="Rbpad" version="1.0">
25
+ <author>Rbpad</author>
26
+ <_description>Classic color scheme</_description>
27
+
28
+ <!-- The scheme tries to look like the default GVim scheme,
29
+ since it is also what the hardwired GtkSourceView 1 color
30
+ scheme did -->
31
+
32
+ <!-- Palette -->
33
+ <color name="white" value="#FFFFFF"/>
34
+ <color name="blue" value="#0000FF"/>
35
+ <color name="magenta" value="#FF00FF"/>
36
+ <color name="violet" value="#6A5ACD"/>
37
+ <color name="cyan" value="#008A8C"/>
38
+ <color name="gray" value="#BEBEBE"/>
39
+ <color name="green" value="#2E8B57"/>
40
+ <color name="bordeaux" value="#A52A2A"/>
41
+ <color name="red" value="#FF0000"/>
42
+ <color name="yellow" value="#FFFF00"/>
43
+ <color name="purple" value="#A020F0"/>
44
+
45
+ <!-- Global Settings -->
46
+ <!-- style name="current-line" background="#eeeeec"/ -->
47
+ <style name="current-line" background="#EEF6FF"/>
48
+ <style name="current-line-number" background="#eeeeec"/>
49
+ <style name="draw-spaces" foreground="#babdb6"/>
50
+ <style name="background-pattern" background="#f3f3f3"/>
51
+
52
+ <!-- Bracket Matching -->
53
+ <style name="bracket-match" foreground="white" background="gray"/>
54
+ <style name="bracket-mismatch" foreground="white" background="red"/>
55
+
56
+ <!-- Right Margin -->
57
+ <style name="right-margin" foreground="#000000" background="#000000"/>
58
+
59
+ <!-- Search Matching -->
60
+ <style name="search-match" background="yellow"/>
61
+
62
+ <!-- Comments -->
63
+ <style name="def:comment" foreground="green" bold="false"/>
64
+ <style name="def:shebang" foreground="blue" bold="true"/>
65
+ <style name="def:doc-comment-element" italic="true"/>
66
+
67
+ <!-- Constants -->
68
+ <!-- style name="def:constant" foreground="bordeaux" bold="true"/ -->
69
+ <style name="def:constant" foreground="#d2691e" bold="true"/> <!-- chocolate -->
70
+ <style name="def:special-char" foreground="#d2691e" bold="true"/> <!-- chocolate -->
71
+
72
+ <!-- Identifiers -->
73
+ <style name="def:identifier" foreground="#4b0082"/> <!-- indigo -->
74
+
75
+ <!-- Statements -->
76
+ <style name="def:statement" foreground="#4b0082" bold="true"/> <!-- indigo -->
77
+
78
+ <!-- Types -->
79
+ <style name="def:type" foreground="#c71585" bold="false"/> <!-- mediumvioletred -->
80
+
81
+ <!-- Others -->
82
+ <style name="def:preprocessor" foreground="#4b0082" bold="true"/> <!-- indigo -->
83
+ <style name="def:error" background="red" bold="true"/>
84
+ <style name="def:warning" background="yellow"/>
85
+ <style name="def:note" foreground="blue" background="yellow" bold="true"/>
86
+ <style name="def:underlined" italic="true" underline="single"/>
87
+
88
+
89
+
90
+
91
+ <!-- Heading styles, uncomment to enable -->
92
+ <!--
93
+ <style name="def:heading0" scale="5.0"/>
94
+ <style name="def:heading1" scale="2.5"/>
95
+ <style name="def:heading2" scale="2.0"/>
96
+ <style name="def:heading3" scale="1.7"/>
97
+ <style name="def:heading4" scale="1.5"/>
98
+ <style name="def:heading5" scale="1.3"/>
99
+ <style name="def:heading6" scale="1.2"/>
100
+ -->
101
+
102
+ <!-- Language specific styles -->
103
+ <!--
104
+ <style name="diff:added-line" foreground="#008B8B"/>
105
+ <style name="diff:removed-line" foreground="#6A5ACD"/>
106
+ <style name="diff:changed-line" use-style="def:preprocessor"/>
107
+ <style name="diff:special-case" use-style="def:constant"/>
108
+ <style name="diff:location" use-style="def:statement"/>
109
+ <style name="diff:diff-file" use-style="def:type"/>
110
+
111
+ <style name="xml:tags" foreground="cyan"/>
112
+ <style name="xml:attribute-name" foreground="violet"/>
113
+ <style name="xml:namespace" foreground="green" bold="true"/>
114
+
115
+ <style name="js:object" foreground="#2E8B57" bold="true"/>
116
+ <style name="js:constructors" foreground="#008B8B"/>
117
+
118
+ <style name="latex:display-math" foreground="#6A5ACD"/>
119
+ <style name="latex:command" foreground="#2E8B57" bold="true"/>
120
+ <style name="latex:include" use-style="def:preprocessor"/>
121
+
122
+ <style name="sh:variable" foreground="#6A5ACD"/>
123
+ -->
124
+
125
+ <!-- legacy styles for old lang files -->
126
+ <!--
127
+ <style name="Others" foreground="#2E8B57" bold="true"/>
128
+ <style name="Others 2" foreground="#008B8B"/>
129
+ <style name="Others 3" foreground="#6A5ACD"/>
130
+ -->
131
+
132
+ </style-scheme>
@@ -0,0 +1,216 @@
1
+
2
+ require 'gtk3'
3
+ require 'rexml/document'
4
+
5
+
6
+ module Rbpad
7
+
8
+ class Config
9
+ attr_reader :menu,
10
+ :actions_menubar,
11
+ :actions_menubar_toggle,
12
+ :messages,
13
+ :platform,
14
+ :sourceview
15
+
16
+ def initialize(context, os, lang = :jp)
17
+ @os = os
18
+ @lang = lang
19
+
20
+ current_dir = File.expand_path(File.dirname(__FILE__))
21
+ @conf_menu = "#{current_dir}/config/menu.xml"
22
+ @conf_actions_menubar = "#{current_dir}/config/actions_menubar.xml"
23
+ @conf_actions_menubar_template = "#{current_dir}/config/actions_menubar_template.xml"
24
+ @conf_actions_menubar_toggle = "#{current_dir}/config/actions_menubar_toggle.xml"
25
+ @conf_messages = "#{current_dir}/config/messages.xml" # fixed words in jp/en
26
+ @conf_platform = "#{current_dir}/config/platform.xml" # command and font on win/mac/linux
27
+
28
+ @sourceview = "#{current_dir}/config/sourceview.xml" # for Syntax Highlight
29
+
30
+ _read_menu
31
+ _read_actions_menubar(context)
32
+ _read_actions_menubar_toggle(context)
33
+ _read_messages
34
+ _read_platform
35
+ end
36
+
37
+ private def _read_menu
38
+ xmldoc = nil
39
+ File.open(@conf_menu) do |fp|
40
+ xmldoc = REXML::Document.new(fp)
41
+ end
42
+
43
+ xmldoc.elements.each('ui/menubar/menu/menuitem') do |e|
44
+ if Regexp.compile(@lang.to_s[0]) !~ e.attributes['lang']
45
+ puts "#{e.attributes['action']} #{e.attributes['lang']}"
46
+ puts e.xpath
47
+ xmldoc.delete_element(e.xpath)
48
+ end
49
+ end
50
+
51
+ xmldoc.elements.each('ui/menubar/menu/separator') do |e|
52
+ if Regexp.compile(@lang.to_s[0]) !~ e.attributes['lang']
53
+ puts "#{e.attributes['action']} #{e.attributes['lang']}"
54
+ puts e.xpath
55
+ xmldoc.delete_element(e.xpath)
56
+ end
57
+ end
58
+ @menu = xmldoc.root.to_s
59
+ end
60
+
61
+ private def _read_actions_menubar(context)
62
+ @actions_menubar = []
63
+
64
+ xmldoc = nil
65
+ File.open(@conf_actions_menubar) do |fp|
66
+ xmldoc = REXML::Document.new(fp)
67
+ end
68
+
69
+ xmldoc.elements.each('actions/menubar_action/branch') do |e| # menu (parent or node)
70
+ @actions_menubar << [e.attributes['id'],
71
+ nil,
72
+ (@lang == :jp ? e.attributes['desc_j'] : e.attributes['desc_e']),
73
+ nil,
74
+ nil,
75
+ Proc.new{ }]
76
+ end
77
+
78
+ xmldoc.elements.each('actions/menubar_action/menuitem') do |e| # menu item
79
+ @actions_menubar << [e.attributes['id'],
80
+ nil,
81
+ (@lang == :jp ? e.attributes['desc_j'] : e.attributes['desc_e']),
82
+ _acckey(e.attributes['acckey']),
83
+ nil,
84
+ context.eval(e.attributes['proc']) ]
85
+ end
86
+
87
+ xmldoc.elements.each('actions/menubar_action/uri') do |e| # URI refer item
88
+ @actions_menubar << [e.attributes['id'],
89
+ nil,
90
+ (@lang == :jp ? e.attributes['desc_j'] : e.attributes['desc_e']),
91
+ _acckey(e.attributes['acckey']),
92
+ nil,
93
+ context.eval((@lang == :jp ? e.attributes['proc_j'] : e.attributes['proc_e'])) ]
94
+ end
95
+
96
+ xmldoc = nil
97
+ File.open(@conf_actions_menubar_template) do |fp|
98
+ xmldoc = REXML::Document.new(fp)
99
+ end
100
+
101
+ xmldoc.elements.each('actions/menubar_action/template') do |e| # template item
102
+ @actions_menubar << [e.attributes['id'],
103
+ nil,
104
+ (@lang == :jp ? e.attributes['desc_j'] : e.attributes['desc_e']),
105
+ _acckey(e.attributes['acckey']),
106
+ nil,
107
+ context.eval(%Q(Proc.new{_load_block("#{e.text.sub(/^\n/, '').chomp}")})) ] # remove only the newline inserted at the beginning
108
+ end
109
+ end
110
+
111
+ private def _read_actions_menubar_toggle(context)
112
+ @actions_menubar_toggle = []
113
+
114
+ File.open(@conf_actions_menubar_toggle) do |fp|
115
+ xmldoc = REXML::Document.new(fp)
116
+
117
+ xmldoc.elements.each('actions/toggle_action/checkitem') do |e| # check item
118
+ @actions_menubar_toggle << [e.attributes['id'],
119
+ nil,
120
+ (@lang == :jp ? e.elements['desc_j'].text : e.elements['desc_e'].text),
121
+ _acckey(e.elements['acckey'].text),
122
+ nil,
123
+ context.eval(e.elements['proc'].text),
124
+ context.eval(e.attributes['value']) ]
125
+ end
126
+ end
127
+ end
128
+
129
+ private def _read_messages
130
+ @messages = {}
131
+ File.open(@conf_messages) do |fp|
132
+ xmldoc = REXML::Document.new(fp)
133
+ xmldoc.elements.each('messages/string') do |e|
134
+ @messages[e.attributes['id'].to_sym] = (@lang == :jp ? e.elements['jp'].text : e.elements['en'].text)
135
+ end
136
+ end
137
+ end
138
+
139
+ private def _read_platform
140
+ @platform = {}
141
+ File.open(@conf_platform) do |fp|
142
+ xmldoc = REXML::Document.new(fp)
143
+
144
+ hash = {}
145
+ xmldoc.elements.each('platform/command') do |e|
146
+ hash[e.attributes['id'].to_sym] = (case @os
147
+ when :windows
148
+ e.elements['win'].text
149
+ when :mac
150
+ e.elements['mac'].text
151
+ when :linux
152
+ e.elements['linux'].text
153
+ end)
154
+ end
155
+ @platform[:command] = hash
156
+
157
+ hash = {}
158
+ xmldoc.elements.each('platform/font') do |e|
159
+ hash[e.attributes['id'].to_sym] = (case @os
160
+ when :windows
161
+ e.elements['win'].text
162
+ when :mac
163
+ e.elements['mac'].text
164
+ when :linux
165
+ e.elements['linux'].text
166
+ end)
167
+ end
168
+ @platform[:font] = hash
169
+ end
170
+ end
171
+
172
+ private def _acckey(key_path)
173
+ # convert key defincation for accelerator ('___' --> 'meta' or 'control')
174
+ if @os == :mac
175
+ s = key_path.sub(/___/, 'meta')
176
+ else
177
+ s = key_path.sub(/___/, 'control')
178
+ end
179
+ s
180
+ end
181
+
182
+ # option IDs
183
+ def option_ids
184
+ ids = []
185
+ @actions_menubar_toggle.each do |item|
186
+ ids << item[0] # attributes['id'] of checkitem
187
+ end
188
+ ids
189
+ end
190
+
191
+ # persist the value of option item
192
+ def persist(param)
193
+ xmldoc = nil
194
+ File.open(@conf_actions_menubar_toggle) do |fp|
195
+ xmldoc = REXML::Document.new(fp)
196
+ end
197
+ param.keys.each do |key|
198
+ xmldoc.elements.each("actions/toggle_action/checkitem") do |e|
199
+ if key.to_s == e.attributes['id']
200
+ e.attributes['value'] = param[key]
201
+ break
202
+ end
203
+ end
204
+ end
205
+ begin
206
+ File.open(@conf_actions_menubar_toggle, 'w+') do |file|
207
+ xmldoc.write(output: file, indent: -1)
208
+ end
209
+ rescue => e
210
+ puts e.inspect
211
+ end
212
+ end
213
+
214
+ end
215
+ end
216
+
@@ -0,0 +1,141 @@
1
+
2
+ require 'gtk3'
3
+
4
+ require 'rbpad/page'
5
+ require 'rbpad/util'
6
+
7
+
8
+ module Rbpad
9
+
10
+ class Editor < Gtk::Notebook
11
+
12
+ def initialize(conf, status_area)
13
+ super()
14
+ @conf = conf
15
+ @status_area = status_area
16
+ @next_pageno = 0
17
+ _append_page
18
+ __debug_status
19
+
20
+ self.scrollable = true
21
+ self.enable_popup = true
22
+
23
+ self.signal_connect("switch-page") do |widget, page, num_page|
24
+ puts "switch page #{widget.page} --> #{num_page} (n_pages = #{widget.n_pages})"
25
+ self.get_nth_page(num_page).display_status
26
+ self.get_nth_page(num_page).set_draw_spaces(@draw_spaces)
27
+ self.get_nth_page(num_page).set_block_match(@block_match)
28
+ end
29
+ end
30
+
31
+ # set focus to the page
32
+ def page_focus
33
+ self.get_nth_page(self.page).set_focus
34
+ end
35
+
36
+ # load statements to new page
37
+ def load_block(statement)
38
+ editor_page = _append_page
39
+ editor_page.insert_block(statement, :start)
40
+ end
41
+
42
+ # save temporary file to specified directory
43
+ def save_tmp(dirname)
44
+ editor_page = self.get_nth_page(self.page)
45
+ basename = "rs_#{Utility.get_uniqname}.rb"
46
+ filename = "#{dirname}/#{basename}"
47
+ editor_page.save(filename, true)
48
+ return basename
49
+ end
50
+
51
+ # save the file
52
+ def save(filename)
53
+ editor_page = self.get_nth_page(self.page)
54
+ p editor_page
55
+ self.get_tab_label(editor_page).text = File.basename(filename) # File.basename(filename, ".*")
56
+ editor_page.save(filename)
57
+ __debug_status
58
+ end
59
+
60
+ # load the file
61
+ def load(filename)
62
+ return if FileTest.directory?(filename)
63
+ tabname = File.basename(filename) # File.basename(filename, ".*")
64
+ dirname = File.dirname(filename)
65
+ editor_page = _append_page(dirname, filename, tabname)
66
+ unless editor_page.load(filename)
67
+ self.remove_page(self.page)
68
+ return false
69
+ end
70
+ __debug_status
71
+ true
72
+ end
73
+
74
+ # close the page
75
+ def close
76
+ self.remove_page(self.page)
77
+ __debug_status
78
+ end
79
+
80
+ # append the new page
81
+ def append
82
+ _append_page
83
+ __debug_status
84
+ end
85
+
86
+ # append the new page (private)
87
+ private def _append_page(dirname = nil, filename = nil, tabname = nil)
88
+ editor_page = Page.new(@conf, @status_area)
89
+ editor_page.set_draw_spaces(@draw_spaces)
90
+ editor_page.set_block_match(@block_match)
91
+ tabname ||= "program#{@next_pageno}"
92
+ @next_pageno += 1
93
+ self.insert_page(editor_page, Gtk::Label.new(tabname), self.n_pages)
94
+ self.show_all
95
+ self.page = self.n_pages - 1 # show the inserted page (it must be set after 'show_all')
96
+
97
+ return editor_page
98
+ end
99
+
100
+ # get the properties of current page
101
+ def get_page_properties
102
+ editor_page = self.get_nth_page(self.page)
103
+ return editor_page.dirname, editor_page.basename, self.get_tab_label(editor_page).text, editor_page.status
104
+ end
105
+
106
+ def undo ; self.get_nth_page(self.page).undo ; end
107
+ def redo ; self.get_nth_page(self.page).redo ; end
108
+ def cut ; self.get_nth_page(self.page).cut ; end
109
+ def copy ; self.get_nth_page(self.page).copy ; end
110
+ def paste ; self.get_nth_page(self.page).paste ; end
111
+ def select_all ; self.get_nth_page(self.page).select_all ; end
112
+
113
+ def find_and_select(word, direction)
114
+ self.get_nth_page(self.page).find_and_select(word, direction)
115
+ end
116
+
117
+ def set_draw_spaces(status)
118
+ self.get_nth_page(self.page).set_draw_spaces(status)
119
+ @draw_spaces = status
120
+ end
121
+
122
+ def set_block_match(status)
123
+ self.get_nth_page(self.page).set_block_match(status)
124
+ @block_match = status
125
+ end
126
+
127
+ private def __debug_status
128
+ puts "next_pageno : #{@next_pageno}"
129
+ if self.n_pages == 0
130
+ puts "[EMPTY]"
131
+ else
132
+ self.n_pages.times do |i|
133
+ editor_page = self.get_nth_page(i)
134
+ puts "#{i} : #{editor_page.dirname} #{editor_page.basename} #{self.get_tab_label(editor_page).text} #{editor_page.status}"
135
+ end
136
+ end
137
+ end
138
+
139
+ end
140
+ end
141
+
@@ -0,0 +1,176 @@
1
+
2
+ module Rbpad
3
+
4
+ module Error_jp
5
+ module_function def get_msg(line)
6
+ /(.*):(\d+)/ =~ line
7
+ name = $1
8
+ pos = $2
9
+ msg_pos = "ファイル #{name} の #{pos}行目でエラーが発生しました。"
10
+ msg_content = "(詳細情報は不明です)"
11
+ if /syntax error/ =~ line
12
+ msg_content = "syntax error"
13
+ if /unexpected end-of-input/ =~ line
14
+ msg_content = %Q(プログラムの構文が途中で終わっています。)
15
+ elsif /unexpected (keyword_)?end/ =~ line
16
+ msg_content = %Q('end'で終わるブロックの対応が不完全です。)
17
+ elsif /unexpected tIDENTIFIER/ =~ line
18
+ msg_content = %Q(全角文字などの使用できない文字が混ざっています。)
19
+ elsif /unexpected t(.*),/ =~ line
20
+ msg_content = %Q(予期しない #{$1} が混ざっています。)
21
+ elsif /unexpected (.*)/ =~ line
22
+ msg_content = %Q(#{$1} という正しくないキーワードが使われています。)
23
+ end
24
+ elsif /\(NameError\)/ =~ line
25
+ msg_content = "NameError"
26
+ if /undefined local variable or method (.*?) / =~ line
27
+ msg_content = %Q(#{$1} という名前の変数またはメソッドが定義されていないか、タイプミスの可能性があります。)
28
+ elsif /uninitialized constant (.*?) / =~ line
29
+ msg_content = %Q(定数 #{$1} の値が初期化されていません。)
30
+ end
31
+ elsif /\(NoMethodError\)/ =~ line
32
+ msg_content = "NoMethodError"
33
+ if /undefined method (.*) for (.*):(.*?) / =~ line
34
+ msg_content = %Q(#{$3} の #{$2} には #{$1} というメソッドは定義されていません。)
35
+ end
36
+ elsif /\(LoadError\)/ =~ line
37
+ msg_content = "ロードできません。"
38
+ if /cannot load such file \-\- (.*) /=~ line
39
+ msg_content = %Q(#{$1} というファイルが見つからないのでロードできません。)
40
+ end
41
+ elsif /\(ArgumentError\)/ =~ line
42
+ msg_content = "ArgumentError"
43
+ if /wrong number of arguments/ =~ line
44
+ msg_content = %Q(メソッドに渡した引数の個数が正しくありません。)
45
+ elsif /must be positive/ =~ line
46
+ msg_content = %Q(引数には正(プラス)の値を渡してください。)
47
+ elsif /must not be negative/ =~ line
48
+ msg_content = %Q(引数には負(マイナス)以外の値を渡してください。)
49
+ end
50
+ elsif /\(TypeError\)/ =~ line
51
+ msg_content = "TypeError"
52
+ if /can't convert (.*) into (.*) \(/ =~ line
53
+ msg_content = %Q(引数には #{$1} ではなく #{$2} を渡してください。)
54
+ end
55
+ else
56
+ if /unterminated string/ =~ line
57
+ msg_content = %Q(文字列が '' や "" で閉じられていません。)
58
+ elsif /unterminated regexp/ =~ line
59
+ msg_content = %Q(正規表現が // で閉じられていません。)
60
+ elsif /class\/module name must be CONSTANT/ =~ line
61
+ msg_content = %Q(クラスやモジュールの名前は大文字で始めてください。)
62
+ elsif /No such file or directory @ rb_sysopen - (.*) / =~ line
63
+ msg_content = %Q(#{$1} というファイルまたはディレクトリ(フォルダ)は存在しないため開くことができません。)
64
+ elsif /Invalid argument @ rb_sysopen - (.*) / =~ line
65
+ msg_content = %Q(#{$1} というファイル名は不正なため開くことができません。)
66
+ elsif /Is a directory @ rb_sysopen - (.*) / =~ line
67
+ msg_content = %Q(#{$1} はディレクトリ(フォルダ)のため開くことができません。)
68
+ end
69
+ end
70
+ "#{msg_pos}\n#{msg_content}"
71
+ end
72
+ end
73
+
74
+ end
75
+
76
+
77
+
78
+
79
+ if $0 == __FILE__
80
+
81
+ require 'fileutils'
82
+
83
+ def run(file)
84
+ cmd = %Q{ruby -E UTF-8 #{file}}
85
+ io = IO.popen(cmd, err: [:child, :out])
86
+ puts "\n[message]"
87
+ jp = nil
88
+ io.each do |line|
89
+ puts line
90
+ jp = Rbpad::Error_jp.get_msg(line) if line =~ /^#{File.basename(file)}/ or line =~ /\(.*Error\)$/
91
+ end
92
+ puts jp if jp
93
+ end
94
+
95
+ def make(cmd)
96
+ puts "---------------------------------------------------"
97
+ puts "[script]"
98
+ puts cmd
99
+ cmd
100
+ end
101
+
102
+
103
+ cmd = [
104
+ #
105
+ # --- syntax error
106
+ #
107
+ %Q!x = !,
108
+ %Q!a = (1 + 2) * (3 + 4!,
109
+ %Q!.to_i!,
110
+ %Q![1, 2, 3].each do!,
111
+ %Q![1, 2, 3].each do |x|!,
112
+ %Q!=begin!,
113
+ %Q!if true!,
114
+ %Q!if!,
115
+ %Q!if\nend!,
116
+ %Q!Class Foo\nend!,
117
+ %Q!class Foo << Array\nend!,
118
+ %Q!a = 100 !,
119
+ %Q!a = [1,\n2,\n3\n4]!,
120
+ #
121
+ # --- NameError
122
+ #
123
+ %Q!foo!,
124
+ %Q!puts v!,
125
+ %Q!result = true\nputs reslt!,
126
+ %Q!puts V!,
127
+ #
128
+ # --- NoMethodError
129
+ #
130
+ %Q![1, 2, 3].foo!,
131
+ %Q!a = []\nif a < 100\n puts "OK"\nend!,
132
+ %Q!/\d/.match("abc").size!,
133
+ %Q!Math.foo!,
134
+ #
135
+ # --- LoadError
136
+ #
137
+ %Q!require 'foo'!,
138
+ %Q!require_relative 'foo'!,
139
+ %Q!load 'foo.rb'!,
140
+ #
141
+ # --- ArgumentError
142
+ #
143
+ %Q!puts Math.sin!,
144
+ %Q!puts Math.sin(0, 0, 0)!,
145
+ %Q!sleep -1!,
146
+ #
147
+ # --- TypeError
148
+ #
149
+ %Q!puts Math.sin('rad')!,
150
+ %Q!sleep ""!,
151
+ %Q!sleep nil!,
152
+ #
153
+ # --- etc.
154
+ #
155
+ %Q!puts 'p!,
156
+ %Q!puts p"!,
157
+ %Q!/3!,
158
+ %Q!class foo\nend!,
159
+ %Q!File.read('aaa')!,
160
+ %Q!File.read('???')!,
161
+ %Q!File.read('.')!,
162
+ ]
163
+
164
+
165
+ Encoding.default_external = 'UTF-8'
166
+
167
+ cmd.each do |c|
168
+ cc = make(c)
169
+ filename = 'program0.rb'
170
+ File.write(filename, cc)
171
+ run(filename)
172
+ FileUtils.rm(filename)
173
+ end
174
+
175
+ end
176
+
@@ -0,0 +1,27 @@
1
+
2
+ require 'gtk3'
3
+ require 'drb/drb'
4
+
5
+
6
+ module Rbpad
7
+
8
+ class ConsoleInput < Gtk::Entry
9
+ def initialize(conf, drb_portno)
10
+ super() # no argument
11
+ self.override_font(Pango::FontDescription.new("#{conf.platform[:font][:input]}"))
12
+ self.signal_connect("activate") do
13
+ text = self.text
14
+ self.text = "" # clear
15
+ puts "Entry contents: #{text}"
16
+ begin
17
+ cl = DRbObject.new_with_uri("druby://127.0.0.1:#{drb_portno}")
18
+ cl.puts(text) # sent to DRb server (Emulate STDIN)
19
+ rescue => e
20
+ p e
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ end
27
+