rbcurse-core 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -41,7 +41,9 @@ Core intends to be :
41
41
 
42
42
  ## Testing Status
43
43
 
44
- * Works on 1.9.3-p392 (my environment is zsh 5.0.x, tmux, TERM=screen-256color, OSX ML)
44
+ * Works on 1.9.3-p392 (my environment is zsh 5.0.x, tmux, TERM=screen-256color, OSX ML)
45
+ * Cannot promise if working on 1.8.7, am making some fixes (thanks hramrach), but may not be able to to
46
+ support 1.8.7 indefinitely. Please submit bugs on 1.8.7 if you find them.
45
47
 
46
48
  ## Other
47
49
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
data/examples/alpmenu.rb CHANGED
@@ -8,35 +8,35 @@ require 'rbcurse/core/util/app'
8
8
  stack :margin_top => 10, :margin_left => 15 do
9
9
  #w = "Messages".length + 1
10
10
  w = 60
11
- menulink :text => "&View Dirs", :width => w, :description => "View Dirs in tree" do |s|
11
+ menulink :text => "&View Dirs", :width => w, :description => "View Dirs in tree" do |s, *stuff|
12
12
  message "Pressed #{s.text} "
13
13
  load './dirtree.rb'
14
14
  #require './viewtodo'; todo = ViewTodo::TodoApp.new; todo.run
15
15
  end
16
16
  blank
17
- menulink :text => "&Tabular", :width => w, :description => "Tabula Rasa" do |s|
17
+ menulink :text => "&Tabular", :width => w, :description => "Tabula Rasa" do |s, *stuff|
18
18
  message "Pressed #{s.text} "
19
19
  load './tabular.rb'
20
20
  #require './testtodo'; todo = TestTodo::TodoApp.new; todo.run
21
21
  end
22
22
  blank
23
- menulink :text => "&Messages", :width => w, :description => "View Tasks" do |s|
23
+ menulink :text => "&Messages", :width => w, :description => "View Tasks" do |s, *stuff|
24
24
  message "Pressed #{s.text} "
25
25
  load './tasks.rb'
26
26
  end
27
27
  blank
28
- menulink :text => "&Database", :width => w, :description => "Database Demo" do |s|
28
+ menulink :text => "&Database", :width => w, :description => "Database Demo" do |s, *stuff|
29
29
  message "Pressed #{s.getvalue} "
30
30
  load './dbdemo.rb'
31
31
  end
32
32
  blank
33
33
  # somehow ? in mnemonic won't work
34
- menulink :text => "&Setup", :width => w, :description => "Configure Alpine options" do |s|
34
+ menulink :text => "&Setup", :width => w, :description => "Configure Alpine options" do |s, *stuff|
35
35
  #message "Pressed #{s.text} "
36
36
  alert "Not done!"
37
37
  end
38
38
  blank
39
- menulink :text => "&Quit", :width => w, :description => "Quit this application" do |s|
39
+ menulink :text => "&Quit", :width => w, :description => "Quit this application" do |s, *stuff|
40
40
  quit
41
41
  end
42
42
  @form.bind(:ENTER) do |w|
data/examples/app.sample CHANGED
@@ -10,7 +10,7 @@ App.new do
10
10
  :color => :black, :bgcolor => :white, :attr => :bold
11
11
  message "Press F10 to exit from here, F1 for help, F2 for menu"
12
12
 
13
- stack :margin_top => 1, height => FFI::NCurses.LINES-3 do
13
+ stack :margin_top => 1, :height => FFI::NCurses.LINES-3 do
14
14
 
15
15
  end # stack
16
16
  status_line :row => FFI::NCurses.LINES-1
data/examples/dbdemo.rb CHANGED
@@ -17,7 +17,7 @@ end
17
17
  def connect dbname
18
18
  $log.debug "XXX: CONNECT got #{dbname} "
19
19
  $current_db = dbname
20
- $db = SQLite3::Database.new(dbname)
20
+ $db = SQLite3::Database.new(dbname) if dbname
21
21
 
22
22
  return $db
23
23
  end
@@ -59,7 +59,9 @@ def create_popup array, selection_mode=:single, &blk
59
59
  end
60
60
  end
61
61
 
62
- def view_data fields='*', name
62
+ #
63
+ # changed order of name and fields, thanks hramrach
64
+ def view_data name, fields="*"
63
65
  stmt = "select #{fields} from #{name}"
64
66
  stmt << $where_string if $where_string
65
67
  stmt << $order_string if $order_string
@@ -192,7 +194,7 @@ App.new do
192
194
  command do |menuitem, text|
193
195
  $current_table = text
194
196
  #alert(get_column_names(text).join(", "))
195
- create_popup(get_column_names(text), :multiple) { |value| view_data( value.join(","), text) }
197
+ create_popup(get_column_names(text), :multiple) { |value| view_data( text, value.join(",") ) }
196
198
  end
197
199
  end
198
200
  item "New", "N"
@@ -281,7 +283,7 @@ App.new do
281
283
  unless c.empty?
282
284
  cols = c.join(",")
283
285
  end
284
- view_data cols, $selected_table
286
+ view_data $selected_table, cols
285
287
  else
286
288
  alert "Select a table first."
287
289
  end
@@ -407,7 +409,7 @@ App.new do
407
409
  unless c.empty?
408
410
  cols = c.join(",")
409
411
  end
410
- view_data cols, $current_table
412
+ view_data $current_table, cols
411
413
  else
412
414
  alert "Select a table first."
413
415
  end
@@ -402,7 +402,8 @@ module Io
402
402
  else
403
403
  raise ArgumentError, "Promptmenu needs hotkey or mnemonic"
404
404
  end
405
- labels << "%c. %s " % [ hk, item.label ]
405
+ # 187compat 2013-03-20 - 19:00 throws up
406
+ labels << "%c. %s " % [ hk.getbyte(0), item.label ]
406
407
  h[hk] = item
407
408
  valid << hk
408
409
  }
@@ -346,7 +346,12 @@ module ListScrollable
346
346
  row1 = @list[ix].to_s
347
347
 
348
348
  # 2011-09-29 crashing on a character F3 in log file
349
- row = row1.encode("ASCII-8BIT", :invalid => :replace, :undef => :replace, :replace => "?")
349
+ # 2013-03-20 - 18:25 187compat
350
+ if row1.respond_to? :encode
351
+ row = row1.encode("ASCII-8BIT", :invalid => :replace, :undef => :replace, :replace => "?")
352
+ else
353
+ row = row1
354
+ end
350
355
 
351
356
  m=row.match(regex)
352
357
  if !m.nil?
@@ -529,7 +534,10 @@ module ListScrollable
529
534
  def sanitize content #:nodoc:
530
535
  if content.is_a? String
531
536
  content.chomp!
532
- content.replace(content.encode("ASCII-8BIT", :invalid => :replace, :undef => :replace, :replace => "?"))
537
+ # 2013-03-20 - 18:29 187compat
538
+ if content.respond_to? :encode
539
+ content.replace(content.encode("ASCII-8BIT", :invalid => :replace, :undef => :replace, :replace => "?"))
540
+ end
533
541
  content.gsub!(/[\t\r\n]/, ' ') # don't display tab, newline
534
542
  content.gsub!(/\n/, ' ') # don't display tab, newline
535
543
  content.gsub!(/[^[:print:]]/, '') # don't display non print characters
@@ -7,8 +7,7 @@ module ColorMap
7
7
  # added check for fixnum if we go beyond these constants 2011-11-28
8
8
  # e.g. to use full 256 colors
9
9
  return colorstring if colorstring.is_a? Fixnum
10
- ret = FFI::NCurses.const_get "COLOR_#{colorstring.upcase}"
11
- #raise "color const nil ColorMap 8 " if !ret
10
+ ret = FFI::NCurses.const_get "COLOR_#{colorstring.to_s.upcase}"
12
11
  end
13
12
  ## private
14
13
  # creates a new color pair, puts in color map and returns color_pair
@@ -7,7 +7,7 @@
7
7
  # Author: rkumar http://github.com/rkumar/rbcurse/
8
8
  # Date: 07.11.11 - 13:17
9
9
  # License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
10
- # Last update: use ,,L
10
+ # Last update: 2013-03-21 00:44
11
11
  # ----------------------------------------------------------------------------- #
12
12
  # == TODO
13
13
  # - perhaps we can compile the regexp once and reuse
@@ -37,7 +37,7 @@ class AnsiParser
37
37
  a.each { |e|
38
38
  ## process color or attrib portion
39
39
  #[ "", "\e[1m", "", "\e[34m", "", "\e[47m", "Showing all items...", "\e[0m", "", "\e[0m", "\n"]
40
- if e[0] == "\x1b" && e[-1] == "m"
40
+ if e[0,1] == "\x1b" && e[-1,1] == "m"
41
41
 
42
42
  #e.each { |f| x=/^.\[(.*).$/.match(f)
43
43
  $log.debug "XXX: ANSI e #{e} "
@@ -7,7 +7,7 @@
7
7
  # Author: rkumar http://github.com/rkumar/rbcurse/
8
8
  # Date: 07.11.11 - 13:17
9
9
  # License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
10
- # Last update: use ,,L
10
+ # Last update: 2013-03-21 00:42
11
11
  # ----------------------------------------------------------------------------- #
12
12
  # == TODO
13
13
  # - perhaps we can compile the regexp once and reuse
@@ -24,6 +24,7 @@ class DefaultColorParser
24
24
  # @since 1.4.1 2011-11-3 experimental, can change
25
25
  # @return [nil] knows nothign about output format.
26
26
 
27
+ # 187compat 2013-03-20 - 19:33 not working in 187 so added ,1 in some cases for string
27
28
  def parse_format s # yields attribs or text
28
29
  ## set default colors
29
30
  color = :white
@@ -35,7 +36,7 @@ class DefaultColorParser
35
36
  a = s.split /(#\[[^\]]*\])/
36
37
  a.each { |e|
37
38
  ## process color or attrib portion
38
- if e[0,2] == "#[" && e[-1] == "]"
39
+ if e[0,2] == "#[" && e[-1,1] == "]"
39
40
  # now resetting 1:20 PM November 3, 2011 , earlier we were carrying over
40
41
  color, bgcolor, attrib = nil, nil, nil
41
42
  catch(:done) do
@@ -37,12 +37,14 @@ module RubyCurses
37
37
  @window = VER::Window.new(@layout)
38
38
  @start = 0 # row for display of text with paging
39
39
  @list = []
40
- require 'forwardable'
40
+ # 2013-03-21 - 00:34 removed due to 187
41
+ #require 'forwardable'
41
42
  require 'rbcurse/core/util/bottomline'
42
43
  @bottomline = Bottomline.new @window, 0
43
44
  @bottomline.name = "rcommandwindow's bl"
44
- extend Forwardable
45
- def_delegators :@bottomline, :ask, :say, :agree, :choose #, :display_text_interactive
45
+ # 187compat next line throws up on 187 module_eval undefined method for commandwindow
46
+ #extend Forwardable
47
+ #def_delegators :@bottomline, :ask, :say, :agree, :choose #, :display_text_interactive
46
48
  if @box == :border
47
49
  @window.box 0,0
48
50
  elsif @box
@@ -63,6 +65,20 @@ module RubyCurses
63
65
  @row_offset = 1
64
66
  end
65
67
  end
68
+ # 2013-03-21 - 187compat
69
+ #def_delegators :@bottomline, :ask, :say, :agree, :choose #, :display_text_interactive
70
+ def ask *args
71
+ @bottomline.send(:ask, *args)
72
+ end
73
+ def say *args
74
+ @bottomline.send(:say, *args)
75
+ end
76
+ def agree *args
77
+ @bottomline.send(:agree, *args)
78
+ end
79
+ def choose *args
80
+ @bottomline.send(:choose, *args)
81
+ end
66
82
  # modify the window title, or get it if no params passed.
67
83
  def title t=nil
68
84
  return @title unless t
@@ -4,7 +4,7 @@
4
4
  # Also, stacks and flows objects
5
5
  # Author: rkumar http://github.com/rkumar/rbcurse/
6
6
  # Date: 05.11.11 - 15:13
7
- # Last update: 2011-11-21 - 19:28
7
+ # Last update: 2013-03-21 00:55
8
8
  #
9
9
  # I hope this slowly does not become an unmaintainable maze like vimsplit
10
10
  #
@@ -93,7 +93,7 @@ module RubyCurses
93
93
  if path
94
94
  p="require \"#{path}\""
95
95
  end
96
- short ||= klass.downcase
96
+ short ||= klass.to_s.downcase
97
97
  eval %{
98
98
  def #{short}(config={}, &block)
99
99
  if config.is_a? String
@@ -8,7 +8,7 @@
8
8
  # Author: rkumar http://github.com/rkumar/rbcurse/
9
9
  # Date: 2011-11-11 - 21:42
10
10
  # License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
11
- # Last update: use ,,L
11
+ # Last update: 2013-03-21 01:45
12
12
  # ----------------------------------------------------------------------------- #
13
13
  #
14
14
  require 'rbcurse'
@@ -35,7 +35,13 @@ module RubyCurses
35
35
  def initialize form, config={}, &block
36
36
  @arrow_key_policy = :ignore
37
37
  @editable = false
38
- @COMBO_SYMBOL = "v".ord # trying this out
38
+ #@COMBO_SYMBOL = "v".ord # trying this out
39
+ # thanks hramrach for fix
40
+ if RUBY_VERSION < "1.9" then
41
+ @COMBO_SYMBOL = "v"[0] # trying this out
42
+ else
43
+ @COMBO_SYMBOL = "v".ord # trying this out
44
+ end
39
45
  @current_index = 0
40
46
  super
41
47
  # added if check since it was overriding set_buffer in creation. 2009-01-18 00:03
@@ -48,8 +54,11 @@ module RubyCurses
48
54
  @show_symbol = true if @show_symbol.nil? # if set to false don't touch
49
55
  #@show_symbol = false if @label # 2011-11-13
50
56
  @COMBO_SYMBOL ||= FFI::NCurses::ACS_DARROW #GEQUAL
51
- bind_key(KEY_UP) { previous_row }
52
- bind_key(KEY_DOWN) { next_row }
57
+
58
+ # next 2 lines giving an error in newtabbedwindow.rb example since the methods
59
+ # have been deprecated.
60
+ #bind_key(KEY_UP) { previous_row }
61
+ #bind_key(KEY_DOWN) { next_row }
53
62
  end
54
63
  def selected_item
55
64
  @list[@current_index]
@@ -9,7 +9,7 @@
9
9
  * Author: rkumar (arunachalesha)
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: 2013-03-16 20:06
12
+ * Last update: 2013-03-21 00:30
13
13
 
14
14
  == CHANGES
15
15
  * 2011-10-2 Added PropertyVetoException to rollback changes to property
@@ -30,10 +30,11 @@ require 'rbcurse/core/include/rinputdataevent' # for FIELD 2010-09-11 12:31
30
30
  require 'rbcurse/core/include/io'
31
31
  require 'rbcurse/core/system/keydefs'
32
32
 
33
- BOLD ||= FFI::NCurses::A_BOLD
34
- REVERSE ||= FFI::NCurses::A_REVERSE
35
- UNDERLINE ||= FFI::NCurses::A_UNDERLINE
36
- NORMAL ||= FFI::NCurses::A_NORMAL
33
+ # 2013-03-21 - 187compat removed ||
34
+ BOLD = FFI::NCurses::A_BOLD
35
+ REVERSE = FFI::NCurses::A_REVERSE
36
+ UNDERLINE = FFI::NCurses::A_UNDERLINE
37
+ NORMAL = FFI::NCurses::A_NORMAL
37
38
 
38
39
  class Object
39
40
  # thanks to terminal-table for this method
@@ -116,15 +117,24 @@ end
116
117
 
117
118
  # 2009-10-04 14:13 added RK after suggestion on http://www.ruby-forum.com/topic/196618#856703
118
119
  # these are for 1.8 compatibility
119
- class Fixnum
120
- def ord
121
- self
122
- end
123
- ## mostly for control and meta characters
124
- def getbyte(n)
125
- self
126
- end
127
- end unless "a"[0] == "a"
120
+ unless "a"[0] == "a"
121
+ class Fixnum
122
+ def ord
123
+ self
124
+ end
125
+ ## mostly for control and meta characters
126
+ def getbyte(n)
127
+ self
128
+ end
129
+ end unless "a"[0] == "a"
130
+ # 2013-03-21 - 187compat
131
+ class String
132
+ ## mostly for control and meta characters
133
+ def getbyte(n)
134
+ self[n]
135
+ end
136
+ end
137
+ end
128
138
 
129
139
  module RubyCurses
130
140
  extend self
@@ -461,7 +471,9 @@ module RubyCurses
461
471
  else
462
472
  raise ArgumentError, "Don't know how to handle #{arg.class} in PrefixManager"
463
473
  end
464
- @descriptions ||= []
474
+ # 2013-03-20 - 18:45 187compat gave error in 187 cannot convert string to int
475
+ #@descriptions ||= []
476
+ @descriptions ||= {}
465
477
  @descriptions[_keycode] = desc
466
478
 
467
479
  if !block_given?
@@ -95,6 +95,7 @@ module RubyCurses
95
95
  t = Time.now
96
96
  tt = t.strftime "%F %H:%M:%S"
97
97
  r = Ncurses.LINES
98
+ # 2013-03-20 - 19:04 next line printing as is in 187 ???? what to do
98
99
  ftext = "#[fg=green,bg=blue] %-20s" % [tt] # print a default
99
100
  @form.window.printstring_formatted_right @row, nil, ftext, $datacolor, Ncurses::A_REVERSE
100
101
  end
data/rbcurse-core.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rbcurse-core"
8
- s.version = "0.0.8"
8
+ s.version = "0.0.9"
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-18"
13
- s.description = "Ruby curses/ncurses widgets for easy application development on text terminals (ruby 1.9, 1.8)"
12
+ s.date = "2013-03-21"
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 = [
16
16
  "README.md"
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.8
4
+ version: 0.0.9
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-18 00:00:00.000000000 Z
12
+ date: 2013-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi-ncurses
@@ -28,7 +28,7 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.4.0
30
30
  description: Ruby curses/ncurses widgets for easy application development on text
31
- terminals (ruby 1.9, 1.8)
31
+ terminals (ruby 1.9)
32
32
  email: sentinel1879@gmail.com
33
33
  executables: []
34
34
  extensions: []