green_shoes 0.233.0 → 0.243.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/green_shoes.rb +4 -0
- data/lib/shoes/app.rb +53 -7
- data/lib/shoes/basic.rb +31 -3
- data/lib/shoes/help.rb +121 -38
- data/lib/shoes/helper_methods.rb +15 -6
- data/lib/shoes/widget.rb +3 -1
- data/samples/sample51.rb +1 -5
- data/static/manual-en.txt +86 -22
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.243.0
|
data/lib/green_shoes.rb
CHANGED
@@ -21,6 +21,10 @@ module Shoes
|
|
21
21
|
VERSION = IO.read(File.join(DIR, '../VERSION')).chomp
|
22
22
|
BASIC_ATTRIBUTES_DEFAULT = {left: 0, top: 0, width: 0, height: 0, angle: 0, curve: 0}
|
23
23
|
SLOT_ATTRIBUTES_DEFAULT = {left: nil, top: nil, width: 1.0, height: 0}
|
24
|
+
KEY_NAMES = %w[exclam quotedbl numbersign dollar percent ampersand apostrophe
|
25
|
+
parenleft parenright minus asciicircum backslash equal asciitilde bar grave at braceleft
|
26
|
+
bracketleft braceright bracketright plus asterisk semicolon colon less greater question
|
27
|
+
comma period slash backslash space]
|
24
28
|
end
|
25
29
|
|
26
30
|
class Object
|
data/lib/shoes/app.rb
CHANGED
@@ -25,13 +25,13 @@ class Shoes
|
|
25
25
|
@width_pre, @height_pre = @width, @height
|
26
26
|
@link_style, @linkhover_style = LINK_DEFAULT, LINKHOVER_DEFAULT
|
27
27
|
@context_angle = @pixbuf_rotate = 0
|
28
|
-
Shoes.APPS << self
|
28
|
+
(Shoes.APPS << self) unless @noapp
|
29
29
|
end
|
30
30
|
|
31
31
|
attr_accessor :cslot, :cmask, :top_slot, :contents, :canvas, :app, :mccs, :mrcs, :mmcs,
|
32
32
|
:mhcs, :mlcs, :shcs, :mcs, :win, :swin, :width_pre, :height_pre, :order, :dics, :fronts, :backs
|
33
33
|
attr_writer :mouse_button, :mouse_pos
|
34
|
-
attr_reader :link_style, :linkhover_style, :animates, :owner, :textcursors
|
34
|
+
attr_reader :link_style, :linkhover_style, :animates, :owner, :textcursors, :textmarkers
|
35
35
|
|
36
36
|
def visit url
|
37
37
|
if url =~ /^(http|https):\/\//
|
@@ -51,13 +51,52 @@ class Shoes
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def stack args={}, &blk
|
54
|
-
args[:
|
55
|
-
|
54
|
+
if args[:scroll]
|
55
|
+
slot_with_scrollbar Stack, args, &blk
|
56
|
+
else
|
57
|
+
args[:app] = self
|
58
|
+
Stack.new slot_attributes(args), &blk
|
59
|
+
end
|
56
60
|
end
|
57
61
|
|
58
62
|
def flow args={}, &blk
|
59
|
-
args[:
|
60
|
-
|
63
|
+
if args[:scroll]
|
64
|
+
slot_with_scrollbar Flow, args, &blk
|
65
|
+
else
|
66
|
+
args[:app] = self
|
67
|
+
Flow.new slot_attributes(args), &blk
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def slot_with_scrollbar slot, args={}, &blk
|
72
|
+
args[:left] ||= 0
|
73
|
+
args[:top] ||= 0
|
74
|
+
args[:width] ||= 200
|
75
|
+
args[:height] ||= 200
|
76
|
+
|
77
|
+
app = App.new noapp: true
|
78
|
+
app.instance_variable_set :@_w, args[:width]
|
79
|
+
app.instance_variable_set :@_h, args[:height]
|
80
|
+
def app.width; @_w end
|
81
|
+
def app.height; @_h end
|
82
|
+
app.win = win
|
83
|
+
|
84
|
+
swin = Gtk::ScrolledWindow.new
|
85
|
+
swin.set_size_request args[:width], args[:height]
|
86
|
+
swin.set_policy Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC
|
87
|
+
swin.vadjustment.step_increment = 10
|
88
|
+
|
89
|
+
layout = Gtk::Layout.new
|
90
|
+
swin.add layout
|
91
|
+
layout.style = @canvas.style
|
92
|
+
|
93
|
+
app.canvas = layout
|
94
|
+
app.top_slot = slot.new app.slot_attributes(app: app, left: args[:left], top: args[:top], width: args[:width], height: args[:height])
|
95
|
+
|
96
|
+
app.instance_eval &blk
|
97
|
+
|
98
|
+
@canvas.put swin, args[:left], args[:top]
|
99
|
+
app.top_slot
|
61
100
|
end
|
62
101
|
|
63
102
|
def mask &blk
|
@@ -284,7 +323,14 @@ class Shoes
|
|
284
323
|
def keypress &blk
|
285
324
|
win.set_events Gdk::Event::BUTTON_PRESS_MASK | Gdk::Event::BUTTON_RELEASE_MASK | Gdk::Event::POINTER_MOTION_MASK | Gdk::Event::KEY_PRESS_MASK
|
286
325
|
win.signal_connect("key_press_event") do |w, e|
|
287
|
-
|
326
|
+
k = Gdk::Keyval.to_name e.keyval
|
327
|
+
k = case
|
328
|
+
when Shoes::KEY_NAMES.include?(k); e.keyval.chr
|
329
|
+
when k == 'Return'; "\n"
|
330
|
+
when k == 'Tab'; "\t"
|
331
|
+
else k
|
332
|
+
end
|
333
|
+
blk[k]
|
288
334
|
end
|
289
335
|
end
|
290
336
|
|
data/lib/shoes/basic.rb
CHANGED
@@ -36,7 +36,7 @@ class Shoes
|
|
36
36
|
|
37
37
|
def move x, y
|
38
38
|
@app.cslot.contents -= [self]
|
39
|
-
@app.canvas.move @real, x, y
|
39
|
+
@app.canvas.move @real, x, y unless @hided
|
40
40
|
move3 x, y
|
41
41
|
self
|
42
42
|
end
|
@@ -168,7 +168,7 @@ class Shoes
|
|
168
168
|
end
|
169
169
|
|
170
170
|
def text
|
171
|
-
@args[:markup].gsub(/\<.*?>/, '')
|
171
|
+
@args[:markup].gsub(/\<.*?>/, '').gsub('&', '&').gsub('<', '<')
|
172
172
|
end
|
173
173
|
|
174
174
|
def text= s
|
@@ -203,7 +203,35 @@ class Shoes
|
|
203
203
|
end
|
204
204
|
|
205
205
|
def cursor
|
206
|
-
@app.textcursors[self][0]
|
206
|
+
@app.textcursors[self] ? @app.textcursors[self][0] : nil
|
207
|
+
end
|
208
|
+
|
209
|
+
def hit x, y
|
210
|
+
a, b, c = @app.make_textcursor_index(self, x - left, y - top + @app.scroll_top)
|
211
|
+
a ? b : nil
|
212
|
+
end
|
213
|
+
|
214
|
+
def marker=(n)
|
215
|
+
if cursor
|
216
|
+
cindex = cursor == -1 ? text.length : cursor
|
217
|
+
len = cindex - n
|
218
|
+
self.text = text[0...n] + @app.bg(text[n, len], @app.yellow) + text[n+len..-1] if len > 1
|
219
|
+
end
|
220
|
+
@app.textmarkers[self] = n
|
221
|
+
end
|
222
|
+
|
223
|
+
def marker
|
224
|
+
@app.textmarkers[self]
|
225
|
+
end
|
226
|
+
|
227
|
+
def highlight
|
228
|
+
unless cursor
|
229
|
+
return nil, 0
|
230
|
+
else
|
231
|
+
cindex = cursor == -1 ? text.length : cursor
|
232
|
+
mindex = marker ? marker : cindex
|
233
|
+
return marker, cindex - mindex
|
234
|
+
end
|
207
235
|
end
|
208
236
|
end
|
209
237
|
|
data/lib/shoes/help.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
class Manual < Shoes
|
2
2
|
url '/', :index
|
3
3
|
url '/manual/(\d+)', :index
|
4
|
+
url '/mk_search_page', :mk_search_page
|
4
5
|
|
5
6
|
include Hpricot
|
6
7
|
include HH::Markup
|
@@ -38,35 +39,12 @@ class Manual < Shoes
|
|
38
39
|
|
39
40
|
def manual pnum, docs_title, docs_description, docs_methods
|
40
41
|
flow do
|
41
|
-
|
42
|
-
|
43
|
-
para fg("The Green Shoes Manual #{VERSION}", gray), left: 120, top: 10
|
44
|
-
title fg(docs_title, white), left: 120, top: 30, font: 'Coolvetica'
|
45
|
-
image File.join(DIR, '../static/gshoes-icon.png'), left: 5, top: -12, width: 110, height: 110, nocontrol: true
|
46
|
-
|
42
|
+
show_header docs_title
|
43
|
+
show_toc
|
47
44
|
paras = mk_paras docs_description
|
48
|
-
|
49
|
-
stack{para NL * 4}
|
50
|
-
flow width: 0.2, margin_left: 10 do
|
51
|
-
para *TOC
|
52
|
-
para link(fg 'to_html', darkmagenta){html_manual}
|
53
|
-
end
|
54
|
-
|
55
45
|
flow width: 0.8, margin: [10, 0, 20, 0] do
|
56
46
|
show_page paras, true
|
57
|
-
docs_methods
|
58
|
-
flow do
|
59
|
-
background rgb(60, 60, 60), curve: 5
|
60
|
-
n = m.index("\u00BB")
|
61
|
-
if n
|
62
|
-
para ' ', fg(strong(m[0...n]), white), fg(strong(m[n..-1]), rgb(160, 160, 160))
|
63
|
-
else
|
64
|
-
para ' ', fg(strong(m), white)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
para
|
68
|
-
show_page mk_paras(d.gsub('&', '\u0026'))
|
69
|
-
end
|
47
|
+
show_methods docs_methods
|
70
48
|
para link('top'){visit "/manual/0"}, " ",
|
71
49
|
link('prev'){visit "/manual/#{(pnum-1)%PEND}"}, " ",
|
72
50
|
link('next'){visit "/manual/#{(pnum+1)%PEND}"}, " ",
|
@@ -75,7 +53,44 @@ class Manual < Shoes
|
|
75
53
|
end
|
76
54
|
end
|
77
55
|
|
78
|
-
def
|
56
|
+
def show_header docs_title
|
57
|
+
background tr_color("#ddd")..white, angle: 90
|
58
|
+
background black..green, height: 90
|
59
|
+
para fg("The Green Shoes Manual #{VERSION}", gray), left: 120, top: 10
|
60
|
+
title fg(docs_title, white), left: 120, top: 30, font: 'Coolvetica'
|
61
|
+
image File.join(DIR, '../static/gshoes-icon.png'), left: 5, top: -12, width: 110, height: 110, nocontrol: true
|
62
|
+
end
|
63
|
+
|
64
|
+
def show_toc
|
65
|
+
stack(height: 120){}
|
66
|
+
flow width: 0.2, margin_left: 10 do
|
67
|
+
flow(margin_right: 20) do
|
68
|
+
background black.push(0.7), curve: 5
|
69
|
+
inscription "Not findng it?\n", 'Try ', link(fg 'Search', white){visit '/mk_search_page'}, '!', align: 'center', stroke: lightgrey
|
70
|
+
end
|
71
|
+
stack(height: 10){}
|
72
|
+
para *TOC
|
73
|
+
para link(fg 'to_html', darkmagenta){html_manual}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def show_methods docs_methods, term = nil
|
78
|
+
docs_methods.each do |m, d|
|
79
|
+
flow do
|
80
|
+
background rgb(60, 60, 60), curve: 5
|
81
|
+
n = m.index("\u00BB")
|
82
|
+
if n
|
83
|
+
para ' ', fg(strong(m[0...n]), white), fg(strong(m[n..-1]), rgb(160, 160, 160))
|
84
|
+
else
|
85
|
+
para ' ', fg(strong(m), white)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
para
|
89
|
+
show_page mk_paras(d.gsub('&', '\u0026')), false, term
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def show_page paras, intro = false, term = nil
|
79
94
|
paras.each_with_index do |text, i|
|
80
95
|
if text.index CODE_RE
|
81
96
|
text.gsub CODE_RE do |lines|
|
@@ -99,28 +114,28 @@ class Manual < Shoes
|
|
99
114
|
if text =~ /\A \* (.+)/m
|
100
115
|
$1.split(/^ \* /).each do |txt|
|
101
116
|
image File.join(DIR, '../static/gshoes-icon.png'), width: 20, height: 20
|
102
|
-
flow(width: 510){show_paragraph txt, intro, i}
|
117
|
+
flow(width: 510){show_paragraph txt, intro, i, term}
|
103
118
|
end
|
104
119
|
else
|
105
|
-
show_paragraph text, intro, i
|
120
|
+
show_paragraph text, intro, i, term
|
106
121
|
end
|
107
122
|
end
|
108
123
|
end
|
109
124
|
|
110
|
-
def show_paragraph txt, intro, i,
|
125
|
+
def show_paragraph txt, intro, i, term = nil
|
111
126
|
txt = txt.gsub("\n", ' ').gsub(/`(.+?)`/m){fg code($1), rgb(255, 30, 0)}.
|
112
127
|
gsub(/\^(.+?)\^/m, '\1').gsub(/'''(.+?)'''/m){strong($1)}.gsub(/''(.+?)''/m){em($1)}.
|
113
128
|
gsub(/\[\[BR\]\]/i, "\n")
|
114
129
|
txts = txt.split(/(\[\[\S+?\]\])/m).map{|s| s.split(/(\[\[\S+? .+?\]\])/m)}.flatten
|
115
130
|
case txts[0]
|
116
|
-
when /\A==== (.+) ====/; caption $1, size: 24
|
117
|
-
when /\A=== (.+) ===/; tagline $1, size: 12, weight: 'bold'
|
118
|
-
when /\A== (.+) ==/; subtitle $1
|
119
|
-
when /\A= (.+) =/; title $1
|
131
|
+
when /\A==== (.+) ====/; caption marker($1, term), size: 24
|
132
|
+
when /\A=== (.+) ===/; tagline marker($1, term), size: 12, weight: 'bold'
|
133
|
+
when /\A== (.+) ==/; subtitle marker($1, term)
|
134
|
+
when /\A= (.+) =/; title marker($1, term)
|
120
135
|
when /\A\{COLORS\}/; flow{color_page}
|
121
136
|
when /\A\{SAMPLES\}/; flow{sample_page}
|
122
137
|
else
|
123
|
-
para *mk_links(txts), NL, (intro and i.zero?) ? {size: 16} : ''
|
138
|
+
para *mk_links(txts, term), NL, (intro and i.zero?) ? {size: 16} : ''
|
124
139
|
txt.gsub IMAGE_RE do
|
125
140
|
image File.join(DIR, "../static/#{$3}"), eval("{#{$2 or "margin_left: 50"}}")
|
126
141
|
para
|
@@ -128,10 +143,11 @@ class Manual < Shoes
|
|
128
143
|
end
|
129
144
|
end
|
130
145
|
|
131
|
-
def mk_links txts
|
146
|
+
def mk_links txts, term = nil
|
132
147
|
txts.map{|txt| txt.gsub(IMAGE_RE, '')}.
|
133
|
-
map{|txt| txt =~ /\[\[(\S+?)\]\]/m ? (t = $1.split('.'); link(ins t.last){visit "/manual/#{find_pnum t.first}"}) : txt}.
|
134
|
-
map{|txt| txt =~ /\[\[(\S+?) (.+?)\]\]/m ? (url = $1; link(ins $2){visit url =~ /^http/ ? url : "/manual/#{find_pnum url}"}) :
|
148
|
+
map{|txt| txt =~ /\[\[(\S+?)\]\]/m ? (t = $1.split('.'); link(ins marker(t.last, term)){visit "/manual/#{find_pnum t.first}"}) : txt}.
|
149
|
+
map{|txt| txt =~ /\[\[(\S+?) (.+?)\]\]/m ? (url = $1; link(ins marker($2, term)){visit url =~ /^http/ ? url : "/manual/#{find_pnum url}"}) :
|
150
|
+
(txt.is_a?(String) ? marker(txt, term) : txt)}
|
135
151
|
end
|
136
152
|
|
137
153
|
def mk_paras str
|
@@ -363,6 +379,73 @@ class Manual < Shoes
|
|
363
379
|
end
|
364
380
|
end
|
365
381
|
|
382
|
+
def mk_search_page
|
383
|
+
flow do
|
384
|
+
show_header 'Search'
|
385
|
+
show_toc
|
386
|
+
pnum, docs_title, docs_description, docs_methods = get_title_and_desc(25)
|
387
|
+
paras = mk_paras docs_description
|
388
|
+
|
389
|
+
flow width: 0.8, margin: [10, 0, 20, 0] do
|
390
|
+
el = edit_line width: 300
|
391
|
+
button 'search' do
|
392
|
+
term = el.text.strip
|
393
|
+
unless term.empty?
|
394
|
+
descs, methods = search term
|
395
|
+
@f.clear{show_search_result term, descs, methods}
|
396
|
+
end
|
397
|
+
end
|
398
|
+
stack(height: 20){}
|
399
|
+
@f = flow{}
|
400
|
+
end
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
def search term
|
405
|
+
descs, methods = [], []
|
406
|
+
PNUMS.each_with_index do |(chapter, section), pnum|
|
407
|
+
pnum, docs_title, docs_description, docs_methods = get_title_and_desc(pnum)
|
408
|
+
paras = mk_paras(docs_description)
|
409
|
+
descs << [chapter, section, docs_title, paras] if paras.map{|txt| txt.gsub(CODE_RE, '').gsub(IMAGE_RE, '')}.join(' ').index(term)
|
410
|
+
docs_methods.each do |docs_method|
|
411
|
+
m, d = docs_method
|
412
|
+
methods << [chapter, section, docs_title, docs_method] if m.index(term) or d.gsub(CODE_RE, '').gsub(IMAGE_RE, '').index(term)
|
413
|
+
end
|
414
|
+
end
|
415
|
+
return descs, methods
|
416
|
+
end
|
417
|
+
|
418
|
+
def show_search_result term, descs, methods
|
419
|
+
return subtitle 'Not Found' if descs.empty? and methods.empty?
|
420
|
+
methods.each do |(chapter, section, docs_title, docs_method)|
|
421
|
+
flow margin: [10, 10, 0, 5] do
|
422
|
+
background rgb(200, 200, 200), curve: 5
|
423
|
+
para "#{DOCS[chapter][0]}: #{docs_title.sub('The', '').split(' ').first}: ",
|
424
|
+
link(docs_method[0]){@f.clear{title docs_title; show_methods [docs_method], term}}, NL
|
425
|
+
end
|
426
|
+
stack(height: 2){}
|
427
|
+
end
|
428
|
+
descs.each do |(chapter, section, docs_title, paras)|
|
429
|
+
flow margin_left: 10 do
|
430
|
+
if section
|
431
|
+
background gray, curve: 5
|
432
|
+
tagline link(fg(docs_title, white)){@f.clear{title docs_title; show_page paras, true, term}}, width: 320
|
433
|
+
inscription "Sub-Section under #{DOCS[chapter][0]}", stroke: lightgrey, width: 180
|
434
|
+
else
|
435
|
+
background black.push(0.8), curve: 5
|
436
|
+
subtitle link(fg(docs_title, white)){@f.clear{title docs_title; show_page paras, true, term}}, width: 320
|
437
|
+
inscription 'Section Header', stroke: lightgrey, width: 100
|
438
|
+
end
|
439
|
+
end
|
440
|
+
stack(height: 2){}
|
441
|
+
end
|
442
|
+
para NL*3
|
443
|
+
end
|
444
|
+
|
445
|
+
def marker txt, term
|
446
|
+
term && txt ? txt.gsub(term, bg(term, yellow)) : txt
|
447
|
+
end
|
448
|
+
|
366
449
|
IMAGE_RE = /\!(\{([^}\n]+)\})?([^!\n]+\.\w+)\!/
|
367
450
|
CODE_RE = /\{{3}(?:\s*\#![^\n]+)?(.+?)\}{3}/m
|
368
451
|
NL = "\n"
|
data/lib/shoes/helper_methods.rb
CHANGED
@@ -36,8 +36,8 @@ class Shoes
|
|
36
36
|
|
37
37
|
module Mod2
|
38
38
|
def init_app_vars
|
39
|
-
@contents, @mccs, @mrcs, @mmcs, @mhcs, @mlcs, @shcs, @mcs, @order, @dics, @animates, @radio_groups, @textcursors, @fronts, @backs =
|
40
|
-
[], [], [], [], [], [], [], [], [], [], [], {}, {}, [], []
|
39
|
+
@contents, @mccs, @mrcs, @mmcs, @mhcs, @mlcs, @shcs, @mcs, @order, @dics, @animates, @radio_groups, @textcursors, @textmarkers, @fronts, @backs =
|
40
|
+
[], [], [], [], [], [], [], [], [], [], [], {}, {}, {}, [], []
|
41
41
|
@cmask = nil
|
42
42
|
@mouse_button, @mouse_pos = 0, [0, 0]
|
43
43
|
@fill, @stroke = black, black
|
@@ -96,12 +96,21 @@ class Shoes
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def make_textcursor_pos tb, n
|
99
|
+
layout = make_textcursor_layout tb
|
100
|
+
n = tb.text.length if n == -1
|
101
|
+
return layout.index_to_pos(n).x / Pango::SCALE, layout.index_to_pos(n).y / Pango::SCALE
|
102
|
+
end
|
103
|
+
|
104
|
+
def make_textcursor_index tb, x, y
|
105
|
+
layout = make_textcursor_layout tb
|
106
|
+
layout.xy_to_index x * Pango::SCALE, y * Pango::SCALE
|
107
|
+
end
|
108
|
+
|
109
|
+
def make_textcursor_layout tb
|
99
110
|
markup, size, width, height, align, font =
|
100
111
|
%w[@markup @size @width @height @align @font].map{|v| tb.instance_variable_get v}
|
101
112
|
text, attr_list = make_pango_attr markup
|
102
|
-
|
103
|
-
n = tb.text.length if n == -1
|
104
|
-
return layout.index_to_pos(n).x / Pango::SCALE, layout.index_to_pos(n).y / Pango::SCALE
|
113
|
+
make_pango_layout(size, width, height, align, font, text, attr_list)[0]
|
105
114
|
end
|
106
115
|
|
107
116
|
def make_pango_attr markup
|
@@ -182,7 +191,7 @@ class Shoes
|
|
182
191
|
n, cursor = v
|
183
192
|
x, y = app.make_textcursor_pos(tb, n)
|
184
193
|
x += tb.left; y += tb.top
|
185
|
-
cursor ? cursor.move(x, y) : app.textcursors[tb][1] = app.line(x, y, x, y+tb.size*1.7)
|
194
|
+
cursor ? cursor.move(x, y) : app.textcursors[tb][1] = app.line(x, y, x, y+tb.size*1.7, strokewidth: 1, stroke: app.black)
|
186
195
|
end
|
187
196
|
end
|
188
197
|
|
data/lib/shoes/widget.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
class Shoes
|
2
2
|
class Widget
|
3
3
|
def self.inherited klass, &blk
|
4
|
-
m = klass.
|
4
|
+
m = klass.to_s[/(^|::)(\w+)$/, 2].
|
5
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
6
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
|
5
7
|
Shoes::App.class_eval do
|
6
8
|
define_method m do |*args, &blk|
|
7
9
|
klass.class_variable_set :@@__app__, self
|
data/samples/sample51.rb
CHANGED
@@ -17,14 +17,10 @@ Shoes.app width: 200, height: 200 do
|
|
17
17
|
#p k
|
18
18
|
msg = case k
|
19
19
|
when 'BackSpace'; @line.text[0..-2]
|
20
|
-
when 'Return'; @line.text + "\n"
|
21
|
-
when 'space'; @line.text + ' '
|
22
|
-
when 'exclam'; @line.text + '!'
|
23
|
-
when 'period'; @line.text + '.'
|
24
20
|
else
|
25
21
|
k.length == 1 ? @line.text + k : nil
|
26
22
|
end
|
27
|
-
(@line.text = strong fg msg, white) if msg
|
23
|
+
(@line.text = strong fg msg.gsub('&', '&').gsub('<', '<'), white) if msg
|
28
24
|
flush
|
29
25
|
end
|
30
26
|
end
|
data/static/manual-en.txt
CHANGED
@@ -1517,7 +1517,23 @@ scrollbar will appear and disappear as needed. It will also appear inside the
|
|
1517
1517
|
width of the slot, meaning the slot's width will never change, regardless of
|
1518
1518
|
whether there is a scrollbar or not.
|
1519
1519
|
|
1520
|
-
'''Note:''' Green Shoes
|
1520
|
+
'''Note:''' Green Shoes has restrictions. `:scroll` style is just a trial so far.
|
1521
|
+
|
1522
|
+
* common Slot instance methods, i.e. clear, hide, etc., don't work well
|
1523
|
+
* doesn't manage any mouse events
|
1524
|
+
* need to write `flush` explicitly
|
1525
|
+
|
1526
|
+
{{{
|
1527
|
+
Shoes.app do
|
1528
|
+
s = stack left: 100, top: 50, width: 300,
|
1529
|
+
height: 100, scroll: true do
|
1530
|
+
background gold
|
1531
|
+
image './loogink.png'
|
1532
|
+
10.times{para 'hello'}
|
1533
|
+
flush
|
1534
|
+
end
|
1535
|
+
end
|
1536
|
+
}}}
|
1521
1537
|
|
1522
1538
|
=== :secret » true or false ===
|
1523
1539
|
|
@@ -3694,27 +3710,6 @@ Lists all of the strings and styled text objects inside this block.
|
|
3694
3710
|
|
3695
3711
|
'''Note:''' Green Shoes doesn't support `contents` method.
|
3696
3712
|
|
3697
|
-
=== replace(a string) ===
|
3698
|
-
|
3699
|
-
Replaces the text of the entire block with the characters of `a string`.
|
3700
|
-
|
3701
|
-
=== text() » a string ===
|
3702
|
-
|
3703
|
-
Return a string of all of the characters in this text box. This will strip off
|
3704
|
-
any style or text classes and just return the actual characters, as if seen on
|
3705
|
-
the screen.
|
3706
|
-
|
3707
|
-
=== text = a string ===
|
3708
|
-
|
3709
|
-
Replaces the text of the entire block with the characters of `a string`.
|
3710
|
-
|
3711
|
-
=== to_s() » a string ===
|
3712
|
-
|
3713
|
-
An alias for [[TextBlock.text]]. Returns a flattened string of all of this
|
3714
|
-
TextBlock's contents.
|
3715
|
-
|
3716
|
-
'''Note:''' Green Shoes doesn't support `to_s` method.
|
3717
|
-
|
3718
3713
|
=== cursor() » an index ===
|
3719
3714
|
|
3720
3715
|
Return a text cursor position. That is an index of the text which is a string
|
@@ -3747,6 +3742,75 @@ Using `cursor = nil` hides the text cursor.
|
|
3747
3742
|
end
|
3748
3743
|
}}}
|
3749
3744
|
|
3745
|
+
=== highlight() » an array ===
|
3746
|
+
|
3747
|
+
Return an array which includes a text marker start position and highlighted length.
|
3748
|
+
|
3749
|
+
=== hit(left, top) » an index or nil ===
|
3750
|
+
|
3751
|
+
Return an index of the text at which the mouse cursor points on.
|
3752
|
+
The `left` and `top` are the mouse coordinates.
|
3753
|
+
|
3754
|
+
{{{
|
3755
|
+
Shoes.app do
|
3756
|
+
para 'index: ', width: 50
|
3757
|
+
index = para '', width: 20
|
3758
|
+
msg = title 'hello ' * 5
|
3759
|
+
click do |b, x, y|
|
3760
|
+
index.text = msg.hit x, y
|
3761
|
+
end
|
3762
|
+
end
|
3763
|
+
}}}
|
3764
|
+
|
3765
|
+
=== marker() » an index ===
|
3766
|
+
|
3767
|
+
Return a text marker start position.
|
3768
|
+
|
3769
|
+
=== marker = an index ===
|
3770
|
+
|
3771
|
+
Highlight a part of text from marker start position to cursor position.
|
3772
|
+
|
3773
|
+
{{{
|
3774
|
+
Shoes.app do
|
3775
|
+
background gainsboro
|
3776
|
+
extend HH::Markup
|
3777
|
+
code = 'alert "Hello Green Shoes! " * 5'
|
3778
|
+
msg = para highlight code, nil
|
3779
|
+
button 'marker' do
|
3780
|
+
msg.cursor = 17
|
3781
|
+
msg.marker = 14
|
3782
|
+
msg.text = highlight msg.markup, nil
|
3783
|
+
para msg.highlight
|
3784
|
+
flush
|
3785
|
+
end
|
3786
|
+
end
|
3787
|
+
}}}
|
3788
|
+
|
3789
|
+
=== markup() » a text ===
|
3790
|
+
|
3791
|
+
Return some marked-up text for Pango.
|
3792
|
+
|
3793
|
+
=== replace(a string) ===
|
3794
|
+
|
3795
|
+
Replaces the text of the entire block with the characters of `a string`.
|
3796
|
+
|
3797
|
+
=== text() » a string ===
|
3798
|
+
|
3799
|
+
Return a string of all of the characters in this text box. This will strip off
|
3800
|
+
any style or text classes and just return the actual characters, as if seen on
|
3801
|
+
the screen.
|
3802
|
+
|
3803
|
+
=== text = a string ===
|
3804
|
+
|
3805
|
+
Replaces the text of the entire block with the characters of `a string`.
|
3806
|
+
|
3807
|
+
=== to_s() » a string ===
|
3808
|
+
|
3809
|
+
An alias for [[TextBlock.text]]. Returns a flattened string of all of this
|
3810
|
+
TextBlock's contents.
|
3811
|
+
|
3812
|
+
'''Note:''' Green Shoes doesn't support `to_s` method.
|
3813
|
+
|
3750
3814
|
== Timers ==
|
3751
3815
|
|
3752
3816
|
Green Shoes contains three timers: the animate, every and
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 243
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.243.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- ashbb
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-07-03 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|