telescope-term 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/telescope +81 -38
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ec5fe7e67a8718b893359293e5effc26ab0231dbb1140f9e7a3bcd27daaf595
4
- data.tar.gz: 2843d0b8045b3a9792c8da5da2fcec973bf52a5157dd704ef7d42ac87ac2d057
3
+ metadata.gz: a1f96d4afdd39035d8aff14031e43034607bd6772e71b57b46a6aca7280e372d
4
+ data.tar.gz: 99560838dfcc2488495387672c46976a2a9131d9196aceaea2a4307b219dd01a
5
5
  SHA512:
6
- metadata.gz: d0b2674b2f1a89074cf8a07da2bf519bf9c3bec13b75b1162331b174dbf55386e4224d8167707a9d6febcebb61da7dd75e13eeeeda6eafc30b367d45619c20bd
7
- data.tar.gz: 5cc9d3afc791fa9faa5e8c8aa27471404422dff3d5657ec99c1f030077ff49e184d08b075768caa6b1ca555bf520e3ee824a6b5233d006ef2841f5b9da81c8fd
6
+ metadata.gz: ab7ea6182535bdfd32f7ef8394630e1c3f17e73716d7ad175c19a7b05a75ea54f9cee7a45a9c69786d1f60d6a2acb55a16b18d97f660601bc2208762b0517286
7
+ data.tar.gz: 83587a7ec14ecf772f49542f2fb491ca3f86e87d1c86c1e5065ef4ed502816f0e09a0ac517778048ecff9e76d37a6ddc748c70fbbc215593445171c7521add29
data/bin/telescope CHANGED
@@ -4,8 +4,9 @@
4
4
  WELCOME TO TELESCOPE - A TERMINAL/CONSOLE PROGRAM FOR THE AMATEUR ASTRONOMER.
5
5
  The top panel lists your telescopes with eyepieces in the lower panel. Add a telescope by pressing 't' and fill in the name, the
6
6
  apperature (APP) and the focal length (FL) in the "command line" at the bottom and press ENTER. Add an eyepiece with 'e' and enter
7
- a name, the focal length (FL) and apparent field of view (AFOV) and press ENTER. Select items by pressing TAB, then UP/DOWN cursor keys.
7
+ a name, the focal length (FL) and apparent field of view (AFOV) and press ENTER. Select items by using the TAB/UP/DOWN cursor keys.
8
8
  Press ENTER on a selected item to change the values in the command line. Delete an item by pressing 'D'. Move an with PgUP/PgDown keys.
9
+ Sort telescopes with 'T' (toggles sorting by the first thre columns; Name, APP, FL). Sort eyepieces in the same way with the 'E' key.
9
10
  Tag items with the SPACE key (untag all with 'u'), then press 'o' to create an observation log file (content shown in the lower panel).
10
11
  Refresh all panels with the 'r' key. Escape the selected panels or the command line by pressing 'Ctrl-G'. Quit via 'q' (or 'Q' if you
11
12
  don't want to save your edits since last session). Save a backup session with 'b' and load a saved backup session with the 'B' key.
@@ -45,8 +46,11 @@ begin # BASIC SETUP
45
46
  @tsmark = false
46
47
  @epmark = false
47
48
 
48
- @tstag = []
49
- @eptag = []
49
+ @tstag = []
50
+ @eptag = []
51
+
52
+ @t_sort = false
53
+ @e_sort = false
50
54
  end
51
55
  if File.exist?(Dir.home+'/.telescope')
52
56
  load(Dir.home+'/.telescope')
@@ -54,6 +58,9 @@ end
54
58
  class Numeric # NUMERIC CLASS EXTENSION
55
59
  def deg
56
60
  self * Math::PI / 180
61
+ end
62
+ def rad
63
+ self * 180 / Math::PI
57
64
  end
58
65
  def dec2
59
66
  "%.2f" % self
@@ -184,12 +191,12 @@ end
184
191
  def main_getkey # GET KEY FROM USER
185
192
  chr = getchr
186
193
  case chr
187
- when '?' # Show helptext in right window
194
+ when '?' # Show helptext in lower panel
188
195
  @w_ep.clr
189
196
  @w_ep.pa(249, 0, 0, @help)
190
197
  @w_ep.p("\n ...Press any key to continue")
191
198
  getch
192
- when 'TAB'
199
+ when 'TAB' # Move between the panels
193
200
  if @tsmark
194
201
  @tsmark = false
195
202
  @epmark = 0
@@ -200,10 +207,10 @@ def main_getkey # GET KEY FROM USER
200
207
  @tsmark = 0
201
208
  @epmark = false
202
209
  end
203
- when 'C-G'
210
+ when 'C-G' # Escape from panel selections or command line
204
211
  @epmark = false
205
212
  @tsmark = false
206
- when 'ENTER'
213
+ when 'ENTER' # Edit selected item in the command line (or refresh panels)
207
214
  if @tsmark
208
215
  out = "#{@ts[@tsmark][0]}, #{@ts[@tsmark][1]}, #{@ts[@tsmark][2]}"
209
216
  ret = w_cm_getstr("", out).split(",")
@@ -219,7 +226,7 @@ def main_getkey # GET KEY FROM USER
219
226
  ret[2] = ret[2].to_i
220
227
  @ep[@epmark] = ret
221
228
  end
222
- when 't'
229
+ when 't' # Add a telescope
223
230
  return if @ts.length == 5
224
231
  ret = w_cm_getstr("", "Telescope, App, FL").split(",")
225
232
  return if ret.length != 3
@@ -228,7 +235,7 @@ def main_getkey # GET KEY FROM USER
228
235
  ret[1] = 1 if ret[1] == 0
229
236
  ret[2] = 1 if ret[2] == 0
230
237
  @ts[@ts.length] = ret
231
- when 'e'
238
+ when 'e' # Add an eyepiece
232
239
  ret = w_cm_getstr("", "Eyepiece, FL, AFOV").split(",")
233
240
  return if ret.length != 3
234
241
  ret[1] = ret[1].to_f
@@ -236,7 +243,7 @@ def main_getkey # GET KEY FROM USER
236
243
  ret[1] = 1 if ret[1] == 0
237
244
  ret[2] = 1 if ret[2] == 0
238
245
  @ep[@ep.length] = ret
239
- when 'D'
246
+ when 'D' # Delete selected item (telescope or eyepiece)
240
247
  if @tsmark
241
248
  @ts.delete_at(@tsmark)
242
249
  @tsmark -= 1
@@ -244,19 +251,55 @@ def main_getkey # GET KEY FROM USER
244
251
  @ep.delete_at(@epmark)
245
252
  @epmark -= 1
246
253
  end
247
- when 'UP' # Examples of moving up and down in a window
254
+ when 'T' # Sort telescopes by next column (Name, APP, FL)
255
+ if @t_sort == false or @t_sort == 2
256
+ @t_sort = 0
257
+ else
258
+ @t_sort += 1
259
+ end
260
+ @ts = @ts.sort {|a,b| b[@t_sort] <=> a[@t_sort]}
261
+ when 'E' # Sort eyepiece by next column (Name, FL, AFOV)
262
+ if @e_sort == false or @e_sort == 2
263
+ @e_sort = 0
264
+ else
265
+ @e_sort += 1
266
+ end
267
+ @ep = @ep.sort {|a,b| b[@e_sort] <=> a[@e_sort]}
268
+ when 'UP' # Move to one item up
248
269
  if @tsmark
249
- @tsmark -= 1 unless @tsmark == 0
270
+ if @tsmark == 0
271
+ @tsmark = false
272
+ else
273
+ @tsmark -= 1
274
+ end
250
275
  elsif @epmark
251
- @epmark -= 1 unless @epmark == 0
276
+ if @epmark == 0
277
+ @epmark = false
278
+ @tsmark = @ts.length - 1
279
+ else
280
+ @epmark -= 1
281
+ end
282
+ else
283
+ @epmark = @ep.length - 1
252
284
  end
253
- when 'DOWN'
285
+ when 'DOWN' # Move to one item down
254
286
  if @tsmark
255
- @tsmark += 1 unless @tsmark == @ts.length - 1
287
+ if @tsmark == @ts.length - 1
288
+ @tsmark = false
289
+ @epmark = 0
290
+ else
291
+ @tsmark += 1
292
+ end
256
293
  elsif @epmark
257
- @epmark += 1 unless @epmark == @ep.length - 1
294
+ if @epmark == @ep.length - 1
295
+ @epmark = false
296
+ else
297
+ @epmark += 1
298
+ end
299
+ else
300
+ @tsmark = 0
258
301
  end
259
- when 'PgUP'
302
+ when 'PgUP' # Move selected item up by one
260
303
  if @tsmark
261
304
  t = @ts.delete_at(@tsmark)
262
305
  @tsmark -= 1 unless @tsmark == 0
@@ -266,7 +309,7 @@ def main_getkey # GET KEY FROM USER
266
309
  @epmark -= 1 unless @epmark == 0
267
310
  @ep.insert(@epmark, e)
268
311
  end
269
- when 'PgDOWN'
312
+ when 'PgDOWN' # Move selected item by one down
270
313
  if @tsmark
271
314
  t = @ts.delete_at(@tsmark)
272
315
  @tsmark += 1 unless @tsmark == @ts.length
@@ -276,19 +319,19 @@ def main_getkey # GET KEY FROM USER
276
319
  @epmark += 1 unless @epmark == @ep.length
277
320
  @ep.insert(@epmark, e)
278
321
  end
279
- when 'HOME'
322
+ when 'HOME' # Jump to first item in the panel
280
323
  if @tsmark
281
324
  @tsmark = 0
282
325
  elsif @epmark
283
326
  @epmark = 0
284
327
  end
285
- when 'END'
328
+ when 'END' # Move to last item in the panel
286
329
  if @tsmark
287
330
  @tsmark = @ts.length - 1
288
331
  elsif @epmark
289
332
  @epmark = @ep.length - 1
290
333
  end
291
- when ' '
334
+ when ' ' # Tag selected item to be used in observation file/log
292
335
  if @tsmark
293
336
  @tstag.include?(@tsmark) ? @tstag.delete(@tsmark) : @tstag.push(@tsmark)
294
337
  @tsmark += 1 unless @tsmark == @ts.length - 1
@@ -296,23 +339,23 @@ def main_getkey # GET KEY FROM USER
296
339
  @eptag.include?(@epmark) ? @eptag.delete(@epmark) : @eptag.push(@epmark)
297
340
  @epmark += 1 unless @epmark == @ep.length - 1
298
341
  end
299
- when 'u'
342
+ when 'u' # Untag all tagget items
300
343
  @tstag.clear
301
344
  @eptag.clear
302
- when 'o'
345
+ when 'o' # Create observation file/log and show content in lower panel
303
346
  observe
304
- when 'b'
347
+ when 'b' # Create backup file (~/.telescope.bu) with current items
305
348
  File.write(Dir.home+'/.telescope.bu',"@ts = #{@ts}\n@ep = #{@ep}")
306
- when 'B'
349
+ when 'B' # Read items from backup file
307
350
  if File.exist?(Dir.home+'/.telescope.bu')
308
351
  load(Dir.home+'/.telescope.bu')
309
352
  end
310
- when 'r'
353
+ when 'r' # Hard refres panels
311
354
  @break = true
312
- when 'q' # Exit
355
+ when 'q' # Exit after saving items to ~/.telescope
313
356
  File.write(Dir.home+'/.telescope',"@ts = #{@ts}\n@ep = #{@ep}")
314
357
  exit 0
315
- when 'Q' # Exit
358
+ when 'Q' # Exit without saving items
316
359
  exit 0
317
360
  else
318
361
  end
@@ -336,7 +379,7 @@ def observe
336
379
  mag = (5 * Math::log(d/10, 10) + 7.5).truncate(1).to_s
337
380
  obs += " Max MAG: " + mag
338
381
  sepd = (115.824/d).truncate(2).to_s
339
- sepr = (3600*Math::asin(671E-6/d)*180/Math::PI).truncate(2).to_s
382
+ sepr = (3600*Math::asin(671E-6/d).rad).truncate(2).to_s
340
383
  obs += " Min SEP: " + sepd + "/" + sepr + "\n"
341
384
  end
342
385
  obs += "No telescope(s) chosen for the observation\n" if @tstag.empty?
@@ -377,16 +420,16 @@ end
377
420
  # TELESCOPE FUNCTIONS (top window, w_ts)
378
421
  def w_ts_show
379
422
  @w_ts.setpos(0,0)
380
- 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"
423
+ 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"
381
424
  heading += " " * (@w_ts.maxx - heading.length).abs
382
425
  @w_ts.pa(255, 94, Curses::A_BOLD, heading)
383
426
  @w_ts.fg = 15
384
427
  @w_ts.bg = 0
385
428
  @ts.each_with_index do |scope, i|
386
- name = scope[0]
429
+ name = scope[0][0...18]
387
430
  d = scope[1]
388
431
  f = scope[2]
389
- out = " " + name.ljust(15)
432
+ out = " " + name.ljust(18)
390
433
  out += d.to_s.rjust(8)
391
434
  out += f.to_s.rjust(8)
392
435
  attr = Curses::A_BOLD
@@ -415,9 +458,9 @@ def w_ts_show
415
458
  @w_ts.pa(189, 0, 0, out) # TGHT2*
416
459
  out = (115.824/d).truncate(2).dec2.to_s.rjust(7)
417
460
  @w_ts.pa(219, 0, 0, out) # DL-SEP
418
- out = (3600*Math::asin(671E-6/d)*180/Math::PI).truncate(2).dec2.to_s.rjust(8)
461
+ out = (3600*Math::asin(671E-6/d).rad).truncate(2).dec2.to_s.rjust(8)
419
462
  @w_ts.pa(219, 0, 0, out) # RC-SEP
420
- moon = (384E6*Math::tan((Math::PI/180*115.824/d)/3600))
463
+ moon = (384E6*Math::tan((115.824.deg/d)/3600))
421
464
  out = moon.to_i.to_s.rjust(6) + "m"
422
465
  @w_ts.pa(225, 0, 0, out) # MOON
423
466
  out = (moon/2.5668).to_i.to_s.rjust(5) + "km"
@@ -436,7 +479,7 @@ end
436
479
  def w_ep_show
437
480
  @w_ep.setpos(0,0)
438
481
  scopes = 5
439
- heading = " ".rjust(32)
482
+ heading = " ".rjust(35)
440
483
  @w_ep.pa(231, 240, 0, heading)
441
484
  @ts.each do |scope|
442
485
  @w_ep.pa(231, 240, Curses::A_BOLD, "│ ")
@@ -445,17 +488,17 @@ def w_ep_show
445
488
  end
446
489
  heading = " " * (@w_ep.maxx - @w_ep.curx)
447
490
  @w_ep.p(heading)
448
- heading = " EYEPIECES FL(mm) AFOV "
491
+ heading = " EYEPIECES FL(mm) AFOV "
449
492
  heading += "│ xMAGN FOV(dms) XPUP " * @ts.length
450
493
  heading += " " * (@w_ep.maxx - heading.length).abs
451
494
  @w_ep.pa(231, 240, Curses::A_BOLD, heading)
452
495
  @w_ep.fg = 15
453
496
  @w_ep.bg = 0
454
497
  @ep.each_with_index do |ep, i|
455
- name = ep[0]
498
+ name = ep[0][0...18]
456
499
  m = ep[1].truncate(1)
457
500
  a = ep[2]
458
- out = " " + name.ljust(15)
501
+ out = " " + name.ljust(18)
459
502
  out += m.to_s.rjust(8)
460
503
  out += a.to_s.rjust(6) + "°"
461
504
  attr = Curses::A_BOLD
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telescope-term
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-11 00:00:00.000000000 Z
11
+ date: 2021-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -32,8 +32,8 @@ dependencies:
32
32
  version: 1.3.2
33
33
  description: 'With this program you can list your telescopes and eyepieces and get
34
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. New in v0.5.2:
36
- Minor fixes.'
35
+ Easy interface. Run the program, then hit ''?'' to show the help file. New in v0.6.0:
36
+ Added sorting of telescopes (via ''T'') and eyepieces (''E'').'
37
37
  email: g@isene.com
38
38
  executables:
39
39
  - telescope