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 37 by bluedwarf, Sun Apr 15 08:56:47 2007 UTC revision 38 by bluedwarf, Wed Apr 18 11:20:22 2007 UTC
# Line 71  module Edmaru Line 71  module Edmaru
71        @buffer.link(self)        @buffer.link(self)
72        @cursor.row = @cursor.column = 0        @cursor.row = @cursor.column = 0
73        refresh        refresh
74    
75          # @modelin is nil, if this window is the mini window.
76          if @modeline != nil
77            @modeline.set_element_text("buffer-name", @buffer.name)
78          end
79      end      end
80    
81      def buffer      def buffer
# Line 102  module Edmaru Line 107  module Edmaru
107      #inserted string.      #inserted string.
108      def insert_at_cursor(str, move_cursor = true)      def insert_at_cursor(str, move_cursor = true)
109        #Insert to the buffer.        #Insert to the buffer.
110        @buffer.insert(@cursor.row, @cursor.column, str)        begin
111            @buffer.insert(@cursor.row, @cursor.column, str)
112    
113        #Move the cursor to the end of inserted string.          #Move the cursor to the end of inserted string.
114        cursor_forward(str.size) if move_cursor          cursor_forward(str.size) if move_cursor
115          rescue ReadOnlyException => e
116            @view.mini_window.show_alert(e.to_s)
117            @view.beep
118          end
119      end      end
120    
121      #Move the cursor forward.      #Move the cursor forward.
# Line 220  module Edmaru Line 230  module Edmaru
230      #=== Warning      #=== Warning
231      #This method *MUST* *NOT* be overrided in derived classes.      #This method *MUST* *NOT* be overrided in derived classes.
232      def backspace      def backspace
233        if @cursor.column == 0 && @cursor.row == 0        pre_cursor = @cursor.clone
234          #ToDo: Alert that the cursor is at the begin of the current buffer.  
235          @view.mini_window.show_alert("Beginning of buffer")        begin
236            if @cursor.column == 0 && @cursor.row == 0
237              #ToDo: Alert that the cursor is at the begin of the current buffer.
238              @view.mini_window.show_alert("Beginning of buffer")
239              @view.beep
240            elsif @cursor.column == 0 # && @cursor.row != 0
241              #Concatenate the current lien into the previous line.
242              @buffer.delete_at(@cursor.row -= 1,
243                                @cursor.column = @buffer.lines[@cursor.row].size)
244              refresh_cursor
245            else
246              @buffer.delete_at(@cursor.row, @cursor.column -= 1)
247              refresh_cursor
248            end
249          rescue ReadOnlyException => e
250            @cursor = pre_cursor
251            @view.mini_window.show_alert(e.to_s)
252          @view.beep          @view.beep
       elsif @cursor.column == 0 # && @cursor.row != 0  
         #Concatenate the current lien into the previous line.  
         @cursor.row -= 1  
         @cursor.column = @buffer.lines[@cursor.row].size  
         delete_at_cursor  
       else  
         @cursor.column -= 1  
         delete_at_cursor  
253        end        end
254      end      end
255    
# Line 245  module Edmaru Line 263  module Edmaru
263        rescue EndOfBufferException => e        rescue EndOfBufferException => e
264          @view.mini_window.show_alert(e.to_s)          @view.mini_window.show_alert(e.to_s)
265          @view.beep          @view.beep
266          rescue ReadOnlyException => e
267            @view.mini_window.show_alert(e.to_s)
268            @view.beep
269        end        end
270      end      end
271    
# Line 256  module Edmaru Line 277  module Edmaru
277      def kill_line      def kill_line
278        begin        begin
279          @view.push_to_kill_ring(@buffer.delete_line(@cursor.row, @cursor.column))          @view.push_to_kill_ring(@buffer.delete_line(@cursor.row, @cursor.column))
280        rescue EndOfBufferException => e        rescue EdmaruException => e
281          @view.mini_window.show_alert(e.to_s)          @view.mini_window.show_alert(e.to_s)
282          @view.beep          @view.beep
283        end        end
# Line 270  module Edmaru Line 291  module Edmaru
291        insert_at_cursor(@view.yank_from_kill_ring)        insert_at_cursor(@view.yank_from_kill_ring)
292      end      end
293    
294        #Scroll down this window.
295        #
296        #=== Warning
297        #This method *SHOULD* be overrided in derived clases.
298        def scroll_down
299        end
300    
301      #Redraw the cursor.      #Redraw the cursor.
302      #      #
303      #=== Warning      #=== Warning

Legend:
Removed from v.37  
changed lines
  Added in v.38

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