Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /modeline.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (hide 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 bluedwarf 10 #
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 bluedwarf 4
20     require "modeline_element.rb"
21    
22     module Edmaru
23 bluedwarf 5
24     module ModeLine
25    
26     #Construct the modeline instance.
27     #
28 bluedwarf 6 #=== 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 bluedwarf 5 #=== Warning
35     #This method *MUST* *NOT* be overrided in derived classes.
36     #
37     #=== Return
38     #An initialized instance of ModeLine.
39 bluedwarf 6 def initialize(window, x, y, col)
40     @window = window
41     @col = col
42 bluedwarf 5 @elements = Hash.new
43 bluedwarf 6 @elements_order = Array.new
44    
45     init_ui(x, y, col)
46 bluedwarf 4 end
47    
48 bluedwarf 5 #The system specific initialization for ModeLine.
49     #
50 bluedwarf 6 #=== 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 bluedwarf 5 #=== Warning
56     #This method *SHOULD* be overrided in derived classes.
57 bluedwarf 6 def init_ui(x, y, col)
58 bluedwarf 4 end
59    
60 bluedwarf 5 #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 bluedwarf 6 @elements_order.push(element.name)
79 bluedwarf 4 end
80    
81 bluedwarf 5 #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 bluedwarf 6 if !@elements.include?(name) || @elements[name].visible?
90 bluedwarf 5 return
91     end
92    
93     @elements[name].visible = true
94    
95 bluedwarf 6 refresh
96 bluedwarf 4 end
97    
98 bluedwarf 5 #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 bluedwarf 6 if !@elements.include?(name) || !@elements[name].visible?
107 bluedwarf 5 return
108     end
109    
110     @elements[name].visible = false
111    
112 bluedwarf 6 refresh
113 bluedwarf 5 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 bluedwarf 6 #Redraws this modeline.
135     #
136     #=== Warning
137     #This method *SHOULD* be overrided in derived classes.
138     def refresh
139     end
140    
141 bluedwarf 5 #Terminate this modeline instance.
142     #
143     #=== Warning
144     #This method *SHOULD* be overrided in derived classes.
145 bluedwarf 4 def terminate
146     end
147     end
148     end

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