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 31 by bluedwarf, Thu Apr 12 05:42:00 2007 UTC revision 33 by bluedwarf, Thu Apr 12 19:31:19 2007 UTC
# Line 88  module Edmaru Line 88  module Edmaru
88      def clear      def clear
89        @cursor.row = @cursor.column = 0        @cursor.row = @cursor.column = 0
90        @buffer.clear        @buffer.clear
       refresh  
91      end      end
92    
93      #Insert the specified string to the buffer shown in this window.      #Insert the specified string to the buffer shown in this window.
# Line 106  module Edmaru Line 105  module Edmaru
105    
106        #Move the cursor to the end of inserted string.        #Move the cursor to the end of inserted string.
107        cursor_forward(str.size) if move_cursor        cursor_forward(str.size) if move_cursor
   
       refresh  
108      end      end
109    
110      #Move the cursor forward.      #Move the cursor forward.
# Line 182  module Edmaru Line 179  module Edmaru
179      #This method *MUST* *NOT* be overrided in derived classes.      #This method *MUST* *NOT* be overrided in derived classes.
180      def cursor_goto_next_line      def cursor_goto_next_line
181        if @cursor.row == (@buffer.lines.size - 1)        if @cursor.row == (@buffer.lines.size - 1)
182          #ToDo: Alert that the cursor is in the last line.          @view.mini_window.show_alert("The last line")        
183          @view.beep          @view.beep
184        else        else
185          @cursor.row += 1          @cursor.row += 1
# Line 200  module Edmaru Line 197  module Edmaru
197      #This method *MUST* *NOT* be overrided in derived classes.      #This method *MUST* *NOT* be overrided in derived classes.
198      def cursor_goto_previous_line      def cursor_goto_previous_line
199        if @cursor.row == 0        if @cursor.row == 0
200          #ToDo: Alert that the cursor is in the previous line.          @view.mini_window.show_alert("The first line")
201          @view.beep          @view.beep
202        else        else
203          @cursor.row -= 1          @cursor.row -= 1
# Line 220  module Edmaru Line 217  module Edmaru
217      def backspace      def backspace
218        if @cursor.column == 0 && @cursor.row == 0        if @cursor.column == 0 && @cursor.row == 0
219          #ToDo: Alert that the cursor is at the begin of the current buffer.          #ToDo: Alert that the cursor is at the begin of the current buffer.
220            @view.mini_window.show_alert("Beginning of buffer")
221          @view.beep          @view.beep
222        elsif @cursor.column == 0        elsif @cursor.column == 0 # && @cursor.row != 0
223          #Concatenate the current lien into the previous line.          #Concatenate the current lien into the previous line.
         current_line = @buffer.lines[@cursor.row]  
         prev_line_size = @buffer.lines[@cursor.row - 1].size  
   
         @buffer.lines[@cursor.row - 1] << current_line  
         @buffer.lines.delete_at(@cursor.row)  
   
         @cursor.column = prev_line_size  
224          @cursor.row -= 1          @cursor.row -= 1
225            @cursor.column = @buffer.lines[@cursor.row].size
226          refresh          delete_at_cursor
227        else        else
         line = @buffer.lines[@cursor.row]  
         @buffer.lines[@cursor.row] =  
           line[0, @cursor.column - 1] + line[@cursor.column .. -1]  
228          @cursor.column -= 1          @cursor.column -= 1
229          refresh          delete_at_cursor
230        end        end
231      end      end
232    
# Line 246  module Edmaru Line 234  module Edmaru
234      #      #
235      #=== Warning      #=== Warning
236      #This method *MUST* *NOT* be overrided in derived classes.      #This method *MUST* *NOT* be overrided in derived classes.
237      def delete      def delete_at_cursor
238        if @cursor.column >= @buffer.lines[@cursor.row].size &&        begin
239            @cursor.row == (@buffer.lines.size - 1)          @buffer.delete_at(@cursor.row, @cursor.column)
240          #ToDo: Alert that the cursor is at the end of this buffer.        rescue EndOfBufferException => e
241            @view.mini_window.show_alert(e.to_s)
242          @view.beep          @view.beep
       elsif @cursor.column >= @buffer.lines[@cursor.row].size  
         #Concatenate the next line behind the current line.  
         @buffer.lines[@cursor.row] << @buffer.lines[@cursor.row + 1]  
         @buffer.lines.delete_at(@cursor.row + 1)  
         refresh  
       else  
         line = @buffer.lines[@cursor.row]  
         @buffer.lines[@cursor.row] =  
           line[0, @cursor.column] + line[@cursor.column + 1 .. -1]  
         refresh  
243        end        end
244      end      end
245    
# Line 270  module Edmaru Line 249  module Edmaru
249      #=== Warning      #=== Warning
250      #This method *MUST* *NOT* be overrided in derived classes.      #This method *MUST* *NOT* be overrided in derived classes.
251      def kill_line      def kill_line
252        if @cursor.column >= @buffer.lines[@cursor.row].size &&        begin
253            @cursor.row == (@buffer.lines.size - 1)          @view.push_to_kill_ring(@buffer.delete_line(@cursor.row, @cursor.column))
254          #ToDo: Alert that the cursor is at the end of this buffer.        rescue EndOfBufferException => e
255            @view.mini_window.show_alert(e.to_s)
256          @view.beep          @view.beep
       elsif @cursor.column >= @buffer.lines[@cursor.row].size  
         #Concatenate the next line into the current line.  
         @buffer.lines[@cursor.row] << @buffer.lines[@cursor.row + 1]  
         @buffer.lines.delete_at(@cursor.row + 1)  
         @view.push_to_kill_ring("\n")  
         refresh  
       else  
         line = @buffer.lines[@cursor.row]  
         @view.push_to_kill_ring(line[@cursor.column .. -1])  
         @buffer.lines[@cursor.row] = line[0, @cursor.column]  
         refresh  
257        end        end
258      end      end
259    

Legend:
Removed from v.31  
changed lines
  Added in v.33

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