sleipnir-api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. data/History.txt +3 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +41 -0
  4. data/README.txt +56 -0
  5. data/Rakefile +201 -0
  6. data/TODO.txt +11 -0
  7. data/examples/reload.rb +18 -0
  8. data/helper/helper.rb +3 -0
  9. data/helper/rake.rb +58 -0
  10. data/helper/rake_sh_filter.rb +23 -0
  11. data/helper/util.rb +19 -0
  12. data/lib/sleipnir_api.rb +177 -0
  13. data/lib/sleipnir_api/dialog.rb +155 -0
  14. data/lib/sleipnir_api/key_state.rb +49 -0
  15. data/lib/sleipnir_api/output.rb +319 -0
  16. data/lib/sleipnir_api/process.rb +69 -0
  17. data/lib/sleipnir_api/profile.rb +332 -0
  18. data/lib/sleipnir_api/registry.rb +30 -0
  19. data/lib/sleipnir_api/security.rb +263 -0
  20. data/lib/sleipnir_api/sleipnir.rb +489 -0
  21. data/lib/sleipnir_api/tab.rb +359 -0
  22. data/lib/sleipnir_api/util.rb +16 -0
  23. data/lib/sleipnir_api/version.rb +9 -0
  24. data/lib/sleipnir_api/win32api.rb +17 -0
  25. data/scripts/rdoc_filter.rb +74 -0
  26. data/setup.rb +1585 -0
  27. data/spec/matchers/path_eql.rb +41 -0
  28. data/spec/sleipnir_api/dialog_mock_spec.rb +99 -0
  29. data/spec/sleipnir_api/key_state_mock_spec.rb +72 -0
  30. data/spec/sleipnir_api/output_spec.rb +242 -0
  31. data/spec/sleipnir_api/profile_mock_spec.rb +128 -0
  32. data/spec/sleipnir_api/registry_spec.rb +13 -0
  33. data/spec/sleipnir_api/security_mock_spec.rb +82 -0
  34. data/spec/sleipnir_api/security_spec.rb +129 -0
  35. data/spec/sleipnir_api/sleipnir_mock_spec.rb +70 -0
  36. data/spec/sleipnir_api/sleipnir_spec.rb +295 -0
  37. data/spec/sleipnir_api/tab_mock_spec.rb +98 -0
  38. data/spec/sleipnir_api/tab_spec.rb +105 -0
  39. data/spec/sleipnir_api_spec.rb +17 -0
  40. data/spec/spec.opts +0 -0
  41. data/spec/spec_helper.rb +8 -0
  42. metadata +91 -0
@@ -0,0 +1,19 @@
1
+ def windows?
2
+ RUBY_PLATFORM =~ /win/
3
+ end
4
+
5
+ def with_temporary_rename(from, to)
6
+ mv from, to
7
+ yield
8
+ ensure
9
+ mv to, from
10
+ end
11
+
12
+ def has_dot?
13
+ if windows?
14
+ v = `dot -V 2>&1` rescue nil
15
+ v and v =~ /Graphviz/
16
+ else
17
+ `which dot` =~ /\/dot/
18
+ end
19
+ end
@@ -0,0 +1,177 @@
1
+ require "win32ole"
2
+
3
+ require "sleipnir_api/version"
4
+ require "sleipnir_api/registry"
5
+ require "sleipnir_api/process"
6
+ require "sleipnir_api/sleipnir"
7
+
8
+ #
9
+ # = Overview
10
+ #
11
+ # == Class / Module
12
+ #
13
+ # * SleipnirAPI
14
+ #
15
+ # このモジュールは Sleipnir の COM サーバ (Sleipnir.API) に接続するための
16
+ # メソッドを提供します。
17
+ #
18
+ # まず new または connect を利用して SleipnirAPI::Sleipnir オブジェクトを取得します。
19
+ #
20
+ # * SleipnirAPI::Sleipnir
21
+ #
22
+ # Sleipnir 全体を操作する API を定義しています。
23
+ # 各ドキュメントを操作する場合は SleipnirAPI::Sleipnir#tab メソッドで
24
+ # SleipnirAPI::Tab を取得して行います。
25
+ #
26
+ # このオブジェクトは SleipnirAPI.new または SleipnirAPI.connect で取得します。
27
+ #
28
+ # SleipnirAPI::KeyState と SleipnirAPI::Dialog で定義されているメソッドが利用できます。
29
+ #
30
+ # * SleipnirAPI::Tab
31
+ #
32
+ # タブ固有の API (Sleipnir.API でドキュメント ID を引数に取る API) を定義しています。
33
+ #
34
+ # このオブジェクトは Sleipnir.API の ドキュメント ID を抽象化したものです。
35
+ # 実際のドキュメントオブジェクト (DispHTMLDocument) の抽象化は行いません。
36
+ #
37
+ # SleipnirAPI::KeyState と SleipnirAPI::Dialog で定義されているメソッドが利用できます。
38
+ # Sleipnir.API の ShiftDown や InputBox はタブ固有の API ではありませんが、
39
+ # 利便性のため SleipnirAPI::Tab でも利用できるようにしてあります。
40
+ #
41
+ # * SleipnirAPI::Security
42
+ #
43
+ # 各タブのセキュリティ設定を変更する API を定義しています。
44
+ #
45
+ # SleipnirAPI::Security::Config またはハッシュを利用して設定を変更できます。
46
+ #
47
+ # * SleipnirAPI::Output
48
+ #
49
+ # スクリプトのアウトプットバーを操作する API を定義しています。
50
+ # SleipnirAPI::Sleipnir#output で取得します。
51
+ #
52
+ # * SleipnirAPI::Profile
53
+ #
54
+ # ini ファイルを操作する API を定義しています。
55
+ # SleipnirAPI::Sleipnir#profile で取得します。
56
+ #
57
+ # == Utility
58
+ #
59
+ # * SleipnirAPI::KeyState
60
+ #
61
+ # Sleipnir.API の ShiftDown, AltDown, CtrlDown の wrapper API を定義します。
62
+ # SleipnirAPI::Sleipnir および SleipnirAPI::Tab でこのモジュールで定義しているメソッドが利用できます。
63
+ #
64
+ # * SleipnirAPI::Dialog
65
+ #
66
+ # Sleipnir.API の InputBox や MessegeBox などのダイアログ API を定義します。
67
+ # SleipnirAPI::Sleipnir および SleipnirAPI::Tab でこのモジュールで定義しているメソッドが利用できます。
68
+ #
69
+ # * SleipnirAPI::VERSION
70
+ #
71
+ # 本ライブラリ (Sleipnir.API の ruby wrapper) のバージョンを定義します。
72
+ # Sleipnir 自体のバージョンは SleipnirAPI::Sleipnir の version から取得できます。
73
+ #
74
+ #
75
+ # === 非互換性
76
+ #
77
+ # Sleipnir 1.xx と Sleipnir 2.xx で API の動作が違う場合は
78
+ # Sleipnir 1.xx の動作に合わせるようにしてあります。
79
+ # そのため、Sleipnir 2.xx 用に書かれたスクリプトをそのまま
80
+ # 移植すると動かない場合があります。
81
+ #
82
+ # 現時点で判明している動作が違う API は以下のとおりです。
83
+ #
84
+ # * SleipnirAPI::Output#insert
85
+ #
86
+ module SleipnirAPI
87
+
88
+ #:stopdoc:
89
+ class SleipnirError < StandardError; end
90
+ class ConnectError < SleipnirError; end
91
+ class ProcessError < SleipnirError; end
92
+ class NotImplementedError < SleipnirError; end
93
+ #:startdoc:
94
+
95
+ class <<self
96
+ include SleipnirAPI::Registry
97
+
98
+ # call-seq:
99
+ # SleipnirAPI.new(quit_on_finish=false) {|pnir| block }
100
+ # SleipnirAPI.new() -> SleipniAPI::Sleipnir object
101
+ #
102
+ # Sleipnir が起動していない場合は Sleipnir を起動して
103
+ # Sleipnir.API サーバに接続します。
104
+ #
105
+ # 既に起動している場合は、その Sleipnir に接続します。
106
+ #
107
+ # ==== params
108
+ #
109
+ # * <tt>quit_on_finish</tt>
110
+ #
111
+ # true の場合、block 終了時に Sleipnir を終了します。
112
+ # block を指定しない場合、この引数は無視されます。
113
+ #
114
+ # ==== return value
115
+ #
116
+ # * block を指定しない場合 SleipnirAPI::Sleipnir オブジェクトを返します。
117
+ # * block を指定した場合は SleipnirAPI::Sleipnir オブジェクトを block の
118
+ # 引数として block を実行し、block の実行結果を返します。
119
+ #
120
+ # ==== example
121
+ #
122
+ # Sleipnir を起動して接続、block 終了時に Sleipnir を終了:
123
+ #
124
+ # SleipnirAPI.new(true) do |pnir|
125
+ # pnir.each do |tab|
126
+ # puts tab.document.location.href
127
+ # end
128
+ # end
129
+ #
130
+ def new(quit_on_finish = false, &block)
131
+ unless SleipnirAPI::Process.exist?
132
+ SleipnirAPI::Process.create
133
+ end
134
+ connect(quit_on_finish, &block)
135
+ end
136
+
137
+ #
138
+ # call-seq:
139
+ # SleipnirAPI.connect(quit_on_finish=false) {|pnir| block }
140
+ # SleipnirAPI.connect() -> SleipniAPI::Sleipnir object
141
+ #
142
+ # 既に起動している Sleipnir の Sleipnir.API サーバに接続します。
143
+ #
144
+ # Sleipnir が起動していない場合は例外を投げます。
145
+ #
146
+ # 引数と戻り値は new と同じです。
147
+ #
148
+ # ==== example
149
+ #
150
+ # 起動中の Sleipnir に接続 (block を使わない):
151
+ #
152
+ # pnir = SleipnirAPI.connect
153
+ # pnir.each do |tab|
154
+ # puts tab.document.location.href
155
+ # end
156
+ #
157
+ def connect(quit_on_finish = false)
158
+ unless SleipnirAPI::Process.exist?
159
+ raise SleipnirAPI::ConnectError, "Sleipnir.API does not running"
160
+ end
161
+ pnir = SleipnirAPI::Sleipnir.new(create_sleipnir_ole_object)
162
+ return pnir unless block_given?
163
+
164
+ begin
165
+ yield pnir
166
+ ensure
167
+ pnir.quit if quit_on_finish
168
+ end
169
+ end
170
+
171
+ def create_sleipnir_ole_object
172
+ WIN32OLE.new(PROG_ID)
173
+ end
174
+ private :create_sleipnir_ole_object
175
+
176
+ end
177
+ end
@@ -0,0 +1,155 @@
1
+ module SleipnirAPI
2
+
3
+ #
4
+ # このモジュールは Sleipnir のダイアログを操作する API を定義しています。
5
+ #
6
+ # SleipnirAPI::Sleipnir、SleipnirAPI::Tab クラスでこのモジュールの API を利用できます。
7
+ #
8
+ # pnir.beep
9
+ # pnir.message_box("処理が終わりました")
10
+ #
11
+ # tab = pnir.active_tab
12
+ # r, v = tab.input_box("パスワード", :mask => true)
13
+ # if r == :ok
14
+ # puts "パスワード: #{v}"
15
+ # else
16
+ # puts "キャンセル"
17
+ # end
18
+ #
19
+ module Dialog
20
+
21
+ # Sleipnir のメッセージボックスを表示します。
22
+ def message_box(message)
23
+ self.sleipnir.api.MessageBox(message)
24
+ end
25
+
26
+ #
27
+ # WinAPI::MessageBox を呼び出します。
28
+ #
29
+ # * <tt>prompt</tt>: メッセージボックスに表示する文字列を指定します
30
+ # * <tt>title</tt>: メッセージボックスのタイトルを指定します
31
+ # * <tt>flag</tt>: WinAPI::MessageBox の値と同じ値を指定します
32
+ #
33
+ # 戻り値は WinAPI::MessageBox のと同じ値です。
34
+ #
35
+ def msgbox(prompt, title, flag)
36
+ self.sleipnir.api.MsgBox(prompt, title, flag)
37
+ end
38
+
39
+ # Beep 音を鳴らします。
40
+ def beep
41
+ self.sleipnir.api.Beep
42
+ end
43
+
44
+ #
45
+ # call-seq:
46
+ # input_box(prompt)
47
+ # input_box(prompt, :default => "default value")
48
+ # input_box(prompt, mask => true)
49
+ # input_box(prompt, mask => true, :default => "default value")
50
+ #
51
+ # 文字列を入力するダイアログを表示します。
52
+ #
53
+ # * <tt>:mask</tt> キーワード引数に true を指定した場合、入力欄はマスクで保護されます。
54
+ # * <tt>:default</tt> キーワード引数で初期値を指定できます。
55
+ #
56
+ # 戻り値は押したボタンと入力欄の値を配列で返します。
57
+ # キャンセルされた場合は、<tt>:default</tt> で指定した値を返します。
58
+ #
59
+ # pnir.input_box("名前", :default => "sleipnir")
60
+ # # firefox を入力し ok を押した場合 => [:ok, "firefox"]
61
+ # # 〃 cancel を押した場合 => [:cancel, "sleipnir"]
62
+ #
63
+ def input_box(prompt, opts = nil)
64
+ opts ||= {}
65
+ if opts[:masked] or opts[:mask]
66
+ r = self.sleipnir.api.MaskedInputBox(prompt, opts[:default])
67
+ else
68
+ r = self.sleipnir.api.InputBox(prompt, opts[:default])
69
+ end
70
+
71
+ if self.sleipnir.api.Result.zero?
72
+ [:cancel, r]
73
+ else
74
+ [:ok, r]
75
+ end
76
+ end
77
+
78
+ end
79
+ end
80
+
81
+
82
+ __END__
83
+
84
+ ──────────────────
85
+ [void] MessageBox(string strMessage)
86
+ ──────────────────
87
+
88
+ [説明]
89
+  Sleipnir のメッセージボックスを表示する。
90
+
91
+ [引数]
92
+  strMessgae: 表示するメッセージ
93
+
94
+ [戻り値]
95
+  なし
96
+
97
+
98
+ ─────────
99
+ [void] Beep(void)
100
+ ─────────
101
+
102
+ [説明]
103
+  Beep 音を鳴らす。
104
+
105
+ [戻り値]
106
+  なし
107
+
108
+
109
+ ───────────────────────────
110
+ [string] InputBox(string strPrompt, string strDefault)
111
+ ───────────────────────────
112
+
113
+ [説明]
114
+  文字列を入力するダイアログを表示する。
115
+
116
+ [引数]
117
+  strPrompt: プロンプト
118
+  strDefault: デフォルトの文字列
119
+
120
+ [戻り値]
121
+  OK の場合は編集された文字列、Cancel の場合は strDefault
122
+  ※Result プロパティに 1(OK)、0(Cancel)が設定される。
123
+
124
+
125
+ ─────────────────────────────
126
+ string MaskedInputBox(string strPrompt, string strDefault)
127
+ ─────────────────────────────
128
+
129
+ [説明]
130
+  マスクで保護された文字列を入力するダイアログを表示する。
131
+
132
+ [引数]
133
+  strPrompt: プロンプト
134
+  strDefault: デフォルトの文字列
135
+
136
+ [戻り値]
137
+  OK の場合は編集された文字列、Cancel の場合は strDefault
138
+  ※Result プロパティに 1(OK)、0(Cancel)が設定される。
139
+
140
+
141
+ ──────────────────────────────
142
+ [long] MsgBox(string strPrompt, string strTitle, long lFlag)
143
+ ──────────────────────────────
144
+
145
+ [説明]
146
+  WinAPI::MessageBox を呼び出す。
147
+
148
+ [引数]
149
+  strPrompt: メッセージボックスに表示する文字列
150
+  strTitle: メッセージボックスのタイトル
151
+  lFlag: WinAPI::MessageBox の値と同じ
152
+
153
+ [戻り値]
154
+  WinAPI::MessageBox の戻り値と同じ
155
+
@@ -0,0 +1,49 @@
1
+ require "sleipnir_api/util"
2
+
3
+ module SleipnirAPI
4
+
5
+ #
6
+ # このモジュールは Sleipnir のキーの状態を取得する API を定義しています。
7
+ #
8
+ # SleipnirAPI::Sleipnir、SleipnirAPI::Tab クラスでこのモジュールの API を利用できます。
9
+ #
10
+ # pnir.shift_down?
11
+ # pnir.alt_down?
12
+ # pnir.ctrl_down?
13
+ #
14
+ module KeyState
15
+ include SleipnirAPI::Util
16
+
17
+ # Shift キーが押下されている場合 true を返します。
18
+ #
19
+ # Sleipnir バージョンが 1.30 より低い場合例外を投げます。
20
+ def shift_down?
21
+ ensure_version 130
22
+ self.sleipnir.api.ShiftDown
23
+ end
24
+
25
+ # Ctrl キーが押下されている場合 true を返します。
26
+ #
27
+ # Sleipnir バージョンが 1.30 より低い場合例外を投げます。
28
+ def ctrl_down?
29
+ ensure_version 130
30
+ self.sleipnir.api.CtrlDown
31
+ end
32
+
33
+ # Alt キーが押下されている場合 true を返します。
34
+ #
35
+ # Sleipnir バージョンが 1.30 より低い場合例外を投げます。
36
+ def alt_down?
37
+ ensure_version 130
38
+ self.sleipnir.api.AltDown
39
+ end
40
+
41
+ end
42
+ end
43
+
44
+ __END__
45
+ // 1.30 以降
46
+
47
+ [bool] ShiftDown(R) Shift キーの状態を返す。
48
+ [bool] CtrlDown(R) Ctrl キーの状態を返す。
49
+ [bool] AltDown(R) Alt キーの状態を返す。
@@ -0,0 +1,319 @@
1
+ require "sleipnir_api/util"
2
+
3
+ module SleipnirAPI
4
+
5
+ #
6
+ # このクラスは Sleipnir の COM オブジェクト (Sleipnir.API) の wrapper クラスです。
7
+ # Sleipnir のアウトプットバーを操作する API を定義しています。
8
+ #
9
+ # * このオブジェクトは SleipnirAPI::Sleipnir#output で取得します。
10
+ # * このクラスは Enumerable を include しています。
11
+ #
12
+ # 例:
13
+ #
14
+ # pnir = SleipnirAPI.new
15
+ # output = pnir.output
16
+ # output.clear
17
+ # output.show
18
+ # output << "foo"
19
+ # output << "fooo"
20
+ # output << "bar"
21
+ # output.count #=> 3
22
+ # output.getlines #=> ["foo", "fooo", "bar"]
23
+ #
24
+ # # Enumerable method
25
+ # output.grep(/foo/) #=> ["foo", "fooo"]
26
+ #
27
+ class Output
28
+ include Enumerable
29
+ include SleipnirAPI::Util
30
+
31
+ # SleipnirAPI::Sleipnir object
32
+ attr_reader :sleipnir
33
+
34
+ def initialize(sleipnir)
35
+ @sleipnir = sleipnir
36
+ end
37
+
38
+
39
+ # アウトプットバーの可視状態を取得します。
40
+ #
41
+ # Sleipnir バージョンが 1.30 より低い場合例外を投げます。
42
+ def visible?
43
+ ensure_version 130
44
+ api.OutputVisible
45
+ end
46
+
47
+ # アウトプットバーの可視状態を設定します。
48
+ #
49
+ # Sleipnir バージョンが 1.30 より低い場合例外を投げます。
50
+ def visible=(show)
51
+ ensure_version 130
52
+ api.OutputVisible=(show) #:nodoc:
53
+ end
54
+
55
+ # アウトプットバーの表示します。
56
+ #
57
+ # Sleipnir バージョンが 1.30 より低い場合例外を投げます。
58
+ def show
59
+ self.visible = true
60
+ end
61
+
62
+ # アウトプットバーの隠します。
63
+ #
64
+ # Sleipnir バージョンが 1.30 より低い場合例外を投げます。
65
+ def hide
66
+ self.visible = false
67
+ end
68
+
69
+ # アウトプットバーの選択行の行番号を取得します。
70
+ #
71
+ # Sleipnir バージョンが 1.30 より低い場合例外を投げます。
72
+ def cursor
73
+ ensure_version 130
74
+ api.OutputCurSel
75
+ end
76
+
77
+ # アウトプットバーの選択行を設定します。
78
+ #
79
+ # Sleipnir バージョンが 1.30 より低い場合例外を投げます。
80
+ #
81
+ # * +lineno+ が範囲外の場合、カーソルは -1 に設定されます。
82
+ def cursor=(lineno)
83
+ ensure_version 130
84
+ if (0...count).include?(lineno)
85
+ api.OutputCurSel=(lineno) #:nodoc:
86
+ else
87
+ api.OutputCurSel=(-1) #:nodoc:
88
+ end
89
+ end
90
+
91
+ # アウトプットでダブルクリックされた時に呼ばれるスクリプトファイルを取得します。
92
+ #
93
+ # Sleipnir バージョンが 1.30 より低い場合例外を投げます。
94
+ def script
95
+ ensure_version 130
96
+ api.OutputScript
97
+ end
98
+
99
+ # アウトプットでダブルクリックされた時に呼ばれるスクリプトファイルを設定します。
100
+ #
101
+ # Sleipnir バージョンが 1.30 より低い場合例外を投げます。
102
+ def script=(filename)
103
+ ensure_version 130
104
+ api.OutputScript=(filename) #:nodoc:
105
+ end
106
+
107
+
108
+ # アウトプットに出力されている文字列の行数を取得します。
109
+ def count
110
+ api.OutputGetCount
111
+ end
112
+
113
+ # アウトプットの最後に文字列を追加します。
114
+ #
115
+ # カーソルは最後に移動します。
116
+ def add(string)
117
+ api.OutputAddString(string)
118
+ end
119
+ alias << add
120
+
121
+ # アウトプットに複数の文字列を追加します。
122
+ def concat(*strings)
123
+ strings.flatten.compact.each do |str|
124
+ add(str)
125
+ end
126
+ end
127
+
128
+ # アウトプットに文字列を挿入します。
129
+ #
130
+ # * 文字列は指定された行に挿入されます。
131
+ # * カーソルは +n+ に移動します。
132
+ #
133
+ # ==== 非互換
134
+ #
135
+ # * Sleipnir 2.x では OutputInsertString 後にカーソルは移動しませんが、
136
+ # このメソッドはカーソルが移動します。
137
+ # Sleipnir 1.x の動作にあわせています。
138
+ #
139
+ def insert(n, string)
140
+ if (0..count).include?(n)
141
+ api.OutputInsertString(n, string)
142
+ self.cursor = n if sleipnir.v2?
143
+ else
144
+ self.cursor = -1
145
+ end
146
+ end
147
+
148
+ # アウトプットに文字列を挿入します。
149
+ #
150
+ # * 文字列は現在のカーソル行の前行に挿入されます。
151
+ # * カーソルがさしている行は変わりません (== insert された分カーソル行が +1 されます)
152
+ def insert_before(string)
153
+ insert(cursor, string)
154
+ self.cursor += 1
155
+ end
156
+
157
+ # アウトプットに文字列を挿入します。
158
+ #
159
+ # * 文字列は現在のカーソル行の次行に挿入されます。
160
+ # * カーソルの移動しません。
161
+ def insert_after(string)
162
+ c = cursor
163
+ insert(c + 1, string)
164
+ self.cursor = c
165
+ end
166
+
167
+ # アウトプットをクリアします。
168
+ def clear
169
+ api.OutputClear
170
+ end
171
+
172
+ # アウトプットから指定された行を削除します。
173
+ #
174
+ # * 引数を省略すると現在のカーソル行を削除します。
175
+ # * 削除する行番号は配列や Range を指定可能です。
176
+ #
177
+ # 例:
178
+ #
179
+ # o = pnir.output
180
+ # o.delete # 現在のカーソル行を削除
181
+ # o.delete(0) # 0 行を削除
182
+ # o.delete(1, 3, 5) # 1, 3, 5 行を削除
183
+ # o.delete([1, 3, 5]) # 同上
184
+ # o.delete(0...5) # 0, 1, 2, 3, 4 行を削除
185
+ # o.dekete(1, 2..3, 10...15) # 1, 2, 3, 10, 11, 12, 13, 14 行を削除
186
+ #
187
+ def delete(*lines)
188
+ if lines.empty?
189
+ delete(self.cursor)
190
+ else
191
+ lines.map{|e| Array(e) }.flatten.compact.sort.uniq.reverse.each do |e|
192
+ api.OutputDeleteString(e)
193
+ end
194
+ end
195
+ end
196
+
197
+ # アウトプットから指定された行を取得します。
198
+ #
199
+ # * +n+ を省略すると現在のカーソル行の文字列を取得します。
200
+ # * +n+ が範囲外の場合 +nil+ を返します。
201
+ def get(n = cursor)
202
+ if (0...count).include?(n)
203
+ api.OutputGetString(n)
204
+ end
205
+ end
206
+
207
+ # アウトプットに出力されている全行を配列で取得します。
208
+ def getlines
209
+ (0...count).map{|i| get(i) }
210
+ end
211
+
212
+ # call-seq:
213
+ # each {|line| ... }
214
+ #
215
+ # アウトプットに出力されている全行を走査します。
216
+ def each
217
+ i = 0
218
+ while i < count
219
+ self.cursor = i
220
+ yield get(i)
221
+ i = i + 1
222
+ end
223
+ end
224
+
225
+ end
226
+ end
227
+
228
+
229
+ __END__
230
+ [bool] OutputVisible アウトプットバーの可視状態を取得/設定する。
231
+ [long] OutputCurSel アウトプットバーの選択行を取得/設定する。
232
+ [string] OutputScript アウトプットでダブルクリックされた時に呼ばれるスクリ
233
+ プトファイルを取得/設定する。このスクリプトは引数とし
234
+ て /output:選択行 が渡される。
235
+
236
+ ────────────
237
+ [long] OutputGetCount()
238
+ ────────────
239
+
240
+ [説明]
241
+  アウトプットに出力されている文字列の行数を取得する。
242
+
243
+ [引数]
244
+  なし
245
+
246
+ [戻り値]
247
+  行数
248
+
249
+
250
+ ─────────────────
251
+ [void] OutputAddString(string str)
252
+ ─────────────────
253
+
254
+ [説明]
255
+  アウトプットに文字列を追加する。
256
+
257
+ [引数]
258
+  str: 出力する文字列
259
+
260
+ [戻り値]
261
+  なし
262
+
263
+
264
+ ───────────────────────
265
+ [void] OutputInsertString(long n, string str)
266
+ ───────────────────────
267
+
268
+ [説明]
269
+  アウトプットに文字列を挿入する。
270
+
271
+ [引数]
272
+  n: 挿入する位置
273
+  str: 出力する文字列
274
+
275
+ [戻り値]
276
+  なし
277
+
278
+
279
+ ──────────
280
+ [void] OutputClear()
281
+ ──────────
282
+
283
+ [説明]
284
+  アウトプットをクリアする。
285
+
286
+ [引数]
287
+  なし
288
+
289
+ [戻り値]
290
+  なし
291
+
292
+
293
+ ────────────────
294
+ [string] OutputGetString(long n)
295
+ ────────────────
296
+
297
+ [説明]
298
+  アウトプットから文字列を取得する。
299
+
300
+ [引数]
301
+  n: 取得する行
302
+
303
+ [戻り値]
304
+  文字列
305
+
306
+
307
+ ─────────────────
308
+ [void] OutputDeleteString(long n)
309
+ ─────────────────
310
+
311
+ [説明]
312
+  アウトプットから文字列を削除する。
313
+
314
+ [引数]
315
+  n: 削除する行
316
+
317
+ [戻り値]
318
+  なし
319
+