telescope-term 0.2
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 +7 -0
- data/bin/telescope +519 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fe9acb76c22f417d5ad5f68dd8c5e34f00dbe06d2d1d3147d3c4c155718d8e20
|
4
|
+
data.tar.gz: 1978de11b2f7d9ad85471ad025087db5ee4c7da050fc81fe8e42b5f9de4c6f74
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8fee3b2e553e25e13f7917f7de3d1acfde610b02b1dc48edc80b5507f741cdba598e6fa208d78cdbe8704dcb6b2047c98ab28819f25e278323bd8af6ca0d88d
|
7
|
+
data.tar.gz: e1391814eb3ff0c53b359c70cdf2a71ab56c6fadf23db979b356829557c31384aa729f471ae9d99de41a01056a174b48f04b4bd795e6d0e2ebbb9990cbf90a7d
|
data/bin/telescope
ADDED
@@ -0,0 +1,519 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
@help = <<HELPTEXT
|
4
|
+
Welcome to Telescope v0.2 - By Geir Isene (https://isene.com). This program is an aid for the amateur astronomer.
|
5
|
+
It shows basic info about your telescopes and your eyepieces in combination with your telescopes.
|
6
|
+
The top panel lists your telescopes with a set of properties. To add a telescope, press 't' and in the "command line"
|
7
|
+
at the bottom enter a name, the apperature (APP) and the focal length (FL) of your telescope, then press ENTER.
|
8
|
+
The lower panel lists your eyepieces with properties for each telescope. To add an eyepiece, press 'e'. Enter a name,
|
9
|
+
the focal length (FL) and apparent field of view (AFOV) and press ENTER.
|
10
|
+
You can select the telescope and eyepiece panel by pressing TAB, and each element of a panel by the UP and DOWN cursor keys.
|
11
|
+
Upon selecting an item, press ENTER and change the values in the command line. Delete an item by pressing 'D'.
|
12
|
+
Move an item up or down in a panel by pressing the PgUP or PgDown keys. Refresh all panels with the 'r' key.
|
13
|
+
You can escape the selected panels or the command line by pressing 'Ctrl-G'. Quit via 'q' or 'Q' if you don't want to
|
14
|
+
save your edits since last session. Telescope and eyepiece data is saved in the file '.telescope' in your home directory.
|
15
|
+
Save a backup session with 'b' and load a previously saved backup session with the 'B' key.
|
16
|
+
|
17
|
+
LIST OF TELESCOPE ABBREVIATIONS: LIST OF EYEPIECE ABBREVIATIONS:
|
18
|
+
APP = Apperature (in millimeters) FL = Focal Length (in millimeters)
|
19
|
+
FL = Focal Length (in millimeters) AFOV = Apparent Field Of View
|
20
|
+
F/? = Focal ratio (FL/APP) xMAGN = Magnification (with that telescope)
|
21
|
+
<MAG = Maximum magnitude visible FOV = True Field Of View (deg/min/sec)
|
22
|
+
xEYE = Light gathering compared to the human eye XPUP = Exit pupil (in millimeters)
|
23
|
+
MINx = Minimum usable magnification (may be lower for refractors)
|
24
|
+
MAXx = Maximum usable magnification
|
25
|
+
*FIELD = Recommended magnification for star fields
|
26
|
+
GX/NEB = Recommended magnification for galaxies and nebulae
|
27
|
+
PL/GCL = Recommended magnification for planets and globular clusters
|
28
|
+
PLd/2* = Recommended magnification for planet details and double stars
|
29
|
+
TGHT2* = Recommended magnification for tight double stars
|
30
|
+
DL-SEP = Minimum separation, Dawes limit
|
31
|
+
RC-SEP = Minimum separation, Rayleigh limit
|
32
|
+
MOON = Minimum feature resolved on the Moon (in meters)
|
33
|
+
SUN = Minimum feature resolved on the Sun (in kilometers)
|
34
|
+
HELPTEXT
|
35
|
+
begin # BASIC SETUP
|
36
|
+
if `tput cols`.to_i < 140
|
37
|
+
puts "You must run Telescope with a minimum tarminal width of 140 chracters."
|
38
|
+
end
|
39
|
+
require 'io/console'
|
40
|
+
require 'curses'
|
41
|
+
include Curses
|
42
|
+
|
43
|
+
Curses.init_screen
|
44
|
+
Curses.start_color
|
45
|
+
Curses.curs_set(0)
|
46
|
+
Curses.noecho
|
47
|
+
Curses.cbreak
|
48
|
+
Curses.stdscr.keypad = true
|
49
|
+
|
50
|
+
@ts = []
|
51
|
+
@ep = []
|
52
|
+
|
53
|
+
@tsmark = false
|
54
|
+
@epmark = false
|
55
|
+
end
|
56
|
+
if File.exist?(Dir.home+'/.telescope')
|
57
|
+
load(Dir.home+'/.telescope')
|
58
|
+
end
|
59
|
+
class Numeric # NUMERIC CLASS EXTENSION
|
60
|
+
def deg
|
61
|
+
self * Math::PI / 180
|
62
|
+
end
|
63
|
+
end
|
64
|
+
class Curses::Window # CLASS EXTENSION
|
65
|
+
# General extensions (see https://github.com/isene/Ruby-Curses-Class-Extension)
|
66
|
+
attr_accessor :color, :fg, :bg, :attr, :update
|
67
|
+
# Set self.color for an already defined color pair such as: init_pair(1, 255, 3)
|
68
|
+
# The color pair is defined like this: init_pair(index, foreground, background)
|
69
|
+
# self.fg is set for the foreground color (and is used if self.color is not set)
|
70
|
+
# self.bg is set for the background color (and is used if self.color is not set)
|
71
|
+
# self.attr is set for text attributes like Curses::A_BOLD
|
72
|
+
def clr # Clears the whole window
|
73
|
+
self.setpos(0, 0)
|
74
|
+
self.maxy.times {self.deleteln()}
|
75
|
+
self.refresh
|
76
|
+
self.setpos(0, 0)
|
77
|
+
end
|
78
|
+
def clr_to_cur_line
|
79
|
+
l = self.cury
|
80
|
+
self.setpos(0, 0)
|
81
|
+
l.times {self.deleteln()}
|
82
|
+
self.refresh
|
83
|
+
end
|
84
|
+
def clr_from_cur_line
|
85
|
+
l = self.cury
|
86
|
+
(self.maxy - l).times {self.deleteln()}
|
87
|
+
self.refresh
|
88
|
+
self.setpos(l, 0)
|
89
|
+
end
|
90
|
+
def fill # Fill window with color as set by self.color (or self.bg if not set)
|
91
|
+
self.setpos(0, 0)
|
92
|
+
self.fill_from_cur_pos
|
93
|
+
end
|
94
|
+
def fill_to_cur_pos # Fills the window up to current line
|
95
|
+
x = self.curx
|
96
|
+
y = self.cury
|
97
|
+
self.setpos(0, 0)
|
98
|
+
blank = " " * self.maxx
|
99
|
+
if self.color == nil
|
100
|
+
self.bg = 0 if self.bg == nil
|
101
|
+
self.fg = 255 if self.fg == nil
|
102
|
+
init_pair(self.fg, self.fg, self.bg)
|
103
|
+
y.times {self.attron(color_pair(self.fg)) {self << blank}}
|
104
|
+
else
|
105
|
+
y.times {self.attron(color_pair(self.color)) {self << blank}}
|
106
|
+
end
|
107
|
+
self.refresh
|
108
|
+
self.setpos(y, x)
|
109
|
+
end
|
110
|
+
def fill_from_cur_pos # Fills the rest of the window from current line
|
111
|
+
x = self.curx
|
112
|
+
y = self.cury
|
113
|
+
self.setpos(y, 0)
|
114
|
+
blank = " " * self.maxx
|
115
|
+
if self.color == nil
|
116
|
+
self.bg = 0 if self.bg == nil
|
117
|
+
self.fg = 255 if self.fg == nil
|
118
|
+
init_pair(self.fg, self.fg, self.bg)
|
119
|
+
self.maxy.times {self.attron(color_pair(self.fg)) {self << blank}}
|
120
|
+
else
|
121
|
+
self.maxy.times {self.attron(color_pair(self.color)) {self << blank}}
|
122
|
+
end
|
123
|
+
self.refresh
|
124
|
+
self.setpos(y, x)
|
125
|
+
end
|
126
|
+
def p(text) # Puts text to window
|
127
|
+
self.attr = 0 if self.attr == nil
|
128
|
+
if self.color == nil
|
129
|
+
self.bg = 0 if self.bg == nil
|
130
|
+
self.fg = 255 if self.fg == nil
|
131
|
+
init_pair(self.fg, self.fg, self.bg)
|
132
|
+
self.attron(color_pair(self.fg) | self.attr) { self << text }
|
133
|
+
else
|
134
|
+
self.attron(color_pair(self.color) | self.attr) { self << text }
|
135
|
+
end
|
136
|
+
self.refresh
|
137
|
+
end
|
138
|
+
def pclr(text) # Puts text to window and clears the rest of the window
|
139
|
+
self.p(text)
|
140
|
+
self.clr_from_cur_line
|
141
|
+
end
|
142
|
+
def paclr(fg, bg, attr, text) # Puts text to window with full set of attributes and clears rest of window
|
143
|
+
self.paclr(fg, bg, attr, text)
|
144
|
+
self.clr_from_cur_line
|
145
|
+
end
|
146
|
+
def pa(fg, bg, attr, text) # Puts text to window with full set of attributes
|
147
|
+
self.fg = fg
|
148
|
+
self.bg = bg
|
149
|
+
self.attr = attr
|
150
|
+
init_pair(self.fg, self.fg, self.bg)
|
151
|
+
self.attron(color_pair(self.fg) | self.attr) { self << text }
|
152
|
+
self.refresh
|
153
|
+
end
|
154
|
+
end
|
155
|
+
def getchr # PROCESS KEY PRESSES
|
156
|
+
c = STDIN.getch
|
157
|
+
case c
|
158
|
+
when "\e" # ANSI escape sequences
|
159
|
+
case $stdin.getc
|
160
|
+
when '[' # CSI
|
161
|
+
case $stdin.getc
|
162
|
+
when 'A' then chr = "UP"
|
163
|
+
when 'B' then chr = "DOWN"
|
164
|
+
when 'C' then chr = "RIGHT"
|
165
|
+
when 'D' then chr = "LEFT"
|
166
|
+
when 'Z' then chr = "S-TAB"
|
167
|
+
when '2' then chr = "INS" ; STDIN.getc
|
168
|
+
when '3' then chr = "DEL" ; STDIN.getc
|
169
|
+
when '5' then chr = "PgUP" ; STDIN.getc
|
170
|
+
when '6' then chr = "PgDOWN" ; STDIN.getc
|
171
|
+
when '7' then chr = "HOME" ; STDIN.getc
|
172
|
+
when '8' then chr = "END" ; STDIN.getc
|
173
|
+
end
|
174
|
+
end
|
175
|
+
when "", "" then chr = "BACK"
|
176
|
+
when "" then chr = "WBACK"
|
177
|
+
when "" then chr = "LDEL"
|
178
|
+
when "" then chr = "C-T"
|
179
|
+
when "" then chr = "C-G"
|
180
|
+
when "\r" then chr = "ENTER"
|
181
|
+
when "\t" then chr = "TAB"
|
182
|
+
when /./ then chr = c
|
183
|
+
end
|
184
|
+
return chr
|
185
|
+
end
|
186
|
+
def main_getkey # GET KEY FROM USER
|
187
|
+
chr = getchr
|
188
|
+
case chr
|
189
|
+
when '?' # Show helptext in right window
|
190
|
+
@w_ep.clr
|
191
|
+
@w_ep.pa(249, 0, 0, @help)
|
192
|
+
@w_ep.p("\n...Press any key to continue")
|
193
|
+
getch
|
194
|
+
when 'TAB'
|
195
|
+
if @tsmark
|
196
|
+
@tsmark = false
|
197
|
+
@epmark = 0
|
198
|
+
elsif @epmark
|
199
|
+
@epmark = false
|
200
|
+
@tsmark = false
|
201
|
+
else
|
202
|
+
@tsmark = 0
|
203
|
+
@epmark = false
|
204
|
+
end
|
205
|
+
when 'C-G'
|
206
|
+
@epmark = false
|
207
|
+
@tsmark = false
|
208
|
+
when 'ENTER'
|
209
|
+
if @tsmark
|
210
|
+
out = "#{@ts[@tsmark][0]}, #{@ts[@tsmark][1]}, #{@ts[@tsmark][2]}"
|
211
|
+
ret = w_cm_getstr("", out).split(",")
|
212
|
+
return if ret.length != 3
|
213
|
+
ret[1] = ret[1].to_i
|
214
|
+
ret[2] = ret[2].to_i
|
215
|
+
@ts[@tsmark] = ret
|
216
|
+
elsif @epmark
|
217
|
+
out = "#{@ep[@epmark][0]}, #{@ep[@epmark][1]}, #{@ep[@epmark][2]}"
|
218
|
+
ret = w_cm_getstr("", out).split(",")
|
219
|
+
return if ret.length != 3
|
220
|
+
ret[1] = ret[1].to_f
|
221
|
+
ret[2] = ret[2].to_i
|
222
|
+
@ep[@epmark] = ret
|
223
|
+
end
|
224
|
+
when 't'
|
225
|
+
return if @ts.length == 5
|
226
|
+
ret = w_cm_getstr("", "Telescope, App, FL").split(",")
|
227
|
+
return if ret.length != 3
|
228
|
+
ret[1] = ret[1].to_i
|
229
|
+
ret[2] = ret[2].to_i
|
230
|
+
ret[1] = 1 if ret[1] == 0
|
231
|
+
ret[2] = 1 if ret[2] == 0
|
232
|
+
@ts[@ts.length] = ret
|
233
|
+
when 'e'
|
234
|
+
ret = w_cm_getstr("", "Eyepiece, FL, AFOV").split(",")
|
235
|
+
return if ret.length != 3
|
236
|
+
ret[1] = ret[1].to_f
|
237
|
+
ret[2] = ret[2].to_i
|
238
|
+
ret[1] = 1 if ret[1] == 0
|
239
|
+
ret[2] = 1 if ret[2] == 0
|
240
|
+
@ep[@ep.length] = ret
|
241
|
+
when 'D'
|
242
|
+
if @tsmark
|
243
|
+
@ts.delete_at(@tsmark)
|
244
|
+
@tsmark -= 1
|
245
|
+
elsif @epmark
|
246
|
+
@ep.delete_at(@epmark)
|
247
|
+
@epmark -= 1
|
248
|
+
end
|
249
|
+
when 'UP' # Examples of moving up and down in a window
|
250
|
+
if @tsmark
|
251
|
+
@tsmark -= 1 unless @tsmark == 0
|
252
|
+
elsif @epmark
|
253
|
+
@epmark -= 1 unless @epmark == 0
|
254
|
+
end
|
255
|
+
when 'DOWN'
|
256
|
+
if @tsmark
|
257
|
+
@tsmark += 1 unless @tsmark == @ts.length - 1
|
258
|
+
elsif @epmark
|
259
|
+
@epmark += 1 unless @epmark == @ep.length - 1
|
260
|
+
end
|
261
|
+
when 'PgUP'
|
262
|
+
if @tsmark
|
263
|
+
t = @ts.delete_at(@tsmark)
|
264
|
+
@tsmark -= 1 unless @tsmark == 0
|
265
|
+
@ts.insert(@tsmark, t)
|
266
|
+
elsif @epmark
|
267
|
+
e = @ep.delete_at(@epmark)
|
268
|
+
@epmark -= 1 unless @epmark == 0
|
269
|
+
@ep.insert(@epmark, e)
|
270
|
+
end
|
271
|
+
when 'PgDOWN'
|
272
|
+
if @tsmark
|
273
|
+
t = @ts.delete_at(@tsmark)
|
274
|
+
@tsmark += 1 unless @tsmark == @ts.length
|
275
|
+
@ts.insert(@tsmark, t)
|
276
|
+
elsif @epmark
|
277
|
+
e = @ep.delete_at(@epmark)
|
278
|
+
@epmark += 1 unless @epmark == @ep.length
|
279
|
+
@ep.insert(@epmark, e)
|
280
|
+
end
|
281
|
+
when 'HOME'
|
282
|
+
if @tsmark
|
283
|
+
@tsmark = 0
|
284
|
+
elsif @epmark
|
285
|
+
@epmark = 0
|
286
|
+
end
|
287
|
+
when 'END'
|
288
|
+
if @tsmark
|
289
|
+
@tsmark = @ts.length - 1
|
290
|
+
elsif @epmark
|
291
|
+
@epmark = @ep.length - 1
|
292
|
+
end
|
293
|
+
when 'b'
|
294
|
+
File.write(Dir.home+'/.telescope.bu',"@ts = #{@ts}\n@ep = #{@ep}")
|
295
|
+
when 'B'
|
296
|
+
if File.exist?(Dir.home+'/.telescope.bu')
|
297
|
+
load(Dir.home+'/.telescope.bu')
|
298
|
+
end
|
299
|
+
when 'r'
|
300
|
+
@break = true
|
301
|
+
when 'q' # Exit
|
302
|
+
File.write(Dir.home+'/.telescope',"@ts = #{@ts}\n@ep = #{@ep}")
|
303
|
+
exit 0
|
304
|
+
when 'Q' # Exit
|
305
|
+
exit 0
|
306
|
+
else
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
# TELESCOPE FUNCTIONS (top window, w_ts)
|
311
|
+
def w_ts_show
|
312
|
+
@w_ts.setpos(0,0)
|
313
|
+
heading = " TELESCOPES APP(mm) FL(mm) F/? <MAG xEYE MINx MAXx *FIELD GX/NEB PL/GCL PLd/2* TGHT2* DL-SEP RC-SEP MOON SUN"
|
314
|
+
heading += " " * (@w_ts.maxx - heading.length).abs
|
315
|
+
@w_ts.pa(255, 94, Curses::A_BOLD, heading)
|
316
|
+
@w_ts.fg = 15
|
317
|
+
@w_ts.bg = 0
|
318
|
+
@ts.each_with_index do |scope, i|
|
319
|
+
name = scope[0]
|
320
|
+
d = scope[1]
|
321
|
+
f = scope[2]
|
322
|
+
out = " " + name.ljust(15)
|
323
|
+
out += d.to_s.rjust(8)
|
324
|
+
out += f.to_s.rjust(8)
|
325
|
+
@tsmark == i ? attr = Curses::A_BOLD | Curses::A_REVERSE : attr = Curses::A_BOLD
|
326
|
+
@w_ts.pa(254, 0, attr, out)
|
327
|
+
out = (f.to_f/d.to_f).truncate(1).to_s.rjust(6)
|
328
|
+
out = (f.to_f/d.to_f).truncate(1).to_s.rjust(6)
|
329
|
+
@w_ts.pa(254, 0, 0, out)
|
330
|
+
out = (5 * Math::log(d/10, 10) + 7.5).truncate(1).to_s.rjust(6)
|
331
|
+
@w_ts.pa(229, 0, 0, out)
|
332
|
+
out = (d**2/49).to_i.to_s.rjust(6)
|
333
|
+
@w_ts.pa(229, 0, 0, out)
|
334
|
+
out = magx(d, f, 1/7.to_f)
|
335
|
+
@w_ts.pa(194, 0, 0, out)
|
336
|
+
out = magx(d, f, 2)
|
337
|
+
@w_ts.pa(194, 0, 0, out)
|
338
|
+
out = magx(d, f, 1/6.4)
|
339
|
+
@w_ts.pa(189, 0, 0, out)
|
340
|
+
out = magx(d, f, 1/3.6)
|
341
|
+
@w_ts.pa(189, 0, 0, out)
|
342
|
+
out = magx(d, f, 1/2.1)
|
343
|
+
@w_ts.pa(189, 0, 0, out)
|
344
|
+
out = magx(d, f, 1/1.3)
|
345
|
+
@w_ts.pa(189, 0, 0, out)
|
346
|
+
out = magx(d, f, 1/0.7)
|
347
|
+
@w_ts.pa(189, 0, 0, out)
|
348
|
+
out = (115.824/d).truncate(2).to_s.rjust(7)
|
349
|
+
@w_ts.pa(219, 0, 0, out)
|
350
|
+
out = (3600*Math::asin(671E-6/d)*180/Math::PI).truncate(2).to_s.rjust(8)
|
351
|
+
@w_ts.pa(219, 0, 0, out)
|
352
|
+
moon = (384E6*Math::tan((Math::PI/180*115.824/d)/3600))
|
353
|
+
out = moon.to_i.to_s.rjust(6) + "m"
|
354
|
+
@w_ts.pa(225, 0, 0, out)
|
355
|
+
out = (moon/2.5668).to_i.to_s.rjust(5) + "km"
|
356
|
+
@w_ts.pa(225, 0, 0, out)
|
357
|
+
@w_ts.p("\n")
|
358
|
+
end
|
359
|
+
@w_ts.clr_from_cur_line
|
360
|
+
end
|
361
|
+
def magx(d, f, r)
|
362
|
+
m = d * r
|
363
|
+
e = f / m
|
364
|
+
return (m.to_i.to_s + "(" + e.to_i.to_s + ")").rjust(8)
|
365
|
+
end
|
366
|
+
|
367
|
+
# EYEPIECE FUNCTIONS (middle window, w_ep)
|
368
|
+
def w_ep_show
|
369
|
+
@w_ep.setpos(0,0)
|
370
|
+
scopes = 5
|
371
|
+
heading = " ".rjust(32)
|
372
|
+
@w_ep.pa(231, 240, 0, heading)
|
373
|
+
@ts.each do |scope|
|
374
|
+
@w_ep.pa(231, 240, Curses::A_BOLD, "│ ")
|
375
|
+
heading = scope[0].ljust(22)
|
376
|
+
@w_ep.pa(172, 240, Curses::A_BOLD, heading)
|
377
|
+
end
|
378
|
+
heading = " " * (@w_ep.maxx - @w_ep.curx)
|
379
|
+
@w_ep.p(heading)
|
380
|
+
heading = " EYEPIECES FL(mm) AFOV "
|
381
|
+
heading += "│ xMAGN FOV(dms) XPUP " * @ts.length
|
382
|
+
heading += " " * (@w_ep.maxx - heading.length).abs
|
383
|
+
@w_ep.pa(231, 240, Curses::A_BOLD, heading)
|
384
|
+
@w_ep.fg = 15
|
385
|
+
@w_ep.bg = 0
|
386
|
+
@ep.each_with_index do |ep, i|
|
387
|
+
name = ep[0]
|
388
|
+
m = ep[1].truncate(1)
|
389
|
+
a = ep[2]
|
390
|
+
out = " " + name.ljust(15)
|
391
|
+
out += m.to_s.rjust(8)
|
392
|
+
out += a.to_s.rjust(6) + "°"
|
393
|
+
@epmark == i ? attr = Curses::A_BOLD | Curses::A_REVERSE : attr = Curses::A_BOLD
|
394
|
+
@w_ep.pa(253, 0, attr, out)
|
395
|
+
@ts.each do |scope|
|
396
|
+
d = scope[1]
|
397
|
+
f = scope[2]
|
398
|
+
mag = (f.to_f/m)
|
399
|
+
out = mag.truncate(1).to_s.rjust(8)
|
400
|
+
@w_ep.pa(156, 0, 0, out)
|
401
|
+
fov = a/mag
|
402
|
+
deg = fov.to_i
|
403
|
+
mins = ((fov - fov.to_i) * 60)
|
404
|
+
min = mins.to_i
|
405
|
+
sec = ((mins - min) * 60).to_i
|
406
|
+
deg == 0 ? dgo = " " : dgo = deg.to_s + "°"
|
407
|
+
mno = min.to_s.rjust(2, " ") + "'"
|
408
|
+
sco = sec.to_s.rjust(2, " ") + "\""
|
409
|
+
out = (dgo + mno + sco).rjust(10)
|
410
|
+
@w_ep.pa(222, 0, 0, out)
|
411
|
+
out = (d/mag).truncate(1).to_s.rjust(6)
|
412
|
+
@w_ep.pa(209, 0, 0, out)
|
413
|
+
end
|
414
|
+
@w_ep.p("\n")
|
415
|
+
end
|
416
|
+
@w_ep.clr_from_cur_line
|
417
|
+
end
|
418
|
+
|
419
|
+
# COMMAND FUNCTIONS (bottom window, w_cm)
|
420
|
+
def w_cm_show
|
421
|
+
@w_cm.fill
|
422
|
+
@w_cm.p(" Telescope v0.2 - By Geir Isene (https://isene.com)")
|
423
|
+
end
|
424
|
+
def w_cm_getstr(pretext, text) # A SIMPLE READLINE-LIKE ROUTINE
|
425
|
+
Curses.curs_set(1)
|
426
|
+
Curses.echo
|
427
|
+
pos = text.length
|
428
|
+
chr = ""
|
429
|
+
while chr != "ENTER"
|
430
|
+
@w_cm.setpos(0,0)
|
431
|
+
init_pair(250, 250, 238)
|
432
|
+
text += " " * (@w_cm.maxx - text.length) if text.length < @w_cm.maxx
|
433
|
+
@w_cm.attron(color_pair(250)) { @w_cm << pretext + text }
|
434
|
+
@w_cm.setpos(0,pretext.length + pos)
|
435
|
+
@w_cm.refresh
|
436
|
+
chr = getchr
|
437
|
+
if chr == "C-G"
|
438
|
+
Curses.curs_set(0)
|
439
|
+
Curses.noecho
|
440
|
+
@w_cm.update = true
|
441
|
+
return ""
|
442
|
+
end
|
443
|
+
case chr
|
444
|
+
when 'RIGHT'
|
445
|
+
pos += 1 unless pos > text.length
|
446
|
+
when 'LEFT'
|
447
|
+
pos -= 1 unless pos == 0
|
448
|
+
when 'HOME'
|
449
|
+
pos = 0
|
450
|
+
when 'END'
|
451
|
+
pos = text.length
|
452
|
+
when 'DEL'
|
453
|
+
text[pos] = ""
|
454
|
+
when 'BACK'
|
455
|
+
unless pos == 0
|
456
|
+
pos -= 1
|
457
|
+
text[pos] = ""
|
458
|
+
end
|
459
|
+
when 'WBACK'
|
460
|
+
unless pos == 0
|
461
|
+
until text[pos - 1] == " " or pos == 0
|
462
|
+
pos -= 1
|
463
|
+
text[pos] = ""
|
464
|
+
end
|
465
|
+
if text[pos - 1] == " "
|
466
|
+
pos -= 1
|
467
|
+
text[pos] = ""
|
468
|
+
end
|
469
|
+
end
|
470
|
+
when 'LDEL'
|
471
|
+
text = ""
|
472
|
+
pos = 0
|
473
|
+
when /^.$/
|
474
|
+
text.insert(pos,chr)
|
475
|
+
pos += 1
|
476
|
+
end
|
477
|
+
end
|
478
|
+
curstr = text
|
479
|
+
Curses.curs_set(0)
|
480
|
+
Curses.noecho
|
481
|
+
return curstr
|
482
|
+
end
|
483
|
+
|
484
|
+
# MAIN PROGRAM
|
485
|
+
loop do # OUTER LOOP - (catching refreshes via 'r')
|
486
|
+
@break = false # Initialize @break variable (set if user hits 'r')
|
487
|
+
begin # Create the four windows/panels
|
488
|
+
if Curses.stdscr.maxx < 140
|
489
|
+
break
|
490
|
+
end
|
491
|
+
Curses.stdscr.bg = 236
|
492
|
+
Curses.stdscr.fg = 236
|
493
|
+
Curses.stdscr.fill
|
494
|
+
maxx = Curses.cols
|
495
|
+
maxy = Curses.lines
|
496
|
+
# Curses::Window.new(h,w,y,x)
|
497
|
+
@w_ts = Curses::Window.new(7, maxx - 2, 1, 1)
|
498
|
+
@w_ep = Curses::Window.new(maxy - 10, maxx - 2, 9, 1)
|
499
|
+
@w_cm = Curses::Window.new(1, maxx, maxy - 1, 0)
|
500
|
+
@w_ts.fg, @w_ts.bg = 15, 0
|
501
|
+
@w_ep.fg, @w_ep.bg = 255, 232
|
502
|
+
@w_cm.fg, @w_cm.bg = 233, 246
|
503
|
+
@w_ts.clr
|
504
|
+
@w_ep.clr
|
505
|
+
@w_cm.fill
|
506
|
+
loop do # INNER, CORE LOOP
|
507
|
+
w_ts_show
|
508
|
+
w_ep_show
|
509
|
+
w_cm_show
|
510
|
+
main_getkey # Get key from user
|
511
|
+
break if @break # Break to outer loop, redrawing windows, if user hit 'r'
|
512
|
+
break if Curses.cols != maxx or Curses.lines != maxy # break on terminal resize
|
513
|
+
end
|
514
|
+
ensure # On exit: close curses, clear terminal
|
515
|
+
close_screen
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
# vim: set sw=2 sts=2 et fdm=syntax fdn=2 fcs=fold\:\ :
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: telescope-term
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.2'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Geir Isene
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: curses
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.3.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.3.2
|
33
|
+
description: With this program you can list your telescopes and eyepieces and get
|
34
|
+
a set of calculations done for each scope and for the combination of scope and eyepiece.
|
35
|
+
Easy interface. Run the program, then hit '?' to show the help file.
|
36
|
+
email: g@isene.com
|
37
|
+
executables:
|
38
|
+
- telescope
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- bin/telescope
|
43
|
+
homepage: https://isene.com/
|
44
|
+
licenses:
|
45
|
+
- Unlicense
|
46
|
+
metadata:
|
47
|
+
source_code_uri: https://github.com/isene/telescope
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubygems_version: 3.1.2
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Terminal program to aid the amateur astronomer.
|
67
|
+
test_files: []
|