Develop and Download Open Source Software

Browse Subversion Repository

Contents of /window.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations) (download)
Thu Apr 5 11:53:35 2007 UTC (16 years, 11 months ago) by bluedwarf
File size: 3255 byte(s)
Added Copyright notice.

1 #
2 # Edmaru: A scalable editor implemented by Ruby.
3 # Copyright (C) 2007 Takashi Nakamoto
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 as
7 # published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 # 02110-1301 USA.
18 #
19
20 require "cursor.rb"
21 require "modeline.rb"
22
23 module Edmaru
24
25 #Abstract class to implement system specific window.
26 module Window
27
28 #Construct a window instance.
29 #
30 #=== Arguments
31 #_view_ :: The parent view.
32 #_x_ :: The left edge position in the parent view.
33 #_y_ :: The top edge position in the parent view.
34 #_col_ :: The max column size allocated for this window.
35 #_row_ :: The max line size allocated for this window including
36 #ModeLine's line size (usually 1).
37 #
38 #=== Warning
39 #This method *MUST* *NOT* be overrided in derived classes.
40 #
41 #=== Return
42 #An initialized instance of Window.
43 def initialize(view, x, y, col, row)
44 @view = view
45 @cursor = Cursor.new(0, 0)
46
47 init_ui(x, y, col, row - 1)
48
49 #Creating modeline bar.
50 @modeline = Edmaru::modeline_class.new(self, x, y + row - 1, col)
51 element = ModeLineElement.new("buffer-name", -1, 1, 1,"*scratch#{$count}*")
52 @modeline.add_element(element)
53 @modeline.show_element("buffer-name")
54 end
55
56 #The system specific initialization for this window.
57 #
58 #=== Arguments
59 #_x_ :: The left edge position in the parent view.
60 #_y_ :: The top edge position in the parent view.
61 #_col_ :: The max column size allocated for this window.
62 #_row_ :: The max line size allocated for this window excluding
63 #ModeLine's line size (usually 1).
64 #
65 #=== Warning
66 #This method *SHOULD* be overrided in derived classes.
67 #And it *MUST* *NOT* deal with anything about modeline bar.
68 def init_ui(x, y, col, row)
69 end
70
71 #Discard the current buffer and set the specified new buffer.
72 #
73 #=== Argument
74 #_new_buffer_ :: The buffer to be shown in this window.
75 def buffer=(new_buffer)
76 if @buffer != nil
77 @buffer.unlink(self)
78 end
79
80 #Linked buffer to this window.
81 @buffer = new_buffer
82 @buffer.link(self)
83 refresh
84 end
85
86 def buffer
87 @buffer
88 end
89
90 #Redraw this window.
91 #
92 #=== Warning
93 #This method *SHOULD* be overrided in derived clases.
94 def refresh
95 if @buffer == nil
96 return
97 end
98 end
99
100 #Terminate this view instance.
101 #
102 #=== Warning
103 #This method *MUST* *NOT* be overrided in derived classes.
104 def terminate
105 @modeline.terminate
106
107 terminate_ui
108 end
109
110 #Free system specific resources.
111 #
112 #=== Warning
113 #This method *SHOULD* be overrided in derived classes.
114 def terminate_ui
115 end
116 end
117 end

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