rbpad 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 73f56a337b60d8ddc30fb4db31ccd631fb860d9f2f81be7d36e898c86c49ae38
4
+ data.tar.gz: 73370ac457e50cecbc149d92c07fb546c20ac2f2ca1abd97c12d47f41f443f0e
5
+ SHA512:
6
+ metadata.gz: 29088635d144f36a5560f5a68998ec524a05107cc2a33d655a8389e08addf02a6a3b3e7a9c732f96aaf21c825c4bf448fbed53b530a81c076ddddaed91452127
7
+ data.tar.gz: 54e70a2e6c65f5d1de03245508a2555862cfecca81a2ac83a965ae0539179087d50712fd1005463e0906a0703e53084391f08d0a5e45e208b14a093f33ed75f9
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in rbpad.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # rbpad
2
+
3
+ 'rbpad' is a programming editor for Ruby,
4
+ you are able to edit and run scripts of Ruby easily.
5
+
6
+ ## Required
7
+
8
+ 'rbpad' has depended on Ruby/GTK3 and Ruby/GtkSourceView3.
9
+
10
+ ## Installation
11
+
12
+ Install it yourself as:
13
+
14
+ $ gem install gtksourceview3
15
+ $ gem install rbpad
16
+
17
+ ## Usage
18
+
19
+ Type following.
20
+
21
+ $ rbpad # Japanese mode
22
+
23
+       ![](rbpad3_jp.png)
24
+
25
+
26
+ With '-e' option, labels are shown as English.
27
+
28
+ $ rbpad -e # English mode
29
+
30
+       ![](rbpad3_en.png)
31
+
32
+ With '-x' option, run as maximum window size.
33
+ Or give 'width' and 'height' argument, can run as specified window size.
34
+
35
+ $ rbpad -x # maximum window size
36
+ $ rbpad 1000 800 # screen size is 1000 x 800
37
+
38
+ Default size is 800 x 650.
39
+
40
+ ## Documents
41
+
42
+ [https://github.com/spoolkitamura/rbpad3-doc-jp/wiki](https://github.com/spoolkitamura/rbpad3-doc-jp/wiki) (Japanese)
43
+ [https://github.com/spoolkitamura/rbpad3-doc-en/wiki](https://github.com/spoolkitamura/rbpad3-doc-en/wiki) (English)
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rbpad"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/rbpad ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rbpad"
@@ -0,0 +1,136 @@
1
+
2
+ require 'gtk3'
3
+ require 'gtksourceview3'
4
+
5
+
6
+ module Rbpad
7
+
8
+ class BlockMatch
9
+ def initialize(textview, attr)
10
+ @textview = textview
11
+ @color = attr[:color] # attribute 'color' of Comment line
12
+ @bold = attr[:bold] # attribute 'bold' of Comment line
13
+ @italic = attr[:italic] # attribute 'italic' of Comment line
14
+ @match_tag = @textview.buffer.create_tag(nil, background_gdk: Gdk::Color.new(0xe0 * 0xff, 0xe0 * 0xff, 0xe0 * 0xff))
15
+ end
16
+
17
+ private def _indent_level(statement, iter)
18
+ return Float::INFINITY if statement =~ /\A\s*\z/ # indent levels of blank line is considered infinite
19
+ /\A(\s*)/ =~ statement
20
+ level = ($1 ? $1.length : 0) # indent level
21
+ if _comment?(iter, level)
22
+ return Float::INFINITY # indent levels of comment line is considered infinite
23
+ else
24
+ return level
25
+ end
26
+ end
27
+
28
+ private def _start(text)
29
+ # must be beginning of line : if, unless, case, class, module, while, until, for
30
+ # not have to be beginning of line : begin, def, do
31
+ # (?:) : not capture in ()
32
+ pattern = /(?:\A(\s*)(?:if|unless|case|class|module|while|until|for)|(\A|\s+)(?:begin|def|do))(?:\z|\s+)/
33
+
34
+ pos = (pattern =~ text)
35
+ if pos
36
+ pos + ($1 ? $1.length : 0) + ($2 ? $2.length : 0) # position of keyword from beginning of line
37
+ else
38
+ nil
39
+ end
40
+ end
41
+
42
+ private def _end(text)
43
+ pattern = /(\A|\s+)(end)(\z|\s+)/
44
+ pos = (pattern =~ text)
45
+ if pos
46
+ pos + ($1 ? $1.length : 0) # position of keyword from beginning of line
47
+ else
48
+ nil
49
+ end
50
+ end
51
+
52
+ private def _comment?(iter, pos)
53
+ iter_check = iter.clone
54
+ iter_check.set_line_offset(pos)
55
+ iter_check.tags.each do |t|
56
+ tag_color = t.foreground_gdk.to_s.downcase
57
+ tag_color = tag_color[0..2] + tag_color[5..6] + tag_color[9..10] # #rrrrggggbbbb to #rrggbb
58
+ tag_bold = (t.weight == 700)
59
+ tag_italic = (t.style == :italic)
60
+ #puts "#{tag_color} #{@color} #{tag_bold} #{tag_italic}"
61
+
62
+ return true if (tag_color == @color and
63
+ tag_bold == @bold and
64
+ tag_italic == @italic) # #rrggbb
65
+ end
66
+ false
67
+ end
68
+
69
+ def status
70
+ puts @color
71
+ puts @bold
72
+ puts @italic
73
+ end
74
+
75
+ def scan
76
+ # ignore the multi statement line
77
+ mark = @textview.buffer.selection_bound # get the mark of cursor position
78
+ iter = @textview.buffer.get_iter_at(mark: mark)
79
+
80
+ iter_s = iter.clone
81
+ iter_s.set_line_offset(0) # beginning of cursor line
82
+ iter_e = iter.clone
83
+ iter_e.forward_lines(1) # end of cursor line
84
+
85
+ iter_s_block = nil
86
+ iter_e_block = nil
87
+
88
+ current_line = @textview.buffer.get_text(iter_s, iter_e, false)
89
+
90
+ if (pos = _start(current_line)) and ! _end(current_line)
91
+ iter_s_block = iter_s.clone
92
+
93
+ if ! _comment?(iter_s, pos)
94
+ current_level = _indent_level(current_line, iter_s)
95
+ begin
96
+ res_s = iter_s.forward_lines(1)
97
+ res_e = iter_e.forward_lines(1)
98
+ next_line = @textview.buffer.get_text(iter_s, iter_e, false)
99
+ next_level = _indent_level(next_line, iter_s)
100
+ #puts "#{current_level} #{next_level}"
101
+ if current_level == next_level and _end(next_line)
102
+ iter_e_block = iter_e.clone
103
+ break
104
+ end
105
+ end until current_level > next_level or res_e == false # indent unmatch or bottom of buffer
106
+ end
107
+ elsif (pos = _end(current_line)) and ! _start(current_line)
108
+ iter_e_block = iter_e.clone
109
+ if ! _comment?(iter_s, pos)
110
+ current_level = _indent_level(current_line, iter_s)
111
+ begin
112
+ res_s = iter_s.backward_lines(1)
113
+ res_e = iter_e.backward_lines(1)
114
+ prev_line = @textview.buffer.get_text(iter_s, iter_e, false)
115
+ prev_level = _indent_level(prev_line, iter_s)
116
+ if current_level == prev_level and _start(prev_line)
117
+ iter_s_block = iter_s.clone
118
+ break
119
+ end
120
+ end until current_level > prev_level or res_s == false # indent unmatch or top of buffer
121
+ end
122
+ end
123
+
124
+ @textview.buffer.remove_tag(@match_tag, @textview.buffer.start_iter, @textview.buffer.end_iter) # Clear @tag
125
+ if iter_s_block and iter_e_block
126
+ @textview.buffer.apply_tag(@match_tag, iter_s_block, iter_e_block) # fill
127
+ end
128
+ end
129
+
130
+ def clear
131
+ @textview.buffer.remove_tag(@match_tag, @textview.buffer.start_iter, @textview.buffer.end_iter) # Clear @tag
132
+ end
133
+
134
+ end
135
+ end
136
+
@@ -0,0 +1,166 @@
1
+ <?xml version="1.0"?>
2
+
3
+ <actions>
4
+
5
+ <menubar_action>
6
+
7
+ <!--
8
+ ================================================================
9
+ ファイルメニュー
10
+ ================================================================
11
+ -->
12
+ <branch id="file" desc_j="ファイル(_F)"
13
+ desc_e="File(_F)" />
14
+
15
+ <menuitem id="run" desc_j="プログラム実行"
16
+ desc_e="Run"
17
+ acckey="&lt;___&gt;R"
18
+ proc="Proc.new{ _exec }" />
19
+
20
+ <menuitem id="kill" desc_j="プログラム停止"
21
+ desc_e="Terminate"
22
+ acckey="&lt;___&gt;T"
23
+ proc="Proc.new{ _kill }" />
24
+
25
+ <menuitem id="info" desc_j="プロパティ"
26
+ desc_e="Property"
27
+ acckey="&lt;___&gt;I"
28
+ proc="Proc.new{ _info }" />
29
+
30
+ <menuitem id="new" desc_j="新規作成"
31
+ desc_e="New"
32
+ acckey="&lt;___&gt;N"
33
+ proc="Proc.new{ _new }" />
34
+
35
+ <menuitem id="open" desc_j="開く..."
36
+ desc_e="Open..."
37
+ acckey="&lt;___&gt;O"
38
+ proc="Proc.new{ _open }" />
39
+
40
+ <menuitem id="save" desc_j="上書き保存"
41
+ desc_e="Save"
42
+ acckey="&lt;___&gt;S"
43
+ proc="Proc.new{ _save }" />
44
+
45
+ <menuitem id="saveas" desc_j="別名で保存..."
46
+ desc_e="Save as..."
47
+ acckey="&lt;shift&gt;&lt;___&gt;S"
48
+ proc="Proc.new{ _save_as }" />
49
+
50
+ <menuitem id="close" desc_j="閉じる"
51
+ desc_e="Close"
52
+ acckey="&lt;___&gt;W"
53
+ proc="Proc.new{ _close }" />
54
+
55
+ <menuitem id="exit" desc_j="終了"
56
+ desc_e="Exit"
57
+ acckey="&lt;___&gt;Q"
58
+ proc="Proc.new{ _close_page_all }" />
59
+
60
+
61
+ <!--
62
+ ================================================================
63
+ 編集メニュー
64
+ ================================================================
65
+ -->
66
+ <branch id="edit" desc_j="編集(_E)"
67
+ desc_e="Edit(_E)" />
68
+
69
+ <menuitem id="undo" desc_j="元に戻す"
70
+ desc_e="Undo"
71
+ acckey="&lt;___&gt;Z"
72
+ proc="Proc.new{ _undo }" />
73
+
74
+ <menuitem id="redo" desc_j="やり直し"
75
+ desc_e="Redo"
76
+ acckey="&lt;___&gt;Y"
77
+ proc="Proc.new{ _redo }" />
78
+
79
+ <menuitem id="cut" desc_j="切り取り"
80
+ desc_e="Cut"
81
+ acckey="&lt;___&gt;X"
82
+ proc="Proc.new{ _cut }" />
83
+
84
+ <menuitem id="copy" desc_j="コピー"
85
+ desc_e="Copy"
86
+ acckey="&lt;___&gt;C"
87
+ proc="Proc.new{ _copy }" />
88
+
89
+ <menuitem id="paste" desc_j="貼り付け"
90
+ desc_e="Paste"
91
+ acckey="&lt;___&gt;V"
92
+ proc="Proc.new{ _paste }" />
93
+
94
+ <menuitem id="select_all" desc_j="すべて選択"
95
+ desc_e="Select all"
96
+ acckey="&lt;___&gt;A"
97
+ proc="Proc.new{ _select_all }" />
98
+
99
+ <menuitem id="clear" desc_j="実行結果クリア"
100
+ desc_e="Clear output"
101
+ acckey="&lt;___&gt;L"
102
+ proc="Proc.new{ _clear_output }" />
103
+
104
+ <!--
105
+ ================================================================
106
+ オプションメニュー
107
+ ================================================================
108
+ -->
109
+ <branch id="option" desc_j="オプション(_O)"
110
+ desc_e="Option(_O)" />
111
+
112
+
113
+ <!--
114
+ ================================================================
115
+ テンプレートメニュー
116
+ ================================================================
117
+ -->
118
+ <branch id="template" desc_j="テンプレート(_T)"
119
+ desc_e="Template(_T)" />
120
+
121
+ <!--
122
+ ================================================================
123
+ ヘルプメニュー
124
+ ================================================================
125
+ -->
126
+ <branch id="help" desc_j="ヘルプ(_H)"
127
+ desc_e="Help(_H)" />
128
+
129
+ <uri id="ref_ruby" desc_j="Rubyリファレンスマニュアル..."
130
+ desc_e="Ruby reference manual..."
131
+ acckey=""
132
+ proc_j="Proc.new{ _startcmd('https://docs.ruby-lang.org/ja') }"
133
+ proc_e="Proc.new{ _startcmd('https://docs.ruby-lang.org/en') }" />
134
+
135
+ <uri id="ref_gosu" desc_j="Gosuチュートリアル..."
136
+ desc_e="Gosu tutorial..."
137
+ acckey=""
138
+ proc_j="Proc.new{ _startcmd('https://gist.github.com/myokoym/7148859#file-gosu-ruby-tutorial-japanese-md') }"
139
+ proc_e="Proc.new{ _startcmd('https://github.com/gosu/gosu/wiki/ruby-tutorial') }" />
140
+
141
+ <uri id="ref_dxruby" desc_j="DXRubyリファレンス..."
142
+ desc_e="DXRuby reference (Japanese)..."
143
+ acckey=""
144
+ proc_j="Proc.new{ _startcmd('http://mirichi.github.io/dxruby-doc/index.html') }"
145
+ proc_e="Proc.new{ _startcmd('http://mirichi.github.io/dxruby-doc/index.html') }" />
146
+
147
+ <uri id="ref_nyle" desc_j="Nyleリファレンス..."
148
+ desc_e="Nyle reference..."
149
+ acckey=""
150
+ proc_j="Proc.new{ _startcmd('https://github.com/spoolkitamura/nyle-doc-jp/wiki') }"
151
+ proc_e="Proc.new{ _startcmd('https://github.com/spoolkitamura/nyle-doc-en/wiki') }" />
152
+
153
+ <uri id="ref_rbpad" desc_j="rbpadヘルプ..."
154
+ desc_e="rbpad help..."
155
+ acckey=""
156
+ proc_j="Proc.new{ _startcmd('https://github.com/spoolkitamura/rbpad3-doc-jp/wiki') }"
157
+ proc_e="Proc.new{ _startcmd('https://github.com/spoolkitamura/rbpad3-doc-en/wiki') }" />
158
+
159
+ <menuitem id="ruby_ver" desc_j="Rubyバージョン"
160
+ desc_e="Ruby version"
161
+ acckey=""
162
+ proc="Proc.new{ _ruby_ver }" />
163
+
164
+ </menubar_action>
165
+
166
+ </actions>
@@ -0,0 +1,126 @@
1
+ <?xml version="1.0"?>
2
+
3
+ <actions>
4
+ <menubar_action>
5
+
6
+ <template id="gosu1" desc_j="Gosuテンプレート (クラス)"
7
+ desc_e="Gosu Template (Class)"
8
+ acckey=""
9
+ valid="t">
10
+ require 'gosu'
11
+
12
+ class Screen &lt; Gosu::Window
13
+ def initialize
14
+ super 640, 480, false
15
+ self.caption = 'Gosu'
16
+ end
17
+
18
+ def draw
19
+ end
20
+
21
+ def update
22
+ close if Gosu.button_down?(Gosu::KB_ESCAPE)
23
+ end
24
+ end
25
+
26
+ screen = Screen.new
27
+ screen.show
28
+
29
+ </template>
30
+
31
+ <template id="dxruby1" desc_j="DXRubyテンプレート"
32
+ desc_e="DXRuby Template"
33
+ acckey=""
34
+ valid="t">
35
+ require 'dxruby'
36
+
37
+ Window.caption = 'DXRuby Application'
38
+ Window.width = 640
39
+ Window.height = 480
40
+ Window.bgcolor = C_BLACK
41
+ Window.x = 260
42
+ Window.y = 240
43
+
44
+ Window.loop do
45
+ break if Input.key_release?(K_ESCAPE)
46
+ end
47
+
48
+ </template>
49
+
50
+ <template id="dxruby2" desc_j="DXRubyテンプレート (クラス)"
51
+ desc_e="DXRuby Template (Class)"
52
+ acckey=""
53
+ valid="t">
54
+ require 'dxruby'
55
+
56
+ class Screen
57
+ def initialize
58
+ Window.caption = 'DXRuby Application'
59
+ Window.width = 640
60
+ Window.height = 480
61
+ Window.bgcolor = C_BLACK
62
+ Window.x = 260
63
+ Window.y = 240
64
+ end
65
+
66
+ def draw
67
+ Window.loop do
68
+ break if Input.key_release?(K_ESCAPE)
69
+ end
70
+ end
71
+ end
72
+
73
+ screen = Screen.new
74
+ screen.draw
75
+
76
+ </template>
77
+
78
+ <template id="nyle1" desc_j="Nyleテンプレート"
79
+ desc_e="Nyle Template"
80
+ acckey=""
81
+ valid="t">
82
+ require 'nyle'
83
+
84
+ screen = Nyle.create_screen(640, 480, {bgcolor: :BLACK})
85
+
86
+ def screen.setup
87
+ end
88
+
89
+ def screen.draw
90
+ end
91
+
92
+ def screen.update
93
+ Nyle.quit if Nyle.key_release?(:ESCAPE)
94
+ end
95
+
96
+ screen.start
97
+
98
+ </template>
99
+
100
+ <template id="nyle2" desc_j="Nyleテンプレート (クラス)"
101
+ desc_e="Nyle Template (Class)"
102
+ acckey=""
103
+ valid="t">
104
+ require 'nyle'
105
+
106
+ class Screen &lt; Nyle::Screen
107
+ def initialize
108
+ super(640, 480, {bgcolor: :BLACK})
109
+ end
110
+
111
+ def draw
112
+ end
113
+
114
+ def update
115
+ Nyle.quit if Nyle.key_release?(:ESCAPE)
116
+ end
117
+ end
118
+
119
+ screen = Screen.new
120
+ screen.show_all
121
+ Nyle.main
122
+
123
+ </template>
124
+
125
+ </menubar_action>
126
+ </actions>
@@ -0,0 +1,27 @@
1
+ <?xml version='1.0'?>
2
+
3
+ <actions>
4
+ <toggle_action>
5
+ <checkitem id='drawspaces' value='true'>
6
+ <acckey>&lt;___&gt;U</acckey>
7
+ <desc_j>空白文字の表示</desc_j>
8
+ <desc_e>Show spaces</desc_e>
9
+ <proc>Proc.new{ |ag, action| _drawspaces(ag, action)}</proc>
10
+ <stockid>''</stockid>
11
+ </checkitem>
12
+ <checkitem id='blockmatch' value='true'>
13
+ <acckey>&lt;___&gt;B</acckey>
14
+ <desc_j>endブロック範囲の表示</desc_j>
15
+ <desc_e>Show end-blocks</desc_e>
16
+ <proc>Proc.new{ |ag, action| _blockmatch(ag, action)}</proc>
17
+ <stockid>''</stockid>
18
+ </checkitem>
19
+ <checkitem id='errorjp' value='true'>
20
+ <acckey>&lt;___&gt;J</acckey>
21
+ <desc_j>日本語エラーメッセージの補助出力</desc_j>
22
+ <desc_e>''</desc_e>
23
+ <proc>Proc.new{ }</proc>
24
+ <stockid>''</stockid>
25
+ </checkitem>
26
+ </toggle_action>
27
+ </actions>