Develop and Download Open Source Software

Browse Subversion Repository

Contents of /window.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9 - (show annotations) (download)
Thu Apr 5 11:26:23 2007 UTC (16 years, 11 months ago) by bluedwarf
File size: 2520 byte(s)
Association buffer with window.

1
2 require "cursor.rb"
3 require "modeline.rb"
4
5 module Edmaru
6
7 #Abstract class to implement system specific window.
8 module Window
9
10 #Construct a window instance.
11 #
12 #=== Arguments
13 #_view_ :: The parent view.
14 #_x_ :: The left edge position in the parent view.
15 #_y_ :: The top edge position in the parent view.
16 #_col_ :: The max column size allocated for this window.
17 #_row_ :: The max line size allocated for this window including
18 #ModeLine's line size (usually 1).
19 #
20 #=== Warning
21 #This method *MUST* *NOT* be overrided in derived classes.
22 #
23 #=== Return
24 #An initialized instance of Window.
25 def initialize(view, x, y, col, row)
26 @view = view
27 @cursor = Cursor.new(0, 0)
28
29 init_ui(x, y, col, row - 1)
30
31 #Creating modeline bar.
32 @modeline = Edmaru::modeline_class.new(self, x, y + row - 1, col)
33 element = ModeLineElement.new("buffer-name", -1, 1, 1,"*scratch#{$count}*")
34 @modeline.add_element(element)
35 @modeline.show_element("buffer-name")
36 end
37
38 #The system specific initialization for this window.
39 #
40 #=== Arguments
41 #_x_ :: The left edge position in the parent view.
42 #_y_ :: The top edge position in the parent view.
43 #_col_ :: The max column size allocated for this window.
44 #_row_ :: The max line size allocated for this window excluding
45 #ModeLine's line size (usually 1).
46 #
47 #=== Warning
48 #This method *SHOULD* be overrided in derived classes.
49 #And it *MUST* *NOT* deal with anything about modeline bar.
50 def init_ui(x, y, col, row)
51 end
52
53 #Discard the current buffer and set the specified new buffer.
54 #
55 #=== Argument
56 #_new_buffer_ :: The buffer to be shown in this window.
57 def buffer=(new_buffer)
58 if @buffer != nil
59 @buffer.unlink(self)
60 end
61
62 #Linked buffer to this window.
63 @buffer = new_buffer
64 @buffer.link(self)
65 refresh
66 end
67
68 def buffer
69 @buffer
70 end
71
72 #Redraw this window.
73 #
74 #=== Warning
75 #This method *SHOULD* be overrided in derived clases.
76 def refresh
77 if @buffer == nil
78 return
79 end
80 end
81
82 #Terminate this view instance.
83 #
84 #=== Warning
85 #This method *MUST* *NOT* be overrided in derived classes.
86 def terminate
87 @modeline.terminate
88
89 terminate_ui
90 end
91
92 #Free system specific resources.
93 #
94 #=== Warning
95 #This method *SHOULD* be overrided in derived classes.
96 def terminate_ui
97 end
98 end
99 end

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