Browse Subversion Repository
Annotation of /buffer_manager.rb
Parent Directory
| Revision Log
Revision 2 -
( hide annotations)
( download)
Tue Apr 3 18:03:39 2007 UTC
(16 years, 11 months ago)
by bluedwarf
File size: 944 byte(s)
* Added Gtk+-2.0 support.
* Implement event handlers and action manager.
| 1 |
bluedwarf |
1 |
|
| 2 |
|
|
require "buffer" |
| 3 |
|
|
|
| 4 |
|
|
module Edmaru |
| 5 |
|
|
|
| 6 |
|
|
#The controller to manage multiple buffers. |
| 7 |
|
|
class BufferManager |
| 8 |
|
|
|
| 9 |
bluedwarf |
2 |
#Create the buffer manager. |
| 10 |
bluedwarf |
1 |
# |
| 11 |
|
|
#=== Return |
| 12 |
|
|
#An initialized manager. |
| 13 |
|
|
def initialize |
| 14 |
|
|
@buffers = Hash.new |
| 15 |
|
|
end |
| 16 |
|
|
|
| 17 |
|
|
#Create a new buffer by specified name. |
| 18 |
|
|
# |
| 19 |
|
|
#=== Argument |
| 20 |
|
|
#_name_ :: the buffer name |
| 21 |
|
|
# |
| 22 |
|
|
#=== Return |
| 23 |
|
|
#_true_ if a new buffer is created successfully. |
| 24 |
|
|
# |
| 25 |
|
|
#=== Note |
| 26 |
|
|
#This method returns if the specified _name_ is already used. |
| 27 |
|
|
def create(name) |
| 28 |
|
|
if @buffers.include?(name) |
| 29 |
|
|
return false |
| 30 |
|
|
end |
| 31 |
|
|
|
| 32 |
|
|
@buffers[name] = Buffer.new(name) |
| 33 |
|
|
end |
| 34 |
|
|
|
| 35 |
|
|
#Return the specified buffer. |
| 36 |
|
|
# |
| 37 |
|
|
#=== Return |
| 38 |
|
|
#The buffer instance whose name is the specified _name_ or _nil_ |
| 39 |
|
|
#if the specified _name_ is not used. |
| 40 |
|
|
def get(name) |
| 41 |
|
|
if @buffers.include?(name) |
| 42 |
|
|
return @buffers[name] |
| 43 |
|
|
else |
| 44 |
|
|
return nil |
| 45 |
|
|
end |
| 46 |
|
|
end |
| 47 |
|
|
|
| 48 |
|
|
end |
| 49 |
|
|
end |
|