rbcurse-core 0.0.13 → 0.0.14

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.
@@ -177,12 +177,16 @@ module RubyCurses
177
177
  alist = val[0]
178
178
  case alist
179
179
  when Array
180
- @list = alist
181
- @current_index = 0
180
+ @list = alist
181
+ # I possibly should call init_vars in these 3 cases but am doing the minimal 2013-04-10 - 18:27
182
+ # Based no issue: https://github.com/rkumar/rbcurse/issues/15
183
+ @current_index = @toprow = @pcol = 0
182
184
  when NilClass
183
185
  @list = [] # or nil ?
186
+ @current_index = @toprow = @pcol = 0
184
187
  when Variable
185
188
  @list = alist.value
189
+ @current_index = @toprow = @pcol = 0
186
190
  else
187
191
  raise ArgumentError, "Listbox list(): do not know how to handle #{alist.class} "
188
192
  end
@@ -9,7 +9,7 @@
9
9
  * Author: rkumar (http://github.com/rkumar/rbcurse/)
10
10
  * Date: 22.10.11 - 20:35
11
11
  * License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
12
- * Last update: Sat Oct 22 20:35:46 IST 2011
12
+ * Last update: 2013-04-01 13:42
13
13
 
14
14
  == CHANGES
15
15
  == TODO
@@ -19,50 +19,52 @@ require 'rbcurse/core/widgets/rtabbedpane'
19
19
  require 'rbcurse/core/widgets/rcontainer'
20
20
 
21
21
  include RubyCurses
22
- class TabbedWindow
23
- attr_reader :tabbed_pane
24
- # The given block is passed to the TabbedPane
25
- # The given dimensions are used to create the window.
26
- # The TabbedPane is placed at 0,0 and fills the window.
27
- def initialize config={}, &block
28
-
29
- h = config.fetch(:height, 0)
30
- w = config.fetch(:width, 0)
31
- t = config.fetch(:row, 0)
32
- l = config.fetch(:col, 0)
33
- @window = VER::Window.new :height => h, :width => w, :top => t, :left => l
34
- @form = Form.new @window
35
- config[:row] = config[:col] = 0
36
- @tabbed_pane = TabbedPane.new @form, config , &block
37
- end
38
- # returns button index
39
- # Call this after instantiating the window
40
- def run
41
- @form.repaint
42
- @window.wrefresh
43
- return handle_keys
44
- end
45
- # returns button index
46
- private
47
- def handle_keys
48
- buttonindex = catch(:close) do
49
- while((ch = @window.getchar()) != FFI::NCurses::KEY_F10 )
50
- break if ch == ?\C-q.getbyte(0)
51
- begin
52
- @form.handle_key(ch)
53
- @window.wrefresh
54
- rescue => err
55
- $log.debug( err) if err
56
- $log.debug(err.backtrace.join("\n")) if err
57
- textdialog ["Error in TabbedWindow: #{err} ", *err.backtrace], :title => "Exception"
58
- $error_message.value = ""
59
- ensure
60
- end
22
+ module RubyCurses
23
+ class TabbedWindow
24
+ attr_reader :tabbed_pane
25
+ # The given block is passed to the TabbedPane
26
+ # The given dimensions are used to create the window.
27
+ # The TabbedPane is placed at 0,0 and fills the window.
28
+ def initialize config={}, &block
29
+
30
+ h = config.fetch(:height, 0)
31
+ w = config.fetch(:width, 0)
32
+ t = config.fetch(:row, 0)
33
+ l = config.fetch(:col, 0)
34
+ @window = VER::Window.new :height => h, :width => w, :top => t, :left => l
35
+ @form = Form.new @window
36
+ config[:row] = config[:col] = 0
37
+ @tabbed_pane = TabbedPane.new @form, config , &block
38
+ end
39
+ # returns button index
40
+ # Call this after instantiating the window
41
+ def run
42
+ @form.repaint
43
+ @window.wrefresh
44
+ return handle_keys
45
+ end
46
+ # returns button index
47
+ private
48
+ def handle_keys
49
+ buttonindex = catch(:close) do
50
+ while((ch = @window.getchar()) != FFI::NCurses::KEY_F10 )
51
+ break if ch == ?\C-q.getbyte(0)
52
+ begin
53
+ @form.handle_key(ch)
54
+ @window.wrefresh
55
+ rescue => err
56
+ $log.debug( err) if err
57
+ $log.debug(err.backtrace.join("\n")) if err
58
+ textdialog ["Error in TabbedWindow: #{err} ", *err.backtrace], :title => "Exception"
59
+ $error_message.value = ""
60
+ ensure
61
+ end
61
62
 
62
- end # while loop
63
- end # close
64
- $log.debug "XXX: CALLER GOT #{buttonindex} "
65
- @window.destroy
66
- return buttonindex
63
+ end # while loop
64
+ end # close
65
+ $log.debug "XXX: CALLER GOT #{buttonindex} "
66
+ @window.destroy
67
+ return buttonindex
68
+ end
67
69
  end
68
70
  end
@@ -8,7 +8,7 @@
8
8
  # Author: rkumar http://github.com/rkumar/mancurses/
9
9
  # Date: 2011-11-09 - 16:59
10
10
  # License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
11
- # Last update: 2013-03-29 18:59
11
+ # Last update: 2013-04-04 00:55
12
12
  #
13
13
  # == CHANGES
14
14
  # == TODO
@@ -55,7 +55,7 @@ module RubyCurses
55
55
  @startrow = 0
56
56
  @startcol = 0
57
57
  # @list is unused, think it can be removed
58
- @list = []
58
+ #@list = []
59
59
  super
60
60
 
61
61
  ## NOTE
@@ -145,9 +145,9 @@ module RubyCurses
145
145
  # 2013-03-27 - 01:51 separated so that widgets with headers such as tables can
146
146
  # override this for better control
147
147
  def render_all
148
- @content.each_index { |ix|
148
+ @content.each_with_index { |line, ix|
149
149
  #FFI::NCurses.mvwaddstr(@pad,ix, 0, @content[ix])
150
- render @pad, ix, @content[ix]
150
+ render @pad, ix, line
151
151
  }
152
152
  end
153
153
 
@@ -299,6 +299,7 @@ module RubyCurses
299
299
  @formatted_text = text
300
300
  @color_parser = fmt
301
301
  @repaint_required = true
302
+ _convert_formatted
302
303
  # don't know if start is always required. so putting in caller
303
304
  #goto_start
304
305
  #remove_all
@@ -361,20 +362,23 @@ module RubyCurses
361
362
  padrefresh
362
363
  return
363
364
  end
364
- if @formatted_text
365
- #$log.debug "XXX: INSIDE FORMATTED TEXT "
366
-
367
- l = RubyCurses::Utils.parse_formatted_text(@color_parser,
368
- @formatted_text)
369
-
370
- text(l)
371
- @formatted_text = nil
372
- end
365
+ # I can't recall why we are doing this late. Is the rreason relevant any longer
366
+ # Some methods that expect data are crashing like tablewidgets model_row
367
+ _convert_formatted
373
368
 
374
- ## moved this line up or else create_p was crashing
375
369
  @window ||= @graphic
376
370
  populate_pad if @_populate_needed
377
371
  #HERE we need to populate once so user can pass a renderer
372
+
373
+ _do_borders
374
+
375
+ padrefresh
376
+ Ncurses::Panel.update_panels
377
+ @repaint_required = false
378
+ @repaint_all = false
379
+ end
380
+
381
+ def _do_borders
378
382
  unless @suppress_borders
379
383
  if @repaint_all
380
384
  ## XXX im not getting the background color.
@@ -390,11 +394,16 @@ module RubyCurses
390
394
  @window.wrefresh
391
395
  end
392
396
  end
397
+ end
398
+ def _convert_formatted
399
+ if @formatted_text
393
400
 
394
- padrefresh
395
- Ncurses::Panel.update_panels
396
- @repaint_required = false
397
- @repaint_all = false
401
+ l = RubyCurses::Utils.parse_formatted_text(@color_parser,
402
+ @formatted_text)
403
+
404
+ text(l)
405
+ @formatted_text = nil
406
+ end
398
407
  end
399
408
 
400
409
  #
data/rbcurse-core.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rbcurse-core"
8
- s.version = "0.0.13"
8
+ s.version = "0.0.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rahul Kumar"]
12
- s.date = "2013-03-29"
12
+ s.date = "2013-04-14"
13
13
  s.description = "Ruby curses/ncurses widgets for easy application development on text terminals (ruby 1.9)"
14
14
  s.email = "sentinel1879@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbcurse-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-29 00:00:00.000000000 Z
12
+ date: 2013-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi-ncurses