rbcurse-core 0.0.1 → 0.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.
@@ -33,6 +33,7 @@ require 'rbcurse'
33
33
  require 'rbcurse/core/include/listscrollable'
34
34
  require 'rbcurse/core/widgets/tabular'
35
35
  require 'rbcurse/core/include/listselectable'
36
+ require 'rbcurse/core/include/bordertitle'
36
37
 
37
38
  #include RubyCurses
38
39
  module RubyCurses
@@ -49,8 +50,8 @@ module RubyCurses
49
50
 
50
51
  include ListScrollable
51
52
  include NewListSelectable
52
- dsl_accessor :title # set this on top
53
- dsl_accessor :title_attrib # bold, reverse, normal
53
+ #dsl_accessor :title # set this on top
54
+ #dsl_accessor :title_attrib # bold, reverse, normal
54
55
  dsl_accessor :footer_attrib # bold, reverse, normal
55
56
  dsl_accessor :list # the array of arrays of data to be sent by user XXX RISKY bypasses set_content
56
57
  dsl_accessor :maxlen # max len to be displayed
@@ -58,9 +59,9 @@ module RubyCurses
58
59
  ##attr_reader :winrow # the row in the viewport/window
59
60
  # painting the footer does slow down cursor painting slightly if one is moving cursor fast
60
61
  dsl_accessor :print_footer
61
- dsl_accessor :suppress_borders
62
+ #dsl_accessor :suppress_borders
62
63
  attr_accessor :current_index
63
- dsl_accessor :border_attrib, :border_color # color pair for border
64
+ #dsl_accessor :border_attrib, :border_color # color pair for border
64
65
  dsl_accessor :header_attrib, :header_fgcolor, :header_bgcolor # 2010-10-15 13:21
65
66
 
66
67
  # boolean, whether lines should be cleaned (if containing tabs/newlines etc)
@@ -125,6 +126,7 @@ module RubyCurses
125
126
  install_keys # << almost jnuk now, clean off TODO
126
127
  init_vars
127
128
  map_keys
129
+ bordertitle_init
128
130
  end
129
131
  def init_vars #:nodoc:
130
132
  @curpos = @pcol = @toprow = @current_index = 0
@@ -135,8 +137,6 @@ module RubyCurses
135
137
  @internal_width = 2
136
138
  @internal_width = 0 if @suppress_borders
137
139
  # added 2010-02-11 15:11 RFED16 so we don't need a form.
138
- @win_left = 0
139
- @win_top = 0
140
140
  @current_column = 0
141
141
  # currently i scroll right only if current line is longer than display width, i should use
142
142
  # longest line on screen.
@@ -145,19 +145,12 @@ module RubyCurses
145
145
 
146
146
  end
147
147
  def map_keys
148
- # remove bindings from here. we call repeatedly
149
- bind_key([?g,?g], 'goto start'){ goto_start } # mapping double keys like vim
150
- bind_key([?',?'], 'goto last'){ goto_last_position } # vim , goto last row position (not column)
151
- bind_key(?/, :ask_search) # XXX TESTME
152
- bind_key(?n, :find_more) # XXX TESTME
153
- bind_key([?\C-x, ?>], :scroll_right)
154
- bind_key([?\C-x, ?<], :scroll_left)
155
- #bind_key(?r) { getstr("Enter a word: ") }
156
- bind_key(?m, :disp_menu) # enhance this or cut it out - how can app leverage this. TODO
148
+ require 'rbcurse/core/include/listbindings'
149
+ bindings()
157
150
  bind_key(?w, :next_column)
158
151
  bind_key(?b, :previous_column)
159
- bind_key(?i, :expand_column)
160
- list_bindings
152
+ bind_key(?>, :expand_column) # just trying out
153
+ list_bindings # selection bindings
161
154
  end
162
155
 
163
156
  #
@@ -367,7 +360,7 @@ module RubyCurses
367
360
  end
368
361
  ## print a border
369
362
  ## Note that print_border clears the area too, so should be used sparingly.
370
- def print_borders #:nodoc:
363
+ def OLDprint_borders #:nodoc:
371
364
  raise "#{self.class} needs width" unless @width
372
365
  raise "#{self.class} needs height" unless @height
373
366
 
@@ -378,7 +371,7 @@ module RubyCurses
378
371
  @graphic.print_border @row, @col, @height-1, @width, bordercolor, borderatt
379
372
  print_title
380
373
  end
381
- def print_title #:nodoc:
374
+ def OLDprint_title #:nodoc:
382
375
  raise "#{self.class} needs width" unless @width
383
376
  $log.debug " print_title #{@row}, #{@col}, #{@width} "
384
377
  @graphic.printstring( @row, @col+(@width-@title.length)/2, @title, $datacolor, @title_attrib) unless @title.nil?
@@ -440,30 +433,6 @@ module RubyCurses
440
433
  return ret unless ret == :UNHANDLED
441
434
  end
442
435
  case ch
443
- when ?\C-d.getbyte(0) #, 32
444
- scroll_forward
445
- when ?\C-b.getbyte(0)
446
- scroll_backward
447
- when ?\C-[.getbyte(0), ?t.getbyte(0)
448
- goto_start #start of buffer # cursor_start
449
- when ?\C-].getbyte(0), ?G.getbyte(0)
450
- goto_end # end / bottom cursor_end
451
- when KEY_UP, ?k.getbyte(0)
452
- #select_prev_row
453
- ret = up
454
- get_window.ungetch(KEY_BTAB) if ret == :NO_PREVIOUS_ROW
455
- check_curpos
456
-
457
- when KEY_DOWN, ?j.getbyte(0)
458
- ret = down
459
- #get_window.ungetch(KEY_TAB) if ret == :NO_NEXT_ROW
460
- check_curpos
461
- when KEY_LEFT, ?h.getbyte(0)
462
- cursor_backward
463
- when KEY_RIGHT, ?l.getbyte(0)
464
- cursor_forward
465
- when KEY_BACKSPACE, KEY_BSPACE, KEY_DELETE
466
- cursor_backward
467
436
  when ?\C-a.getbyte(0) #, ?0.getbyte(0)
468
437
  # take care of data that exceeds maxlen by scrolling and placing cursor at start
469
438
  @repaint_required = true if @pcol > 0 # tried other things but did not work
@@ -476,11 +445,7 @@ module RubyCurses
476
445
  blen = @buffer.rstrip.length
477
446
  set_form_col blen
478
447
  # search related
479
- when @KEY_ASK_FIND # FIXME
480
- ask_search
481
- when @KEY_FIND_MORE # FIXME
482
- find_more
483
- when 10, 13, KEY_ENTER
448
+ when KEY_ENTER, FFI::NCurses::KEY_ENTER
484
449
  #fire_handler :PRESS, self
485
450
  fire_action_event
486
451
  when ?0.getbyte(0)..?9.getbyte(0)
@@ -498,14 +463,6 @@ module RubyCurses
498
463
  # storing digits entered so we can multiply motion actions
499
464
  $multiplier *= 10 ; $multiplier += (ch-48)
500
465
  return 0
501
- #when ?\C-u.getbyte(0)
502
- ## multiplier. Series is 4 16 64
503
- #@multiplier = (@multiplier == 0 ? 4 : @multiplier *= 4)
504
- #return 0
505
- when ?\M-l.getbyte(0) # just added 2010-03-05 not perfect
506
- scroll_right # scroll data horizontally
507
- when ?\M-h.getbyte(0)
508
- scroll_left
509
466
  when ?\C-c.getbyte(0)
510
467
  $multiplier = 0
511
468
  return 0
@@ -516,15 +473,16 @@ module RubyCurses
516
473
  rescue => err
517
474
  $error_message.value = err.to_s
518
475
  # @form.window.print_error_message # changed 2011 dts
519
- textdialog ["Error in TabularWidget: #{err} ", *err.backtrace], :title => "Exception"
520
476
  $log.error " Tabularwidget ERROR #{err} "
521
477
  $log.debug(err.backtrace.join("\n"))
478
+ textdialog ["Error in TabularWidget: #{err} ", *err.backtrace], :title => "Exception"
522
479
  # XXX caller app has no idea error occurred so can't do anything !
523
480
  end
524
481
  return :UNHANDLED if ret == :UNHANDLED
525
482
  end
526
483
  $multiplier = 0 # you must reset if you've handled a key. if unhandled, don't reset since parent could use
527
484
  set_form_row
485
+ $status_message.value = "F10 quit, F1 Help, : menu, toprow #{@toprow} current #{@current_index} " if $log.debug?
528
486
  return 0 # added 2010-01-12 22:17 else down arrow was going into next field
529
487
  end
530
488
  #
@@ -658,8 +616,6 @@ module RubyCurses
658
616
  my_win = @target_window
659
617
  end
660
618
  @graphic = my_win unless @graphic
661
- @win_left = my_win.left
662
- @win_top = my_win.top
663
619
  tm = get_content
664
620
  rc = tm.length
665
621
  _estimate_column_widths if rc > 0 # will set preferred_width 2011-10-4
@@ -671,7 +627,6 @@ module RubyCurses
671
627
 
672
628
  print_borders if (@suppress_borders == false && @repaint_all) # do this once only, unless everything changes
673
629
  _maxlen = @maxlen || @width-@internal_width
674
- $log.debug " #{@name} Tabularwidget repaint width is #{@width}, height is #{@height} , maxlen #{maxlen}/ #{@maxlen}, #{@graphic.name} roff #{@row_offset} coff #{@col_offset}"
675
630
  tr = @toprow
676
631
  acolor = get_color $datacolor
677
632
  h = scrollatrow()
@@ -679,6 +634,7 @@ module RubyCurses
679
634
  print_header
680
635
  r += @_header_adjustment # for column header
681
636
  @longest_line = @width #maxlen
637
+ $log.debug " #{@name} Tabularwidget repaint width is #{@width}, height is #{@height} , maxlen #{maxlen}/ #{@maxlen}, #{@graphic.name} roff #{@row_offset} coff #{@col_offset}, r #{r} top #{toprow} ci #{current_index} "
682
638
  0.upto(h - @_header_adjustment) do |hh|
683
639
  crow = tr+hh
684
640
  if crow < rc
@@ -901,39 +857,10 @@ module RubyCurses
901
857
  #$log.debug " FMT : #{@fmstr} "
902
858
  #alert "format: #{@fmstr} "
903
859
  end
904
- ## this is just a test of prompting user for a string
905
- #+ as an alternative to the dialog.
906
- def getstr prompt, maxlen=10 #:nodoc:
907
- tabc = Proc.new {|str| Dir.glob(str +"*") }
908
- config={}; config[:tab_completion] = tabc
909
- config[:default] = "default"
910
- $log.debug " inside getstr before call "
911
- ret, str = rbgetstr(@form.window, @row+@height-1, @col+1, prompt, maxlen, config)
912
- $log.debug " rbgetstr returned #{ret} , #{str} "
913
- return "" if ret != 0
914
- return str
915
- end
916
- # this is just a test of the simple "most" menu
917
- def disp_menu #:nodoc:
918
- $error_message_row ||= 23 # FIXME
919
- $error_message_col ||= 1 # FIXME
920
- menu = PromptMenu.new self
921
- menu.add( menu.create_mitem( 's', "Goto start ", "Going to start", Proc.new { goto_start} ))
922
- menu.add(menu.create_mitem( 'r', "scroll right", "I have scrolled ", :scroll_right ))
923
- menu.add(menu.create_mitem( 'l', "scroll left", "I have scrolled ", :scroll_left ))
924
- item = menu.create_mitem( 'm', "submenu", "submenu options" )
925
- menu1 = PromptMenu.new( self, "Submenu Options")
926
- menu1.add(menu1.create_mitem( 's', "CASE sensitive", "Ignoring Case in search" ))
927
- menu1.add(menu1.create_mitem( 't', "goto last position", "moved to previous position", Proc.new { goto_last_position} ))
928
- item.action = menu1
929
- menu.add(item)
930
- # how do i know what's available. the application or window should know where to place
931
- #menu.display @form.window, 23, 1, $datacolor #, menu
932
- menu.display @form.window, $error_message_row, $error_message_col, $datacolor #, menu
933
- end
934
860
  ##
935
861
  # dynamically load a module and execute init method.
936
862
  # Hopefully, we can get behavior like this such as vieditable or multibuffers
863
+ # TODO CUT THIS OUT AND FIX IT, there are simpler ways like extend()
937
864
  def load_module requirename, includename
938
865
  require "rbcurse/#{requirename}"
939
866
  extend Object.const_get("#{includename}")
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rbcurse-core"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
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 = "2011-12-09"
12
+ s.date = "2011-12-13"
13
13
  s.description = "Ruby curses/ncurses widgets for easy application development on text terminals (ruby 1.9, 1.8)"
14
14
  s.email = "sentinel1879@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -58,6 +58,7 @@ Gem::Specification.new do |s|
58
58
  "lib/rbcurse/core/include/bordertitle.rb",
59
59
  "lib/rbcurse/core/include/chunk.rb",
60
60
  "lib/rbcurse/core/include/io.rb",
61
+ "lib/rbcurse/core/include/listbindings.rb",
61
62
  "lib/rbcurse/core/include/listcellrenderer.rb",
62
63
  "lib/rbcurse/core/include/listeditable.rb",
63
64
  "lib/rbcurse/core/include/listscrollable.rb",
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-09 00:00:00.000000000 Z
12
+ date: 2011-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi-ncurses
16
- requirement: &2232533180 !ruby/object:Gem::Requirement
16
+ requirement: &70266141084420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.4.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2232533180
24
+ version_requirements: *70266141084420
25
25
  description: Ruby curses/ncurses widgets for easy application development on text
26
26
  terminals (ruby 1.9, 1.8)
27
27
  email: sentinel1879@gmail.com
@@ -72,6 +72,7 @@ files:
72
72
  - lib/rbcurse/core/include/bordertitle.rb
73
73
  - lib/rbcurse/core/include/chunk.rb
74
74
  - lib/rbcurse/core/include/io.rb
75
+ - lib/rbcurse/core/include/listbindings.rb
75
76
  - lib/rbcurse/core/include/listcellrenderer.rb
76
77
  - lib/rbcurse/core/include/listeditable.rb
77
78
  - lib/rbcurse/core/include/listscrollable.rb