Module: Ncurses

Defined in:
lib/ncurses_sugar.rb,
lib/ncurses_sugar.rb

Defined Under Namespace

Modules: Destroy_checker, Form, Menu, Namespace, Panel Classes: MEVENT, SCREEN, WINDOW

Constant Summary collapse

GETSTR_LIMIT =
1024
Ncurses =

for accessing Ncurses from a Module that includes Ncurses

self

Class Method Summary collapse

Class Method Details

.eraseObject



251
252
253
# File 'lib/ncurses_sugar.rb', line 251

def Ncurses.erase
  Ncurses.werase(Ncurses.stdscr)
end

.getbegx(win) ⇒ Object



233
234
235
# File 'lib/ncurses_sugar.rb', line 233

def Ncurses.getbegx(win)
  x = []; y = []; Ncurses.getbegyx(win, y,x); x[0]
end

.getbegy(win) ⇒ Object



236
237
238
# File 'lib/ncurses_sugar.rb', line 236

def Ncurses.getbegy(win)
  x = []; y = []; Ncurses.getbegyx(win, y,x); y[0]
end

.getcurx(win) ⇒ Object



227
228
229
# File 'lib/ncurses_sugar.rb', line 227

def Ncurses.getcurx(win)
  x = []; y = []; Ncurses.getyx(win, y,x); x[0]
end

.getcury(win) ⇒ Object



230
231
232
# File 'lib/ncurses_sugar.rb', line 230

def Ncurses.getcury(win)
  x = []; y = []; Ncurses.getyx(win, y,x); y[0]
end

.getmaxx(win) ⇒ Object



239
240
241
# File 'lib/ncurses_sugar.rb', line 239

def Ncurses.getmaxx(win)
  x = []; y = []; Ncurses.getmaxyx(win, y,x); x[0]
end

.getmaxy(win) ⇒ Object



242
243
244
# File 'lib/ncurses_sugar.rb', line 242

def Ncurses.getmaxy(win)
  x = []; y = []; Ncurses.getmaxyx(win, y,x); y[0]
end

.getnstr(str, n) ⇒ Object



179
180
181
# File 'lib/ncurses_sugar.rb', line 179

def Ncurses.getnstr(str,n)
  Ncurses.wgetnstr(Ncurses.stdscr, str, n)
end

.getparx(win) ⇒ Object



245
246
247
# File 'lib/ncurses_sugar.rb', line 245

def Ncurses.getparx(win)
  x = []; y = []; Ncurses.getparyx(win, y,x); x[0]
end

.getpary(win) ⇒ Object



248
249
250
# File 'lib/ncurses_sugar.rb', line 248

def Ncurses.getpary(win)
  x = []; y = []; Ncurses.getparyx(win, y,x); y[0]
end

.getstr(str) ⇒ Object



254
255
256
# File 'lib/ncurses_sugar.rb', line 254

def Ncurses.getstr(str)
  Ncurses.getnstr(str, Ncurses::GETSTR_LIMIT)
end

.inchnstr(str, n) ⇒ Object



149
150
151
# File 'lib/ncurses_sugar.rb', line 149

def Ncurses.inchnstr(str,n)
  Ncurses.winchnstr(Ncurses.stdscr, str, n)
end

.inchstr(str) ⇒ Object



152
153
154
# File 'lib/ncurses_sugar.rb', line 152

def Ncurses.inchstr(str)
  Ncurses.winchstr(Ncurses.stdscr, str)
end

.innstr(str, n) ⇒ Object



193
194
195
# File 'lib/ncurses_sugar.rb', line 193

def Ncurses.innstr(str,n)
  Ncurses.winnstr(Ncurses.stdscr, str, n)
end

.instr(str) ⇒ Object



196
197
198
# File 'lib/ncurses_sugar.rb', line 196

def Ncurses.instr(str)
  Ncurses.winstr(Ncurses.stdscr, str)
end

.mouse_trafo(pY, pX, to_screen) ⇒ Object



223
224
225
# File 'lib/ncurses_sugar.rb', line 223

def Ncurses.mouse_trafo(pY, pX, to_screen)
  Ncurses.wmouse_trafo(Ncurses.stdscr, pY, pX, to_screen)
end

.mvgetnstr(y, x, str, n) ⇒ Object



182
183
184
# File 'lib/ncurses_sugar.rb', line 182

def Ncurses.mvgetnstr(y,x, str, n)
  Ncurses.mvwgetnstr(Ncurses.stdscr, y,x, str, n)
end

.mvgetstr(y, x, str) ⇒ Object



257
258
259
# File 'lib/ncurses_sugar.rb', line 257

def Ncurses.mvgetstr(y,x, str)
  Ncurses.mvgetnstr(y,x, str, Ncurses::GETSTR_LIMIT)
end

.mvinchnstr(y, x, str, n) ⇒ Object



155
156
157
# File 'lib/ncurses_sugar.rb', line 155

def Ncurses.mvinchnstr(y,x, str, n)
  Ncurses.mvwinchnstr(Ncurses.stdscr, y,x, str, n)
end

.mvinchstr(y, x, str) ⇒ Object



158
159
160
# File 'lib/ncurses_sugar.rb', line 158

def Ncurses.mvinchstr(y,x, str)
  Ncurses.mvwinchstr(Ncurses.stdscr, y,x, str)
end

.mvinnstr(y, x, str, n) ⇒ Object



199
200
201
# File 'lib/ncurses_sugar.rb', line 199

def Ncurses.mvinnstr(y,x, str, n)
  Ncurses.mvwinnstr(Ncurses.stdscr, y,x, str, n)
end

.mvinstr(y, x, str) ⇒ Object



202
203
204
# File 'lib/ncurses_sugar.rb', line 202

def Ncurses.mvinstr(y,x, str)
  Ncurses.mvwinstr(Ncurses.stdscr, y,x, str)
end

.mvprintw(*args) ⇒ Object



290
291
292
# File 'lib/ncurses_sugar.rb', line 290

def Ncurses.mvprintw(*args)
  Ncurses.mvwprintw(Ncurses.stdscr, *args)
end

.mvscanw(y, x, format, result) ⇒ Object



270
271
272
# File 'lib/ncurses_sugar.rb', line 270

def Ncurses.mvscanw(y,x, format, result)
  Ncurses.mvwscanw(Ncurses.stdscr, y,x, format, result)
end

.mvwgetnstr(win, y, x, str, n) ⇒ Object



185
186
187
188
189
190
191
# File 'lib/ncurses_sugar.rb', line 185

def Ncurses.mvwgetnstr(win, y,x, str, n)
  if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
    Ncurses::ERR
  else
    Ncurses.wgetnstr(win,str,n)
  end
end

.mvwgetstr(win, y, x, str) ⇒ Object



260
261
262
# File 'lib/ncurses_sugar.rb', line 260

def Ncurses.mvwgetstr(win, y,x, str)
  Ncurses.mvwgetnstr(win, y,x, str, Ncurses::GETSTR_LIMIT)
end

.mvwinchnstr(win, y, x, str, n) ⇒ Object



161
162
163
164
165
166
167
# File 'lib/ncurses_sugar.rb', line 161

def Ncurses.mvwinchnstr(win, y,x, str, n)
  if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
    Ncurses::ERR
  else
    Ncurses.winchnstr(win,str,n)
  end
end

.mvwinchstr(win, y, x, str) ⇒ Object



168
169
170
171
172
# File 'lib/ncurses_sugar.rb', line 168

def Ncurses.mvwinchstr(win, y,x, str)
  maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
  return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
  Ncurses.mvwinchnstr(win, y,x, str, maxx[0]+1)
end

.mvwinnstr(win, y, x, str, n) ⇒ Object



205
206
207
208
209
210
211
# File 'lib/ncurses_sugar.rb', line 205

def Ncurses.mvwinnstr(win, y,x, str, n)
  if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
    Ncurses::ERR
  else
    Ncurses.winnstr(win,str,n)
  end
end

.mvwinstr(win, y, x, str) ⇒ Object



212
213
214
215
216
# File 'lib/ncurses_sugar.rb', line 212

def Ncurses.mvwinstr(win, y,x, str)
  maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
  return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
  Ncurses.mvwinnstr(win, y,x, str, maxx[0]+1)
end

.mvwprintw(win, y, x, *args) ⇒ Object



293
294
295
296
297
298
299
# File 'lib/ncurses_sugar.rb', line 293

def Ncurses.mvwprintw(win, y,x, *args)
  if (Ncurses.wmove(win,y,x) == Ncurses::ERR)
    Ncurses::ERR
  else
    wprintw(win, *args)
  end
end

.mvwscanw(win, y, x, format, result) ⇒ Object



273
274
275
276
277
278
279
# File 'lib/ncurses_sugar.rb', line 273

def Ncurses.mvwscanw(win, y,x, format, result)
  if (Ncurses.wmove(win, y,x) == Ncurses::ERR)
    Ncurses::ERR
  else
    Ncurses.wscanw(win, format, result)
  end
end

.printw(*args) ⇒ Object



300
301
302
# File 'lib/ncurses_sugar.rb', line 300

def Ncurses.printw(*args)
  Ncurses.wprintw(Ncurses.stdscr, *args)
end

.scanw(format, result) ⇒ Object



267
268
269
# File 'lib/ncurses_sugar.rb', line 267

def Ncurses.scanw(format, result)
  Ncurses.wscanw(Ncurses.stdscr, format, result)
end

.touchline(win, start, count) ⇒ Object



303
304
305
# File 'lib/ncurses_sugar.rb', line 303

def Ncurses.touchline(win, start, count)
  Ncurses.wtouchln(win, start, count, 1)
end

.touchwin(win) ⇒ Object



306
307
308
# File 'lib/ncurses_sugar.rb', line 306

def Ncurses.touchwin(win)
  wtouchln(win, 0, getmaxy(win), 1)
end

.wgetstr(win, str) ⇒ Object



263
264
265
# File 'lib/ncurses_sugar.rb', line 263

def Ncurses.wgetstr(win, str)
  Ncurses.wgetnstr(win, str, Ncurses::GETSTR_LIMIT)
end

.winchstr(win, str) ⇒ Object



173
174
175
176
177
# File 'lib/ncurses_sugar.rb', line 173

def Ncurses.winchstr(win, str)
  maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
  return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
  Ncurses.winchnstr(win, str, maxx[0]+1)
end

.winstr(win, str) ⇒ Object



217
218
219
220
221
# File 'lib/ncurses_sugar.rb', line 217

def Ncurses.winstr(win, str)
  maxy = []; maxx = []; getmaxyx(win, maxy,maxx)
  return Ncurses::ERR if (maxx[0] == Ncurses::ERR)
  Ncurses.winnstr(win, str, maxx[0]+1)
end

.wscanw(win, format, result) ⇒ Object



280
281
282
283
284
285
286
287
288
# File 'lib/ncurses_sugar.rb', line 280

def Ncurses.wscanw(win, format, result)
  str = ""
  if (Ncurses.wgetstr(win, str) == Ncurses::ERR)
    Ncurses::ERR
  else
    require "scanf.rb" # Use ruby's implementation of scanf
    result.replace(str.scanf(format))
  end
end