rubytext 0.1.22 → 0.1.26

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc35032215721ae6cc67dcb1a801f94ea6eaabd68716362f62a1f82c84cf9c8e
4
- data.tar.gz: 4298fe621d895c5392a2170f0ec29ba043516e4f245d80d80ef5c99cc01e9526
3
+ metadata.gz: a0c50000434ad20cb7840df116171801b29d072998863cb0cb2703bf6336ca04
4
+ data.tar.gz: f96ba638ab88f3cf872d368e517c5c226fb2170e1d2bfb64b72c0322a7b1b6e5
5
5
  SHA512:
6
- metadata.gz: 210598d6cacdfbe8ae32ef68f9997d094038486068e2fb5b453578aea53cd4b075cc26a1d2f191419b79e22c800989312f8a1c4ffe23f322a3cd74ba3dfe25d3
7
- data.tar.gz: 63a08f8589711d9cb0b8c7224aba3fc5630dc474b24d92678c4ab0f3165d95689db0c1bee38a924c3f541a0a86863a83ca0de8a2f80607dc9e63aa73d7c18bb2
6
+ metadata.gz: 0c77ca1db3bf70632673e5870376a62fddbfbde1f26b6b66949514fae6ed63da5377867d08ec1f04bfa5b40a9f6c58b4521f5f6c9afdd02cbaa5e0af8372ca28
7
+ data.tar.gz: 93b54ed04273d55785a46b5e194dfe23f5cd0a15b5cd4e8553f031410c3516c98ccc3daf3a9548de7eb22ab4985cbea3176d2c7976e0cb87bfc04b99274e7051
@@ -0,0 +1,56 @@
1
+ if ARGV.size != 2
2
+ STDERR.puts "Usage: ruby ide.rb libname.rb progname.rb"
3
+ exit
4
+ end
5
+
6
+ require 'rubytext'
7
+
8
+ RubyText.start
9
+
10
+ @lib, @code = ARGV
11
+
12
+ def shell(str)
13
+ STDSCR.clear
14
+ RubyText.show_cursor
15
+ system("stty sane") # FIXME - dumb hack
16
+ STDSCR.puts "\n\n When you exit, you will\n return to the IDE.\n "
17
+ system(str)
18
+ Curses.noecho # FIXME Shouldn't have to do this stuff
19
+ Curses.stdscr.keypad(true)
20
+ Curses.cbreak # by default
21
+ end
22
+
23
+ items = ["Edit lib", # 0
24
+ "Edit code", # 1
25
+ "Run code", # 2
26
+ "pry", # 3
27
+ "Shell", # 4
28
+ "irb", # 5
29
+ "RubyDocs", # 6
30
+ "Quit"] # 7
31
+
32
+ def show
33
+ STDSCR.clear
34
+ puts
35
+ puts " World's Simplest Ruby IDE\n "
36
+ puts " Lib = #{@lib}"
37
+ puts " Code = #{@code}"
38
+ puts
39
+ end
40
+
41
+ loop do
42
+ show
43
+ n, str = STDSCR.menu(r: 10, c: 5, items: items)
44
+ puts n.inspect
45
+ case n
46
+ when 0; system("vi #{@lib}")
47
+ when 1; system("vi #{@code}")
48
+ when 2; system("tput clear; ruby #{@code}; sleep 5")
49
+ when 3; shell("pry")
50
+ when 4; shell("bash")
51
+ when 5; shell("irb")
52
+ when 6; system("open -a Safari http://ruby-doc.org")
53
+ when 7; exit
54
+ end
55
+ end
56
+
@@ -0,0 +1,11 @@
1
+ color.rb d552ca3774fec443741a1c7993a9faeabb51e171
2
+ effects.rb f80b21fd2814e2be300b43e90aca9ee49209079d
3
+ keys.rb f637ea231d87bd4626b52451ce1fa01eabb724ea
4
+ menu.rb 76eff0cd409b933d4a53464c2134a221a4f7f15c
5
+ navigation.rb 29c3bbe5165dd38fb27982974e491532b135f8f1
6
+ output.rb 01efbae8b21ef79d2fddb30c6e7c675fbec34130
7
+ rubytext.rb 00a98c8f3d89f41595f6587641447f5db3fffabf
8
+ rubytext_version.rb 6f68d9df18334626e2fafa09456e6b12b26aae75
9
+ settings.rb 655076feb7afef3252e650587b6e2ab25ed43634
10
+ widgets.rb fc1a9cf8fb9aa1a0b677dad687206eb27429b222
11
+ window.rb 5dca11357213d1dd54b0435ecaf4688a81e559f4
File without changes
Binary file
Binary file
Binary file
data/lib/color.rb CHANGED
@@ -5,20 +5,29 @@ Black, Blue, Cyan, Green, Magenta, Red, White, Yellow =
5
5
 
6
6
  Colors = [Black, Blue, Cyan, Green, Magenta, Red, White, Yellow]
7
7
 
8
+ # Handles color constants and fg/bg pairs
9
+
8
10
  class RubyText::Color
11
+
9
12
  Colors = ::Colors
10
13
 
11
14
  # FIXME some should be private
12
15
  # TODO add color-pair constants
13
16
 
17
+ # Convert Ruby symbol to curses color constant name
18
+
14
19
  def self.sym2const(color) # to curses constant
15
20
  Curses.const_get("COLOR_#{color.to_s.upcase}")
16
21
  end
17
22
 
23
+ # Find "our" color number
24
+
18
25
  def self.index(color)
19
26
  Colors.find_index(color) # "our" number
20
27
  end
21
28
 
29
+ # Define a fg/bg color pair
30
+
22
31
  def self.pair(fg, bg)
23
32
  nf, nb = index(fg), index(bg)
24
33
  num = 8*nf + nb
@@ -27,7 +36,12 @@ class RubyText::Color
27
36
  end
28
37
  end
29
38
 
39
+ # Reopening: Wrapper for curses windows
40
+
30
41
  class RubyText::Window
42
+
43
+ # Set up a window with fg/bg
44
+
31
45
  def self.colorize!(cwin, fg, bg)
32
46
  cp = RubyText::Color.pair(fg, bg)
33
47
  cwin.color_set(cp)
@@ -43,11 +57,15 @@ class RubyText::Window
43
57
  end
44
58
  end
45
59
 
60
+ # Assign color pair to curses window
61
+
46
62
  def set_colors(fg, bg)
47
63
  cp = RubyText::Color.pair(fg, bg)
48
64
  @cwin.color_set(cp)
49
65
  end
50
66
 
67
+ # Set up a window with fg/bg
68
+
51
69
  def colorize!(fg, bg)
52
70
  set_colors(fg, bg)
53
71
  num = @cwin.maxx * @cwin.maxy
@@ -56,10 +74,14 @@ class RubyText::Window
56
74
  @cwin.refresh
57
75
  end
58
76
 
77
+ # Set foreground color
78
+
59
79
  def fg=(sym)
60
80
  set_colors(sym, @bg)
61
81
  end
62
82
 
83
+ # Set background color
84
+
63
85
  def bg=(sym)
64
86
  set_colors(@fg, sym)
65
87
  end
@@ -0,0 +1,366 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: RubyText::Color
8
+
9
+ &mdash; Documentation by YARD 0.9.24
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "RubyText::Color";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (C)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../RubyText.html" title="RubyText (module)">RubyText</a></span></span>
41
+ &raquo;
42
+ <span class="title">Color</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: RubyText::Color
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">RubyText::Color</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>color.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>Handles color constants and fg/bg pairs</p>
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
112
+
113
+ </div>
114
+
115
+ <h2>
116
+ Constant Summary
117
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
118
+ </h2>
119
+
120
+ <dl class="constants">
121
+
122
+ <dt id="Colors-constant" class="">Colors =
123
+
124
+ </dt>
125
+ <dd><pre class="code"><span class='op'>::</span><span class='const'><span class='object_link'><a href="../top-level-namespace.html#Colors-constant" title="Colors (constant)">Colors</a></span></span></pre></dd>
126
+
127
+ </dl>
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+ <h2>
138
+ Class Method Summary
139
+ <small><a href="#" class="summary_toggle">collapse</a></small>
140
+ </h2>
141
+
142
+ <ul class="summary">
143
+
144
+ <li class="public ">
145
+ <span class="summary_signature">
146
+
147
+ <a href="#index-class_method" title="index (class method)">.<strong>index</strong>(color) &#x21d2; Object </a>
148
+
149
+
150
+
151
+ </span>
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+ <span class="summary_desc"><div class='inline'>
162
+ <p>Find “our” color number.</p>
163
+ </div></span>
164
+
165
+ </li>
166
+
167
+
168
+ <li class="public ">
169
+ <span class="summary_signature">
170
+
171
+ <a href="#pair-class_method" title="pair (class method)">.<strong>pair</strong>(fg, bg) &#x21d2; Object </a>
172
+
173
+
174
+
175
+ </span>
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+ <span class="summary_desc"><div class='inline'>
186
+ <p>Define a fg/bg color pair.</p>
187
+ </div></span>
188
+
189
+ </li>
190
+
191
+
192
+ <li class="public ">
193
+ <span class="summary_signature">
194
+
195
+ <a href="#sym2const-class_method" title="sym2const (class method)">.<strong>sym2const</strong>(color) &#x21d2; Object </a>
196
+
197
+
198
+
199
+ </span>
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+ <span class="summary_desc"><div class='inline'>
210
+ <p>Convert Ruby symbol to curses color constant name.</p>
211
+ </div></span>
212
+
213
+ </li>
214
+
215
+
216
+ </ul>
217
+
218
+
219
+
220
+
221
+ <div id="class_method_details" class="method_details_list">
222
+ <h2>Class Method Details</h2>
223
+
224
+
225
+ <div class="method_details first">
226
+ <h3 class="signature first" id="index-class_method">
227
+
228
+ .<strong>index</strong>(color) &#x21d2; <tt>Object</tt>
229
+
230
+
231
+
232
+
233
+
234
+ </h3><div class="docstring">
235
+ <div class="discussion">
236
+
237
+ <p>Find “our” color number</p>
238
+
239
+
240
+ </div>
241
+ </div>
242
+ <div class="tags">
243
+
244
+
245
+ </div><table class="source_code">
246
+ <tr>
247
+ <td>
248
+ <pre class="lines">
249
+
250
+
251
+ 25
252
+ 26
253
+ 27</pre>
254
+ </td>
255
+ <td>
256
+ <pre class="code"><span class="info file"># File 'color.rb', line 25</span>
257
+
258
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
259
+ <span class='const'><span class='object_link'><a href="#Colors-constant" title="RubyText::Color::Colors (constant)">Colors</a></span></span><span class='period'>.</span><span class='id identifier rubyid_find_index'>find_index</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span> <span class='comment'># &quot;our&quot; number
260
+ </span><span class='kw'>end</span></pre>
261
+ </td>
262
+ </tr>
263
+ </table>
264
+ </div>
265
+
266
+ <div class="method_details ">
267
+ <h3 class="signature " id="pair-class_method">
268
+
269
+ .<strong>pair</strong>(fg, bg) &#x21d2; <tt>Object</tt>
270
+
271
+
272
+
273
+
274
+
275
+ </h3><div class="docstring">
276
+ <div class="discussion">
277
+
278
+ <p>Define a fg/bg color pair</p>
279
+
280
+
281
+ </div>
282
+ </div>
283
+ <div class="tags">
284
+
285
+
286
+ </div><table class="source_code">
287
+ <tr>
288
+ <td>
289
+ <pre class="lines">
290
+
291
+
292
+ 31
293
+ 32
294
+ 33
295
+ 34
296
+ 35
297
+ 36</pre>
298
+ </td>
299
+ <td>
300
+ <pre class="code"><span class="info file"># File 'color.rb', line 31</span>
301
+
302
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_pair'>pair</span><span class='lparen'>(</span><span class='id identifier rubyid_fg'>fg</span><span class='comma'>,</span> <span class='id identifier rubyid_bg'>bg</span><span class='rparen'>)</span>
303
+ <span class='id identifier rubyid_nf'>nf</span><span class='comma'>,</span> <span class='id identifier rubyid_nb'>nb</span> <span class='op'>=</span> <span class='id identifier rubyid_index'>index</span><span class='lparen'>(</span><span class='id identifier rubyid_fg'>fg</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='lparen'>(</span><span class='id identifier rubyid_bg'>bg</span><span class='rparen'>)</span>
304
+ <span class='id identifier rubyid_num'>num</span> <span class='op'>=</span> <span class='int'>8</span><span class='op'>*</span><span class='id identifier rubyid_nf'>nf</span> <span class='op'>+</span> <span class='id identifier rubyid_nb'>nb</span>
305
+ <span class='const'>Curses</span><span class='period'>.</span><span class='id identifier rubyid_init_pair'>init_pair</span><span class='lparen'>(</span><span class='id identifier rubyid_num'>num</span><span class='comma'>,</span> <span class='id identifier rubyid_sym2const'>sym2const</span><span class='lparen'>(</span><span class='id identifier rubyid_fg'>fg</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_sym2const'>sym2const</span><span class='lparen'>(</span><span class='id identifier rubyid_bg'>bg</span><span class='rparen'>)</span><span class='rparen'>)</span>
306
+ <span class='id identifier rubyid_num'>num</span>
307
+ <span class='kw'>end</span></pre>
308
+ </td>
309
+ </tr>
310
+ </table>
311
+ </div>
312
+
313
+ <div class="method_details ">
314
+ <h3 class="signature " id="sym2const-class_method">
315
+
316
+ .<strong>sym2const</strong>(color) &#x21d2; <tt>Object</tt>
317
+
318
+
319
+
320
+
321
+
322
+ </h3><div class="docstring">
323
+ <div class="discussion">
324
+
325
+ <p>Convert Ruby symbol to curses color constant name</p>
326
+
327
+
328
+ </div>
329
+ </div>
330
+ <div class="tags">
331
+
332
+
333
+ </div><table class="source_code">
334
+ <tr>
335
+ <td>
336
+ <pre class="lines">
337
+
338
+
339
+ 19
340
+ 20
341
+ 21</pre>
342
+ </td>
343
+ <td>
344
+ <pre class="code"><span class="info file"># File 'color.rb', line 19</span>
345
+
346
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_sym2const'>sym2const</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span> <span class='comment'># to curses constant
347
+ </span> <span class='const'>Curses</span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>COLOR_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_upcase'>upcase</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
348
+ <span class='kw'>end</span></pre>
349
+ </td>
350
+ </tr>
351
+ </table>
352
+ </div>
353
+
354
+ </div>
355
+
356
+ </div>
357
+
358
+ <div id="footer">
359
+ Generated on Sat Feb 8 04:23:59 2020 by
360
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
361
+ 0.9.24 (ruby-2.4.2).
362
+ </div>
363
+
364
+ </div>
365
+ </body>
366
+ </html>