rkumar-rbcurse 0.1.1 → 0.1.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.
- data/CHANGELOG +40 -0
- data/History.txt +13 -0
- data/README.txt +13 -12
- data/examples/rfe.rb +150 -34
- data/examples/rfe_renderer.rb +6 -0
- data/examples/sqlc.rb +419 -0
- data/examples/testtable.rb +0 -4
- data/examples/testtabp.rb +2 -0
- data/examples/testtodo.rb +73 -23
- data/examples/todocsv.csv +28 -0
- data/lib/rbcurse.rb +1 -1
- data/lib/rbcurse/defaultlistselectionmodel.rb +14 -0
- data/lib/rbcurse/listcellrenderer.rb +7 -0
- data/lib/rbcurse/listkeys.rb +7 -4
- data/lib/rbcurse/listscrollable.rb +144 -7
- data/lib/rbcurse/listselectable.rb +23 -2
- data/lib/rbcurse/rlistbox.rb +69 -15
- data/lib/rbcurse/rmessagebox.rb +14 -5
- data/lib/rbcurse/rtabbedpane.rb +64 -2
- data/lib/rbcurse/rtable.rb +223 -18
- data/lib/rbcurse/rtextarea.rb +34 -2
- data/lib/rbcurse/rtextview.rb +27 -4
- data/lib/rbcurse/rwidget.rb +9 -3
- data/lib/rbcurse/table/tablecellrenderer.rb +1 -0
- metadata +4 -1
data/lib/rbcurse/rtextarea.rb
CHANGED
@@ -27,6 +27,8 @@ module RubyCurses
|
|
27
27
|
## a multiline text editing widget
|
28
28
|
# TODO - giving data to user - adding newlines, and withog adding.
|
29
29
|
# - respect newlines for incoming data
|
30
|
+
# we need a set_text method, passing nil or blank clears
|
31
|
+
# current way is not really good. remove_all sucks.
|
30
32
|
#
|
31
33
|
class TextArea < Widget
|
32
34
|
include ListScrollable
|
@@ -58,7 +60,7 @@ module RubyCurses
|
|
58
60
|
# this does result in a blank line if we insert after creating. That's required at
|
59
61
|
# present if we wish to only insert
|
60
62
|
if @list.empty?
|
61
|
-
|
63
|
+
# @list << "\r" # removed this on 2009-02-15 17:25 lets see how it goes
|
62
64
|
end
|
63
65
|
# @scrollatrow = @height-2
|
64
66
|
@content_rows = @list.length
|
@@ -66,6 +68,7 @@ module RubyCurses
|
|
66
68
|
# init_scrollable
|
67
69
|
print_borders
|
68
70
|
@maxlen ||= @width-2
|
71
|
+
install_keys
|
69
72
|
init_vars
|
70
73
|
end
|
71
74
|
def init_vars
|
@@ -90,6 +93,7 @@ module RubyCurses
|
|
90
93
|
end
|
91
94
|
def remove_all
|
92
95
|
@list = []
|
96
|
+
set_modified # added 2009-02-13 22:28 so repaints
|
93
97
|
end
|
94
98
|
##
|
95
99
|
# trying to wrap and insert
|
@@ -259,6 +263,18 @@ module RubyCurses
|
|
259
263
|
when ?\C-e
|
260
264
|
cursor_eol
|
261
265
|
#set_form_col @buffer.length
|
266
|
+
#when @KEY_ASK_FIND_FORWARD
|
267
|
+
# ask_search_forward
|
268
|
+
#when @KEY_ASK_FIND_BACKWARD
|
269
|
+
# ask_search_backward
|
270
|
+
when @KEY_ASK_FIND
|
271
|
+
ask_search
|
272
|
+
when @KEY_FIND_MORE
|
273
|
+
find_more
|
274
|
+
#when @KEY_FIND_NEXT
|
275
|
+
# find_next
|
276
|
+
#when @KEY_FIND_PREV
|
277
|
+
# find_prev
|
262
278
|
else
|
263
279
|
#$log.debug(" textarea ch #{ch}")
|
264
280
|
ret = putc ch
|
@@ -622,6 +638,7 @@ module RubyCurses
|
|
622
638
|
end
|
623
639
|
str
|
624
640
|
end
|
641
|
+
alias :get_text :to_s
|
625
642
|
## ---- for listscrollable ---- ##
|
626
643
|
def scrollatrow
|
627
644
|
@height-2
|
@@ -644,7 +661,7 @@ module RubyCurses
|
|
644
661
|
if crow < rc
|
645
662
|
#focussed = @current_index == crow ? true : false
|
646
663
|
#selected = is_row_selected crow
|
647
|
-
|
664
|
+
content = tm[crow].chomp rescue ""
|
648
665
|
content.gsub!(/\t/, ' ') # don't display tab
|
649
666
|
content.gsub!(/[^[:print:]]/, '') # don't display non print characters
|
650
667
|
if !content.nil?
|
@@ -659,6 +676,11 @@ module RubyCurses
|
|
659
676
|
#renderer.repaint @form.window, r+hh, c+(colix*11), content, focussed, selected
|
660
677
|
#renderer.repaint @form.window, r+hh, c, content, focussed, selected
|
661
678
|
@form.window.printstring r+hh, c, "%-*s" % [@width-2,content], acolor, @attr
|
679
|
+
if @search_found_ix == tr+hh
|
680
|
+
if !@find_offset.nil?
|
681
|
+
@form.window.mvchgat(y=r+hh, x=c+@find_offset, @find_offset1-@find_offset, Ncurses::A_NORMAL, $reversecolor, nil)
|
682
|
+
end
|
683
|
+
end
|
662
684
|
|
663
685
|
else
|
664
686
|
# clear rows
|
@@ -668,6 +690,16 @@ module RubyCurses
|
|
668
690
|
@table_changed = false
|
669
691
|
@repaint_required = false
|
670
692
|
end
|
693
|
+
def ask_search_forward
|
694
|
+
regex = get_string("Enter regex to search", 20, @last_regex||"")
|
695
|
+
ix = _find_next regex, @current_index
|
696
|
+
if ix.nil?
|
697
|
+
alert("No matching data for: #{regex}")
|
698
|
+
else
|
699
|
+
set_focus_on(ix)
|
700
|
+
set_form_col @find_offset
|
701
|
+
end
|
702
|
+
end
|
671
703
|
end # class textarea
|
672
704
|
##
|
673
705
|
end # modul
|
data/lib/rbcurse/rtextview.rb
CHANGED
@@ -59,6 +59,7 @@ module RubyCurses
|
|
59
59
|
#init_scrollable
|
60
60
|
print_borders
|
61
61
|
@maxlen ||= @width-2
|
62
|
+
install_keys
|
62
63
|
init_vars
|
63
64
|
end
|
64
65
|
def init_vars
|
@@ -174,13 +175,13 @@ module RubyCurses
|
|
174
175
|
@buffer = @list[@current_index]
|
175
176
|
end
|
176
177
|
return if @buffer.nil?
|
177
|
-
|
178
|
+
#$log.debug " before: curpos #{@curpos} blen: #{@buffer.length}"
|
178
179
|
if @curpos > @buffer.length
|
179
180
|
addcol((@buffer.length-@curpos)+1)
|
180
181
|
@curpos = @buffer.length
|
181
182
|
set_form_col
|
182
183
|
end
|
183
|
-
|
184
|
+
#$log.debug "TV after loop : curpos #{@curpos} blen: #{@buffer.length}"
|
184
185
|
#pre_key
|
185
186
|
case ch
|
186
187
|
when ?\C-n
|
@@ -216,6 +217,8 @@ module RubyCurses
|
|
216
217
|
when ?\C-e
|
217
218
|
# take care of data that exceeds maxlen by scrolling and placing cursor at end
|
218
219
|
blen = @buffer.rstrip.length
|
220
|
+
set_form_col blen
|
221
|
+
=begin
|
219
222
|
if blen < @maxlen
|
220
223
|
set_form_col blen
|
221
224
|
else
|
@@ -223,8 +226,14 @@ module RubyCurses
|
|
223
226
|
#wrong curpos wiill be reported
|
224
227
|
set_form_col @maxlen-1
|
225
228
|
end
|
229
|
+
=end
|
230
|
+
# search related added on 2009-02-15 21:36
|
231
|
+
when @KEY_ASK_FIND
|
232
|
+
ask_search
|
233
|
+
when @KEY_FIND_MORE
|
234
|
+
find_more
|
226
235
|
else
|
227
|
-
|
236
|
+
#$log.debug("TEXTVIEW XXX ch #{ch}")
|
228
237
|
return :UNHANDLED
|
229
238
|
end
|
230
239
|
#post_key
|
@@ -253,7 +262,13 @@ module RubyCurses
|
|
253
262
|
# set cursor on correct column tview
|
254
263
|
def set_form_col col=@curpos
|
255
264
|
@curpos = col
|
256
|
-
|
265
|
+
#@curpos = @maxlen if @curpos > @maxlen
|
266
|
+
if @curpos > @maxlen
|
267
|
+
@pcol = @curpos - @maxlen
|
268
|
+
@curpos = @maxlen - 1
|
269
|
+
else
|
270
|
+
@pcol = 0
|
271
|
+
end
|
257
272
|
@form.col = @orig_col + @col_offset + @curpos
|
258
273
|
@repaint_required = true
|
259
274
|
end
|
@@ -322,6 +337,14 @@ module RubyCurses
|
|
322
337
|
#renderer.repaint @form.window, r+hh, c+(colix*11), content, focussed, selected
|
323
338
|
#renderer.repaint @form.window, r+hh, c, content, focussed, selected
|
324
339
|
@form.window.printstring r+hh, c, "%-*s" % [@width-2,content], acolor, @attr
|
340
|
+
if @search_found_ix == tr+hh
|
341
|
+
if !@find_offset.nil?
|
342
|
+
# handle exceed bounds, and if scrolling
|
343
|
+
if @find_offset1 < maxlen+@pcol and @find_offset > @pcol
|
344
|
+
@form.window.mvchgat(y=r+hh, x=c+@find_offset-@pcol, @find_offset1-@find_offset, Ncurses::A_NORMAL, $reversecolor, nil)
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
325
348
|
|
326
349
|
else
|
327
350
|
# clear rows
|
data/lib/rbcurse/rwidget.rb
CHANGED
@@ -143,9 +143,11 @@ module RubyCurses
|
|
143
143
|
return "btab"
|
144
144
|
when 481
|
145
145
|
return "M-S-tab"
|
146
|
+
when 393..402
|
147
|
+
return "M-F"+ (keycode-392).to_s
|
146
148
|
else
|
147
|
-
others=[?\M--,?\M-+,?\M-=,?\M-',?\M-",?\M-;,?\M-:,?\M-\,, ?\M-.,?\M-<,?\M
|
148
|
-
s_others=%w[M-- M-+ M-= M-' M-" M-; M-: M
|
149
|
+
others=[?\M--,?\M-+,?\M-=,?\M-',?\M-",?\M-;,?\M-:,?\M-\,, ?\M-.,?\M-<,?\M->,?\M-?,?\M-/]
|
150
|
+
s_others=%w[M-- M-+ M-= M-' M-" M-; M-: M-, M-. M-< M-> M-? M-/ ]
|
149
151
|
if others.include? keycode
|
150
152
|
index = others.index keycode
|
151
153
|
return s_others[index]
|
@@ -882,7 +884,7 @@ module RubyCurses
|
|
882
884
|
attr_reader :form
|
883
885
|
attr_reader :handler # event handler
|
884
886
|
attr_reader :type # datatype of field, currently only sets chars_allowed
|
885
|
-
attr_reader :curpos # cursor position in buffer current
|
887
|
+
#attr_reader :curpos # cursor position in buffer current, in WIDGET
|
886
888
|
attr_accessor :datatype # crrently set during set_buffer
|
887
889
|
attr_reader :original_value # value on entering field
|
888
890
|
|
@@ -997,6 +999,9 @@ module RubyCurses
|
|
997
999
|
end
|
998
1000
|
def repaint
|
999
1001
|
# $log.debug("FIELD: #{id}, #{zorder}, #{focusable}")
|
1002
|
+
#return if display_length <= 0 # added 2009-02-17 00:17 sometimes editor comp has 0 and that
|
1003
|
+
# becomes negative below, no because editing still happens
|
1004
|
+
@display_length = 1 if display_length == 0
|
1000
1005
|
printval = getvalue_for_paint().to_s # added 2009-01-06 23:27
|
1001
1006
|
printval = show()*printval.length unless @show.nil?
|
1002
1007
|
if !printval.nil?
|
@@ -1472,6 +1477,7 @@ module RubyCurses
|
|
1472
1477
|
@text_variable.nil? ? @text : @text_variable.get_value(@name)
|
1473
1478
|
end
|
1474
1479
|
|
1480
|
+
# ensure text has been passed or action
|
1475
1481
|
def getvalue_for_paint
|
1476
1482
|
ret = getvalue
|
1477
1483
|
@text_offset = @surround_chars[0].length
|
@@ -51,6 +51,7 @@ module RubyCurses
|
|
51
51
|
lablist << value
|
52
52
|
end
|
53
53
|
len = @display_length || value.length
|
54
|
+
$log.debug "less ZERO #{@display_length} || #{value.length}, ri: #{row_index}" if len < 0
|
54
55
|
acolor = get_color $datacolor
|
55
56
|
#acolor =get_color $datacolor, @color || @parent.color, @bgcolor || @parent.bgcolor #unless @parent.nil?
|
56
57
|
_attr = Ncurses::A_NORMAL
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rkumar-rbcurse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rahul Kumar
|
@@ -14,6 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hoe
|
17
|
+
type: :development
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -86,6 +87,8 @@ files:
|
|
86
87
|
- examples/testtabp.rb
|
87
88
|
- examples/testtodo.rb
|
88
89
|
- examples/viewtodo.rb
|
90
|
+
- examples/todocsv.csv
|
91
|
+
- examples/sqlc.rb
|
89
92
|
has_rdoc: false
|
90
93
|
homepage: http://rbcurse.rubyforge.org/
|
91
94
|
post_install_message:
|