IRGoggles 0.0.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,52 @@
1
+ module IRGoggles
2
+
3
+ require 'sdl'
4
+ require 'open3'
5
+
6
+ DURR = (File.dirname(__FILE__) + "/")
7
+ SRCFLD = DURR + "IRGoggles/"
8
+ DATFLD = DURR + "datum/"
9
+
10
+ SDL.init(SDL::INIT_VIDEO)
11
+ SDL::WM::set_caption("IR Goggles!",'Super Sexy Terminal Display for Lovers')
12
+ SDL::TTF.init
13
+
14
+ Frames = [
15
+ [0.0,0.0,1.0,1.0],
16
+ [0.2,0.2,0.8,0.8],
17
+ [0.0,0.0,1.0,0.6],
18
+ [0.0,0.6,1.0,1.0],
19
+ [0.0,0.0,1.0,0.55],
20
+ [0.0,0.65,1.0,1.0],
21
+ [0.0,0.55,1.0,0.65],
22
+ [0.0,0.8,1.0,1.0]
23
+ ]
24
+ Opts = {
25
+ :Back_Color => [20,150,150],
26
+ :Text_Color => [210,230,210],
27
+ :Frame_Color => [40,200,200],
28
+ :Back_Alpha => 200,
29
+ :Text_Alpha => 200,
30
+ :Frame_Alpha => 200,
31
+ :Use_Font => [:LOCAL, 0],
32
+ :Font_Size => 24,
33
+ :Resolution => [800,600]
34
+ }
35
+
36
+
37
+ def IRGoggles.massload(duhrekt)
38
+ Dir.entries(duhrekt).each{|e|
39
+ if e[-3,3] == '.rb'
40
+ Kernel.load(duhrekt + e)
41
+ end
42
+ }
43
+ end
44
+
45
+ def IRGoggles.start
46
+ Strap.engauge!
47
+ end
48
+
49
+
50
+ IRGoggles.massload(SRCFLD)
51
+ Strap = Session.new
52
+ end
@@ -0,0 +1,215 @@
1
+ module IRGoggles
2
+
3
+ class IRGoggleERR < Exception
4
+ end
5
+
6
+ class Redicle
7
+
8
+ attr_accessor :imary, :ents, :rin, :rout, :rerr
9
+ attr_reader :w, :h, :cx, :cy
10
+
11
+ def initialize(matron)
12
+ @matron = matron
13
+ @imary = []
14
+ @sorted = []
15
+ @ents = []
16
+ @w, @h = Opts[:Resolution]
17
+ @cx = 0
18
+ @cy = 0
19
+ @thrds = []
20
+ @datelist = []
21
+ @keeplist = []
22
+ @anilist = []
23
+ @corrections = []
24
+ @marked = []
25
+ @update = false
26
+ @upkeep = false
27
+ @aminate = false
28
+ @gtg = false
29
+ end
30
+
31
+ #@imary stores all the graphics to be printed to the mainscreen
32
+ #[surface,width,height,pos_x,pos_y,priority]
33
+ #everything is an integer, except for the surface
34
+ #priority :to determine display order for #sort_imgz command.
35
+
36
+ def add_img(e)
37
+ unless c = @imary.rindex(nil)
38
+ c = @imary.size
39
+ end
40
+ @imary[c] = e
41
+ return c
42
+ end
43
+
44
+ def del_img(e)
45
+ @sorted.delete(e)
46
+ @imary[e][0].destroy
47
+ @imary[e] = nil
48
+ end
49
+
50
+ def sort_imgz
51
+ cow = 0
52
+ @imary.each_index.sort{|a,b| @imary[a][5] <=> @imary[b][5]}.each{|i|
53
+ @sorted[cow] = i
54
+ cow += 1
55
+ }
56
+ while @sorted.size > cow
57
+ @sorted.delete(-1)
58
+ end
59
+ end
60
+
61
+ def cull_lists
62
+ if @datelist.empty?
63
+ @update = false
64
+ end
65
+ if @keeplist.empty?
66
+ @upkeep = false
67
+ end
68
+ if @anilist.empty?
69
+ @aminate = false
70
+ end
71
+ end
72
+
73
+ #because I used this framework for other programs, an object contained in the @ents array
74
+ # are hardly ever of a uniform class. Therefore, they are referenced by index in the various
75
+ # update and display loops. Here, in #add_ent are they orginized:
76
+
77
+ def add_ent(e)
78
+ c = @ents.size
79
+ @ents[c] = e
80
+ if e.methods.include?(:animate)
81
+ @anilist << c
82
+ end
83
+
84
+ if e.methods.include?(:update)
85
+ @datelist << c
86
+ end
87
+
88
+ if e.methods.include?(:upkeep)
89
+ @keeplist << c
90
+ end
91
+
92
+ if e.methods.include?(:correct)
93
+ @corrections << c
94
+ end
95
+
96
+ if e.methods.include?(:set_dex)
97
+ @ents[c].set_dex(c)
98
+ end
99
+ return c
100
+ end
101
+
102
+ #auspizer :sets (or resets) the window and the display surfaces which rely on the size of the window:
103
+ def auspizer(w,h)
104
+ @w = w
105
+ @h = h
106
+ @img = SDL::Screen.open(@w, @h, 32, SDL::RESIZABLE)
107
+ @corrections.each{|e| @ents[e].correct(@w, @h)}
108
+ end
109
+
110
+ #begins update, upkeep and animation threads. Then, activates the display cycle
111
+ def instigate
112
+ raise IRGoggleERR, "Cannot display nothing!" if (@ents.size == 0)
113
+ @update = true
114
+ @upkeep = true
115
+ @aminate = true
116
+ @gtg = true
117
+ aniloop
118
+ updateloop
119
+ upkeeploop
120
+ mainloop
121
+ end
122
+
123
+ #resolve stops and clears any current threads, pausing a moment to complete, then ends the display cycle
124
+ def resolve
125
+ @update = false
126
+ @upkeep = false
127
+ @aminate = false
128
+ sleep 1
129
+ @thrds.clear
130
+ @gtg = false
131
+ end
132
+
133
+
134
+ private
135
+
136
+
137
+ #finally, we have various loops. Only the #mainloop function is called in the current processes,
138
+ # all other loops are inbedded within Threads.
139
+ # The intention here is to streamline the mainloop so any function which does not have do to with
140
+ # keyboard & mouse input or drawing the window is shunted elsewhere.
141
+
142
+ def aniloop
143
+ @thrds << Thread.new{
144
+ begin
145
+ while @aminate
146
+ @anilist.each{|a| @ents[a].animate}
147
+ sleep(0.6)
148
+ end
149
+ rescue Exception
150
+ @aminate = false
151
+ puts("animatino error\n#{$!}\n#{$!.backtrace}")
152
+ end
153
+ }
154
+ end
155
+
156
+ def updateloop
157
+ @thrds << Thread.new{
158
+ begin
159
+ while @update
160
+ @datelist.each{|a| @ents[a].update}
161
+ sleep(0.03)
162
+ end
163
+ rescue Exception
164
+ @update = false
165
+ p("update error\n#{$!}\n#{$!.backtrace}")
166
+ end
167
+ }
168
+ end
169
+
170
+ def upkeeploop
171
+ @thrds << Thread.new{
172
+ begin
173
+ while @upkeep
174
+ @keeplist.each{|a| @ents[a].upkeep}
175
+ sleep(0.05)
176
+ end
177
+ rescue Exception
178
+ @upkeep = false
179
+ p("upkeep error\n#{$!}\n#{$!.backtrace}")
180
+ end
181
+ }
182
+ end
183
+
184
+ def mainloop
185
+ while @gtg
186
+ @img.draw_rect(0,0,@w,@h,[0,0,0],true,50)
187
+ @sorted.each{|x|
188
+ SDL::Surface.blit(@imary[x][0],0,0,@imary[x][1],@imary[x][2],@img,@imary[x][3],@imary[x][4])
189
+ }
190
+ @img.flip
191
+ sleep(0.02)
192
+ while eve = SDL::Event.poll
193
+ case eve
194
+ when SDL::Event::VideoResize
195
+ auspizer(eve.w, eve.h)
196
+ when SDL::Event::Quit
197
+ @gtg = false
198
+ when SDL::Event::KeyUp
199
+ @matron.keyin.insert(0,[eve.sym,false])
200
+ when SDL::Event::KeyDown
201
+ @matron.keyin.insert(0, [eve.sym,true])
202
+ when SDL::Event::MouseMotion
203
+ @cx = eve.x
204
+ @cy = eve.y
205
+ when SDL::Event::MouseButtonUp
206
+ @matron.mousin.insert(0,[eve.button, false])
207
+ when SDL::Event::MouseButtonDown
208
+ @matron.mousin.insert(0,[eve.button, true])
209
+ end
210
+ end
211
+ end
212
+ end
213
+ end
214
+
215
+ end
@@ -0,0 +1,311 @@
1
+ module IRGoggles
2
+
3
+ class Session
4
+ attr_accessor :keyin, :mousin
5
+ attr_reader :active
6
+ def initialize
7
+ @matron = Redicle.new(self)
8
+ @sessions = []
9
+ @select = nil
10
+ @size = 0
11
+ @active = false
12
+ @threads = []
13
+ @keyin = []
14
+ @mousin = []
15
+ @shft_l = false
16
+ @cntrl_l = false
17
+ @shft_r = false
18
+ @caps = false
19
+ @caplock = false
20
+ @cntrl_r = false
21
+ end
22
+
23
+ def new_ir
24
+ @sessions[@size] = Open3.popen3('irb --noinspect')
25
+ @size += 1
26
+ return (@size-1)
27
+ end
28
+
29
+ def engauge!
30
+ unless @active
31
+ @active = true
32
+ @select = new_ir
33
+ w, h = IRGoggles::Opts[:Resolution]
34
+ @matron.auspizer(w,h)
35
+ @spout = @matron.add_ent(Texen.new(@matron, 4))
36
+ @spin = @matron.add_ent(Texen.new(@matron, 5))
37
+ text_relay
38
+ text_reply
39
+ logic_bomb
40
+ @matron.instigate
41
+ @active = false
42
+ end
43
+ end
44
+
45
+ def capcheck
46
+ if @caplock
47
+ if @shft_l
48
+ @caps = false
49
+ elsif @shft_r
50
+ @caps = false
51
+ else
52
+ @caps = true
53
+ end
54
+ else
55
+ if @shft_l
56
+ @caps = true
57
+ elsif @shft_r
58
+ @caps = true
59
+ else
60
+ @caps = false
61
+ end
62
+ end
63
+ end
64
+
65
+ def controller(chr,bool)
66
+ if bool
67
+ case chr
68
+ when 8#backspace
69
+ @matron.ents[@spin].bckspx
70
+ #when 9#tab
71
+ when 13#return
72
+ if @cntrl_l || @cntrl_r
73
+ @sessions[@select][0].puts(@matron.ents[@spin].slasher)
74
+ else
75
+ @matron.ents[@spin].newlin
76
+ end
77
+ #when 27#esc
78
+ #when 32#space
79
+ when 39#'
80
+ if @shft_l || @sft_r
81
+ @matron.ents[@spin].append('"')
82
+ else
83
+ @matron.ents[@spin].append("'")
84
+ end
85
+ when 44# comma
86
+ if @shft_l || @sft_r
87
+ @matron.ents[@spin].append("<")
88
+ else
89
+ @matron.ents[@spin].append(",")
90
+ end
91
+ when 45#minus -
92
+ if @shft_l || @sft_r
93
+ @matron.ents[@spin].append("_")
94
+ else
95
+ @matron.ents[@spin].append("-")
96
+ end
97
+ when 46# period
98
+ if @shft_l || @sft_r
99
+ @matron.ents[@spin].append(">")
100
+ else
101
+ @matron.ents[@spin].append(".")
102
+ end
103
+ when 47#foreslash?
104
+ if @shft_l || @sft_r
105
+ @matron.ents[@spin].append("?")
106
+ else
107
+ @matron.ents[@spin].append("/")
108
+ end
109
+ when 48#0
110
+ if @shft_l || @sft_r
111
+ @matron.ents[@spin].append(")")
112
+ else
113
+ @matron.ents[@spin].append("0")
114
+ end
115
+ when 49#1
116
+ if @shft_l || @sft_r
117
+ @matron.ents[@spin].append("!")
118
+ else
119
+ @matron.ents[@spin].append("1")
120
+ end
121
+ when 50#2
122
+ if @shft_l || @sft_r
123
+ @matron.ents[@spin].append("@")
124
+ else
125
+ @matron.ents[@spin].append("2")
126
+ end
127
+ when 51#3
128
+ if @shft_l || @sft_r
129
+ @matron.ents[@spin].append("#")
130
+ else
131
+ @matron.ents[@spin].append("3")
132
+ end
133
+ when 52#4
134
+ if @shft_l || @sft_r
135
+ @matron.ents[@spin].append("$")
136
+ else
137
+ @matron.ents[@spin].append("4")
138
+ end
139
+ when 53#5
140
+ if @shft_l || @sft_r
141
+ @matron.ents[@spin].append("%")
142
+ else
143
+ @matron.ents[@spin].append("5")
144
+ end
145
+ when 54#6
146
+ if @shft_l || @sft_r
147
+ @matron.ents[@spin].append("^")
148
+ else
149
+ @matron.ents[@spin].append("6")
150
+ end
151
+ when 55#7
152
+ if @shft_l || @sft_r
153
+ @matron.ents[@spin].append("&")
154
+ else
155
+ @matron.ents[@spin].append("7")
156
+ end
157
+ when 56#8
158
+ if @shft_l || @sft_r
159
+ @matron.ents[@spin].append("*")
160
+ else
161
+ @matron.ents[@spin].append("8")
162
+ end
163
+ when 57#9
164
+ if @shft_l || @sft_r
165
+ @matron.ents[@spin].append("(")
166
+ else
167
+ @matron.ents[@spin].append("9")
168
+ end
169
+ when 59
170
+ if @shft_l || @sft_r
171
+ @matron.ents[@spin].append(":")
172
+ else
173
+ @matron.ents[@spin].append(";")
174
+ end
175
+ when 61#plus +
176
+ if @shft_l || @sft_r
177
+ @matron.ents[@spin].append("+")
178
+ else
179
+ @matron.ents[@spin].append("=")
180
+ end
181
+ when 91#bra
182
+ if @shft_l || @sft_r
183
+ @matron.ents[@spin].append("{")
184
+ else
185
+ @matron.ents[@spin].append("[")
186
+ end
187
+ when 92#bar and backslash
188
+ if @shft_l || @sft_r
189
+ @matron.ents[@spin].append("|")
190
+ else
191
+ @matron.ents[@spin].append("\\")
192
+ end
193
+ when 93#ket
194
+ if @shft_l || @sft_r
195
+ @matron.ents[@spin].append("}")
196
+ else
197
+ @matron.ents[@spin].append("]")
198
+ end
199
+ when 96#tilde&backquote
200
+ if @shft_l || @sft_r
201
+ @matron.ents[@spin].append("~")
202
+ else
203
+ @matron.ents[@spin].append("`")
204
+ end
205
+ when 127#delete
206
+ @matron.ents[@spin].leet
207
+ when 273#up
208
+ @matron.ents[@spin].uparrow
209
+ when 274#down
210
+ @matron.ents[@spin].downarrow
211
+ when 275#right
212
+ @matron.ents[@spin].rightarrow
213
+ when 276#left
214
+ @matron.ents[@spin].leftarrow
215
+ when 277#insert
216
+ @matron.ents[@spin].certify
217
+ when 278#HOme
218
+ @matron.ents[@spin].homekey
219
+ when 279#end
220
+ @matron.ents[@spin].endkey
221
+ when 280#pageup
222
+ @matron.ents[@spin].pageup
223
+ when 281#pagedown
224
+ @matron.ents[@spin].pagedown
225
+ #when 282#F1
226
+ #when 293#F12
227
+ when 303
228
+ @shft_r = true
229
+ when 304
230
+ @shft_l = true
231
+ when 305
232
+ @cntrl_l = true
233
+ when 306
234
+ @cntrl_r = true
235
+
236
+ else
237
+ capcheck
238
+ if (@caps == true)
239
+ @matron.ents[@spin].append(chr.chr.upcase)
240
+ else
241
+ @matron.ents[@spin].append(chr.chr)
242
+ end
243
+ end
244
+ else #key is lifted
245
+ case chr
246
+ when 303
247
+ @shft_r = false
248
+ when 304
249
+ @shft_l = false
250
+ when 305
251
+ @cntrl_l = false
252
+ when 306
253
+ @cntrl_r = false
254
+ end
255
+ end
256
+ end
257
+
258
+ def text_reply
259
+ @threads << Thread.new{
260
+ p("Thread start")
261
+ begin
262
+ while @active
263
+ while line = @sessions[@select][1].gets
264
+ p("GETTING LINE = #{line}")
265
+ @matron.ents[@spout].dump(line)
266
+ end
267
+ sleep(0.06)
268
+ end
269
+ rescue Exception
270
+ p("FEED error\n#{$!}\n#{$!.backtrace}")
271
+ @active = false
272
+ end
273
+ p("Threadstop ply")
274
+ }
275
+
276
+ end
277
+ def text_relay
278
+ @threads << Thread.new{
279
+ p("Thread start")
280
+ begin
281
+ while @active
282
+ while lout = @keyin.pop
283
+ controller(lout[0],lout[1])
284
+ p("KEYING INT = #{lout}")
285
+ end
286
+ sleep(0.1)
287
+ end
288
+ rescue Exception
289
+ p("FEED error\n#{$!}\n#{$!.backtrace}")
290
+ @active = false
291
+ end
292
+ p("Threadstop lay")
293
+ }
294
+ end
295
+
296
+ def logic_bomb
297
+ @threads << Thread.new{
298
+ begin
299
+ while @active
300
+ @matron.sort_imgz
301
+ @matron.cull_lists
302
+ sleep 2
303
+ end
304
+ rescue Exception
305
+ p("LOGICERR error\n#{$!}\n#{$!.backtrace}")
306
+ @active = false
307
+ end
308
+ }
309
+ end
310
+ end
311
+ end
@@ -0,0 +1,358 @@
1
+ module IRGoggles
2
+
3
+ class OperatingSystemErr < StandardError
4
+ end
5
+
6
+ class Overlay
7
+ def initialize(mat,frmst)
8
+ @matron = mat
9
+ @margie = [0.1,0.05,0.03,0.03]
10
+ @spd = 0.07
11
+ @frmst = IRGoggles::Frames[frmst]
12
+ @x = 0
13
+ @y = 0
14
+ @w = 0
15
+ @h = 0
16
+ @kex = Array.new(4, 0.0)
17
+ @p = 1000
18
+ @refresh = true
19
+
20
+ setdat
21
+ correct(@matron.w, @matron.h)
22
+ make_margin
23
+
24
+ set_image_array
25
+ end
26
+ def set_dex(c)
27
+ @entdex = c
28
+ end
29
+ def setdat
30
+ @bgc = Opts[:Back_Color]
31
+ @txtc = Opts[:Text_Color]
32
+ @fgc = Opts[:Frame_Color]
33
+ @bga = Opts[:Back_Alpha]
34
+ @txta = Opts[:Text_Alpha]
35
+ @fga = Opts[:Frame_Alpha]
36
+ end
37
+ def correct(w,h)
38
+ x,y,xx,yy = @frmst
39
+ @tw = ((xx - x)*w).to_i
40
+ @th = ((yy - y)*h).to_i
41
+ @tx = (x*w).to_i
42
+ @ty = (y*h).to_i
43
+
44
+ end
45
+
46
+ def set_image_array
47
+ preren = SDL::Surface.new(SDL::HWSURFACE,@w,@h,32,0,0,0,0)
48
+ preren.set_color_key(SDL::SRCALPHA, 0)
49
+ @idex = @matron.add_img([preren.display_format_alpha,@w,@h,@x,@y,@p])
50
+ end
51
+
52
+ def make_margin
53
+ @marg_t = (@h*@margie[0]).round
54
+ @marg_b = (@h*@margie[1]).round
55
+ @marg_l = (@w*@margie[2]).round
56
+ @marg_r = (@w*@margie[3]).round
57
+ end
58
+ def fixed_margin
59
+ @marg_t, @marg_b, @marg_l, @marg_r = @margie.collect{|e| (e*512).to_i}
60
+ end
61
+
62
+ def update
63
+ #p("tz = #{[@tx,@ty,@tw,@th]}\t\tzz = #{[@x,@y,@w,@h]}\n\tk = #{@kex}")
64
+ k = (@tx - @x)
65
+ #p("\n\t\t\tk = #{k}")
66
+ if k.abs < 10
67
+ @kex[0] = 0.0
68
+ @x = @tx
69
+ else
70
+ @kex[0] = (@kex[0] + k)*@spd
71
+ end
72
+ k = (@ty - @y)
73
+ #p("\n\t\t\tk = #{k}")
74
+ if k.abs < 10
75
+ @kex[1] = 0.0
76
+ @y = @ty
77
+ else
78
+ @kex[1] = (@kex[1] + k)*@spd
79
+ end
80
+ k = (@tw - @w)
81
+ #p("\n\t\t\tk = #{k}")
82
+ if k.abs < 10
83
+ @kex[2] = 0.0
84
+ @w = @tw
85
+ else
86
+ @kex[2] = (@kex[2] + k)*@spd
87
+ end
88
+ k = (@th - @h)
89
+ #p("\n\t\t\tk = #{k}")
90
+ if k.abs < 10
91
+ @kex[3] = 0.0
92
+ @h = @th
93
+ else
94
+ @kex[3] = (@kex[3] + k)*@spd
95
+ end
96
+ unless @kex[0] == 0.0
97
+ @matron.imary[@idex][3] = @x = (@x + @kex[0]).round
98
+ @refresh = true
99
+ end
100
+ unless @kex[1] == 0.0
101
+ @matron.imary[@idex][4] = @y = (@y + @kex[1]).round
102
+ @refresh = true
103
+ end
104
+ unless @kex[2] == 0.0
105
+ #p "matroim = #{@matron.imary[@idex]}"
106
+ @matron.imary[@idex][1] = @w = (@w + @kex[2]).round
107
+ @refresh = true
108
+ end
109
+ unless @kex[3] == 0.0
110
+ @matron.imary[@idex][2] = @h = (@h + @kex[3]).round
111
+ @refresh = true
112
+ end
113
+ end
114
+
115
+ def upkeep
116
+ if @refresh
117
+ @matron.imary[@idex][0] = @matron.imary[@idex][0].copy_rect(0,0,@w,@h)
118
+ make_margin
119
+ @matron.imary[@idex][0].draw_rect(0,0,@w,@h,@bgc,true,@bga)
120
+ @matron.imary[@idex][0].draw_rect(0,0,@w,@marg_t,@fgc,true,@fga)
121
+ @matron.imary[@idex][0].draw_rect(0,@h-@marg_b,@w,@marg_b,@fgc,true,@fga)
122
+ @matron.imary[@idex][0].draw_rect(0,@marg_t,@marg_l,@h-@marg_b-@marg_b,@fgc,true,@fga)
123
+ @matron.imary[@idex][0].draw_rect(@w-@marg_r,@marg_t,@marg_r,@h-@marg_b-@marg_b,@fgc,true,@fga)
124
+ @refresh = false
125
+ end
126
+ end
127
+ end#end overlayclass
128
+
129
+
130
+ class Texen < Overlay
131
+ def initialize(mat,frmst)
132
+ super
133
+ set_fawnt
134
+ @tileW = @fawn.text_size('W')[0]
135
+ @tileH = @ch = @fawn.line_skip
136
+ @space = @fawn.text_size(' ')[0]
137
+ @xset = 0
138
+ @yset = 0
139
+ @xcur = 0
140
+ @ycur = 0
141
+ @tlin = 0
142
+ @tcur = 0
143
+ @cursed = false
144
+ @wrap = false
145
+ @texas = ['']
146
+ @cert = true
147
+ @page = 0
148
+ @gappe = 0
149
+ @xscroll = 0
150
+ @yscroll = 0
151
+ @mamory = []
152
+ end
153
+ def dump(str)
154
+ str.lines("\n").to_a.collect{|e| e.lines("\r").to_a}.flatten.each{|w|
155
+ @texas << w.rstrip
156
+ @tlin += 1
157
+ }
158
+ @tcur = @texas[-1].size#-1
159
+ seek
160
+ @refresh = true
161
+ end
162
+ def slasher
163
+ dat = (@texas.join('') + "\r")
164
+ @mamory << dat
165
+ @texas = ['']
166
+ @tlin = 0
167
+ @tcur = 0
168
+ @refresh = true
169
+ return dat
170
+ end
171
+ def seek
172
+ @yscroll = (@tlin-(@page/2))
173
+ @xscroll = (@tcur-(@gappe/2))
174
+ if @yscroll < 0
175
+ @yscroll = 0
176
+ end
177
+ if @xscroll < 0
178
+ @xscroll = 0
179
+ end
180
+ @refresh = true
181
+ end
182
+ def homekey
183
+ @tcur = 0
184
+ seek
185
+ end
186
+ def endkey
187
+ @tcur = @texas[@tlin].size
188
+ seek
189
+ end
190
+ def pageup
191
+ @tlin -= @page
192
+ if @tlin < 0
193
+ @tlin = 0
194
+ end
195
+ seek
196
+ end
197
+ def pagedown
198
+ @tlin += @page
199
+ if @tlin > @texas.size
200
+ @tlin = @texas.size
201
+ end
202
+ seek
203
+ end
204
+ def uparrow
205
+ unless @tlin == 0
206
+ @tlin -= 1
207
+ seek
208
+ else
209
+ homekey
210
+ end
211
+ end
212
+
213
+ def downarrow
214
+ if @tlin < (@texas.size-1)
215
+ @tlin += 1
216
+ seek
217
+ else
218
+ endkey
219
+ end
220
+ end
221
+
222
+ def leftarrow
223
+ if @tcur == 0
224
+ uparrow
225
+ @tcur = @texas[@tlin].size
226
+ else
227
+ @tcur -= 1
228
+ end
229
+ seek
230
+ end
231
+ def rightarrow
232
+ if @tcur == @texas[@tlin].size
233
+ downarrow
234
+ @tcur = 0
235
+ else
236
+ @tcur += 1
237
+ end
238
+ seek
239
+ end
240
+
241
+ def newlin
242
+ a = "#{@texas[@tlin][0..@tcur]}\n"
243
+ b = "#{@texas[@tlin][@tcur+1..-1]}"
244
+ @texas[@tlin] = a
245
+ @tlin += 1
246
+ @texas.insert(@tlin,b)
247
+ @tcur = 0
248
+ end
249
+ def bckspx
250
+ leftarrow
251
+ @texas[@tlin][@tcur] = ''
252
+ @refresh = true
253
+ end
254
+ def leet
255
+ @texas[@tlin][@tcur] = ''
256
+ end
257
+ def append(crz)
258
+ if @cert
259
+ @texas[@tlin].insert(@tcur,crz)
260
+ @tcur += 1
261
+ else
262
+ @texas[@tlin][@tcur] = crz
263
+ @tcur += 1
264
+ end
265
+ @refresh = true
266
+ end
267
+ def certify
268
+ @cert = !@cert
269
+ end
270
+ def resolve_scope
271
+ @h_span = (@h - @marg_t - @marg_b)
272
+ @w_span = (@w - @marg_l - @marg_r)
273
+ @page = ( @h_span / @tileH)
274
+ @gappe = ( @w_span / @space)
275
+ end
276
+ def set_fawnt
277
+ param, val = Opts[:Use_Font]
278
+ case param
279
+ when :WINXP
280
+ raise OperatingSystemERR, "You're using windows xp? fuhreal?? ohmegurd, Mr. Babbage, you're not allowed."
281
+ when :WIN7
282
+ t = IRGoggles.win7_fonts[val]
283
+ when :NIXIE
284
+ t = IRGoggles.nix_fonts[val]
285
+ when :LOCAL
286
+ t = (IRGoggles.ttf_durr(DATFLD))[val]
287
+ end
288
+ @fawn = SDL::TTF.open(t[1],Opts[:Font_Size])
289
+ @fawn.style = SDL::TTF::STYLE_NORMAL
290
+ end
291
+
292
+ def rend(wrd)
293
+ wrd.rstrip!
294
+ unless wrd.size == 0
295
+ len = @fawn.text_size(wrd)[0]
296
+ if ((@xset + len) > (@w_span))
297
+ if @wrap
298
+ @xset = @marg_l
299
+ @yset += @tileH
300
+ @fawn.draw_solid_utf8(@matron.imary[@idex][0],wrd,@xset,@yset,@txtc[0],@txtc[1],@txtc[2])
301
+ @xset += (len + @space)
302
+ end
303
+ else
304
+ @fawn.draw_solid_utf8(@matron.imary[@idex][0],wrd,@xset,@yset,@txtc[0],@txtc[1],@txtc[2])
305
+ @xset += (len + @space)
306
+ end
307
+ end
308
+ end
309
+
310
+ def texprint
311
+ # p("printing text!!! #{self.__id__}, #{@bstring}: :#{@fstring}")
312
+ @yset = @marg_t
313
+ @xset = @marg_l
314
+ sample = @texas[@yscroll,@page]
315
+ lin_cow = @yscroll
316
+ wrd_cow = @xscroll
317
+ sample.each{|line|
318
+ sline = line[@xscroll, @gappe]
319
+ unless sline == nil
320
+ if @tlin == lin_cow
321
+ sline[0..(@tcur-1)].lines(' ').each{|wrd| rend(wrd) }
322
+ nxcur = @xset-@space
323
+ nycur = @yset
324
+ @matron.imary[@idex][0].draw_rect(nxcur,nycur,@tileW,@tileH,[100,20,120],true,60)
325
+ unless sline[@tcur] == nil
326
+ sline[@tcur..-1].lines(' ').each{|wrd| rend(wrd) }
327
+ end
328
+ else
329
+ sline.lines(' ').each{|wrd| rend(wrd) }
330
+ end
331
+ end
332
+ lin_cow += 1
333
+ @yset += @tileH
334
+ @xset = @marg_l
335
+ }
336
+ end
337
+ def upkeep
338
+ if @refresh
339
+ #p("refreshing ket = #{@kex}")
340
+ @matron.imary[@idex][0] = @matron.imary[@idex][0].copy_rect(0,0,@w,@h)
341
+ @matron.imary[@idex][0].draw_rect(0,0,@w,@h,@bgc,true,@bga)
342
+ make_margin
343
+ resolve_scope
344
+ texprint
345
+ @matron.imary[@idex][0].draw_rect(0,0,@w,@marg_t,@fgc,true,@fga)
346
+ @matron.imary[@idex][0].draw_rect(0,@h-@marg_b,@w,@marg_b,@fgc,true,@fga)
347
+ @matron.imary[@idex][0].draw_rect(0,@marg_t,@marg_l,@h-@marg_b-@marg_b,@fgc,true,@fga)
348
+ @matron.imary[@idex][0].draw_rect(@w-@marg_r,@marg_t,@marg_r,@h-@marg_b-@marg_b,@fgc,true,@fga)
349
+ @refresh = false
350
+ end
351
+ end
352
+
353
+ end
354
+
355
+ end#end mod
356
+
357
+
358
+
@@ -0,0 +1,51 @@
1
+ module IRGoggles
2
+
3
+ def IRGoggles.ttf_durr(lookin)
4
+ ret = []
5
+ Dir.entries(lookin).keep_if{|g| g[-4,4] == '.ttf'}.each{|v|
6
+ ret << [v[0..-4], (lookin + v)]
7
+ }
8
+ return ret
9
+ end
10
+
11
+ def IRGoggles.winXP_fonts
12
+ tink = []
13
+ lookin = ENV['SystemRoot'] + "/Fonts/"
14
+ Dir.entries(lookin).keep_if{|g| g[-4,4] == '.ttf'}.each{|v|
15
+ tink << [v[0..-4], (lookin + v)]
16
+ }
17
+ return tink
18
+ end
19
+
20
+ def IRGoggles.win7_fonts
21
+ fink = []
22
+ lookin = "C:/Windows/winsxs"
23
+ ffix = "amd64_microsoft-windows-font-truetype-/"
24
+ tup = Dir.entries(path).keep_if{|g| g[-4,4] == ".ttf"}
25
+ a = Dir.entries(lookin).keep_if{|x| (x[0,ffix.size] == ffix)}
26
+ b = a.collect{|v| Dir.entries(lookin + v) }
27
+ b.size.times{|g|
28
+ if b[g][-4,4] == ".ttf"
29
+ fink << [b[g][0..-4], a[g], tup]
30
+ end
31
+ }
32
+ return fink
33
+ end
34
+
35
+ def IRGoggles.nix_fonts
36
+ flib = []
37
+ sear = "/usr/share/fonts/truetype/"
38
+ Dir.entries(sear).each{|p|
39
+ unless ((p == '.') || (p == '..'))
40
+ fin = (sear + "/" + p)
41
+ Dir.entries(fin).each{|e|
42
+ if e[-4,4] == '.ttf'
43
+ flib << [e[0..-4], (fin + e)]
44
+ end
45
+ }
46
+ end
47
+ }
48
+ return flib
49
+ end
50
+
51
+ end#endmod
Binary file
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: IRGoggles
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.alpha
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Nietzschette
9
+ - Bangarang
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2015-06-26 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rubysdl
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.0
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 2.0.0
31
+ description: SDL-based interface for IRB.
32
+ email: Nietzschette01@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/IRGoggles.rb
38
+ - lib/IRGoggles/entities.rb
39
+ - lib/IRGoggles/Redicle.rb
40
+ - lib/IRGoggles/Strap.rb
41
+ - lib/IRGoggles/utilities.rb
42
+ - lib/datum/Basicdots.ttf
43
+ homepage: http://irgoggles.sourceforge.net
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>'
59
+ - !ruby/object:Gem::Version
60
+ version: 1.3.1
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.23
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: IR = Interactive Ruby. Goggles = for your face!
67
+ test_files: []