Develop and Download Open Source Software

Browse Subversion Repository

Contents of /view.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Thu Apr 12 05:42:00 2007 UTC (16 years, 11 months ago) by bluedwarf
File size: 4826 byte(s)
Scroll function for NCurses mode.

1 # view.rb: the module definition of Edmaru::View.
2 #
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 "event_manager.rb"
21 require "window.rb"
22
23 module Edmaru
24
25 #Abstract class to implement system specific view.
26 module View
27
28 #Construct a view instance.
29 #
30 #=== Warning
31 #This method *MUST* *NOT* be overrided in derived classes.
32 #
33 #=== Argument
34 #_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 #
38 #=== Return
39 #An initialized instance of View.
40 def initialize(config, event_manager, buffer_manager)
41 @config = config
42 @event_manager = event_manager
43 @buffer_manager = buffer_manager
44 @kill_ring = nil
45
46 init_ui
47
48 @windows = Array.new
49 @windows.push(Edmaru::SYSTEM_WINDOW.new(self, @config))
50 @focused_window = @windows[0]
51 @mini_window = Edmaru::SYSTEM_MINI_WINDOW.new(self, @config)
52
53 init_windows
54
55 element = ModeLineElement.new("buffer-name", -1, 1, 1, "*scratch*")
56 @windows[0].modeline.add_element(element)
57 @windows[0].modeline.show_element("buffer-name")
58
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 end
63
64 #The system specific initialization for this view.
65 #
66 #=== Warning
67 #This method *SHOULD* be overrided in derived classes.
68 def init_ui
69 end
70
71 #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 #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 #The mini window displayed in the bottom of the screen.
87 #
88 #=== Warning
89 #This method *MUST* *NOT* be overrided in derived classes.
90 def mini_window
91 @mini_window
92 end
93
94 #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 #The focused window.
103 #
104 #=== Warning
105 #This method *MUST* *NOT* be overrided in derived classes.
106 def focused_window
107 @focused_window
108 end
109
110
111 #Cause the specfieid window have focus.
112 #
113 #=== Warning
114 #This method *MUST* *NOT* be overrided in derived classes.
115 def focused_window=(window)
116 prev_focused_window = @focused_window
117 @focused_window = window
118
119 prev_focused_window.refresh_cursor
120 @focused_window.refresh_cursor
121 end
122
123 #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 #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 #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 #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 #This method *MUST* *NOT* be overrided in derived classes.
169 def terminate
170 @windows.each{ |window|
171 window.terminate
172 }
173 @mini_window.terminate
174
175 terminate_ui
176 end
177
178 #Free system specifiec resources.
179 #
180 #=== Warning
181 #This method *SHOULD* be overrided in derived classes.
182 def terminate_ui
183 end
184 end
185 end

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