Develop and Download Open Source Software

Browse Subversion Repository

Diff of /mini_buffer.rb

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

revision 35 by bluedwarf, Sat Apr 14 00:06:24 2007 UTC revision 36 by bluedwarf, Sat Apr 14 17:29:51 2007 UTC
# Line 96  module Edmaru Line 96  module Edmaru
96        return if str.empty? # Nothing to be inserted.        return if str.empty? # Nothing to be inserted.
97    
98        if str.include?("\n")        if str.include?("\n")
99          new_lines = str.split(/\n/, -1)          str = str.split(/\n/, -1)[0]
         new_lines[0] =  
           @lines[row][0, col] + new_lines[0]  
         new_lines[new_lines.size - 1] <<  
           @lines[row][col .. -1]  
         @lines[row] = new_lines  
         @lines.flatten!  
       else  
         current_line = @lines[row]  
         @lines[row] = ""  
         if col > 0  
           @lines[row] = current_line[0, col]  
         end  
         @lines[row] << str  
         @lines[row] << current_line[col .. -1]  
100        end        end
101    
102          pre = @line.clone
103          @line = pre[0, col]
104          @line << str
105          @line << pre[col .. -1]
106    
107        refresh_windows        refresh_windows
108      end      end
109    
110        #Delete one character at the specified position
111        #
112        #=== Arguments
113        #_row_ :: Row position or line number. This must be 1 for mini buffer.
114        #_col_ :: Column position.
115        def delete_at(row, col)
116          if !valid_position?(row, col)
117            raise "Invalid position was specified for 'delete' method."
118          end
119    
120          if col >= @line.size
121            raise EndOfBufferException.new
122          else
123            @line = @line[0, col] + @line[col + 1 .. -1]
124            refresh_windows
125          end
126        end
127        
128        #DDelete all characters in this buffer to make it empty.
129        def clear
130          @line = ""
131          
132          refresh_windows
133        end
134    end    end
135  end  end

Legend:
Removed from v.35  
changed lines
  Added in v.36

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