rbcurse 1.4.1 → 1.5.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +31 -0
- data/README.markdown +69 -11
- data/VERSION +1 -1
- data/lib/rbcurse.rb +5 -5
- metadata +10 -198
- data/Makefile +0 -21
- data/Manifest.txt +0 -91
- data/TODO +0 -372
- data/TODO2.txt +0 -118
- data/examples/README.txt +0 -67
- data/examples/abasiclist.rb +0 -33
- data/examples/alpmenu.rb +0 -42
- data/examples/app.rb +0 -859
- data/examples/app.sample +0 -10
- data/examples/appdirtree.rb +0 -75
- data/examples/appemail.rb +0 -191
- data/examples/appemaillb.rb +0 -308
- data/examples/appgcompose.rb +0 -315
- data/examples/atree.rb +0 -64
- data/examples/common/file.rb +0 -40
- data/examples/common/rmail.rb +0 -257
- data/examples/data.txt +0 -683
- data/examples/data/README.markdown +0 -9
- data/examples/data/brew.txt +0 -38
- data/examples/data/color.2 +0 -37
- data/examples/data/gemlist.txt +0 -60
- data/examples/data/lotr.txt +0 -12
- data/examples/data/ports.txt +0 -136
- data/examples/data/tasks.txt +0 -27
- data/examples/data/todocsv.csv +0 -28
- data/examples/data/unix1.txt +0 -21
- data/examples/data/unix2.txt +0 -11
- data/examples/dbdemo.rb +0 -495
- data/examples/deprecated/appgmail.rb +0 -952
- data/examples/deprecated/splitp.rb +0 -56
- data/examples/deprecated/testscrolllb.rb +0 -86
- data/examples/deprecated/testscrollp.rb +0 -88
- data/examples/deprecated/testscrollta.rb +0 -80
- data/examples/deprecated/testscrolltable.rb +0 -165
- data/examples/deprecated/testsplit.rb +0 -87
- data/examples/deprecated/testsplit2.rb +0 -123
- data/examples/deprecated/testsplit3.rb +0 -215
- data/examples/deprecated/testsplit3_1.rb +0 -244
- data/examples/deprecated/testsplit3a.rb +0 -215
- data/examples/deprecated/testsplit3b.rb +0 -237
- data/examples/deprecated/testsplitta.rb +0 -148
- data/examples/deprecated/testsplittv.rb +0 -142
- data/examples/deprecated/testsplittvv.rb +0 -144
- data/examples/deprecated/testtpane.rb +0 -215
- data/examples/deprecated/testtpane2.rb +0 -145
- data/examples/deprecated/testtpanetable.rb +0 -203
- data/examples/dirtree.rb +0 -88
- data/examples/experimental/resultsetdemo.rb +0 -280
- data/examples/experimental/testmform.rb +0 -35
- data/examples/experimental/testscroller.rb +0 -117
- data/examples/experimental/teststackflow.rb +0 -111
- data/examples/menu1.rb +0 -112
- data/examples/multispl.rb +0 -86
- data/examples/newmessagebox.rb +0 -130
- data/examples/newtabbedwindow.rb +0 -100
- data/examples/newtesttabp.rb +0 -121
- data/examples/qdfilechooser.rb +0 -68
- data/examples/rfe.rb +0 -1195
- data/examples/rfe_renderer.rb +0 -121
- data/examples/sqlc.rb +0 -454
- data/examples/sqlm.rb +0 -437
- data/examples/sqlt.rb +0 -408
- data/examples/status.txt +0 -68
- data/examples/table1.rb +0 -24
- data/examples/term2.rb +0 -84
- data/examples/test1.rb +0 -239
- data/examples/test2.rb +0 -674
- data/examples/testapp.rb +0 -44
- data/examples/testapp2.rb +0 -58
- data/examples/testchars.rb +0 -137
- data/examples/testcombo.rb +0 -91
- data/examples/testkeypress.rb +0 -66
- data/examples/testlistbox.rb +0 -113
- data/examples/testmenu.rb +0 -101
- data/examples/testmulticomp.rb +0 -70
- data/examples/testmulticontainer.rb +0 -94
- data/examples/testmultispl.rb +0 -199
- data/examples/testree.rb +0 -106
- data/examples/testtable.rb +0 -263
- data/examples/testtabp.rb +0 -107
- data/examples/testtodo.rb +0 -584
- data/examples/testvimsplit.rb +0 -112
- data/examples/testwsshortcuts.rb +0 -64
- data/examples/testwsshortcuts2.rb +0 -126
- data/examples/todo.db +0 -0
- data/examples/todo.yml +0 -191
- data/examples/viewtodo.rb +0 -574
- data/lib/rbcurse/action.rb +0 -40
- data/lib/rbcurse/app.rb +0 -1374
- data/lib/rbcurse/applicationheader.rb +0 -102
- data/lib/rbcurse/celleditor.rb +0 -112
- data/lib/rbcurse/checkboxcellrenderer.rb +0 -57
- data/lib/rbcurse/colormap.rb +0 -159
- data/lib/rbcurse/comboboxcellrenderer.rb +0 -30
- data/lib/rbcurse/common/ansiparser.rb +0 -117
- data/lib/rbcurse/common/appmethods.rb +0 -112
- data/lib/rbcurse/common/basestack.rb +0 -407
- data/lib/rbcurse/common/bordertitle.rb +0 -41
- data/lib/rbcurse/common/chunk.rb +0 -177
- data/lib/rbcurse/common/colorparser.rb +0 -71
- data/lib/rbcurse/common/keydefs.rb +0 -30
- data/lib/rbcurse/common/widgetshortcuts.rb +0 -302
- data/lib/rbcurse/defaultlistselectionmodel.rb +0 -79
- data/lib/rbcurse/deprecated/README.markdown +0 -12
- data/lib/rbcurse/deprecated/rscrollpane.rb +0 -512
- data/lib/rbcurse/deprecated/rsplitpane.rb +0 -894
- data/lib/rbcurse/deprecated/rsplitpane2.rb +0 -1009
- data/lib/rbcurse/deprecated/rviewport.rb +0 -204
- data/lib/rbcurse/experimental/README.markdown +0 -14
- data/lib/rbcurse/experimental/resultsettextview.rb +0 -585
- data/lib/rbcurse/experimental/stackflow.rb +0 -478
- data/lib/rbcurse/extras/bottomline.rb +0 -1850
- data/lib/rbcurse/extras/box.rb +0 -58
- data/lib/rbcurse/extras/directorylist.rb +0 -467
- data/lib/rbcurse/extras/directorytree.rb +0 -69
- data/lib/rbcurse/extras/divider.rb +0 -310
- data/lib/rbcurse/extras/focusmanager.rb +0 -31
- data/lib/rbcurse/extras/horizlist.rb +0 -203
- data/lib/rbcurse/extras/listselectable.rb +0 -264
- data/lib/rbcurse/extras/masterdetail.rb +0 -166
- data/lib/rbcurse/extras/menutree.rb +0 -63
- data/lib/rbcurse/extras/multiform.rb +0 -330
- data/lib/rbcurse/extras/multilinelabel.rb +0 -142
- data/lib/rbcurse/extras/newmessagebox.rb +0 -328
- data/lib/rbcurse/extras/newtabbedpane.rb +0 -612
- data/lib/rbcurse/extras/newtabbedwindow.rb +0 -68
- data/lib/rbcurse/extras/padreader.rb +0 -189
- data/lib/rbcurse/extras/rcomboedit.rb +0 -256
- data/lib/rbcurse/extras/resultsetbrowser.rb +0 -281
- data/lib/rbcurse/extras/rlink.rb +0 -27
- data/lib/rbcurse/extras/rmenulink.rb +0 -21
- data/lib/rbcurse/extras/scrollbar.rb +0 -143
- data/lib/rbcurse/extras/statusline.rb +0 -94
- data/lib/rbcurse/extras/stdscrwindow.rb +0 -309
- data/lib/rbcurse/extras/tableextended.rb +0 -40
- data/lib/rbcurse/extras/tabular.rb +0 -264
- data/lib/rbcurse/extras/tabularwidget.rb +0 -1150
- data/lib/rbcurse/extras/textpad.rb +0 -516
- data/lib/rbcurse/extras/viewer.rb +0 -136
- data/lib/rbcurse/io.rb +0 -850
- data/lib/rbcurse/keylabelprinter.rb +0 -178
- data/lib/rbcurse/listcellrenderer.rb +0 -140
- data/lib/rbcurse/listeditable.rb +0 -310
- data/lib/rbcurse/listkeys.rb +0 -37
- data/lib/rbcurse/listscrollable.rb +0 -564
- data/lib/rbcurse/listselectable.rb +0 -142
- data/lib/rbcurse/mapper.rb +0 -130
- data/lib/rbcurse/orderedhash.rb +0 -77
- data/lib/rbcurse/ractionevent.rb +0 -67
- data/lib/rbcurse/rbasiclistbox.rb +0 -768
- data/lib/rbcurse/rchangeevent.rb +0 -27
- data/lib/rbcurse/rcombo.rb +0 -238
- data/lib/rbcurse/rcommandwindow.rb +0 -587
- data/lib/rbcurse/rcontainer.rb +0 -415
- data/lib/rbcurse/rdialogs.rb +0 -451
- data/lib/rbcurse/rinputdataevent.rb +0 -47
- data/lib/rbcurse/rlistbox.rb +0 -1196
- data/lib/rbcurse/rmenu.rb +0 -939
- data/lib/rbcurse/rmessagebox.rb +0 -348
- data/lib/rbcurse/rmulticontainer.rb +0 -304
- data/lib/rbcurse/rmultisplit.rb +0 -722
- data/lib/rbcurse/rmultitextview.rb +0 -306
- data/lib/rbcurse/rpopupmenu.rb +0 -755
- data/lib/rbcurse/rprogress.rb +0 -118
- data/lib/rbcurse/rscrollform.rb +0 -418
- data/lib/rbcurse/rtabbedpane.rb +0 -1158
- data/lib/rbcurse/rtabbedwindow.rb +0 -167
- data/lib/rbcurse/rtable.rb +0 -1718
- data/lib/rbcurse/rtextarea.rb +0 -920
- data/lib/rbcurse/rtextview.rb +0 -761
- data/lib/rbcurse/rtree.rb +0 -780
- data/lib/rbcurse/rvimsplit.rb +0 -763
- data/lib/rbcurse/rwidget.rb +0 -2915
- data/lib/rbcurse/scrollable.rb +0 -301
- data/lib/rbcurse/table/tablecellrenderer.rb +0 -86
- data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -98
- data/lib/rbcurse/tree/treecellrenderer.rb +0 -150
- data/lib/rbcurse/tree/treemodel.rb +0 -428
- data/lib/rbcurse/undomanager.rb +0 -188
- data/lib/rbcurse/vieditable.rb +0 -144
- data/lib/ver/keyboard.rb +0 -150
- data/lib/ver/keyboard2.rb +0 -170
- data/lib/ver/ncurses.rb +0 -218
- data/lib/ver/panel.rb +0 -162
- data/lib/ver/rpad.rb +0 -375
- data/lib/ver/window.rb +0 -882
- data/test/test_rbcurse.rb +0 -0
data/lib/rbcurse/undomanager.rb
DELETED
@@ -1,188 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
* Name: UndoManager
|
3
|
-
* Description: Manages undo of text components
|
4
|
-
* Author: rkumar (arunachalesha)
|
5
|
-
|
6
|
-
ISSUES
|
7
|
-
|
8
|
-
This is a very simple, undo facility. This could change in the near future.
|
9
|
-
|
10
|
-
Todo:
|
11
|
-
We need to handle block updates - several undo ops to be done together.
|
12
|
-
|
13
|
-
|
14
|
-
--------
|
15
|
-
* Date: 2010-03-07 19:42
|
16
|
-
* License:
|
17
|
-
Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
18
|
-
|
19
|
-
=end
|
20
|
-
|
21
|
-
#
|
22
|
-
#
|
23
|
-
module RubyCurses
|
24
|
-
#
|
25
|
-
# AbstractUndo has the basic workings of the undo redo facility.
|
26
|
-
# It leaves the actual undo and redo to the implementing source object. However,
|
27
|
-
# it does the work of storing edits, and passing the correct edit to the implementor
|
28
|
-
# when the source object calls for an undo or redo operation. It thus manages the edit (undo) queue.
|
29
|
-
#
|
30
|
-
class AbstractUndo
|
31
|
-
# initialize the source object which will issue undo requests
|
32
|
-
def initialize _source
|
33
|
-
source(_source) #if _source
|
34
|
-
@pointer = 0
|
35
|
-
@actions = []
|
36
|
-
$log.debug " INSIDE UNDO CONSTR "
|
37
|
-
end
|
38
|
-
def source(_source)
|
39
|
-
$log.debug " calling source= "
|
40
|
-
raise "Cannot pass a nil source" unless _source
|
41
|
-
@source = _source
|
42
|
-
# currently this is very hardcode again. we need to see this in the light of other objects
|
43
|
-
#@source.bind(:CHANGE){|eve| add_edit(eve) }
|
44
|
-
# a little roundabout but done for getting things up fast
|
45
|
-
@source.undo_handler(self)
|
46
|
-
$log.debug " I am listening to change events on #{@source.name} "
|
47
|
-
end
|
48
|
-
# this is called whenever an undoable edit has happened.
|
49
|
-
# Currently, it is linked above in the bind statement. We've attached this
|
50
|
-
# method as a listener to the source.
|
51
|
-
def add_edit event
|
52
|
-
# this debug is very specific. it should be removed later. We do not know about the object
|
53
|
-
$log.debug " UNDO GOT #{event}: #{event.type}, (#{event.text}), rej: #{@reject_update} "
|
54
|
-
return if @reject_update
|
55
|
-
if @pointer < @actions.length
|
56
|
-
$log.debug " removing some actions since #{@pointer} < #{@actions.length} "
|
57
|
-
@actions.slice!(@pointer..-1)
|
58
|
-
$log.debug " removed actions since #{@pointer} , #{@actions.length} "
|
59
|
-
end
|
60
|
-
@actions << event
|
61
|
-
@pointer = @actions.length
|
62
|
-
end
|
63
|
-
# this has to be bound in source component
|
64
|
-
# typically bind C-_ to undo()
|
65
|
-
# this method figures out the correct undo object to be sent
|
66
|
-
# to the implementor
|
67
|
-
def undo
|
68
|
-
$log.debug " got UNDO call #{@pointer}, sz:#{@actions.size} "
|
69
|
-
return if @pointer == 0
|
70
|
-
@reject_update = true
|
71
|
-
@pointer -=1 #if @pointer > 0
|
72
|
-
@source.repaint_required true
|
73
|
-
@reject_update = false
|
74
|
-
edit = @actions[@pointer]
|
75
|
-
perform_undo edit
|
76
|
-
end
|
77
|
-
# this has to be bound in source
|
78
|
-
# typically bind C-r to redo()
|
79
|
-
# this method figures out the correct redo object to be sent
|
80
|
-
# to the implementor
|
81
|
-
def redo
|
82
|
-
$log.debug "UNDO GOT REDO call #{@pointer}, #{@actions.size} "
|
83
|
-
return if @pointer >= @actions.size
|
84
|
-
@reject_update = true
|
85
|
-
edit = @actions[@pointer]
|
86
|
-
perform_redo edit
|
87
|
-
@source.repaint_required true
|
88
|
-
@pointer +=1 #if @pointer > 0
|
89
|
-
@reject_update = false
|
90
|
-
end
|
91
|
-
def perform_redo edit
|
92
|
-
raise "You must implement this for your undoable component "
|
93
|
-
end
|
94
|
-
def perform_undo edit
|
95
|
-
raise "You must implement this for your undoable component "
|
96
|
-
# to be implemented
|
97
|
-
end
|
98
|
-
#def to_s
|
99
|
-
#inspect
|
100
|
-
#end
|
101
|
-
#def inspect
|
102
|
-
### now that textarea.to_s prints content we shouldn pass it here.
|
103
|
-
##"#{@type.to_s}, #{@source}, ind0:#{@index0}, ind1:#{@index1}, row:#{@row}, text:#{@text}"
|
104
|
-
#"#{@type.to_s}, ind0:#{@index0}, ind1:#{@index1}, row:#{@row}, text:#{@text}"
|
105
|
-
#end
|
106
|
-
end
|
107
|
-
## An implementation of AbstractUndo for textarea.
|
108
|
-
# Very basic.
|
109
|
-
class SimpleUndo < AbstractUndo
|
110
|
-
def initialize _source
|
111
|
-
super
|
112
|
-
end
|
113
|
-
def source(_source)
|
114
|
-
super
|
115
|
-
_source.bind(:CHANGE){|eve| add_edit(eve) }
|
116
|
-
end
|
117
|
-
def perform_undo act
|
118
|
-
row = act.row
|
119
|
-
col = act.index0
|
120
|
-
$log.debug " processing #{act} "
|
121
|
-
case act.type
|
122
|
-
when :INSERT
|
123
|
-
howmany = act.index1 - col
|
124
|
-
@source.list[row].slice!(col,howmany)
|
125
|
-
when :DELETE
|
126
|
-
$log.debug " UNDO processing DELETE #{col}, (#{act.text}) "
|
127
|
-
@source.list[row].insert(col, act.text.chomp)
|
128
|
-
when :DELETE_LINE
|
129
|
-
$log.debug " UNDO inside delete-line #{row} "
|
130
|
-
#@source.list.insert(row, act.text) # insert a blank line, since one was deleted
|
131
|
-
case act.text
|
132
|
-
when Array
|
133
|
-
index = row
|
134
|
-
act.text.each_with_index{|r,i| @source.list.insert index+i, r}
|
135
|
-
when String
|
136
|
-
@source.list.insert row, act.text
|
137
|
-
end
|
138
|
-
when :INSERT_LINE
|
139
|
-
$log.debug " UNDO inside insert-line #{row} "
|
140
|
-
case act.text
|
141
|
-
when Array
|
142
|
-
act.text.size.times { @source.list.delete_at row }
|
143
|
-
when String
|
144
|
-
@source.list.delete_at row
|
145
|
-
end
|
146
|
-
else
|
147
|
-
$log.warn "unhandled change type #{act.type} "
|
148
|
-
end
|
149
|
-
@source.repaint_required true
|
150
|
-
@reject_update = false
|
151
|
-
end
|
152
|
-
# this has to be bound in source
|
153
|
-
def perform_redo act
|
154
|
-
row = act.row
|
155
|
-
col = act.index0
|
156
|
-
$log.debug " REDO processing #{act} "
|
157
|
-
case act.type
|
158
|
-
when :INSERT
|
159
|
-
@source.list[row].insert(col, act.text)
|
160
|
-
when :DELETE
|
161
|
-
row = act.row
|
162
|
-
col = act.index0
|
163
|
-
howmany = act.index1 - col
|
164
|
-
@source.list[row].slice!(col,howmany)
|
165
|
-
when :DELETE_LINE
|
166
|
-
#$log.debug " UNDO redo got deleteline #{row} "
|
167
|
-
#@source.list.delete_at row
|
168
|
-
# changed on 2010-05-23 12:21 since was not handling mult delete
|
169
|
-
case act.text
|
170
|
-
when Array
|
171
|
-
act.text.size.times { @source.list.delete_at row }
|
172
|
-
when String
|
173
|
-
@source.list.delete_at row
|
174
|
-
end
|
175
|
-
when :INSERT_LINE
|
176
|
-
case act.text
|
177
|
-
when Array
|
178
|
-
index = row
|
179
|
-
act.text.each_with_index{|r,i| @source.list.insert index+i, r}
|
180
|
-
when String
|
181
|
-
@source.list.insert row, act.text
|
182
|
-
end
|
183
|
-
else
|
184
|
-
$log.warn "unhandled change type #{act.type} "
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end # module
|
data/lib/rbcurse/vieditable.rb
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
#**************************************************************
|
2
|
-
# Author: rkumar (arunachalesha)
|
3
|
-
# Date: 2010-03-11 22:18
|
4
|
-
# Provides the caller ability to do some edit operations
|
5
|
-
# on list widgets using either keys (vim largely)
|
6
|
-
# or a menu. made originally for textview and multitextview
|
7
|
-
#
|
8
|
-
#**************************************************************
|
9
|
-
|
10
|
-
|
11
|
-
require 'rbcurse/listeditable'
|
12
|
-
module ViEditable
|
13
|
-
include ListEditable
|
14
|
-
|
15
|
-
def vieditable_init
|
16
|
-
$log.debug " inside vieditable_init "
|
17
|
-
@editable = true
|
18
|
-
bind_key( ?C, :edit_line)
|
19
|
-
#bind_key( ?o, :insert_line)
|
20
|
-
#bind_key( ?O) { insert_line(@current_index-1) }
|
21
|
-
bind_key( ?o) { insert_line(@current_index+1) }
|
22
|
-
bind_key( ?O) { insert_line(@current_index) }
|
23
|
-
bind_key( ?D, :delete_eol)
|
24
|
-
bind_key( [?d, ?$], :delete_eol)
|
25
|
-
bind_key( [?d, ?d] , :delete_line )
|
26
|
-
bind_key( [?d, ?w], :delete_word )
|
27
|
-
bind_key( [?d, ?t], :delete_till )
|
28
|
-
bind_key( [?d, ?f], :delete_forward )
|
29
|
-
bind_key( ?\C-_ ) { @undo_handler.undo if @undo_handler }
|
30
|
-
bind_key( ?u ) { @undo_handler.undo if @undo_handler }
|
31
|
-
bind_key( ?\C-r ) { @undo_handler.redo if @undo_handler }
|
32
|
-
bind_key( ?x, :delete_curr_char )
|
33
|
-
bind_key( ?X, :delete_prev_char )
|
34
|
-
bind_key( [?y, ?y] , :kill_ring_save )
|
35
|
-
bind_key( ?p, :yank ) # paste after this line
|
36
|
-
bind_key( ?P ) { yank(@current_index - 1) } # should be before this line
|
37
|
-
bind_key(?\w, :forward_word)
|
38
|
-
bind_key(?f, :forward_char)
|
39
|
-
bind_key(?\M-y, :yank_pop)
|
40
|
-
bind_key(?\M-w, :kill_ring_save)
|
41
|
-
@_events.push :CHANGE # thru vieditable
|
42
|
-
|
43
|
-
end
|
44
|
-
##
|
45
|
-
# Separate mappings for listboxes.
|
46
|
-
# Some methods don;'t make sense for listboxes and are crashing
|
47
|
-
# since not present for them. f was being overwritten, too.
|
48
|
-
# Sorry for duplication, need to clean this somehow.
|
49
|
-
def vieditable_init_listbox
|
50
|
-
$log.debug " inside vieditable_init_listbox "
|
51
|
-
@editable = true
|
52
|
-
bind_key( ?C, :edit_line)
|
53
|
-
bind_key( ?o) { insert_line(@current_index+1) }
|
54
|
-
bind_key( ?O) { insert_line(@current_index) }
|
55
|
-
bind_key( [?d, ?d] , :delete_line )
|
56
|
-
bind_key( ?\C-_ ) { @undo_handler.undo if @undo_handler }
|
57
|
-
bind_key( ?u ) { @undo_handler.undo if @undo_handler }
|
58
|
-
bind_key( ?\C-r ) { @undo_handler.redo if @undo_handler }
|
59
|
-
bind_key( [?y, ?y] , :kill_ring_save )
|
60
|
-
bind_key( ?p, :yank ) # paste after this line
|
61
|
-
bind_key( ?P ) { yank(@current_index - 1) } # should be before this line
|
62
|
-
bind_key(?\w, :forward_word)
|
63
|
-
bind_key(?\M-y, :yank_pop)
|
64
|
-
bind_key(?\C-y, :yank)
|
65
|
-
bind_key(?\M-w, :kill_ring_save)
|
66
|
-
@_events.push :CHANGE # thru vieditable
|
67
|
-
#bind_key( ?D, :delete_eol)
|
68
|
-
#bind_key( [?d, ?$], :delete_eol)
|
69
|
-
#bind_key(?f, :forward_char)
|
70
|
-
#bind_key( ?x, :delete_curr_char )
|
71
|
-
#bind_key( ?X, :delete_prev_char )
|
72
|
-
#bind_key( [?d, ?w], :delete_word )
|
73
|
-
#bind_key( [?d, ?t], :delete_till )
|
74
|
-
#bind_key( [?d, ?f], :delete_forward )
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
##
|
79
|
-
# edit current or given line
|
80
|
-
def edit_line lineno=@current_index
|
81
|
-
line = self[lineno]
|
82
|
-
prompt = "Edit: "
|
83
|
-
maxlen = 80
|
84
|
-
config={};
|
85
|
-
oldline = line.dup
|
86
|
-
config[:default] = line
|
87
|
-
ret, str = rbgetstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)
|
88
|
-
$log.debug " rbgetstr returned #{ret} , #{str} "
|
89
|
-
return if ret != 0
|
90
|
-
self[lineno].replace(str)
|
91
|
-
fire_handler :CHANGE, InputDataEvent.new(0,oldline.length, self, :DELETE_LINE, lineno, oldline) # 2008-12-24 18:34
|
92
|
-
fire_handler :CHANGE, InputDataEvent.new(0,str.length, self, :INSERT_LINE, lineno, str)
|
93
|
-
@repaint_required = true
|
94
|
-
end
|
95
|
-
##
|
96
|
-
# insert a line
|
97
|
-
# FIXME needs to fire handler 2010-05-23 11:40
|
98
|
-
def insert_line lineno=@current_index
|
99
|
-
prompt = "Insert: "
|
100
|
-
maxlen = 80
|
101
|
-
#config={};
|
102
|
-
#config[:default] = line
|
103
|
-
#ret, str = rbgetstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)
|
104
|
-
ret, str = input_string prompt
|
105
|
-
#ret, str = rbgetstr(@form.window, @row+@height-1, @col+1, prompt, maxlen, config)
|
106
|
-
$log.debug " rbgetstr returned #{ret} , #{str} "
|
107
|
-
return if ret != 0
|
108
|
-
@list.insert lineno, str
|
109
|
-
## added handler on 2010-05-23 11:46 - undo works - tested in testlistbox.rb
|
110
|
-
fire_handler :CHANGE, InputDataEvent.new(0,str.length, self, :INSERT_LINE, lineno, str)
|
111
|
-
@repaint_required = true
|
112
|
-
end
|
113
|
-
##
|
114
|
-
# common method to edit given string
|
115
|
-
# @param [String] string to edit/modify
|
116
|
-
# @param [String] prompt to display before string
|
117
|
-
# @param [int] max length of input
|
118
|
-
# @return [0, -1] return value 0 if okay, -1 if error
|
119
|
-
#
|
120
|
-
def edit_string string, prompt="Edit: ", maxlen=80
|
121
|
-
config={};
|
122
|
-
config[:default] = string
|
123
|
-
ret, str = rbgetstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)
|
124
|
-
#return str if ret == 0
|
125
|
-
#return ""
|
126
|
-
end
|
127
|
-
##
|
128
|
-
# common method to input a blank string
|
129
|
-
# @param [String] prompt to display before string
|
130
|
-
# @param [int] max length of input
|
131
|
-
# @return [0, -1] return value 0 if okay, -1 if error
|
132
|
-
def input_string prompt="Insert: ", maxlen=80
|
133
|
-
#ret, str = rbgetstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)
|
134
|
-
ret, str = rbgetstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)
|
135
|
-
#return str if ret == 0
|
136
|
-
#return ""
|
137
|
-
end
|
138
|
-
def edit_chars
|
139
|
-
|
140
|
-
end
|
141
|
-
def edit_word
|
142
|
-
|
143
|
-
end
|
144
|
-
end # module
|
data/lib/ver/keyboard.rb
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
module VER
|
2
|
-
module Keyboard # avoid initialize
|
3
|
-
ESC = 27 # keycode
|
4
|
-
@polling = false
|
5
|
-
|
6
|
-
module_function
|
7
|
-
|
8
|
-
def focus=(receiver)
|
9
|
-
@stack = []
|
10
|
-
@focus = receiver
|
11
|
-
poll unless @polling
|
12
|
-
end
|
13
|
-
|
14
|
-
def poll
|
15
|
-
@polling = true
|
16
|
-
|
17
|
-
while char = @focus.window.getch
|
18
|
-
break if @focus.stopping? # XXX
|
19
|
-
#break if VER.stopping?
|
20
|
-
$log.debug("char: #{char} stakc: #{@stack.inspect}") if char != Ncurses::ERR
|
21
|
-
if char == Ncurses::ERR # timeout or signal
|
22
|
-
@focus.press('esc') if @stack == [ESC]
|
23
|
-
@stack.clear
|
24
|
-
elsif ready = resolve(char)
|
25
|
-
$log.debug("char: #{char} ready: #{ready}")
|
26
|
-
@stack.clear
|
27
|
-
@focus.press(ready)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
ensure
|
32
|
-
@polling = false
|
33
|
-
end
|
34
|
-
|
35
|
-
def resolve(char)
|
36
|
-
@stack << char
|
37
|
-
|
38
|
-
if @stack.first == ESC
|
39
|
-
MOD_KEYS[@stack] || SPECIAL_KEYS[@stack]
|
40
|
-
else
|
41
|
-
NCURSES_KEYS[char] || CONTROL_KEYS[char] || PRINTABLE_KEYS[char]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# TODO: make this section sane
|
46
|
-
|
47
|
-
ASCII = (0..255).map{|c| c.chr }
|
48
|
-
CONTROL = ASCII.grep(/[[:cntrl:]]/)
|
49
|
-
PRINTABLE = ASCII.grep(/[[:print:]]/)
|
50
|
-
|
51
|
-
SPECIAL_KEYS = {
|
52
|
-
[27, 79, 50, 81] => 'F14',
|
53
|
-
[27, 79, 50, 82] => 'F15',
|
54
|
-
[27, 79, 70] => 'end',
|
55
|
-
[27, 79, 70] => 'end',
|
56
|
-
[27, 79, 72] => 'home',
|
57
|
-
[27, 79, 80] => 'F1',
|
58
|
-
[27, 79, 81] => 'F2',
|
59
|
-
[27, 79, 82] => 'F3',
|
60
|
-
[27, 79, 83] => 'F4',
|
61
|
-
[27, 91, 49, 126] => 'end',
|
62
|
-
[27, 91, 49, 126] => 'home',
|
63
|
-
[27, 91, 49, 49, 126] => 'F1',
|
64
|
-
[27, 91, 49, 50, 126] => 'F2',
|
65
|
-
[27, 91, 49, 51, 126] => 'F3',
|
66
|
-
[27, 91, 49, 52, 126] => 'F4',
|
67
|
-
[27, 91, 49, 52, 126] => 'F4',
|
68
|
-
[27, 91, 49, 53, 126] => 'F5',
|
69
|
-
[27, 91, 49, 55, 126] => 'F6',
|
70
|
-
[27, 91, 49, 56, 59, 50, 126] => 'F19',
|
71
|
-
[27, 91, 49, 56, 59, 51, 126] => 'F7',
|
72
|
-
[27, 91, 49, 59, 51, 65] => 'ppage',
|
73
|
-
[27, 91, 49, 59, 51, 66] => 'npage',
|
74
|
-
[27, 91, 49, 59, 53, 65] => 'ppage',
|
75
|
-
[27, 91, 49, 59, 53, 66] => 'npage',
|
76
|
-
[27, 91, 49, 59, 53, 70] => 'M-<',
|
77
|
-
[27, 91, 49, 59, 53, 72] => 'M->',
|
78
|
-
[27, 91, 50, 54, 126] => 'F14',
|
79
|
-
[27, 91, 50, 56, 126] => 'F15',
|
80
|
-
[27, 91, 51, 59, 51, 126] => 'del',
|
81
|
-
[27, 91, 52, 126] => 'end',
|
82
|
-
[27, 91, 55, 126] => 'home',
|
83
|
-
[27, 91, 55, 126] => 'home',
|
84
|
-
[27, 91, 56, 126] => 'end',
|
85
|
-
[27, 91, 56, 126] => 'end',
|
86
|
-
[27, 91, 65] => 'up',
|
87
|
-
[27, 91, 66] => 'down',
|
88
|
-
[27, 91, 67] => 'right',
|
89
|
-
[27, 91, 68] => 'left',
|
90
|
-
[27, 91, 70] => 'end',
|
91
|
-
[27, 91, 72] => 'end',
|
92
|
-
[27, 91, 72] => 'home',
|
93
|
-
[27, 91, 91, 65] => 'F1',
|
94
|
-
[27, 91, 91, 66] => 'F2',
|
95
|
-
[27, 91, 91, 67] => 'F3',
|
96
|
-
[27, 91, 91, 68] => 'F4',
|
97
|
-
[27, 91, 91, 69] => 'F5',
|
98
|
-
}
|
99
|
-
|
100
|
-
CONTROL_KEYS = {
|
101
|
-
0 => 'C-space',
|
102
|
-
1 => 'C-a',
|
103
|
-
2 => 'C-b',
|
104
|
-
3 => 'C-c',
|
105
|
-
4 => 'C-d',
|
106
|
-
5 => 'C-e',
|
107
|
-
6 => 'C-f',
|
108
|
-
7 => 'C-g',
|
109
|
-
8 => 'C-h',
|
110
|
-
9 => 'tab',
|
111
|
-
10 => 'return', # C-j
|
112
|
-
11 => 'C-k',
|
113
|
-
12 => 'C-l',
|
114
|
-
13 => 'return', # C-m
|
115
|
-
14 => 'C-n',
|
116
|
-
15 => 'C-o',
|
117
|
-
16 => 'C-p',
|
118
|
-
17 => 'C-q',
|
119
|
-
18 => 'C-r',
|
120
|
-
19 => 'C-s',
|
121
|
-
20 => 'C-t',
|
122
|
-
21 => 'C-u',
|
123
|
-
22 => 'C-v',
|
124
|
-
23 => 'C-w',
|
125
|
-
24 => 'C-x',
|
126
|
-
25 => 'C-y',
|
127
|
-
26 => 'C-z', # FIXME: is usually suspend in shell job control
|
128
|
-
# 27 => 'esc',
|
129
|
-
32 => 'space',
|
130
|
-
127 => 'backspace',
|
131
|
-
}
|
132
|
-
|
133
|
-
PRINTABLE_KEYS = {}
|
134
|
-
MOD_KEYS = {}
|
135
|
-
|
136
|
-
PRINTABLE.each do |key|
|
137
|
-
code = key.unpack('c')[0] # using unpack to be compatible with 1.9
|
138
|
-
PRINTABLE_KEYS[code] = key
|
139
|
-
MOD_KEYS[[ESC, code]] = "M-#{key}" unless key == '[' # don't map esc
|
140
|
-
end
|
141
|
-
|
142
|
-
NCURSES_KEYS = {}
|
143
|
-
Ncurses.constants.grep(/^KEY_/).each do |const|
|
144
|
-
value = Ncurses.const_get(const)
|
145
|
-
key = const[/^KEY_(.*)/, 1]
|
146
|
-
key = key =~ /^F/ ? key : key.downcase # function keys
|
147
|
-
NCURSES_KEYS[value] = key
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|