Develop and Download Open Source Software

Browse Subversion Repository

Contents of /modeline.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: 3840 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 "modeline_element.rb"
21
22 module Edmaru
23
24 module ModeLine
25
26 #Construct the modeline instance.
27 #
28 #=== Arguments
29 #_window_ :: The parent window.
30 #_x_ :: The left edge position in the window's parent view.
31 #_y_ :: The right edge position in the window's parent view.
32 #_col_ :: The column size allocated for this modeline.
33 #
34 #=== Warning
35 #This method *MUST* *NOT* be overrided in derived classes.
36 #
37 #=== Return
38 #An initialized instance of ModeLine.
39 def initialize(window, x, y, col)
40 @window = window
41 @col = col
42 @elements = Hash.new
43 @elements_order = Array.new
44
45 init_ui(x, y, col)
46 end
47
48 #The system specific initialization for ModeLine.
49 #
50 #=== Arguments
51 #_x_ :: The left edge position in the window's parent view.
52 #_y_ :: The right edge position in the window's parent view.
53 #_col_ :: The column size allocated for this modeline.
54 #
55 #=== Warning
56 #This method *SHOULD* be overrided in derived classes.
57 def init_ui(x, y, col)
58 end
59
60 #Add the specified _element_, an instance of ModeLineElement, to
61 #this ModeLine.
62 #
63 #=== Argument
64 #_element_ :: an instance of ModeLineElement to be added.
65 #
66 #=== Warning
67 #This method *MUST* *NOT* be overrided in derived classes.
68 #
69 #=== Return
70 #_true_ if the addition is succeeded.
71 #_false_ if the _element_'s name has already reserved.
72 def add_element(element)
73 if @elements.include?(element.name)
74 return false
75 end
76
77 @elements[element.name] = element
78 @elements_order.push(element.name)
79 end
80
81 #Show the specified element.
82 #
83 #=== Argument
84 #_name_ :: the name of the element.
85 #
86 #=== Warning
87 #This method *MUST* *NOT* be overrided in derived classes.
88 def show_element(name)
89 if !@elements.include?(name) || @elements[name].visible?
90 return
91 end
92
93 @elements[name].visible = true
94
95 refresh
96 end
97
98 #Hide the specified element.
99 #
100 #=== Argument
101 #_name_ :: the name of the element.
102 #
103 #=== Warning
104 #This method *MUST* *NOT* be overrided in derived classes.
105 def hide_element(name)
106 if !@elements.include?(name) || !@elements[name].visible?
107 return
108 end
109
110 @elements[name].visible = false
111
112 refresh
113 end
114
115 #Get the specified element.
116 #
117 #=== Warning
118 #This method *MUST* *NOT* be overrided in derived classes.
119 #
120 #=== Argument
121 #_name_ :: the name of the element.
122 #
123 #=== Return
124 #An instance of ModeLineElement whose name is the specified name
125 #or _nil_ if the specified name is not registered.
126 def get_element(name)
127 if !@elements.include?(name)
128 return nil
129 end
130
131 @elements[name]
132 end
133
134 #Redraws this modeline.
135 #
136 #=== Warning
137 #This method *SHOULD* be overrided in derived classes.
138 def refresh
139 end
140
141 #Terminate this modeline instance.
142 #
143 #=== Warning
144 #This method *SHOULD* be overrided in derived classes.
145 def terminate
146 end
147 end
148 end

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