rbcurse-core 0.0.11 → 0.0.12
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/VERSION +1 -1
- data/lib/rbcurse.rb +1 -1
- data/lib/rbcurse/core/include/listbindings.rb +2 -1
- data/lib/rbcurse/core/include/listscrollable.rb +42 -0
- data/lib/rbcurse/core/include/listselectable.rb +13 -6
- data/lib/rbcurse/core/include/ractionevent.rb +6 -0
- data/lib/rbcurse/core/system/window.rb +1 -1
- data/lib/rbcurse/core/util/colorparser.rb +4 -1
- data/lib/rbcurse/core/widgets/rwidget.rb +1 -1
- data/lib/rbcurse/core/widgets/statusline.rb +11 -8
- data/lib/rbcurse/core/widgets/textpad.rb +31 -1
- data/rbcurse-core.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12
|
data/lib/rbcurse.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Author: rkumar http://github.com/rkumar/rbcurse/
|
5
5
|
# Date: 2011-12-11 - 12:58
|
6
6
|
# License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
7
|
-
# Last update: 2013-03-
|
7
|
+
# Last update: 2013-03-25 01:53
|
8
8
|
# ----------------------------------------------------------------------------- #
|
9
9
|
#
|
10
10
|
module RubyCurses
|
@@ -44,6 +44,7 @@ module RubyCurses
|
|
44
44
|
bind_key(?k, 'previous row'){ previous_row() }
|
45
45
|
## added 2013-03-04 - 17:52
|
46
46
|
bind_key(?w, 'forward_word'){ forward_word }
|
47
|
+
bind_key(?b, 'backward_word'){ backward_word }
|
47
48
|
bind_key(?\C-d, 'scroll forward'){ scroll_forward() }
|
48
49
|
bind_key(?\C-b, 'scroll backward'){ scroll_backward() }
|
49
50
|
bind_key([?g,?g], 'goto start'){ goto_start } # mapping double keys like vim
|
@@ -490,6 +490,48 @@ module ListScrollable
|
|
490
490
|
set_form_col pos
|
491
491
|
@repaint_required = true
|
492
492
|
end
|
493
|
+
|
494
|
+
##
|
495
|
+
# go to beginning of previous word somewhat similar to vim's 'b' movement.
|
496
|
+
# Introduced on 2013-03-25 - 00:49 and has some errors but mostly quite
|
497
|
+
# helpful - i think i've fixed the error of getting stuck on a line
|
498
|
+
def backward_word
|
499
|
+
$multiplier = 1 if !$multiplier || $multiplier == 0
|
500
|
+
line = @current_index
|
501
|
+
buff = @list[line].to_s
|
502
|
+
return unless buff
|
503
|
+
pos = @curpos || 0 # list does not have curpos
|
504
|
+
$multiplier.times {
|
505
|
+
#found = buff.index(/[[:punct:][:space:]]+/, pos)
|
506
|
+
# 2013-03-04 - 17:35 modified so it skips spaces and puncts
|
507
|
+
# ouch pos becomes -2 and remains in same line !
|
508
|
+
|
509
|
+
spos = pos -2
|
510
|
+
spos = 0 if spos < 0
|
511
|
+
found = buff.rindex(/[[:punct:][:space:]]\w/, spos)
|
512
|
+
if !found || found == 0
|
513
|
+
# if not found, we've lost a counter/multiplier
|
514
|
+
if pos > 0
|
515
|
+
pos = 0
|
516
|
+
elsif line > 0
|
517
|
+
line -= 1
|
518
|
+
buff = @list[line].to_s
|
519
|
+
pos = buff.size - 1
|
520
|
+
else
|
521
|
+
return
|
522
|
+
end
|
523
|
+
else
|
524
|
+
pos = found + 1
|
525
|
+
end
|
526
|
+
$log.debug "BBB backward_word: pos #{pos} line #{line} buff: #{buff}, found #{found}"
|
527
|
+
}
|
528
|
+
@current_index = line
|
529
|
+
@curpos = pos
|
530
|
+
@buffer = @list[@current_index].to_s
|
531
|
+
set_form_row
|
532
|
+
set_form_col pos
|
533
|
+
@repaint_required = true
|
534
|
+
end
|
493
535
|
##
|
494
536
|
# goes to next occurence of <char> (or nth occurence)
|
495
537
|
# Actually, we can club this with forward_word so no duplication
|
@@ -203,16 +203,23 @@ module RubyCurses
|
|
203
203
|
return []
|
204
204
|
end # mod
|
205
205
|
# Applications may call this or just copy and modify
|
206
|
+
|
207
|
+
##
|
208
|
+
# bindings related to selection
|
209
|
+
#
|
206
210
|
def list_bindings
|
207
211
|
# what about users wanting 32 and ENTER to also go to next row automatically
|
208
212
|
# should make that optional, TODO
|
209
213
|
bind_key($row_selector || 32, 'toggle selection') { toggle_row_selection }
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
214
|
+
# 2013-03-24 - 14:46 added condition so single select does not get these
|
215
|
+
if @selection_mode == :multiple
|
216
|
+
bind_key(0, 'range select') { add_to_selection }
|
217
|
+
bind_key(?+, :ask_select) # --> calls select_values
|
218
|
+
bind_key(?-, :ask_unselect) # please implement FIXME TODO
|
219
|
+
bind_key(?a, :select_all)
|
220
|
+
bind_key(?*, :invert_selection)
|
221
|
+
bind_key(?u, :clear_selection)
|
222
|
+
end
|
216
223
|
@_header_adjustment ||= 0 # incase caller does not use
|
217
224
|
@_events << :LIST_SELECTION_EVENT unless @_events.include? :LIST_SELECTION_EVENT
|
218
225
|
end
|
@@ -57,6 +57,12 @@ module RubyCurses
|
|
57
57
|
def word_under_cursor line=text(), pos=@curpos, delim=" "
|
58
58
|
line ||= text()
|
59
59
|
pos ||= @curpos
|
60
|
+
# if pressed on a space, try to go to next word to make easier 2013-03-24
|
61
|
+
if line[pos,1] == delim
|
62
|
+
while line[pos,1] == delim
|
63
|
+
pos += 1
|
64
|
+
end
|
65
|
+
end
|
60
66
|
finish = line.index(delim, pos)
|
61
67
|
start = line.rindex(delim,pos)
|
62
68
|
finish = -1 if finish.nil?
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# Author: rkumar http://github.com/rkumar/rbcurse/
|
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: 2013-03-
|
7
|
+
# Last update: 2013-03-25 12:38
|
8
8
|
#
|
9
9
|
# == CHANGED
|
10
10
|
# removed Pad and Subwin to lib/ver/rpad.rb - hopefully I've seen the last of both
|
@@ -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: 2013-03-
|
10
|
+
# Last update: 2013-03-25 13:32
|
11
11
|
# ----------------------------------------------------------------------------- #
|
12
12
|
# == TODO
|
13
13
|
# - perhaps we can compile the regexp once and reuse
|
@@ -60,6 +60,9 @@ class DefaultColorParser
|
|
60
60
|
attrib = part[0]
|
61
61
|
end
|
62
62
|
}
|
63
|
+
# 2013-03-25 - 13:31 if numeric color specified
|
64
|
+
color = color.to_i if color =~ /^[0-9]+$/
|
65
|
+
bgcolor = bgcolor.to_i if bgcolor =~ /^[0-9]+$/
|
63
66
|
yield [color,bgcolor,attrib] if block_given?
|
64
67
|
end # catch
|
65
68
|
else
|
@@ -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-
|
12
|
+
* Last update: 2013-03-25 12:56
|
13
13
|
|
14
14
|
== CHANGES
|
15
15
|
* 2011-10-2 Added PropertyVetoException to rollback changes to property
|
@@ -75,28 +75,31 @@ module RubyCurses
|
|
75
75
|
#ftext = " %-20s | %s" % [Time.now, status] # should we print a default value just in case user doesn't
|
76
76
|
ftext = status # should we print a default value just in case user doesn't
|
77
77
|
end
|
78
|
+
# 2013-03-25 - 11:52 replaced $datacolor with @color_pair - how could this have been ?
|
79
|
+
# what if user wants to change attrib ?
|
78
80
|
if ftext =~ /#\[/
|
79
|
-
|
81
|
+
# hopefully color_pair does not clash with formatting
|
82
|
+
@form.window.printstring_formatted @row, @col, ftext, @color_pair, Ncurses::A_REVERSE
|
80
83
|
else
|
81
|
-
@form.window.printstring @row, @col, ftext,
|
84
|
+
@form.window.printstring @row, @col, ftext, @color_pair, Ncurses::A_REVERSE
|
82
85
|
end
|
83
|
-
# move this to formatted FIXME
|
84
|
-
#@form.window.printstring_or_chunks @row, @col, ftext, $datacolor, Ncurses::A_REVERSE
|
85
86
|
|
86
87
|
if @right_text
|
87
88
|
ftext = @right_text.call(self, @right_args)
|
88
89
|
if ftext =~ /#\[/
|
89
|
-
|
90
|
+
# hopefully color_pair does not clash with formatting
|
91
|
+
@form.window.printstring_formatted_right @row, nil, ftext, @color_pair, Ncurses::A_REVERSE
|
90
92
|
else
|
91
93
|
c = len - ftext.length
|
92
|
-
@form.window.printstring @row, c, ftext,
|
94
|
+
@form.window.printstring @row, c, ftext, @color_pair, Ncurses::A_REVERSE
|
93
95
|
end
|
94
96
|
else
|
95
97
|
t = Time.now
|
96
98
|
tt = t.strftime "%F %H:%M:%S"
|
97
99
|
r = Ncurses.LINES
|
98
|
-
#
|
99
|
-
|
100
|
+
# somehow the bg defined here affects the bg in left text, if left does not define
|
101
|
+
# a bg. The bgcolor defined of statusline is ignored in left or overriden by this
|
102
|
+
ftext = "#[fg=green,bg=blue] %-20s#[/end]" % [tt] # print a default
|
100
103
|
@form.window.printstring_formatted_right @row, nil, ftext, $datacolor, Ncurses::A_REVERSE
|
101
104
|
end
|
102
105
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# Author: rkumar http://github.com/rkumar/mancurses/
|
9
9
|
# Date: 2011-11-09 - 16:59
|
10
10
|
# License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
11
|
-
# Last update: 2013-03-
|
11
|
+
# Last update: 2013-03-25 01:52
|
12
12
|
#
|
13
13
|
# == CHANGES
|
14
14
|
# == TODO
|
@@ -397,6 +397,7 @@ module RubyCurses
|
|
397
397
|
bind_key(?M, :middle_of_window)
|
398
398
|
bind_key(?H, :top_of_window)
|
399
399
|
bind_key(?w, :forward_word)
|
400
|
+
bind_key(?b, :backward_word)
|
400
401
|
bind_key(?l, :cursor_forward)
|
401
402
|
bind_key(?h, :cursor_backward)
|
402
403
|
bind_key(?$, :cursor_eol)
|
@@ -814,6 +815,35 @@ module RubyCurses
|
|
814
815
|
ensure_visible
|
815
816
|
@repaint_required = true
|
816
817
|
end
|
818
|
+
def backward_word
|
819
|
+
$multiplier = 1 if !$multiplier || $multiplier == 0
|
820
|
+
line = @current_index
|
821
|
+
buff = @content[line].to_s
|
822
|
+
return unless buff
|
823
|
+
pos = @curpos || 0 # list does not have curpos
|
824
|
+
$multiplier.times {
|
825
|
+
found = buff.rindex(/[[:punct:][:space:]]\w/, pos-2)
|
826
|
+
if !found || found == 0
|
827
|
+
# if not found, we've lost a counter
|
828
|
+
if pos > 0
|
829
|
+
pos = 0
|
830
|
+
elsif line > 0
|
831
|
+
line -= 1
|
832
|
+
pos = @content[line].to_s.size
|
833
|
+
else
|
834
|
+
return
|
835
|
+
end
|
836
|
+
else
|
837
|
+
pos = found + 1
|
838
|
+
end
|
839
|
+
$log.debug " backward_word: pos #{pos} line #{line} buff: #{buff}"
|
840
|
+
}
|
841
|
+
$multiplier = 0
|
842
|
+
@current_index = line
|
843
|
+
@curpos = pos
|
844
|
+
ensure_visible
|
845
|
+
@repaint_required = true
|
846
|
+
end
|
817
847
|
#
|
818
848
|
# move cursor forward by one char (currently will not pan)
|
819
849
|
def cursor_forward
|
data/rbcurse-core.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "rbcurse-core"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.12"
|
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-
|
12
|
+
s.date = "2013-03-25"
|
13
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 = [
|
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.
|
4
|
+
version: 0.0.12
|
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-
|
12
|
+
date: 2013-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi-ncurses
|