Module: Canis::ViEditable
- Includes:
- ListEditable
- Defined in:
- lib/canis/core/include/vieditable.rb
Instance Method Summary collapse
-
#edit_chars ⇒ Object
return str if ret == 0 return “”.
-
#edit_line(lineno = @current_index) ⇒ Object
edit current or given line.
-
#edit_string(string, prompt = "Edit: ", maxlen = 80) ⇒ 0, -1
common method to edit given string.
- #edit_word ⇒ Object
-
#input_string(prompt = "Insert: ", maxlen = 80) ⇒ 0, -1
common method to input a blank string.
-
#insert_line(lineno = @current_index) ⇒ Object
insert a line FIXME needs to fire handler 2010-05-23 11:40.
- #vieditable_init ⇒ Object
-
#vieditable_init_listbox ⇒ Object
Separate mappings for listboxes.
-
#vieditable_init_tabular ⇒ Object
currently only adding delete_line and some yank pop functions These will all give wrong results in table due to _header_offset.
Methods included from ListEditable
#add_to_kill_ring, #append_next_kill, #append_row, #delete_at, #delete_curr_char, #delete_eol, #delete_forward, #delete_line, #delete_prev_char, #delete_word, #join_next_line, #kill_ring_save, #remove_all, #undo_handler, #yank, #yank_pop
Instance Method Details
#edit_chars ⇒ Object
return str if ret == 0 return “”
168 169 170 |
# File 'lib/canis/core/include/vieditable.rb', line 168 def edit_chars end |
#edit_line(lineno = @current_index) ⇒ Object
edit current or given line
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/canis/core/include/vieditable.rb', line 105 def edit_line lineno=@current_index line = self[lineno] prompt = "Edit: " maxlen = 80 config={}; oldline = line.dup config[:default] = line ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config) $log.debug " rb_getstr returned #{ret} , #{str} " return if ret != 0 # we possibly cou;d have done []= but maybe in textpad or something that would replace a row pointer ?? self[lineno].replace(str) fire_handler :CHANGE, InputDataEvent.new(0,oldline.length, self, :DELETE_LINE, lineno, oldline) # 2008-12-24 18:34 fire_handler :CHANGE, InputDataEvent.new(0,str.length, self, :INSERT_LINE, lineno, str) fire_row_changed lineno end |
#edit_string(string, prompt = "Edit: ", maxlen = 80) ⇒ 0, -1
common method to edit given string
150 151 152 153 154 155 156 |
# File 'lib/canis/core/include/vieditable.rb', line 150 def edit_string string, prompt="Edit: ", maxlen=80 config={}; config[:default] = string ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config) #return str if ret == 0 #return "" end |
#edit_word ⇒ Object
171 172 173 |
# File 'lib/canis/core/include/vieditable.rb', line 171 def edit_word end |
#input_string(prompt = "Insert: ", maxlen = 80) ⇒ 0, -1
common method to input a blank string
162 163 164 165 166 167 |
# File 'lib/canis/core/include/vieditable.rb', line 162 def input_string prompt="Insert: ", maxlen=80 #ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config) ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config) #return str if ret == 0 #return "" end |
#insert_line(lineno = @current_index) ⇒ Object
insert a line FIXME needs to fire handler 2010-05-23 11:40
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/canis/core/include/vieditable.rb', line 124 def insert_line lineno=@current_index prompt = "Insert: " maxlen = 80 #config={}; #config[:default] = line #ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config) ret, str = input_string prompt #ret, str = rb_getstr(@form.window, @row+@height-1, @col+1, prompt, maxlen, config) $log.debug " rb_getstr returned #{ret} , #{str} " return if ret != 0 # pad based expect @content not list # remove list after a while FIXME @list ||= @content @list.insert lineno, str ## added handler on 2010-05-23 11:46 - undo works - tested in testlistbox.rb fire_handler :CHANGE, InputDataEvent.new(0,str.length, self, :INSERT_LINE, lineno, str) fire_dimension_changed end |
#vieditable_init ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/canis/core/include/vieditable.rb', line 16 def vieditable_init $log.debug " inside vieditable_init " @editable = true bind_key( ?C, :edit_line) #bind_key( ?o, :insert_line) #bind_key( ?O) { insert_line(@current_index-1) } bind_key( ?o) { insert_line(@current_index+1) } bind_key( ?O) { insert_line(@current_index) } bind_key( ?D, :delete_eol) bind_key( [?d, ?$], :delete_eol) bind_key( [?d, ?d] , :delete_line ) bind_key( [?d, ?w], :delete_word ) bind_key( [?d, ?t], :delete_till ) bind_key( [?d, ?f], :delete_forward ) bind_key( ?\C-_ ) { @undo_handler.undo if @undo_handler } bind_key( ?u ) { @undo_handler.undo if @undo_handler } bind_key( ?\C-r ) { @undo_handler.redo if @undo_handler } bind_key( ?x, :delete_curr_char ) bind_key( ?X, :delete_prev_char ) bind_key( [?y, ?y] , :kill_ring_save ) bind_key( ?p, :yank ) # paste after this line bind_key( ?P ) { yank(@current_index - 1) } # should be before this line bind_key(?w, :forward_word) bind_key(?f, :forward_char) bind_key(?\M-y, :yank_pop) bind_key(?\M-w, :kill_ring_save) @_events.push :CHANGE # thru vieditable end |
#vieditable_init_listbox ⇒ Object
Separate mappings for listboxes. Some methods don;‘t make sense for listboxes and are crashing since not present for them. f was being overwritten, too. Sorry for duplication, need to clean this somehow.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/canis/core/include/vieditable.rb', line 50 def vieditable_init_listbox $log.debug " inside vieditable_init_listbox " @editable = true bind_key( ?C, :edit_line) bind_key( ?o) { insert_line(@current_index+1) } bind_key( ?O) { insert_line(@current_index) } bind_key( [?d, ?d] , :delete_line ) bind_key( ?\C-_ ) { @undo_handler.undo if @undo_handler } bind_key( ?u ) { @undo_handler.undo if @undo_handler } bind_key( ?\C-r ) { @undo_handler.redo if @undo_handler } bind_key( [?y, ?y] , :kill_ring_save ) bind_key( ?p, :yank ) # paste after this line #bind_key( ?P ) { yank(@current_index - 1) } # should be before this line # seems -1 was pasting 2 lines before bind_key( ?P ) { yank(@current_index - 0) } # should be before this line bind_key(?w, :forward_word) bind_key(?\M-y, :yank_pop) bind_key(?\C-y, :yank) bind_key(?\M-w, :kill_ring_save) @_events.push :CHANGE # thru vieditable #bind_key( ?D, :delete_eol) #bind_key( [?d, ?$], :delete_eol) #bind_key(?f, :forward_char) #bind_key( ?x, :delete_curr_char ) #bind_key( ?X, :delete_prev_char ) #bind_key( [?d, ?w], :delete_word ) #bind_key( [?d, ?t], :delete_till ) #bind_key( [?d, ?f], :delete_forward ) end |
#vieditable_init_tabular ⇒ Object
currently only adding delete_line and some yank pop functions These will all give wrong results in table due to _header_offset
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/canis/core/include/vieditable.rb', line 83 def vieditable_init_tabular $log.debug " inside vieditable_init tabular" @editable = true #bind_key( ?C, :edit_line) #bind_key( ?o, :insert_line) #bind_key( ?O) { insert_line(@current_index-1) } #bind_key( ?o) { insert_line(@current_index+1) } #bind_key( ?O) { insert_line(@current_index) } bind_key( [?d, ?d] , :delete_line ) #bind_key( ?\C-_ ) { @undo_handler.undo if @undo_handler } #bind_key( ?u ) { @undo_handler.undo if @undo_handler } #bind_key( ?\C-r ) { @undo_handler.redo if @undo_handler } bind_key( [?y, ?y] , :kill_ring_save ) bind_key( ?p, :yank ) # paste after this line bind_key( ?P ) { yank(@current_index - 1) } # should be before this line bind_key(?\M-y, :yank_pop) bind_key(?\M-w, :kill_ring_save) @_events.push :CHANGE # thru vieditable end |