Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /view.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (hide annotations) (download)
Thu Apr 12 16:59:17 2007 UTC (16 years, 11 months ago) by bluedwarf
File size: 4825 byte(s)
Improvement on mini buffer.

1 bluedwarf 12 # view.rb: the module definition of Edmaru::View.
2 bluedwarf 10 #
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 1
20 bluedwarf 4 require "event_manager.rb"
21     require "window.rb"
22    
23 bluedwarf 1 module Edmaru
24    
25     #Abstract class to implement system specific view.
26     module View
27    
28 bluedwarf 6 #Construct a view instance.
29 bluedwarf 1 #
30     #=== Warning
31     #This method *MUST* *NOT* be overrided in derived classes.
32     #
33 bluedwarf 2 #=== Argument
34 bluedwarf 20 #_config_ :: An instance of Edmaru::ConfigurationManager.
35     #_event_manager_ :: An instance of Edmaru::EventManager to handle all events raised from this view.
36     #_buffer_manager_ :: An instance of Edmaru::BufferManager.
37 bluedwarf 2 #
38 bluedwarf 1 #=== Return
39     #An initialized instance of View.
40 bluedwarf 20 def initialize(config, event_manager, buffer_manager)
41     @config = config
42 bluedwarf 2 @event_manager = event_manager
43 bluedwarf 9 @buffer_manager = buffer_manager
44 bluedwarf 32 @kill_ring = ""
45 bluedwarf 6
46     init_ui
47    
48 bluedwarf 4 @windows = Array.new
49 bluedwarf 20 @windows.push(Edmaru::SYSTEM_WINDOW.new(self, @config))
50 bluedwarf 18 @focused_window = @windows[0]
51 bluedwarf 20 @mini_window = Edmaru::SYSTEM_MINI_WINDOW.new(self, @config)
52 bluedwarf 15
53     init_windows
54    
55     element = ModeLineElement.new("buffer-name", -1, 1, 1, "*scratch*")
56 bluedwarf 18 @windows[0].modeline.add_element(element)
57     @windows[0].modeline.show_element("buffer-name")
58 bluedwarf 31
59     element = ModeLineElement.new("cursor-position", -1, 1, 1, "(0,0)")
60     @windows[0].modeline.add_element(element)
61     @windows[0].modeline.show_element("cursor-position")
62 bluedwarf 1 end
63    
64     #The system specific initialization for this view.
65     #
66     #=== Warning
67 bluedwarf 5 #This method *SHOULD* be overrided in derived classes.
68 bluedwarf 3 def init_ui
69 bluedwarf 1 end
70    
71 bluedwarf 15 #The system specific initialization for windows that belongs to this view.
72     #
73     #=== Warning
74     #This method *SHOULD* be overrided in derived classes.
75     def init_windows
76     end
77    
78 bluedwarf 7 #The event manager linked to this view.
79     #
80     #=== Warning
81     #This method *MUST* *NOT* be overrided in derived classes.
82     def event_manager
83     @event_manager
84     end
85    
86 bluedwarf 18 #The mini window displayed in the bottom of the screen.
87 bluedwarf 6 #
88     #=== Warning
89 bluedwarf 18 #This method *MUST* *NOT* be overrided in derived classes.
90     def mini_window
91     @mini_window
92 bluedwarf 6 end
93    
94 bluedwarf 31 #The main wnidow
95     #
96     #=== Warning
97     #This method *MUST* *NOT* be overrided in derived classes.
98     def main_window
99     @windows[0]
100     end
101    
102 bluedwarf 18 #The focused window.
103 bluedwarf 6 #
104     #=== Warning
105 bluedwarf 4 #This method *MUST* *NOT* be overrided in derived classes.
106 bluedwarf 18 def focused_window
107     @focused_window
108 bluedwarf 4 end
109    
110 bluedwarf 18
111     #Cause the specfieid window have focus.
112 bluedwarf 4 #
113     #=== Warning
114     #This method *MUST* *NOT* be overrided in derived classes.
115 bluedwarf 18 def focused_window=(window)
116 bluedwarf 27 prev_focused_window = @focused_window
117 bluedwarf 18 @focused_window = window
118 bluedwarf 27
119     prev_focused_window.refresh_cursor
120     @focused_window.refresh_cursor
121 bluedwarf 4 end
122    
123 bluedwarf 26 #Push the specified string to the kill ring.
124     #
125     #ToDo: This implementation is incomplete. Kill ring doesn't store multiple
126     # strings.
127     def push_to_kill_ring(str)
128     @kill_ring = str
129     end
130    
131     #Get a string from kill ring.
132     #
133     #ToDo: This implementation is incomplete. Kill ring doesn't store multiple
134     # strings.
135     def yank_from_kill_ring
136     @kill_ring
137     end
138    
139 bluedwarf 1 #Main loop to catch all events.
140     #
141     #=== Warning
142     #This method *SHOULD* be overrided in derived classes.
143     def main_loop
144     end
145    
146 bluedwarf 3 #Exit the running main loop.
147     #
148     #=== Warning
149     #This method *SHOULD* be overrided in derived classes.
150     #
151     #=== Note
152     #Some UI systems (such as Ncurses) don't exit the main loop as
153     #soon as this method is called.
154     def exit_main_loop
155     end
156    
157 bluedwarf 1 #Beep once.
158     #
159     #=== Warning
160     #This method *SHOULD* be overrided in derived classes.
161     def beep
162     false
163     end
164    
165     #Terminate this view instance.
166     #
167     #=== Warning
168 bluedwarf 7 #This method *MUST* *NOT* be overrided in derived classes.
169 bluedwarf 1 def terminate
170 bluedwarf 7 @windows.each{ |window|
171     window.terminate
172     }
173     @mini_window.terminate
174    
175     terminate_ui
176 bluedwarf 1 end
177 bluedwarf 7
178     #Free system specifiec resources.
179     #
180     #=== Warning
181     #This method *SHOULD* be overrided in derived classes.
182     def terminate_ui
183     end
184 bluedwarf 1 end
185     end

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