Class: Ncurses::WINDOW
Constant Summary collapse
- KEYS =
keys
Instance Method Summary collapse
- #beginx ⇒ Object
- #beginxy ⇒ Object
- #beginy ⇒ Object
- #convert_xy(x = nil, y = nil) ⇒ Object
- #echo(*args) ⇒ Object
- #getc ⇒ Object
- #h ⇒ Object
-
#initialize ⇒ WINDOW
constructor
A new instance of WINDOW.
- #mvx(x, &blk) ⇒ Object
- #mvxy(x, y, &blk) ⇒ Object
- #mvy(y, &blk) ⇒ Object
- #necho(*args) ⇒ Object
- #restore ⇒ Object
- #rmvx(x, &blk) ⇒ Object
- #rmvxy(x, y, &blk) ⇒ Object
- #rmvy(y, &blk) ⇒ Object
- #save ⇒ Object
- #w ⇒ Object
- #wh ⇒ Object
- #x ⇒ Object
-
#xy ⇒ Object
xy mvxy wh ..
- #y ⇒ Object
Constructor Details
Instance Method Details
#beginx ⇒ Object
170 |
# File 'lib/tagen/ncurses.rb', line 170 def beginx; beginxy[0] end |
#beginxy ⇒ Object
165 166 167 168 169 |
# File 'lib/tagen/ncurses.rb', line 165 def beginxy y,x=[],[] Ncurses.getbegyx(self,y,x) [x,y] end |
#beginy ⇒ Object
171 |
# File 'lib/tagen/ncurses.rb', line 171 def beginy; beginxy[1] end |
#convert_xy(x = nil, y = nil) ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/tagen/ncurses.rb', line 173 def convert_xy x=nil,y=nil x = self.x+x.to_i if x and String===x y = self.y+y.to_i if y and String===y if x and y [x,y] elsif x x elsif y y end end |
#echo(*args) ⇒ Object
243 |
# File 'lib/tagen/ncurses.rb', line 243 def echo *args; necho *args, "\n" end |
#getc ⇒ Object
229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/tagen/ncurses.rb', line 229 def getc key = getch if key==27 c = getch (value=KEYS[[27, c]]) ? value : "\e"+c.chr elsif value=KEYS[key] value else # a "\C-a" key.chr end end |
#h ⇒ Object
163 |
# File 'lib/tagen/ncurses.rb', line 163 def h; wh[1] end |
#mvx(x, &blk) ⇒ Object
150 |
# File 'lib/tagen/ncurses.rb', line 150 def mvx x, &blk; mvxy(x, self.y) end |
#mvxy(x, y, &blk) ⇒ Object
140 141 142 143 144 145 146 147 148 |
# File 'lib/tagen/ncurses.rb', line 140 def mvxy x,y, &blk x,y = convert_xy(x,y) x_, y_ = self.xy Ncurses.move(y,x) if blk blk.call Ncurses.move(y_, x_) end end |
#mvy(y, &blk) ⇒ Object
151 |
# File 'lib/tagen/ncurses.rb', line 151 def mvy y, &blk; mvxy(self.x, y) end |
#necho(*args) ⇒ Object
242 |
# File 'lib/tagen/ncurses.rb', line 242 def necho(*args); Ncurses.addstr(args.gach{|v|v.to_s}.join(" ")) end |
#restore ⇒ Object
138 |
# File 'lib/tagen/ncurses.rb', line 138 def restore; xy *@save_xy end |
#rmvx(x, &blk) ⇒ Object
154 |
# File 'lib/tagen/ncurses.rb', line 154 def rmvx x, &blk; mvx(x.to_s, &blk) end |
#rmvxy(x, y, &blk) ⇒ Object
153 |
# File 'lib/tagen/ncurses.rb', line 153 def rmvxy x,y, &blk; mvxy(x.to_s, y.to_s, &blk) end |
#rmvy(y, &blk) ⇒ Object
155 |
# File 'lib/tagen/ncurses.rb', line 155 def rmvy y, &blk; mvy(y.to_s, &blk) end |
#save ⇒ Object
137 |
# File 'lib/tagen/ncurses.rb', line 137 def save; @save_xy = xy end |
#w ⇒ Object
162 |
# File 'lib/tagen/ncurses.rb', line 162 def w; wh[0] end |
#wh ⇒ Object
157 158 159 160 161 |
# File 'lib/tagen/ncurses.rb', line 157 def wh y,x=[],[] Ncurses.getmaxyx(self,y,x) [x, y] end |
#x ⇒ Object
134 |
# File 'lib/tagen/ncurses.rb', line 134 def x; xy[0] end |
#xy ⇒ Object
xy mvxy wh ..
129 130 131 132 133 |
# File 'lib/tagen/ncurses.rb', line 129 def xy y,x=[],[] Ncurses.getyx(self,y,x) [x[0], y[0]] end |
#y ⇒ Object
135 |
# File 'lib/tagen/ncurses.rb', line 135 def y; xy[1] end |