Develop and Download Open Source Software

Browse Subversion Repository

Diff of /window.rb

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 20 by bluedwarf, Sun Apr 8 18:25:08 2007 UTC revision 21 by bluedwarf, Mon Apr 9 17:45:05 2007 UTC
# Line 180  module Edmaru Line 180  module Edmaru
180          if @buffer.lines[@cursor.row].size < @cursor.column          if @buffer.lines[@cursor.row].size < @cursor.column
181            @cursor.column = @buffer.lines[@cursor.row].size            @cursor.column = @buffer.lines[@cursor.row].size
182          end          end
       end  
183    
184        refresh_cursor          refresh_cursor
185          end
186      end      end
187    
188      #Move the cursor to the previous line.      #Move the cursor to the previous line.
# Line 198  module Edmaru Line 198  module Edmaru
198          if @buffer.lines[@cursor.row].size < @cursor.column          if @buffer.lines[@cursor.row].size < @cursor.column
199            @cursor.column = @buffer.lines[@cursor.row].size            @cursor.column = @buffer.lines[@cursor.row].size
200          end          end
201    
202            refresh_cursor
203          end
204        end
205    
206        #Remove a character just in front of the cursor and move the cursor
207        #backward.
208        #
209        #=== Warning
210        #This method *MUST* *NOT* be overrided in derived classes.
211        def backspace
212          if @cursor.column == 0 && @cursor.row == 0
213            #ToDo: Alert that the cursor is at the begin of the current buffer.
214            @view.beep
215          elsif @cursor.column == 0
216            #Concatenate the current lien into the previous line.
217            current_line = @buffer.lines[@cursor.row]
218            prev_line_size = @buffer.lines[@cursor.row - 1].size
219    
220            @buffer.lines[@cursor.row - 1] << current_line
221            @buffer.lines.delete_at(@cursor.row)
222    
223            @cursor.column = prev_line_size
224            @cursor.row -= 1
225    
226            refresh
227          else
228            line = @buffer.lines[@cursor.row]
229            @buffer.lines[@cursor.row] =
230              line[0, @cursor.column - 1] + line[@cursor.column .. -1]
231            @cursor.column -= 1
232            refresh
233        end        end
234        end
235    
236        refresh_cursor      #Remove a character beneath the cursor.
237        #
238        #=== Warning
239        #This method *MUST* *NOT* be overrided in derived classes.
240        def delete
241          if @cursor.column >= @buffer.lines[@cursor.row].size &&
242              @cursor.row == (@buffer.lines.size - 1)
243            #ToDo: Alert that the cursor is at the end of this buffer.
244            @view.beep
245          elsif @cursor.column >= @buffer.lines[@cursor.row].size
246            #Concatenate the next line behind the current line.
247            @buffer.lines[@cursor.row] << @buffer.lines[@cursor.row + 1]
248            @buffer.lines.delete_at(@cursor.row + 1)
249            refresh
250          else
251            line = @buffer.lines[@cursor.row]
252            @buffer.lines[@cursor.row] =
253              line[0, @cursor.column] + line[@cursor.column + 1 .. -1]
254            refresh
255          end
256      end      end
257    
258      #Redraw the cursor.      #Redraw the cursor.

Legend:
Removed from v.20  
changed lines
  Added in v.21

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26