canis 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ # Some methods an application may like to use such as the ability to suspend cooked mode
2
+ # and go to shell, or run a command and view output without leaving the app.
1
3
  module Canis
2
4
  module Utils
3
5
  private
@@ -77,17 +79,24 @@ module Canis
77
79
  # takes a unix command (system) and executes the same. No output
78
80
  # @return return value of system command
79
81
  #
80
- def shell_out command
81
- w = @window || @form.window
82
- w.hide
82
+ def shell_out command=nil
83
+ $shell_history ||= []
84
+ command ||= get_string("Enter system command:", :maxlen => 50) do |f|
85
+ require 'canis/core/include/rhistory'
86
+ f.extend(FieldHistory)
87
+ f.history($shell_history)
88
+ end
89
+ ##w = @window || @form.window
90
+ #w.hide
83
91
  Ncurses.endwin
84
92
  ret = system command
85
93
  Ncurses.refresh
86
94
  #Ncurses.curs_set 0 # why ?
87
- w.show
95
+ #w.show
88
96
  return ret
89
97
  end
90
98
  end # utils
99
+
91
100
  class PrefixCommand
92
101
  attr_accessor :object
93
102
  def initialize _symbol, calling, config={}, &block
@@ -5,7 +5,7 @@
5
5
  # Author: jkepler http://github.com/mare-imbrium/canis/
6
6
  # Date: 07.11.11 - 12:31
7
7
  # Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
8
- # Last update: 2014-06-23 01:43
8
+ # Last update: 2014-09-01 11:57
9
9
  # ------------------------------------------------------------ #
10
10
  #
11
11
 
@@ -236,8 +236,8 @@ module Canis
236
236
  self.form = cp
237
237
  end
238
238
  @attr ||= FFI::NCurses::A_NORMAL
239
- @color ||= :white
240
- @bgcolor ||= :black
239
+ @color ||= $def_fg_color
240
+ @bgcolor ||= $def_bg_color
241
241
  @color_pair = get_color($datacolor, @color, @bgcolor)
242
242
  @color_array = [@color]
243
243
  @bgcolor_array = [@bgcolor]
@@ -345,6 +345,7 @@ module Canis
345
345
  res = ChunkLine.new
346
346
  # stack the values, so when user issues "/end" we can pop earlier ones
347
347
 
348
+ _color, _bgcolor = ColorMap.get_colors_for_pair colorp # 2014-08-31 - 13:31
348
349
  newblockflag = false
349
350
  @chunk_parser.parse_format(s) do |p|
350
351
  case p
@@ -358,26 +359,32 @@ module Canis
358
359
  if ls
359
360
  #sc, sb, sa = resolve_style ls
360
361
  map = resolve_style ls
361
- $log.debug " STYLLE #{ls} : #{map} "
362
+ #$log.debug " STYLLE #{ls} : #{map} "
362
363
  lc ||= map[:color]
363
364
  lb ||= map[:bgcolor]
364
365
  la ||= map[:attr]
365
366
  end
367
+ # 2014-09-01 should i set these to _color and _bgcolor if nil. NOTE
366
368
  @_bgcolor = lb
367
369
  @_color = lc
368
370
  if la
369
371
  @attr = get_attrib la
370
372
  end
371
373
  @_color_pair = nil
374
+ @_color_pair = colorp # 2014-08-31 - 13:20
375
+ # 2014-09-01 - 11:52 if only one of the two is given we were ignoring, now we
376
+ # need to derive the other one
372
377
  if lc && lb
373
378
  # we know only store color_pair if both are mentioned in style or tag
374
- @_color_pair = get_color(nil, lc, lb)
379
+ @_color_pair = get_color(colorp, lc, lb)
380
+ # added next two conditions on 2014-09-01 - 11:56 to take care of only one mentioned in
381
+ # #{ block.
382
+ elsif lc
383
+ @_color_pair = get_color(colorp, lc, _bgcolor)
384
+ elsif lb
385
+ @_color_pair = get_color(colorp, _color, lb)
375
386
  end
376
387
 
377
- #@color_pair_array << @color_pair
378
- #@attrib_array << @attr
379
- #$log.debug "XXX: CHUNK start cp=#{@color_pair} , a=#{@attr} :: c:#{lc} b:#{lb} : @c:#{@color} @bg: #{@bgcolor} "
380
- #$log.debug "XXX: CHUNK start arr #{@color_pair_array} :: #{@attrib_array} ::#{@color_array} ::: #{@bgcolor_array} "
381
388
 
382
389
  when :endcolor
383
390
 
@@ -387,6 +394,11 @@ module Canis
387
394
  @_color_pair = nil
388
395
  @attr = nil
389
396
 
397
+ # trying out 2014-08-31 - 13:09 since we have to respect passed in colors
398
+ @_color , @_bgcolor = _color, _bgcolor
399
+ @_color_pair = colorp
400
+ @attr = att
401
+
390
402
  #$log.debug "XXX: CHUNK end parents:#{@parents.count}, last: #{@parents.last} "
391
403
  when :reset # ansi has this
392
404
  # end all previous colors
@@ -396,6 +408,11 @@ module Canis
396
408
  @_bgcolor = @_color = nil
397
409
  @_color_pair = nil
398
410
  @attr = nil
411
+
412
+ # trying out 2014-08-31 - 13:09 since we have to respect passed in colors
413
+ @_color, @_bgcolor = _color, _bgcolor
414
+ @_color_pair = colorp
415
+ @attr = att
399
416
 
400
417
 
401
418
  when String
@@ -403,7 +420,11 @@ module Canis
403
420
  ## create the chunk
404
421
  #$log.debug "XXX: CHUNK using on #{p} : #{@_color_pair} , #{@attr}, fg: #{@_color}, #{@_bgcolor}, parent: #{@parents.last} " # 2011-12-10 12:38:51
405
422
 
406
- #chunk = [color_pair, p, attr]
423
+ # trying out 2014-08-31 - 13:09 since we have to respect passed in colors
424
+ @_color ||= _color
425
+ @_bgcolor ||= _bgcolor
426
+ @color_pair ||= colorp
427
+ @attr ||= att
407
428
  chunk = Chunk.new @_color_pair, p, @attr
408
429
  chunk.color = @_color
409
430
  chunk.bgcolor = @_bgcolor
@@ -5,7 +5,7 @@
5
5
  # Author: j kepler http://github.com/mare-imbrium/canis/
6
6
  # Date: 2014-04-10 - 21:04
7
7
  # License: Same as ruby license
8
- # Last update: 2014-07-07 00:36
8
+ # Last update: 2014-08-28 18:30
9
9
  # ----------------------------------------------------------------------------- #
10
10
  # listselectionmodel.rb Copyright (C) 2012-2014 j kepler
11
11
  # ----------------------------------------------------------------------------- #
@@ -43,7 +43,7 @@ module Canis
43
43
  # selection modes may be :multiple, :single or :none
44
44
  dsl_accessor :selection_mode
45
45
  # color of selected rows, and attribute of selected rows
46
- dsl_accessor :selected_color, :selected_bgcolor, :selected_attr
46
+ dsl_property :selected_color, :selected_bgcolor, :selected_attr
47
47
  # indices of selected rows
48
48
  dsl_accessor :selected_indices
49
49
  # model that takes care of selection operations
@@ -9,7 +9,7 @@
9
9
  # Author: jkepler http://github.com/mare-imbrium/canis/
10
10
  # Date: 2011-11-27 - 18:10
11
11
  # License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
12
- # Last update: 2011-11-27 - 20:11
12
+ # Last update: 2014-08-19 00:02
13
13
  # ----------------------------------------------------------------------------- #
14
14
  #
15
15
  # supply history for this object, at least give an empty array
@@ -83,7 +83,7 @@ module Canis
83
83
  #end
84
84
  r = @_history_config[:row] || r
85
85
  c = @_history_config[:col] || c
86
- ret = popuplist(list, :row => r, :col => c, :title => " History ")
86
+ ret = popuplist(list, :row => r, :col => c, :title => " History ", :color => :white, :bgcolor => :cyan)
87
87
  if ret
88
88
  self.text = list[ret]
89
89
  self.set_form_col
@@ -82,8 +82,8 @@ module Canis
82
82
  $color_map = {}
83
83
  FFI::NCurses.start_color();
84
84
  # Initialize few color pairs
85
- $def_fg_color = :white # pls set these 2 for your application
86
- $def_bg_color = :black
85
+ $def_fg_color ||= :white # pls set these 2 for your application
86
+ $def_bg_color ||= :black
87
87
  #COLORS = [COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE,
88
88
  # COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE]
89
89
  @@colors = [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white]
@@ -100,7 +100,7 @@ module Canis
100
100
  $errorcolor = ColorMap.get_color :white, :red
101
101
  #$promptcolor = $selectedcolor = ColorMap.get_color(:yellow, :red)
102
102
  $promptcolor = ColorMap.get_color(:yellow, :red)
103
- $normalcolor = $datacolor = ColorMap.get_color(:white, :black)
103
+ $normalcolor = $datacolor = ColorMap.get_color($def_fg_color, $def_bg_color)
104
104
  $bottomcolor = $topcolor = ColorMap.get_color(:white, :blue)
105
105
  $selectedcolor = $datacolor # since we now use reverse attr in list
106
106
 
@@ -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-08-15 12:12
7
+ # Last update: 2014-08-20 15:08
8
8
  #
9
9
  # == CHANGED
10
10
  # removed dead or redudant code - 2014-04-22 - 12:53
@@ -88,7 +88,7 @@ module Canis
88
88
  @visible = true
89
89
  set_layout(layout)
90
90
 
91
- #$log.debug "XXX:WINDOW got h #{@height}, w #{@width}, t #{@top}, l #{@left} "
91
+ $log.debug "XXX:WINDOW got h #{@height}, w #{@width}, t #{@top}, l #{@left} "
92
92
 
93
93
  @height = FFI::NCurses.LINES if @height == 0 # 2011-11-14 added since tired of checking for zero
94
94
  @width = FFI::NCurses.COLS if @width == 0
@@ -97,7 +97,7 @@ module Canis
97
97
  # trying out refreshing underlying window.
98
98
  $global_windows ||= []
99
99
  # this causes issues padrefresh failing when display_list does a resize.
100
- #$global_windows << self
100
+ $global_windows << self
101
101
  @panel = Ncurses::Panel.new(@window) # added FFI 2011-09-6
102
102
  #$error_message_row = $status_message_row = Ncurses.LINES-1
103
103
  $error_message_row ||= Ncurses.LINES-1
@@ -125,6 +125,7 @@ module Canis
125
125
  #Ncurses::wtimeout(@window, $ncurses_timeout || 500) # will wait a second on wgetch so we can get gg and qq
126
126
  #@stack = [] # since we have moved to handler 2014-04-20 - 11:15
127
127
  @name ||="#{self}"
128
+ $log.debug " WINDOW NAME is #{@name} "
128
129
  @modified = true
129
130
  $catch_alt_digits ||= false # is this where is should put globals ? 2010-03-14 14:00 XXX
130
131
  end
@@ -163,6 +164,7 @@ module Canis
163
164
  # above blanks out entire screen
164
165
  # in case of multiple root windows lets just do last otherwise too much refreshing.
165
166
  gw = $global_windows
167
+ $log.debug " REFRESH_ALL windows count = #{gw.count} "
166
168
  if current_win
167
169
  gw = $global_windows.select {|e| e != current_win }
168
170
  end
@@ -177,6 +179,8 @@ module Canis
177
179
  if f
178
180
  # send hack to root windows form if passed.
179
181
  f.handle_key 1000
182
+ else
183
+ $log.warn " REFRESH_ALL on #{w.name} (#{i}) NO FORM so could not send 1000 #{f}"
180
184
  end
181
185
  #w.ungetch(1000)
182
186
  # below blanks out entire screen too
@@ -440,6 +444,7 @@ module Canis
440
444
  # added here to hopefully take care of this issue once and for all.
441
445
  # Whenever any window is destroyed, the root window is repainted.
442
446
  #
447
+ # 2014-08-18 - 20:35 trying out without refresh all since lower dialog gets erased
443
448
  Window.refresh_all
444
449
  #$log.debug "win destroy end"
445
450
  end
@@ -1,7 +1,8 @@
1
1
  =begin
2
2
  * Name: App
3
- * Description: Experimental Application class
4
- * Author: jkepler (ABCD)
3
+ * Description: Application class that wraps starting and shutting ncurses and creating a root window
4
+ and form.
5
+ * Author: jkepler
5
6
  * file created 2010-09-04 22:10
6
7
  Todo:
7
8
 
@@ -34,7 +35,6 @@ module Canis
34
35
  # - box / rect
35
36
  # - para looks like a label that is more than one line, and calculates rows itself based on text
36
37
  # - multicontainer
37
- # - multitextview, multisplit
38
38
  # - tabbedpane
39
39
  # / table - more work regarding vim keys, also editable
40
40
  # - margin - is left offset
@@ -42,6 +42,8 @@ module Canis
42
42
  #
43
43
 
44
44
  # 2014-04-17 - 13:15 XXX are these used. required ???
45
+ =begin
46
+ # 2014-08-19 - 20:48 trying to remove excess convenience code
45
47
  class Widget
46
48
  def changed *args, &block
47
49
  bind :CHANGED, *args, &block
@@ -57,9 +59,11 @@ module Canis
57
59
  bind :PRESS, *args, &block
58
60
  end
59
61
  end
62
+ =end
60
63
  class CheckBox
61
64
  # a little dicey XXX
62
65
  def text(*val)
66
+ raise "FIXME this is being used Checkbox app.rb text(), otherwise delete this. 2014-08-19 - 21:01 "
63
67
  if val.empty?
64
68
  @value ? @onvalue : @offvalue
65
69
  else
@@ -75,8 +79,6 @@ module Canis
75
79
  attr_reader :form
76
80
  attr_reader :window
77
81
  attr_writer :quit_key
78
- # the row on which to prompt user for any inputs
79
- #attr_accessor :prompt_row # 2011-10-17 14:06:22
80
82
 
81
83
  # TODO: i should be able to pass window coords here in config
82
84
  # :title
@@ -87,7 +89,7 @@ module Canis
87
89
  widget_shortcuts_init
88
90
  @variables = {}
89
91
  # if we are creating child objects then we will not use outer form. this object will manage
90
- @current_object = []
92
+ #@current_object = [] # 2014-08-29 - 17:35 unused
91
93
  @_system_commands = %w{ bind_global bind_component field_help_text }
92
94
 
93
95
  init_vars
@@ -102,8 +104,6 @@ module Canis
102
104
  init_ncurses
103
105
  end
104
106
  $lastline = Ncurses.LINES - 1
105
- #@message_row = Ncurses.LINES-1
106
- #@prompt_row = @message_row # hope to use for ask etc # 2011-10-17 14:06:27
107
107
  unless $log
108
108
  logpath=ENV["CANIS_LOG_PATH"]
109
109
  $log = create_logger(logpath || "/dev/null")
@@ -112,7 +112,7 @@ module Canis
112
112
  def logger; return $log; end
113
113
  def close
114
114
  $log.debug " INSIDE CLOSE, #{@stop_ncurses_on_close} "
115
- @window.destroy if !@window.nil?
115
+ @window.destroy if @window
116
116
  $log.debug " INSIDE CLOSE, #{@stop_ncurses_on_close} "
117
117
  if @stop_ncurses_on_close
118
118
  Canis::stop_ncurses
@@ -138,39 +138,39 @@ module Canis
138
138
  while true
139
139
  catch :close do
140
140
  while((ch = @window.getchar()) != 999 )
141
- #break if ch == @break_key
142
141
  if ch == @break_key || ch == @quit_key
143
- #stopping = @window.fire_close_handler
144
- #break if stopping.nil? || stopping
145
142
  break
146
143
  end
147
144
 
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
153
- if @keyblock
154
- str = keycode_tos ch
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
159
- end
160
145
 
161
- yield ch if block # <<<----
146
+ # 2014-08-19 - 22:51 commented next line, too much choice. keep it simple. delete in a month FIXME
147
+ #yield ch if block # <<<----
148
+
162
149
  # this is what the user should have control ove. earlier we would put this in
163
150
  # a try catch block so user could do what he wanted with the error. Now we
164
151
  # need to get it to him somehow, perhaps through a block or on_error event
165
152
  begin
153
+ # execute a code block so caller program can handle keys from a hash or whatever.
154
+ # NOTE: these keys will not appear in help
155
+ # FIXME : ideally if its just a hash, we should allow user to give it to form
156
+ # or widget which it will use, or merge, and be able to print help from
157
+ if @keyblock
158
+ str = keycode_tos ch
159
+ # why did we ever want to convert to a symbol. why not just pass it as is.
160
+ #@keyblock.call(str.gsub(/-/, "_").to_sym) # not used ever
161
+ ret = @keyblock.call(str)
162
+ if ret
163
+ @form.repaint
164
+ next
165
+ end
166
+ end
166
167
  @form.handle_key ch
167
168
  rescue => err
168
- $log.debug( "handle_key rescue reached ")
169
+ $log.debug( "app.rb handle_key rescue reached ")
169
170
  $log.debug( err.to_s)
170
171
  $log.debug(err.backtrace.join("\n"))
171
172
  textdialog [err.to_s, *err.backtrace], :title => "Exception"
172
173
  end
173
- #@form.repaint # was this duplicate ?? handle calls repaint not needed
174
174
  @window.wrefresh
175
175
  end
176
176
  end # catch
@@ -181,6 +181,7 @@ module Canis
181
181
  end
182
182
  # if calling loop separately better to call this, since it will shut off ncurses
183
183
  # and print error on screen.
184
+ # UNUSED
184
185
  def safe_loop &block
185
186
  begin
186
187
  loop &block
@@ -296,14 +297,6 @@ module Canis
296
297
  @form.bind_key(key){ send(cmd.to_sym) }
297
298
  end
298
299
  end
299
- def bind_component
300
- #rb_puts "Todo. ", :color_pair => get_color($promptcolor, :red, :black)
301
- print_error_message "Todo this. "
302
- # the idea here is to get the current component
303
- # and bind some keys to some methods.
304
- # however, how do we divine the methods we can map to
305
- # and also in some cases the components itself has multiple components
306
- end
307
300
  # displays help_text associated with field. 2011-10-15
308
301
  def field_help_text
309
302
  f = @form.get_current_field
@@ -389,6 +382,7 @@ module Canis
389
382
  # @example
390
383
  # hline :width => 55
391
384
  def hline config={}
385
+ raise "I think this is unused. removed if this does not raise 2014-08-29 - 12:43 "
392
386
  row = config[:row] || @app_row
393
387
  width = config[:width] || 20
394
388
  _position config
@@ -457,63 +451,6 @@ module Canis
457
451
  awin = @window
458
452
  catch(:close) do
459
453
  @form = Form.new @window
460
- @form.bind_key([?\C-x, ?c], 'suspend') { suspend(false) do
461
- system("tput cup 26 0")
462
- system("tput ed")
463
- system("echo Enter C-d to return to application")
464
- system (ENV['PS1']='\s-\v\$ ')
465
- system(ENV['SHELL']);
466
- end
467
- }
468
- # this is a very rudimentary default command executer, it does not
469
- # allow tab completion. App should use M-x with names of commands
470
- # as in appgmail
471
- # NOTE: This is gonna change very soon - 2012-01-8
472
- @form.bind_key(?:, 'prompt') {
473
- str = get_command_from_user
474
- }
475
-
476
- # this M-x stuff has to be moved out so it can be used by all. One should be able
477
- # to add_commands properly to this, and to C-x. I am thinking how to go about this,
478
- # and what function M-x actually serves.
479
-
480
- @form.bind_key(?\M-x, 'M-x commands'){
481
- # TODO previous command to be default
482
- opts = get_all_commands()
483
- @_command_history ||= Array.new
484
- # previous command should be in opts, otherwise it is not in this context
485
- cmd = rb_gets("Command: ", opts){ |q| q.default = @_previous_command; q.history = @_command_history }
486
- if cmd.nil? || cmd == ""
487
- else
488
- @_command_history << cmd unless @_command_history.include? cmd
489
- cmdline = cmd.split
490
- cmd = cmdline.shift
491
- # check if command is a substring of a larger command
492
- if !opts.include?(cmd)
493
- rcmd = _resolve_command(opts, cmd) if !opts.include?(cmd)
494
- if rcmd.size == 1
495
- cmd = rcmd.first
496
- elsif !rcmd.empty?
497
- rb_puts "Cannot resolve #{cmd}. Matches are: #{rcmd} "
498
- end
499
- end
500
- if respond_to?(cmd, true)
501
- @_previous_command = cmd
502
- begin
503
- send cmd, *cmdline
504
- rescue => exc
505
- $log.error "ERR EXC: send throwing an exception now. Duh. IMAP keeps crashing haha !! #{exc} " if $log.debug?
506
- if exc
507
- $log.debug( exc)
508
- $log.debug(exc.backtrace.join("\n"))
509
- rb_puts exc.to_s
510
- end
511
- end
512
- else
513
- rb_puts("Command [#{cmd}] not supported by #{self.class} ", :color_pair => $promptcolor)
514
- end
515
- end
516
- }
517
454
  #@form.bind_key(KEY_F1, 'help'){ display_app_help } # NOT REQUIRED NOW 2012-01-7 since form does it
518
455
  @form.bind_key([?q,?q], 'quit' ){ throw :close } if $log.debug?
519
456
 
@@ -524,7 +461,7 @@ module Canis
524
461
  #$error_message.update_command { @message.set_value($error_message.value) }
525
462
  if block
526
463
  begin
527
- yield_or_eval &block if block_given? # modified 2010-11-17 20:36
464
+ yield_or_eval &block if block_given?
528
465
  # how the hell does a user trap exception if the loop is hidden from him ? FIXME
529
466
  loop
530
467
  rescue => ex
@@ -549,8 +486,72 @@ module Canis
549
486
  end # :close
550
487
  end
551
488
  end
489
+ # Some bindings that were earlier part of App (in the run block), but now optional for an
490
+ # app. I would like to move it out, so they can be mapped separately to whatever a user wants
491
+ # and be improved. these are very experimental and bare as yet.
492
+ # They should also be usable outside of App.
493
+ def app_bindings
494
+ @form.bind_key([?\C-x, ?c], 'suspend') { suspend(false) do
495
+ system("tput cup 26 0")
496
+ system("tput ed")
497
+ system("echo Enter C-d to return to application")
498
+ system (ENV['PS1']='\s-\v\$ ')
499
+ system(ENV['SHELL']);
500
+ end
501
+ }
502
+ # this is a very rudimentary default command executer, it does not
503
+ # allow tab completion. App should use M-x with names of commands
504
+ # as in appgmail
505
+ # NOTE: This is gonna change very soon - 2012-01-8
506
+ @form.bind_key(?:, 'prompt') {
507
+ str = get_command_from_user
508
+ }
509
+
510
+ # this M-x stuff has to be moved out so it can be used by all. One should be able
511
+ # to add_commands properly to this, and to C-x. I am thinking how to go about this,
512
+ # and what function M-x actually serves.
513
+
514
+ @form.bind_key(?\M-x, 'M-x commands'){
515
+ # TODO previous command to be default
516
+ opts = get_all_commands()
517
+ @_command_history ||= Array.new
518
+ # previous command should be in opts, otherwise it is not in this context
519
+ cmd = rb_gets("Command: ", opts){ |q| q.default = @_previous_command; q.history = @_command_history }
520
+ if cmd.nil? || cmd == ""
521
+ else
522
+ @_command_history << cmd unless @_command_history.include? cmd
523
+ cmdline = cmd.split
524
+ cmd = cmdline.shift
525
+ # check if command is a substring of a larger command
526
+ if !opts.include?(cmd)
527
+ rcmd = _resolve_command(opts, cmd) if !opts.include?(cmd)
528
+ if rcmd.size == 1
529
+ cmd = rcmd.first
530
+ elsif !rcmd.empty?
531
+ rb_puts "Cannot resolve #{cmd}. Matches are: #{rcmd} "
532
+ end
533
+ end
534
+ if respond_to?(cmd, true)
535
+ @_previous_command = cmd
536
+ begin
537
+ send cmd, *cmdline
538
+ rescue => exc
539
+ $log.error "ERR EXC: send throwing an exception now. Duh. IMAP keeps crashing haha !! #{exc} " if $log.debug?
540
+ if exc
541
+ $log.debug( exc)
542
+ $log.debug(exc.backtrace.join("\n"))
543
+ rb_puts exc.to_s
544
+ end
545
+ end
546
+ else
547
+ rb_puts("Command [#{cmd}] not supported by #{self.class} ", :color_pair => $promptcolor)
548
+ end
549
+ end
550
+ }
551
+ end
552
552
  # process args, all widgets should call this
553
553
  def _process_args args, config, block_event, events #:nodoc:
554
+ raise "FIXME seems uncalled _process_args, remove it this does not come up within a month 2014-08-19 "
554
555
  args.each do |arg|
555
556
  case arg
556
557
  when Array