canis 0.0.5 → 0.0.7
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.
- checksums.yaml +4 -4
- data/CHANGES +10 -0
- data/README.md +99 -4
- data/examples/common/devel.rb +84 -1
- data/examples/dbdemo.rb +356 -30
- data/lib/canis/core/include/appmethods.rb +13 -4
- data/lib/canis/core/include/colorparser.rb +31 -10
- data/lib/canis/core/include/listselectionmodel.rb +2 -2
- data/lib/canis/core/include/rhistory.rb +2 -2
- data/lib/canis/core/system/colormap.rb +3 -3
- data/lib/canis/core/system/window.rb +8 -3
- data/lib/canis/core/util/app.rb +94 -93
- data/lib/canis/core/util/defaultcolorparser.rb +7 -3
- data/lib/canis/core/util/rdialogs.rb +325 -5
- data/lib/canis/core/util/viewer.rb +1 -1
- data/lib/canis/core/util/widgetshortcuts.rb +3 -3
- data/lib/canis/core/widgets/applicationheader.rb +2 -4
- data/lib/canis/core/widgets/extras/rtextarea.rb +3 -1
- data/lib/canis/core/widgets/listbox.rb +2 -1
- data/lib/canis/core/widgets/rmenu.rb +45 -31
- data/lib/canis/core/widgets/rmessagebox.rb +51 -2
- data/lib/canis/core/widgets/rwidget.rb +23 -15
- data/lib/canis/core/widgets/statusline.rb +19 -9
- data/lib/canis/core/widgets/textpad.rb +2 -2
- data/lib/canis/version.rb +1 -1
- metadata +2 -2
@@ -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: 2014-
|
11
|
+
# Last update: 2014-09-01 13:09
|
12
12
|
#
|
13
13
|
# CHANGES:
|
14
14
|
# For some terminals, like xterm-256color which were not printing spaces
|
@@ -96,7 +96,6 @@ module Canis
|
|
96
96
|
#len = @window.width
|
97
97
|
#len = Ncurses.COLS-0 if len == 0
|
98
98
|
#
|
99
|
-
#@form.window.printstring r, c, "%-*s" % [len, htext], @color_pair, @attr
|
100
99
|
@form.window.printstring r, c, htext, @color_pair, @attr
|
101
100
|
end
|
102
101
|
# internal method, called by repaint to print text_center in the center
|
@@ -105,7 +104,6 @@ module Canis
|
|
105
104
|
len = win.getmaxx
|
106
105
|
len = Ncurses.COLS-0 if len == 0 || len > Ncurses.COLS
|
107
106
|
#
|
108
|
-
#@form.window.printstring r, c, "%-*s" % [len, htext], @color_pair, @attr
|
109
107
|
win.printstring r, ((len-htext.length)/2).floor, htext, @color_pair, @attr
|
110
108
|
end
|
111
109
|
# internal method to print text_right
|
@@ -113,7 +111,7 @@ module Canis
|
|
113
111
|
hlen = htext.length
|
114
112
|
len = @window.getmaxx # width was not changing when resize happens
|
115
113
|
len = Ncurses.COLS-0 if len == 0 || len > Ncurses.COLS
|
116
|
-
|
114
|
+
#$log.debug " def print_top_right(#{htext}) #{len} #{Ncurses.COLS} "
|
117
115
|
@form.window.printstring 0, len-hlen, htext, @color_pair, @attr
|
118
116
|
end
|
119
117
|
##
|
@@ -269,6 +269,7 @@ module Canis
|
|
269
269
|
### FOR scrollable ###
|
270
270
|
def repaint # textarea
|
271
271
|
#return unless @repaint_required # 2010-02-12 19:08 TRYING - won't let footer print if only col move
|
272
|
+
@graphic = @form.window unless @graphic # print_border not getting it 2014-08-30 - 20:41
|
272
273
|
paint if @repaint_required
|
273
274
|
print_foot if @print_footer && !@suppress_borders && (@repaint_footer_required || @repaint_required)
|
274
275
|
end
|
@@ -839,7 +840,8 @@ module Canis
|
|
839
840
|
# not sure where to put this, once for all or repeat 2010-02-12 RFED16
|
840
841
|
#my_win = @form? @form.window : @target_window
|
841
842
|
#$log.warn "neither form not target window given!!! TA paint 751" unless my_win
|
842
|
-
raise "
|
843
|
+
raise "height or width nil h:#{@height} , w: #{@width} " if @height.nil? || @width.nil?
|
844
|
+
raise "graphic is nil in textarea paint()" unless @graphic
|
843
845
|
print_borders if (@suppress_borders == false && @repaint_all) # do this once only, unless everything changes
|
844
846
|
rc = row_count
|
845
847
|
_maxlen = @maxlen || @width-@internal_width # TODO fix in other branches remove ||=
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Author: jkepler http://github.com/mare-imbrium/canis/
|
6
6
|
# Date: 2014-04-06 - 19:37
|
7
7
|
# License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
8
|
-
# Last update: 2014-
|
8
|
+
# Last update: 2014-08-28 17:05
|
9
9
|
# ----------------------------------------------------------------------------- #
|
10
10
|
# listbox.rb Copyright (C) 2012-2014 kepler
|
11
11
|
|
@@ -272,6 +272,7 @@ module Canis
|
|
272
272
|
bg = @source.selected_bgcolor || bg
|
273
273
|
att = @source.selected_attr || REVERSE
|
274
274
|
cp = get_color($datacolor, fg, bg)
|
275
|
+
|
275
276
|
elsif lineno == @source.current_index
|
276
277
|
# print focussed row in different attrib
|
277
278
|
if @source.should_show_focus
|
@@ -47,7 +47,11 @@ module Canis
|
|
47
47
|
end
|
48
48
|
def repaint
|
49
49
|
acolor = get_color($reversecolor, @color, @bgcolor)
|
50
|
-
|
50
|
+
#@parent.window.printstring( @row, 0, "|%s|" % ("-"*@width), acolor)
|
51
|
+
@parent.window.mvwhline( @row, 1, Ncurses::ACS_HLINE, @width)
|
52
|
+
# these 2 are probably overwritten by the borders
|
53
|
+
@parent.window.mvaddch( @row, 0, Ncurses::ACS_LTEE)
|
54
|
+
@parent.window.mvaddch( @row, @width+1, Ncurses::ACS_RTEE)
|
51
55
|
end
|
52
56
|
def destroy
|
53
57
|
end
|
@@ -133,14 +137,8 @@ module Canis
|
|
133
137
|
#$log.debug "HL XXX #{self} - > #{@parent} parent nil"
|
134
138
|
end
|
135
139
|
if tf
|
136
|
-
#color = $datacolor
|
137
|
-
#@parent.window.mvchgat(y=@row, x=1, @width, Ncurses::A_NORMAL, color, nil)
|
138
|
-
# above line did not work in vt100, 200 terminals, next works.
|
139
|
-
# @parent.window.mvchgat(y=@row, x=1, @width, Ncurses::A_REVERSE, $reversecolor, nil) # changed 2011 dts 2011-09-24 multicolumn, 1 skips the border
|
140
140
|
@color_pair ||= get_color($reversecolor, @color, @bgcolor)
|
141
141
|
@parent.window.mvchgat(y=@row, x=@col+1, @width, Ncurses::A_REVERSE, @color_pair, nil)
|
142
|
-
#@parent.window.mvaddch @row, @col, "*".ord
|
143
|
-
#@parent.window.wmove @row, @col # 2011-09-25 V1.3.1 NO EFFECT
|
144
142
|
else
|
145
143
|
repaint
|
146
144
|
end
|
@@ -148,7 +146,6 @@ module Canis
|
|
148
146
|
end
|
149
147
|
def repaint # menuitem.repaint
|
150
148
|
if @parent.nil? or @parent.window.nil?
|
151
|
-
$log.debug "repaint #{self} parent nil"
|
152
149
|
# return
|
153
150
|
end
|
154
151
|
r = @row
|
@@ -168,16 +165,18 @@ module Canis
|
|
168
165
|
elsif !@mnemonic.nil?
|
169
166
|
m = @mnemonic
|
170
167
|
ix = text.index(m) || text.index(m.swapcase)
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
168
|
+
if ix
|
169
|
+
charm = text[ix,1]
|
170
|
+
#@parent.window.printstring( r, ix+1, charm, $datacolor) if !ix.nil?
|
171
|
+
# prev line changed since not working in vt100 and vt200
|
172
|
+
@parent.window.printstring( r, ix+1, charm, $reversecolor, 'reverse') if !ix.nil?
|
173
|
+
end
|
175
174
|
end
|
176
175
|
#@parent.window.wmove r, c # NO EFFECT
|
177
176
|
end
|
178
177
|
end
|
179
178
|
def destroy
|
180
|
-
|
179
|
+
#$log.debug "DESTROY menuitem #{@text}"
|
181
180
|
end
|
182
181
|
end
|
183
182
|
## class Menu. Contains menuitems, and can be a menuitem itself.
|
@@ -495,6 +494,7 @@ module Canis
|
|
495
494
|
@layout = { :height => h-1, :width => ww, :top => t, :left => @coffset }
|
496
495
|
@win = Canis::Window.new(@layout)
|
497
496
|
@window = @win
|
497
|
+
@window.name = "WINDOW:menu"
|
498
498
|
@color_pair ||= get_color($datacolor, @color, @bgcolor)
|
499
499
|
@rev_color_pair ||= get_color($reversecolor, @color, @bgcolor)
|
500
500
|
@win.bkgd(Ncurses.COLOR_PAIR(@color_pair));
|
@@ -532,18 +532,22 @@ module Canis
|
|
532
532
|
@window.printstring( h-2, 0, "+%s+" % ("-"*(ww1)), @rev_color_pair)
|
533
533
|
# in case of multiple rows
|
534
534
|
@window.printstring( r, c, "+%s+" % ("-"*(ww1)), @rev_color_pair)
|
535
|
+
# added box with proper ncurses extended char set 2014-08-27 - 14:30
|
536
|
+
@window.print_border_only 0,0,h-2, ww, @rev_color_pair
|
535
537
|
select_item 0
|
536
538
|
@window.refresh
|
537
539
|
return @window
|
538
540
|
end
|
539
541
|
# private
|
542
|
+
# returns length of longest item in array
|
540
543
|
def array_width a
|
541
544
|
longest = a.max {|a,b| a.to_s.length <=> b.to_s.length }
|
542
545
|
#$log.debug "array width #{longest}"
|
543
546
|
longest.to_s.length
|
544
547
|
end
|
548
|
+
# destroys windows and each item within (submenus)
|
545
549
|
def destroy
|
546
|
-
$log.debug "
|
550
|
+
$log.debug "DESTROY menu #{@text}"
|
547
551
|
return if @window.nil?
|
548
552
|
@visible = false
|
549
553
|
#2014-05-12 - 20:53 next 3 replaced with destroy since destroy refreshes root window.
|
@@ -552,7 +556,6 @@ module Canis
|
|
552
556
|
#@window.delwin if !@window.nil?
|
553
557
|
@window.destroy
|
554
558
|
@items.each do |item|
|
555
|
-
#next if item == :SEPARATOR
|
556
559
|
item.destroy
|
557
560
|
end
|
558
561
|
@window = nil
|
@@ -689,13 +692,13 @@ module Canis
|
|
689
692
|
@active_index = 0
|
690
693
|
@repaint_required = true
|
691
694
|
end
|
695
|
+
# is this widget focusable, always returns false
|
692
696
|
def focusable
|
693
697
|
false
|
694
698
|
end
|
695
699
|
alias :focusable? focusable
|
696
|
-
# add a precreated menu
|
700
|
+
# add a precreated menu, returning self
|
697
701
|
def add menu
|
698
|
-
#$log.debug "YYYY inside MB: add #{menu.text} "
|
699
702
|
@items << menu
|
700
703
|
return self
|
701
704
|
end
|
@@ -705,13 +708,13 @@ module Canis
|
|
705
708
|
# 2010-09-10 12:07 added while simplifying the interface
|
706
709
|
# this calls add so you get the MB back, not a ref to the menu created NOTE
|
707
710
|
def menu text, &block
|
708
|
-
#$log.debug "YYYY inside MB: menu text #{text} "
|
709
711
|
m = Menu.new text, &block
|
710
712
|
m.color = @color
|
711
713
|
m.bgcolor = @bgcolor
|
712
714
|
add m
|
713
715
|
return m
|
714
716
|
end
|
717
|
+
# move focus to next menu
|
715
718
|
def next_menu
|
716
719
|
#$log.debug "next meu: #{@active_index} "
|
717
720
|
if @active_index < @items.length-1
|
@@ -720,6 +723,7 @@ module Canis
|
|
720
723
|
set_menu 0
|
721
724
|
end
|
722
725
|
end
|
726
|
+
# move focus to previous menu
|
723
727
|
def prev_menu
|
724
728
|
#$log.debug "prev meu: #{@active_index} "
|
725
729
|
if @active_index > 0
|
@@ -728,18 +732,29 @@ module Canis
|
|
728
732
|
set_menu @items.length-1
|
729
733
|
end
|
730
734
|
end
|
735
|
+
|
736
|
+
# set the given menu index as the current or active menu
|
737
|
+
# after closing the active menu.
|
738
|
+
# @param Fixnum index of menu to activate, starting 0
|
731
739
|
def set_menu index
|
732
740
|
#$log.debug "set meu: #{@active_index} #{index}"
|
741
|
+
# first leave the existing window
|
733
742
|
menu = @items[@active_index]
|
734
743
|
menu.on_leave # hide its window, if open
|
744
|
+
# now move to given menu
|
735
745
|
@active_index = index
|
736
746
|
menu = @items[@active_index]
|
737
747
|
menu.on_enter #display window, if previous was displayed
|
748
|
+
# move cursor to selected menu option on top, not inside list
|
738
749
|
@window.wmove menu.row, menu.col
|
739
750
|
# menu.show
|
740
751
|
# menu.window.wrefresh # XXX we need this
|
741
752
|
end
|
742
753
|
|
754
|
+
# keep the menu bar visible at all times.
|
755
|
+
# If not, then it appears only on using the toggle key.
|
756
|
+
# In any case, control only goes to the menubar when you use the toggle key,
|
757
|
+
# so it is best NOT to keep it visible.
|
743
758
|
def keep_visible flag=nil
|
744
759
|
return @keep_visible unless flag
|
745
760
|
@keep_visible = flag
|
@@ -760,7 +775,7 @@ module Canis
|
|
760
775
|
when -1
|
761
776
|
next
|
762
777
|
when KEY_DOWN
|
763
|
-
|
778
|
+
|
764
779
|
if !@selected
|
765
780
|
current_menu.fire
|
766
781
|
else
|
@@ -770,28 +785,20 @@ module Canis
|
|
770
785
|
@selected = true
|
771
786
|
when KEY_ENTER, 10, 13, 32
|
772
787
|
@selected = true
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
#break; ## 2008-12-29 18:00 This will close after firing
|
777
|
-
#anything
|
778
|
-
break if ret == :CLOSE
|
788
|
+
ret = current_menu.handle_key ch
|
789
|
+
#break; ## 2008-12-29 18:00 This will close after firing anything
|
790
|
+
break if ret == :CLOSE
|
779
791
|
when KEY_UP
|
780
|
-
#$log.debug " mb insdie keyUPP : #{ch}"
|
781
792
|
current_menu.handle_key ch
|
782
793
|
when KEY_LEFT
|
783
|
-
#$log.debug " mb insdie KEYLEFT : #{ch}"
|
784
794
|
ret = current_menu.handle_key ch
|
785
795
|
prev_menu if ret == :UNHANDLED
|
786
|
-
#display_items if @selected
|
787
796
|
when KEY_RIGHT
|
788
|
-
#$log.debug " mb insdie KEYRIGHT : #{ch}"
|
789
797
|
ret = current_menu.handle_key ch
|
790
798
|
next_menu if ret == :UNHANDLED
|
791
799
|
when ?\C-g.getbyte(0) # abort
|
792
800
|
throw :menubarclose
|
793
801
|
else
|
794
|
-
#$log.debug " mb insdie ELSE : #{ch}"
|
795
802
|
ret = current_menu.handle_key ch
|
796
803
|
if ret == :UNHANDLED
|
797
804
|
Ncurses.beep
|
@@ -808,11 +815,13 @@ module Canis
|
|
808
815
|
ensure
|
809
816
|
#ensure is required becos one can throw a :close
|
810
817
|
$log.debug " DESTROY IN ENSURE"
|
811
|
-
current_menu.clear_menus
|
818
|
+
current_menu.clear_menus
|
812
819
|
@repaint_required = false
|
813
820
|
destroy # Note that we destroy the menu bar upon exit
|
814
821
|
end
|
815
822
|
end
|
823
|
+
|
824
|
+
# returns current_menu
|
816
825
|
def current_menu
|
817
826
|
@items[@active_index]
|
818
827
|
end
|
@@ -877,8 +886,13 @@ module Canis
|
|
877
886
|
end
|
878
887
|
def create_window_menubar
|
879
888
|
@layout = { :height => 1, :width => 0, :top => 0, :left => 0 }
|
889
|
+
$log.debug "create window menu bar "
|
880
890
|
@win = Canis::Window.new(@layout)
|
891
|
+
@win.name = "WINDOW:menubar"
|
881
892
|
@window = @win
|
893
|
+
# hack since we put all windows in there, and this should not be coming after Root.
|
894
|
+
# This should not have been a window in the first place.
|
895
|
+
$global_windows.delete @win
|
882
896
|
att = get_attrib @attr
|
883
897
|
@win.bkgd(Ncurses.COLOR_PAIR(5)); # <---- FIXME
|
884
898
|
len = @window.width
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Author: jkepler http://github.com/mare-imbrium/canis/
|
6
6
|
# Date: 03.11.11 - 22:15
|
7
7
|
# License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
8
|
-
# Last update: 2014-
|
8
|
+
# Last update: 2014-08-30 17:47
|
9
9
|
# == CHANGES
|
10
10
|
# == TODO
|
11
11
|
# _ <ENTER> should result in OK being pressed if its default, ESC should result in cancel esp 2 time
|
@@ -74,6 +74,8 @@ module Canis
|
|
74
74
|
|
75
75
|
end
|
76
76
|
def item widget
|
77
|
+
# # normalcolor gives a white on black stark title like links and elinks
|
78
|
+
# You can also do 'acolor' to give you a sober title that does not take attention away, like mc
|
77
79
|
# remove from existing form if set, problem with this is mnemonics -- rare situation.
|
78
80
|
if widget.form
|
79
81
|
f = widget.form
|
@@ -134,8 +136,11 @@ module Canis
|
|
134
136
|
@window.print_border_mb 1,2, @height, @width, bordercolor, borderatt
|
135
137
|
@window.wattroff(Ncurses.COLOR_PAIR(bordercolor) | (borderatt || FFI::NCurses::A_NORMAL))
|
136
138
|
@title ||= "+-+"
|
139
|
+
@title_color ||= $normalcolor
|
137
140
|
title = " "+@title+" "
|
138
|
-
|
141
|
+
# normalcolor gives a white on black stark title like links and elinks
|
142
|
+
# You can also do 'acolor' to give you a sober title that does not take attention away, like mc
|
143
|
+
@window.printstring(@row=1,@col=(@width-title.length)/2,title, color=@title_color)
|
139
144
|
#print_message if @message
|
140
145
|
create_action_buttons unless @action_buttons
|
141
146
|
end
|
@@ -227,6 +232,46 @@ module Canis
|
|
227
232
|
end
|
228
233
|
alias :text= :text
|
229
234
|
|
235
|
+
# similar to +text+ but to view a hash using a tree object, so one can
|
236
|
+
# drill down.
|
237
|
+
# Added on 2014-08-30 - 17:39 to view an objects instance_variables and public_methods.
|
238
|
+
def tree message
|
239
|
+
require 'canis/core/widgets/tree'
|
240
|
+
@suggested_w = @width || (FFI::NCurses.COLS * 0.80).floor
|
241
|
+
@suggested_h = @height || (FFI::NCurses.LINES * 0.80).floor
|
242
|
+
|
243
|
+
message_col = 3
|
244
|
+
r = 2
|
245
|
+
display_length = @suggested_w-4
|
246
|
+
display_length -= message_col
|
247
|
+
clr = @color || :white
|
248
|
+
bgclr = @bgcolor || :black
|
249
|
+
|
250
|
+
# now that we have moved to textpad that +8 was causing black lines to remain after the text
|
251
|
+
#message_height = message.size #+ 8
|
252
|
+
message_height = 20
|
253
|
+
# reduce if possible if its not required.
|
254
|
+
#
|
255
|
+
r1 = (FFI::NCurses.LINES-@suggested_h)/2
|
256
|
+
r1 = r1.floor
|
257
|
+
w = @suggested_w
|
258
|
+
c1 = (FFI::NCurses.COLS-w)/2
|
259
|
+
c1 = c1.floor
|
260
|
+
@suggested_row = r1
|
261
|
+
@suggested_col = c1
|
262
|
+
brow = @button_row || @suggested_h-4
|
263
|
+
available_ht = brow - r + 1
|
264
|
+
message_height = [message_height, available_ht].min
|
265
|
+
# replaced 2014-04-14 - 23:51
|
266
|
+
tree = Canis::Tree.new @form, {:name=>"treedialogtree", :data => message,
|
267
|
+
:row => r, :col => message_col, :width => display_length, :suppress_borders => true,
|
268
|
+
:height => message_height, :bgcolor => bgclr , :color => clr}
|
269
|
+
#message_label.set_content message
|
270
|
+
tree.treemodel.root_visible = false
|
271
|
+
yield tree if block_given?
|
272
|
+
|
273
|
+
end
|
274
|
+
|
230
275
|
# returns button index (or in some cases, whatever value was thrown
|
231
276
|
# if user did not specify any button_type but gave his own and did throw (:close, x)
|
232
277
|
private
|
@@ -235,6 +280,10 @@ module Canis
|
|
235
280
|
while((ch = @window.getchar()) != FFI::NCurses::KEY_F10 )
|
236
281
|
break if ch == ?\C-q.getbyte(0) || ch == 2727 # added double esc
|
237
282
|
begin
|
283
|
+
# trying out repaint of window also if repaint all asked for. 12 is C-l
|
284
|
+
if ch == 1000 or ch == 12
|
285
|
+
repaint
|
286
|
+
end
|
238
287
|
@form.handle_key(ch)
|
239
288
|
@window.wrefresh
|
240
289
|
rescue => err
|
@@ -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-08-
|
12
|
+
* Last update: 2014-08-28 16:58
|
13
13
|
|
14
14
|
== CHANGES
|
15
15
|
* 2011-10-2 Added PropertyVetoException to rollback changes to property
|
@@ -477,8 +477,7 @@ module Canis
|
|
477
477
|
case keycode
|
478
478
|
when String
|
479
479
|
# single assignment
|
480
|
-
keycode = keycode.getbyte(0)
|
481
|
-
#@_key_map[keycode] = blk
|
480
|
+
keycode = keycode.getbyte(0)
|
482
481
|
when Array
|
483
482
|
# double assignment
|
484
483
|
# this means that all these keys have to be pressed in succession for this block, like "gg" or "C-x C-c"
|
@@ -545,7 +544,7 @@ module Canis
|
|
545
544
|
$log.debug " composite contains #{key} : #{val} "
|
546
545
|
end
|
547
546
|
def check_composite_mapping key, window
|
548
|
-
|
547
|
+
#$log.debug "inside check with #{key} "
|
549
548
|
return nil if !@_key_composite_map
|
550
549
|
return nil if !@_key_composite_map.key? key
|
551
550
|
$log.debug " composite has #{key} "
|
@@ -577,7 +576,7 @@ module Canis
|
|
577
576
|
# instead of just nil, we need to go back up, but since not recursive ...
|
578
577
|
#return nil unless n
|
579
578
|
unless n
|
580
|
-
# testing shift otherwise it seems current key evaluated twice
|
579
|
+
# testing shift otherwise it seems current key evaluated twice 2014-08-17
|
581
580
|
unconsumed.shift
|
582
581
|
$log.debug "push unconsumed:#{unconsumed} " unless n
|
583
582
|
unconsumed.each {|e| window.ungetch(e)} unless n
|
@@ -1244,7 +1243,7 @@ module Canis
|
|
1244
1243
|
fire_handler :ENTER, self
|
1245
1244
|
end
|
1246
1245
|
end
|
1247
|
-
##
|
1246
|
+
## Called when user exits a widget
|
1248
1247
|
def on_leave
|
1249
1248
|
@state = :NORMAL # duplicating since often these are inside containers
|
1250
1249
|
@focussed = false
|
@@ -1609,7 +1608,8 @@ module Canis
|
|
1609
1608
|
# what kind of key-bindings do you want, :vim or :emacs
|
1610
1609
|
$key_map_type ||= :vim ## :emacs or :vim, keys to be defined accordingly. TODO
|
1611
1610
|
|
1612
|
-
bind_key(KEY_F1, 'help') { hm = help_manager(); hm.display_help }
|
1611
|
+
#bind_key(KEY_F1, 'help') { hm = help_manager(); hm.display_help }
|
1612
|
+
map_keys unless @keys_mapped
|
1613
1613
|
end
|
1614
1614
|
##
|
1615
1615
|
# set this menubar as the form's menu bar.
|
@@ -2064,6 +2064,7 @@ module Canis
|
|
2064
2064
|
#
|
2065
2065
|
def map_keys
|
2066
2066
|
return if @keys_mapped
|
2067
|
+
bind_key(KEY_F1, 'help') { hm = help_manager(); hm.display_help }
|
2067
2068
|
bind_keys([?\M-?,?\?], 'show field help') {
|
2068
2069
|
#if get_current_field.help_text
|
2069
2070
|
#textdialog(get_current_field.help_text, 'title' => 'Help Text', :bgcolor => 'green', :color => :white)
|
@@ -2084,17 +2085,19 @@ module Canis
|
|
2084
2085
|
# this forces a repaint of all visible widgets and has been added for the case of overlapping
|
2085
2086
|
# windows, since a black rectangle is often left when a window is destroyed. This is internally
|
2086
2087
|
# triggered whenever a window is destroyed, and currently only for root window.
|
2088
|
+
# NOTE: often the window itself or spaces between widgets also gets cleared, so basically
|
2089
|
+
# the window itself may need recreating ? 2014-08-18 - 21:03
|
2087
2090
|
def repaint_all_widgets
|
2088
|
-
|
2091
|
+
$log.debug " REPAINT ALL in FORM called "
|
2089
2092
|
@widgets.each do |w|
|
2090
2093
|
next if w.visible == false
|
2091
2094
|
next if w.class.to_s == "Canis::MenuBar"
|
2092
|
-
|
2095
|
+
$log.debug " ---- REPAINT ALL #{w.name} "
|
2093
2096
|
#w.repaint_required true
|
2094
2097
|
w.repaint_all true
|
2095
2098
|
w.repaint
|
2096
2099
|
end
|
2097
|
-
|
2100
|
+
$log.debug " REPAINT ALL in FORM complete "
|
2098
2101
|
# place cursor on current_widget
|
2099
2102
|
setpos
|
2100
2103
|
end
|
@@ -2107,7 +2110,8 @@ module Canis
|
|
2107
2110
|
# NOTE : please rescue exceptions when you use this in your main loop and alert() user
|
2108
2111
|
#
|
2109
2112
|
def handle_key(ch)
|
2110
|
-
|
2113
|
+
# 2014-08-19 - 21:10 moving to init, so that user may override or remove
|
2114
|
+
#map_keys unless @keys_mapped
|
2111
2115
|
handled = :UNHANDLED # 2011-10-4
|
2112
2116
|
if ch == ?\C-u.getbyte(0)
|
2113
2117
|
ret = universal_argument
|
@@ -2127,11 +2131,16 @@ module Canis
|
|
2127
2131
|
case ch
|
2128
2132
|
when -1
|
2129
2133
|
return
|
2130
|
-
when 1000
|
2131
|
-
|
2134
|
+
when 1000, 12
|
2135
|
+
# NOTE this works if widgets cover entire screen like text areas and lists but not in
|
2136
|
+
# dialogs where there is blank space. only widgets are painted.
|
2137
|
+
# testing out 12 is C-l
|
2138
|
+
$log.debug " form REFRESH_ALL repaint_all HK #{ch} #{self}, #{@name} "
|
2132
2139
|
repaint_all_widgets
|
2133
2140
|
return
|
2134
|
-
when FFI::NCurses::KEY_RESIZE
|
2141
|
+
when FFI::NCurses::KEY_RESIZE # SIGWINCH
|
2142
|
+
# note that in windows that have dialogs or text painted on window such as title or
|
2143
|
+
# box, the clear call will clear it out. these are not redrawn.
|
2135
2144
|
lines = Ncurses.LINES
|
2136
2145
|
cols = Ncurses.COLS
|
2137
2146
|
x = Ncurses.stdscr.getmaxy
|
@@ -2578,7 +2587,6 @@ module Canis
|
|
2578
2587
|
#
|
2579
2588
|
def handle_key ch
|
2580
2589
|
@repaint_required = true
|
2581
|
-
#map_keys unless @keys_mapped # moved to init
|
2582
2590
|
case ch
|
2583
2591
|
when 32..126
|
2584
2592
|
#$log.debug("FIELD: ch #{ch} ,at #{@curpos}, buffer:[#{@buffer}] bl: #{@buffer.to_s.length}")
|