canis 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 816492c76956497f6216f58530ac662a8914f404
4
- data.tar.gz: 81030d5970df8c6ada548ad6a5cbe1782d8c2f16
3
+ metadata.gz: d5a775dee6fbf1b0f9bc371c1e11ec5822241396
4
+ data.tar.gz: ac9799e0d5419870a54b30f388b0e56984def45e
5
5
  SHA512:
6
- metadata.gz: 6a2294dabd5cd4b38db99ca783c7b3d2005dd9c3b3cb2823c4d284cf60d88f503f870cca06b9596224696a4e70f611417a9e29a341f862921df3e07497face81
7
- data.tar.gz: 6510464a766ee936761d32fbbaef6e2d9ed21f3e81d7425956f7d45de5dd2d5b1797cfd71c8799f1499187917f1d8a4c971ab8c0de88d777f134ed00730873f5
6
+ metadata.gz: f261dc96bb4b87476193966e16cbf8c417de1cd49f4b4e99a173837045ea527dc6e503916c06a868c2e9598fa981c30eaf7f749b58c7d730e5c4e2c06fb1aa3a
7
+ data.tar.gz: 992fe5d6546ece188d6b5599a03d94b6f3b35e86fb40e878dcda350107a389f51edd31929a522546a3d3ac6fd26ea263d194f766eb64fe14aba61be2f96f956b
data/CHANGES CHANGED
@@ -50,3 +50,8 @@ Built 0.0.2 but i did not release it.
50
50
  This way an app can have its own logger and not bother about canis' logging.
51
51
  Or it can merge the two.
52
52
  - Moved helpmanager from rwidgets to its own file. Needs to be refactored and cleaned up.
53
+
54
+ 2014-08-18 - 17:11
55
+ - for 0.0.5
56
+ - fixed a bug in handling of multiple key assignments due to which extra keys pushed onto stack
57
+ - App keyblock yields string of key without changing or converting to symbol
@@ -62,7 +62,7 @@ if $0 == __FILE__
62
62
  str = keycode_tos ch if ch.is_a? Fixnum
63
63
  #str1 = @window.key_tos ch if ch.is_a? Fixnum
64
64
  str1 = $key_chr
65
- $log.debug "#{ch} got (#{str} #{str1})"
65
+ $log.debug "#{ch} got (#{str} $key_chr:#{str1})"
66
66
  texta << "#{ch} got (#{str}) #{str1}"
67
67
  if ch == 99999
68
68
  name = get_string "Add a name for #{$key_chr}?"
@@ -28,6 +28,9 @@ module Canis
28
28
  # Maybe not be able to get your prompt correctly.
29
29
  #
30
30
  public
31
+ #
32
+ # suspends current program and puts user on unix prompt
33
+ #
31
34
  def suspend
32
35
  _suspend(false) do
33
36
  system("tput cup 26 0")
@@ -70,6 +73,10 @@ module Canis
70
73
  # Earlier close key was ENTER but we need that to execute or fire
71
74
  Canis::Viewer.view(res.split("\n"), :close_key => 'q', :title => "<q> to close, M-l M-h to scroll")
72
75
  end
76
+ #
77
+ # takes a unix command (system) and executes the same. No output
78
+ # @return return value of system command
79
+ #
73
80
  def shell_out command
74
81
  w = @window || @form.window
75
82
  w.hide
@@ -1,5 +1,20 @@
1
1
  require 'canis/core/system/ncurses'
2
2
 
3
+ # 2014-08-11 - 09:54
4
+ # There is a limit to the number of color pairs one can make 0 .. COLOR_PAIRS - 1
5
+ # which i why i get junk colors after 255. In my program, color_pairs is 32767 ???
6
+ #
7
+ # curses.init_pair(pair_number, fg, bg)
8
+ #
9
+ # Change the definition of a color-pair. It takes three arguments: the
10
+ # number of the color-pair to be changed, the foreground color number, and the
11
+ # background color number. The value of pair_number must be between 1 and
12
+ # COLOR_PAIRS - 1 (the 0 color pair is wired to white on black and cannot be
13
+ # changed). The value of fg and bg arguments must be between 0 and COLORS. If the
14
+ # color-pair was previously initialized, the screen is refreshed and all
15
+ # occurrences of that color-pair are changed to the new definition.
16
+ # - https://docs.python.org/2/library/curses.html
17
+
3
18
  module Canis
4
19
  module ColorMap
5
20
  # 2010-09-20 12:22 changed colors from string to symbol
@@ -17,6 +32,8 @@ module Canis
17
32
  def ColorMap.install_color fgc, bgc
18
33
  #$log.debug " install_color found #{fgc} #{@bgc} "
19
34
  @color_id += 1
35
+ # testing to see, since i get junk after 255 or so
36
+ #@color_id = 255 if @color_id > 255
20
37
  fg = ColorMap.get_color_const fgc
21
38
  bg = ColorMap.get_color_const bgc
22
39
  FFI::NCurses.init_pair(@color_id, fg, bg);
@@ -93,6 +110,13 @@ module Canis
93
110
 
94
111
  # $log.debug " colormap SETUP: #{$datacolor} #{$reversecolor} "
95
112
  end
113
+ # reset the color_id to zero so one can create colors from scratch.
114
+ # This is only to be used in the case of a color demo when you don't want the colors
115
+ # we originally made, since there seems to be a shortage of slots.
116
+ def ColorMap.reset_color_id
117
+ @color_id = 0
118
+ $color_map = {}
119
+ end
96
120
 
97
121
  end # modul
98
122
  if $0 == __FILE__
@@ -4,7 +4,7 @@
4
4
  # Author: jkepler http://github.com/mare-imbrium/canis/
5
5
  # Date: Around for a long time
6
6
  # License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
7
- # Last update: 2014-07-10 00:13
7
+ # Last update: 2014-08-15 12:12
8
8
  #
9
9
  # == CHANGED
10
10
  # removed dead or redudant code - 2014-04-22 - 12:53
@@ -18,16 +18,6 @@
18
18
  #
19
19
  require 'canis/core/system/ncurses'
20
20
  require 'canis/core/system/panel'
21
- # this is since often windows are declared with 0 height or width and this causes
22
- # crashes in the most unlikely places. This prevceents me from having to write ternary
23
- # e.g.
24
- # @layout[:width].ifzero(FFI::NCurses::LINES-2)
25
- class Fixnum
26
- def ifzero v
27
- return self if self != 0
28
- return v
29
- end
30
- end
31
21
  # This class is to be extended so that it can be called by anyone wanting to implement
32
22
  # chunks ot text with color and attributes. Chunkline consists of multiple chunks of colored text
33
23
  # and should implement a +each_with_color+.
@@ -36,21 +26,51 @@ end
36
26
  class AbstractChunkLine; end
37
27
 
38
28
  module Canis
29
+ # A Basic class of this library, all output is eventually done on a window.
30
+ # Root windows and dialogs use this class.
31
+ # A root window covers the entire screen, and is the basis of an application usually.
32
+ #
33
+ # == Examples
34
+ #
35
+ # w = Canis::Window.root_window
36
+ #
37
+ # w = Canis::Window.create_window( ht, wid, top, left)
38
+ #
39
+ # w = Canis::Window.new( ht, wid, top, left)
40
+ #
41
+ # layout = { :height => ht, :width => w, :top => t, :left => l }
42
+ # w = Canis::Window.new( layout )
43
+ #
44
+ # == Commonly used methods
45
+ #
46
+ # - destroy
47
+ # - printstring
48
+ # - wrefresh
49
+ # - getchar
50
+ # - print_border
51
+ #
39
52
  class Window
53
+ # dimensions of window
40
54
  attr_reader :width, :height, :top, :left
55
+ # hash containing dimensions
41
56
  attr_accessor :layout # hash containing hwtl
57
+ # panel related to window, used to delete it in the end
42
58
  attr_reader :panel # reader requires so he can del it in end
43
59
  attr_accessor :name # more for debugging log files. 2010-02-02 19:58
44
60
  #attr_accessor :modified # has it been modified and may need a refresh 2014-04-22 - 10:23 CLEANUP
61
+ #
45
62
  # for root windows we need to know the form so we can ask it to update when
46
63
  # there are overlapping windows.
47
64
  attr_accessor :form
48
65
 
49
- # creation and layout related {{{
66
+ # window init {{{
67
+ # creation and layout related.
50
68
  # @param [Array, Hash] window coordinates (ht, w, top, left)
69
+ #
51
70
  # or
71
+ #
52
72
  # @param [int, int, int, int] window coordinates (ht, w, top, left)
53
- # 2011-09-21 allowing array, or 4 ints, in addition to hash @since 1.3.1
73
+ #
54
74
  def initialize(*args)
55
75
 
56
76
  case args.size
@@ -109,7 +129,8 @@ module Canis
109
129
  $catch_alt_digits ||= false # is this where is should put globals ? 2010-03-14 14:00 XXX
110
130
  end
111
131
  ##
112
- # this is an alternative constructor
132
+ # this is an alternative constructor, which by default creates a window that covers the entire
133
+ # screen
113
134
  def self.root_window(layout = { :height => 0, :width => 0, :top => 0, :left => 0 })
114
135
 
115
136
  @layout = layout
@@ -131,6 +152,11 @@ module Canis
131
152
  # NOTE : if there are too many root windows, this could get expensive since we are updating all.
132
153
  # We may need to have a way to specify which window to repaint.
133
154
  # If there are non-root windows above, we may have manually refresh only the previous one.
155
+ # FIXME NOTE current our examples have lists and textpads that cover the root window so the
156
+ # refresh all is fine, but if there is screen area vacant then that will still be left black
157
+ # Similarly in the case of a dialog below, the window and box will not be painted.
158
+ # We may need a key for refreshing the entire window, such as ^L in which the form and the window
159
+ # is repainted.
134
160
  #
135
161
  def self.refresh_all current_win=nil
136
162
  #Ncurses.touchwin(FFI::NCurses.stdscr)
@@ -220,7 +246,9 @@ module Canis
220
246
  def wrefresh
221
247
  Ncurses.wrefresh(@window)
222
248
  end
223
- def delwin # 2011-09-7
249
+ #
250
+ # called by destroy()
251
+ def delwin
224
252
  Ncurses.delwin(@window)
225
253
  end
226
254
  def attron *args
@@ -251,6 +279,8 @@ module Canis
251
279
  #end
252
280
  # since include FFI is taking over, i need to force it here. not going into
253
281
  # method_missing
282
+
283
+ # move window to row and col
254
284
  def wmove y,x
255
285
  #Ncurses.wmove @window, y, x
256
286
  FFI::NCurses.wmove @window, y, x
@@ -366,6 +396,7 @@ module Canis
366
396
 
367
397
  # Ncurses panel
368
398
 
399
+ # hide the window
369
400
  def hide
370
401
  #return unless visible? # added 2011-10-14 these 2 are not behaving properly
371
402
  Ncurses::Panel.hide_panel @panel.pointer
@@ -374,6 +405,7 @@ module Canis
374
405
  @visible = false
375
406
  end
376
407
 
408
+ # show the window
377
409
  def show
378
410
  #return if visible? # added 2011-10-14 these 2 are not behaving properly
379
411
  Ncurses::Panel.show_panel @panel.pointer
@@ -413,7 +445,6 @@ module Canis
413
445
  end
414
446
 
415
447
  #
416
- # 2011-11-13 since 1.4.1
417
448
  # Widgets can get window to create a pad for them. This way when the window
418
449
  # is destroyed, it will delete all the pads. A widget wold not be able to do this.
419
450
  # The destroy method of the widget will be called.
@@ -680,6 +711,7 @@ module Canis
680
711
  # take some actions
681
712
  # end
682
713
  # end
714
+ # @see +command+ (alias)
683
715
  def close_command *args, &block
684
716
  @close_command ||= []
685
717
  @close_args ||= []
@@ -743,7 +775,7 @@ module Canis
743
775
  class DefaultKeyReader # --- {{{
744
776
  def initialize win
745
777
  @window = win
746
- @stack = []
778
+ #@stack = []
747
779
  end
748
780
 
749
781
  # return an int for the key read. this is just a single int, and is not interpreted
@@ -120,6 +120,9 @@ module Canis
120
120
  end
121
121
  $log.debug " CLOSING APP"
122
122
  end
123
+
124
+ # This method is called by run, and thus in most cases this is what is used.
125
+ # +run+ calls this without a block
123
126
  # not sure, but user shuld be able to trap keystrokes if he wants
124
127
  # but do i still call handle_key if he does, or give him total control.
125
128
  # But loop is already called by framework
@@ -142,9 +145,17 @@ module Canis
142
145
  break
143
146
  end
144
147
 
148
+ # execute a code block so caller program can handle keys from a hash or whatever.
149
+ # Currently this has the issue that the key is still evaluated again in the next block
150
+ # - A double evaluation can happen
151
+ # - these keys will not appear in help
152
+ # FIXME
145
153
  if @keyblock
146
154
  str = keycode_tos ch
147
- @keyblock.call(str.gsub(/-/, "_").to_sym) # not used ever
155
+ # why did we ever want to convert to a symbol. why not just pass it as is.
156
+ #@keyblock.call(str.gsub(/-/, "_").to_sym) # not used ever
157
+ ret = @keyblock.call(str)
158
+ @form.repaint if ret
148
159
  end
149
160
 
150
161
  yield ch if block # <<<----
@@ -191,6 +202,9 @@ module Canis
191
202
  # returns a symbol of the key pressed
192
203
  # e.g. :C_c for Ctrl-C
193
204
  # :Space, :bs, :M_d etc
205
+ # NOTE 2014-08-15 Trying with just string returned by keycode_tos
206
+ # This should allow for simpler apps that want to handle keys perhaps taken from a config file
207
+ # rather than bind each key manually.
194
208
  def keypress &block
195
209
  @keyblock = block
196
210
  end
@@ -198,7 +212,6 @@ module Canis
198
212
  # a label so it can be printed.
199
213
  def message text
200
214
  $status_message.value = text # trying out 2011-10-9
201
- #@message.value = text # 2011-10-17 14:07:01
202
215
  end
203
216
 
204
217
  # used only by LiveConsole, if enables in an app, usually only during testing.
@@ -366,17 +379,6 @@ module Canis
366
379
  #colorlabel = Label.new @form, {'text' => "Select a color:", "row" => row, "col" => col, "color"=>"cyan", "mnemonic" => 'S'}
367
380
  alias :text :label
368
381
 
369
- # print a title on first row -- this is so bad, not even a label
370
- def title string, config={}
371
- raise "don't use DELETE dead code"
372
- ## TODO center it
373
- @window.printstring 1, 30, string, $normalcolor, 'reverse'
374
- end
375
- # print a sutitle on second row, center and use a label, if this is even used.
376
- def subtitle string, config={}
377
- raise "don't use DELETE"
378
- @window.printstring 2, 30, string, $datacolor, 'normal'
379
- end
380
382
  # menu bar
381
383
 
382
384
  # displays a horizontal line
@@ -446,6 +448,7 @@ module Canis
446
448
  matches = opts.grep Regexp.new("^#{cmd}")
447
449
  end
448
450
 
451
+ # This is the method that is called by all apps usually that define an App block
449
452
  def run &block
450
453
  begin
451
454
 
@@ -4,7 +4,7 @@
4
4
  * Author: jkepler (http://github.com/mare-imbrium/canis/)
5
5
  * Date: 22.10.11 - 20:35
6
6
  * License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
7
- * Last update: 2013-04-01 13:43
7
+ * Last update: 2014-08-09 20:25
8
8
 
9
9
  == CHANGES
10
10
  == TODO
@@ -14,6 +14,17 @@
14
14
  NOTE: I have continued this in textpad which is a widget that uses pads to scroll.
15
15
  This is very rough, i may work on this more later.
16
16
  =end
17
+ # this is since often windows are declared with 0 height or width and this causes
18
+ # crashes in the most unlikely places. This prevceents me from having to write ternary
19
+ # e.g.
20
+ # @layout[:width].ifzero(FFI::NCurses::LINES-2)
21
+ class Fixnum
22
+ def ifzero v
23
+ return self if self != 0
24
+ return v
25
+ end
26
+ end
27
+
17
28
  require 'canis'
18
29
 
19
30
  include Canis
@@ -5,7 +5,7 @@
5
5
  # Author: j kepler http://github.com/mare-imbrium/canis/
6
6
  # Date: 2014-04-25 - 12:32
7
7
  # License: MIT
8
- # Last update: 2014-04-27 00:10
8
+ # Last update: 2014-08-09 18:55
9
9
  # ----------------------------------------------------------------------------- #
10
10
  # promptmenu.rb Copyright (C) 2012-2014 j kepler
11
11
  # Depends on rcommandwindow for display_menu
@@ -42,6 +42,7 @@ module Canis
42
42
  # and the rest are ordinary characters.
43
43
  #
44
44
  # == Example
45
+ #
45
46
  # menu = PromptMenu.new self do
46
47
  # item :s, :goto_start
47
48
  # item :b, :goto_bottom
@@ -358,18 +358,33 @@ class StatusWindow # --- {{{
358
358
  end # }}}
359
359
  # returns instance of a status_window for sending multiple
360
360
  # statuses during some process
361
+ # TODO FIXME block got ignored
361
362
  def status_window aconfig={}, &block
362
- return StatusWindow.new aconfig
363
+ sw = StatusWindow.new aconfig
364
+ return sw unless block_given?
365
+ begin
366
+ yield sw
367
+ ensure
368
+ sw.destroy if sw
369
+ end
363
370
  end
364
371
  # this is a popup dialog box on which statuses can be printed as a process is taking place.
365
372
  # I am reusing StatusWindow and so there's an issue since I've put a box, so in clearing
366
373
  # the line, I might overwrite the box
367
374
  def progress_dialog aconfig={}, &block
368
375
  aconfig[:layout] = [10,60,10,20]
376
+ # since we are printing a border
377
+ aconfig[:row_offset] ||= 4
378
+ aconfig[:col_offset] ||= 5
369
379
  window = status_window aconfig
370
380
  height = 10; width = 60
371
381
  window.win.print_border_mb 1,2, height, width, $normalcolor, FFI::NCurses::A_REVERSE
372
- return window
382
+ return window unless block_given?
383
+ begin
384
+ yield window
385
+ ensure
386
+ window.destroy if window
387
+ end
373
388
  end
374
389
  #
375
390
  # Display a popup and return the seliected index from list
@@ -8,7 +8,7 @@
8
8
  # Author: jkepler http://github.com/mare-imbrium/canis-core/
9
9
  # Date:
10
10
  # License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
11
- # Last update: 2011-11-16 - 00:07
11
+ # Last update: 2014-08-10 14:53
12
12
  #
13
13
  # CHANGES:
14
14
  # For some terminals, like xterm-256color which were not printing spaces
@@ -19,13 +19,27 @@
19
19
  require 'canis/core/widgets/rwidget'
20
20
  include Canis
21
21
  module Canis
22
+ # Maintain an application header on the top of an application.
23
+ # Application related text may be placed in the left, center or right slots.
24
+ #
25
+ # == Example
26
+ # a = ApplicationHeader.new "MyApp v1.0", :text_center => "Application Name", :text_right => "module",
27
+ # :color => :white, :bgcolor => :blue
28
+ #
29
+ # # Later as user traverses a list or table, update row number on app header
30
+ # a.text_right "Row #{n}"
31
+ #
22
32
  class ApplicationHeader < Widget
33
+ # text on left of header
23
34
  dsl_property :text1
35
+ # text on left of header, after text1
24
36
  dsl_property :text2
37
+ # text in center of header
25
38
  dsl_property :text_center
39
+ # text on right side of header
26
40
  dsl_property :text_right
27
41
 
28
-
42
+ # @param text1 String text on left of header
29
43
  def initialize form, text1, config={}, &block
30
44
 
31
45
  @name = "header"
@@ -47,6 +61,7 @@ module Canis
47
61
  @text_center ||= ""
48
62
  @text_right ||= ""
49
63
  end
64
+ # returns value of text1, i.e. text on left of header
50
65
  def getvalue
51
66
  @text1
52
67
  end
@@ -56,6 +71,8 @@ module Canis
56
71
  def repaint
57
72
  return unless @repaint_required
58
73
 
74
+ # 2014-08-10 - 14:53 changing bgcolor or color resets color_pair, so this must be reset if nil
75
+ @color_pair ||= get_color $bottomcolor, @color, @bgcolor
59
76
  #print_header(htext, posy = 0, posx = 0)
60
77
  att = get_attrib @attr
61
78
  len = @window.width
@@ -73,6 +90,7 @@ module Canis
73
90
  print_top_right(@text_right)
74
91
  @repaint_required = false
75
92
  end
93
+ # internal method, called by repain to print text1 and text2 on left side
76
94
  def print_header(htext, r = 0, c = 0)
77
95
  #win = @window
78
96
  #len = @window.width
@@ -81,6 +99,7 @@ module Canis
81
99
  #@form.window.printstring r, c, "%-*s" % [len, htext], @color_pair, @attr
82
100
  @form.window.printstring r, c, htext, @color_pair, @attr
83
101
  end
102
+ # internal method, called by repaint to print text_center in the center
84
103
  def print_center(htext, r = 0, c = 0)
85
104
  win = @window
86
105
  len = win.getmaxx
@@ -89,6 +108,7 @@ module Canis
89
108
  #@form.window.printstring r, c, "%-*s" % [len, htext], @color_pair, @attr
90
109
  win.printstring r, ((len-htext.length)/2).floor, htext, @color_pair, @attr
91
110
  end
111
+ # internal method to print text_right
92
112
  def print_top_right(htext)
93
113
  hlen = htext.length
94
114
  len = @window.getmaxx # width was not changing when resize happens
@@ -9,7 +9,7 @@
9
9
  * Author: jkepler (ABCD)
10
10
  * Date: 2008-11-19 12:49
11
11
  * License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
12
- * Last update: 2014-07-10 00:07
12
+ * Last update: 2014-08-18 14:58
13
13
 
14
14
  == CHANGES
15
15
  * 2011-10-2 Added PropertyVetoException to rollback changes to property
@@ -576,9 +576,13 @@ module Canis
576
576
  $log.debug " got node #{n} with #{e} "
577
577
  # instead of just nil, we need to go back up, but since not recursive ...
578
578
  #return nil unless n
579
- $log.debug "push unconsumed:#{unconsumed} " unless n
580
- unconsumed.each {|e| window.ungetch(e)} unless n
581
- return actions.last unless n
579
+ unless n
580
+ # testing shift otherwise it seems current key evaluated twice
581
+ unconsumed.shift
582
+ $log.debug "push unconsumed:#{unconsumed} " unless n
583
+ unconsumed.each {|e| window.ungetch(e)} unless n
584
+ return actions.last unless n
585
+ end
582
586
  mp = n.map
583
587
  # there are no more keys, only an action
584
588
  if mp.nil? or mp.empty?
@@ -766,7 +770,7 @@ module Canis
766
770
  # so that if block does not handle, the key can still be handled
767
771
  # e.g. table last row, last col does not handle, so it will auto go to next field
768
772
  # 2010-02-24 13:45 handles 2 key combinations, copied from Form, must be identical in logic
769
- # except maybe for window pointer. TODO not tested
773
+ # except maybe for window pointer.
770
774
  def _process_key keycode, object, window
771
775
  return :UNHANDLED if @_key_map.nil?
772
776
  chr = nil
@@ -1513,7 +1517,13 @@ module Canis
1513
1517
  end # }}}
1514
1518
 
1515
1519
  ##
1520
+ # Manages the controls/widgets on a screen.
1521
+ # Manages traversal, rendering and events of all widgets that are associated with it
1522
+ # via the +add_widget+ method.
1516
1523
  #
1524
+ # Passes keys pressed by user to the current field.
1525
+ # Any keys that are not handled by the current field, are handled by the form if the application
1526
+ # has bound the key via +bind_key+.
1517
1527
  # TODO: we don't have an event for when form is entered and exited.
1518
1528
  class Form # {{{
1519
1529
  include EventHandler
@@ -1872,7 +1882,10 @@ module Canis
1872
1882
  end
1873
1883
  f = @widgets[@active_index]
1874
1884
  index = @focusables.index(f)
1875
- index += 1
1885
+ # 2014-08-09 - 13:09 f may be status_line esp if ai is -1, so it is not found in focusables
1886
+ # why are we first checking widgets and then focusables.
1887
+ #index += 1
1888
+ index = index ? index+1 : 0
1876
1889
  f = @focusables[index]
1877
1890
  if f
1878
1891
  select_field f
@@ -2118,8 +2131,7 @@ module Canis
2118
2131
  $log.debug " form RESIZE HK #{ch} #{self}, #{@name} "
2119
2132
  repaint_all_widgets
2120
2133
  return
2121
- #when Ncurses::KEY_RESIZE # SIGWINCH
2122
- when FFI::NCurses::KEY_RESIZE # SIGWINCH # FFI
2134
+ when FFI::NCurses::KEY_RESIZE # SIGWINCH
2123
2135
  lines = Ncurses.LINES
2124
2136
  cols = Ncurses.COLS
2125
2137
  x = Ncurses.stdscr.getmaxy
@@ -4,8 +4,15 @@ module Canis
4
4
 
5
5
  #
6
6
  # A vim-like application status bar that can display time and various other statuses
7
- # at the bottom, typically above the dock (3rd line from last).
7
+ # at the bottom, typically above the dock (3rd line from last), or else the last line.
8
8
  #
9
+ # == Example
10
+ #
11
+ # require 'canis/core/widgets/statusline'
12
+ # @status_line = Canis::StatusLine.new @form, :row => Ncurses.LINES-2
13
+ # @status_line.command {
14
+ # "F1 Help | F2 Menu | F3 View | F4 Shell | F5 Sh | %20s" % [message_label.text]
15
+ # }
9
16
  class StatusLine < Widget
10
17
  #attr_accessor :row_relative # lets only advertise this when we've tested it out
11
18
 
@@ -36,9 +43,10 @@ module Canis
36
43
  #
37
44
  # command that returns a string that populates the status line (left aligned)
38
45
  # @see :right
39
- # See dbdemo.rb
40
- # e.g.
41
- # @l.command { "%-20s [DB: %-s | %-s ]" % [ Time.now, $current_db || "None", $current_table || "----"] }
46
+ # @see dbdemo.rb
47
+ # == Example
48
+ #
49
+ # @l.command { "%-20s [DB: %-s | %-s ]" % [ Time.now, $current_db || "None", $current_table || "----"] }
42
50
  #
43
51
  def command *args, &blk
44
52
  @command = blk
@@ -47,7 +55,7 @@ module Canis
47
55
  alias :left :command
48
56
 
49
57
  #
50
- # Procudure for text to be right aligned in statusline
58
+ # Procedure for text to be right aligned in statusline
51
59
  def right *args, &blk
52
60
  @right_text = blk
53
61
  @right_args = args
@@ -105,7 +113,8 @@ module Canis
105
113
 
106
114
  @repaint_required = false
107
115
  end
108
- def handle_keys ch
116
+ # not used since not focusable
117
+ def handle_keys ch
109
118
  return :UNHANDLED
110
119
  end
111
120
 
@@ -1,3 +1,3 @@
1
1
  module Canis
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kepler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-12 00:00:00.000000000 Z
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler