Class: Newt::Screen

Inherits:
Object
  • Object
show all
Defined in:
ext/ruby_newt/ruby_newt.c

Class Method Summary collapse

Class Method Details

.bellObject



170
171
172
173
174
175
# File 'ext/ruby_newt/ruby_newt.c', line 170

static VALUE rb_ext_Screen_Bell(VALUE self)
{
  newtBell();

  return Qnil;
}

.centered_window(width, height, title) ⇒ Object



109
110
111
112
# File 'ext/ruby_newt/ruby_newt.c', line 109

static VALUE rb_ext_Screen_CenteredWindow(VALUE self, VALUE width, VALUE height, VALUE title)
{
  return INT2NUM(newtCenteredWindow(NUM2INT(width), NUM2INT(height), StringValuePtr(title)));
}

.clear_keybufferObject



95
96
97
98
99
100
# File 'ext/ruby_newt/ruby_newt.c', line 95

static VALUE rb_ext_Screen_ClearKeyBuffer()
{
  newtClearKeyBuffer();

  return Qnil;
}

.clsObject



75
76
77
78
79
# File 'ext/ruby_newt/ruby_newt.c', line 75

static VALUE rb_ext_Screen_Cls()
{
  newtCls();
  return Qnil;
}

.draw_roottext(col, row, text) ⇒ Object



142
143
144
145
146
147
# File 'ext/ruby_newt/ruby_newt.c', line 142

static VALUE rb_ext_Screen_DrawRootText(VALUE self, VALUE col, VALUE row, VALUE text)
{

  newtDrawRootText(NUM2INT(col), NUM2INT(row), StringValuePtr(text));
  return Qnil;
}

.finishObject



81
82
83
84
85
86
# File 'ext/ruby_newt/ruby_newt.c', line 81

static VALUE rb_ext_Screen_Finished()
{
  newtFinished();

  return Qnil;
}

.initObject



69
70
71
72
73
# File 'ext/ruby_newt/ruby_newt.c', line 69

static VALUE rb_ext_Screen_Init()
{
  newtInit();
  return Qnil;
}

.newObject



61
62
63
64
65
66
67
# File 'ext/ruby_newt/ruby_newt.c', line 61

static VALUE rb_ext_Screen_new()
{
  newtInit();
  newtCls();

  return Qnil;
}

.open_window(left, top, width, height, title) ⇒ Object



102
103
104
105
106
107
# File 'ext/ruby_newt/ruby_newt.c', line 102

static VALUE rb_ext_Screen_OpenWindow(VALUE self, VALUE left, VALUE top,
    VALUE width, VALUE height, VALUE title)
{
  return INT2NUM(newtOpenWindow(NUM2INT(left), NUM2INT(top),
        NUM2INT(width), NUM2INT(height), StringValuePtr(title)));
}

.pop_helplineObject



163
164
165
166
167
168
# File 'ext/ruby_newt/ruby_newt.c', line 163

static VALUE rb_ext_Screen_PopHelpLine(VALUE self)
{
  newtPopHelpLine();

  return Qnil;
}

.pop_windowObject



114
115
116
117
118
# File 'ext/ruby_newt/ruby_newt.c', line 114

static VALUE rb_ext_Screen_PopWindow(VALUE self)
{
  newtPopWindow();
  return Qnil;
}

.push_helpline(text) ⇒ Object



149
150
151
152
153
154
# File 'ext/ruby_newt/ruby_newt.c', line 149

static VALUE rb_ext_Screen_PushHelpLine(VALUE self, VALUE text)
{
  newtPushHelpLine(StringValuePtr(text));

  return Qnil;
}

.redraw_helplineObject



156
157
158
159
160
161
# File 'ext/ruby_newt/ruby_newt.c', line 156

static VALUE rb_ext_Screen_RedrawHelpLine(VALUE self)
{
  newtRedrawHelpLine();

  return Qnil;
}

.refreshObject



135
136
137
138
139
140
# File 'ext/ruby_newt/ruby_newt.c', line 135

static VALUE rb_ext_Screen_Refresh()
{
  newtRefresh();

  return Qnil;
}

.resumeObject



121
122
123
124
125
126
# File 'ext/ruby_newt/ruby_newt.c', line 121

static VALUE rb_ext_Screen_Resume()
{
  newtResume();

  return Qnil;
}

.sizeObject



177
178
179
180
181
182
183
184
185
186
187
# File 'ext/ruby_newt/ruby_newt.c', line 177

static VALUE rb_ext_Screen_Size(VALUE self)
{
  int cols, rows;
  VALUE ary = rb_ary_new2(2);

  newtGetScreenSize(&cols, &rows);
  rb_ary_push(ary, INT2NUM(cols));
  rb_ary_push(ary, INT2NUM(rows));

  return ary;
}

.suspendObject



128
129
130
131
132
133
# File 'ext/ruby_newt/ruby_newt.c', line 128

static VALUE rb_ext_Screen_Suspend()
{
  newtSuspend();

  return Qnil;
}

.wait_for_keyObject



88
89
90
91
92
93
# File 'ext/ruby_newt/ruby_newt.c', line 88

static VALUE rb_ext_Screen_WaitForKey()
{
  newtWaitForKey();

  return Qnil;
}

.win_choice(args) ⇒ Object



201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'ext/ruby_newt/ruby_newt.c', line 201

static VALUE rb_ext_Screen_WinChoice(VALUE self, VALUE args)
{
  int result = 0;

  if (RARRAY_LEN(args) < 4) {
    rb_raise(rb_eArgError, "4 arguments required");
  } else {
    result = newtWinChoice(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
        StringValuePtr(RARRAY_PTR(args)[2]), StringValuePtr(RARRAY_PTR(args)[3]));
  }

  return INT2NUM(result);
}

.win_entries(args) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'ext/ruby_newt/ruby_newt.c', line 263

static VALUE rb_ext_Screen_WinEntries(VALUE self, VALUE args)
{
  long len;
  int i;
  struct newtWinEntry *items;
  char * entries[10];
  VALUE ary;

  memset(entries, 0, sizeof(entries));
  ary = rb_ary_new();

  len = RARRAY_LEN(args);
  if (len == 8) {
    Check_Type(RARRAY_PTR(args)[6], T_ARRAY);

    len = RARRAY_LEN(RARRAY_PTR(args)[6]);
    if (len > 8) rb_raise(rb_eArgError, "8 or less arguments required");
    items = ALLOCA_N(struct newtWinEntry, len + 1);
    for (i = 0; i < len; i++) {
      Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
      items[i].text = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
      items[i].value = entries + i;
      items[i].flags = 0;
    }
    items[len].text = NULL;
    items[len].value = NULL;
    items[len].flags = 0;

    newtWinEntries(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
        NUM2INT(RARRAY_PTR(args)[2]),
        NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
        NUM2INT(RARRAY_PTR(args)[5]),
        items, StringValuePtr(RARRAY_PTR(args)[7]), NULL);
    for (i = 0; i < len; i++) {
      rb_ary_push(ary, rb_str_new2(entries[i]));
    }
    return ary;
  } else if (len == 9) {
    Check_Type(RARRAY_PTR(args)[6], T_ARRAY);

    len = RARRAY_LEN(RARRAY_PTR(args)[6]);
    if (len > 8) rb_raise(rb_eArgError, "8 or less arguments required");
    items = ALLOCA_N(struct newtWinEntry, len + 1);
    for (i = 0; i < len; i++) {
      Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
      items[i].text = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
      items[i].value = entries + i;
      items[i].flags = 0;
    }
    items[len].text = NULL;
    items[len].value = NULL;
    items[len].flags = 0;

    newtWinEntries(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
        NUM2INT(RARRAY_PTR(args)[2]),
        NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
        NUM2INT(RARRAY_PTR(args)[5]),
        items, StringValuePtr(RARRAY_PTR(args)[7]), StringValuePtr(RARRAY_PTR(args)[8]), NULL);
    for (i = 0; i < len; i++) {
      rb_ary_push(ary, rb_str_new2(entries[i]));
    }
    return ary;
  } else {
    rb_raise(rb_eArgError, "8 or 9 arguments required");
  }

  return Qnil;
}

.win_menu(args) ⇒ Object



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'ext/ruby_newt/ruby_newt.c', line 215

static VALUE rb_ext_Screen_WinMenu(VALUE self, VALUE args)
{
  long len;
  int i, listItem;
  char **cptr;

  len = RARRAY_LEN(args);
  if (len == 8) {
    Check_Type(RARRAY_PTR(args)[6], T_ARRAY);

    len = RARRAY_LEN(RARRAY_PTR(args)[6]);
    cptr = ALLOCA_N(char*, len + 1);
    for (i = 0; i < len; i++) {
      Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
      cptr[i] = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
    }
    cptr[len] = NULL;

    newtWinMenu(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
        NUM2INT(RARRAY_PTR(args)[2]),
        NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
        NUM2INT(RARRAY_PTR(args)[5]),
        cptr, &listItem, StringValuePtr(RARRAY_PTR(args)[7]), NULL);
    return INT2NUM(listItem);
  } else if (len == 9) {
    Check_Type(RARRAY_PTR(args)[6], T_ARRAY);

    len = RARRAY_LEN(RARRAY_PTR(args)[6]);
    cptr = ALLOCA_N(char*, len + 1);
    for (i = 0; i < len; i++) {
      Check_Type(RARRAY_PTR(RARRAY_PTR(args)[6])[i], T_STRING);
      cptr[i] = StringValuePtr(RARRAY_PTR(RARRAY_PTR(args)[6])[i]);
    }
    cptr[len] = NULL;

    newtWinMenu(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]),
        NUM2INT(RARRAY_PTR(args)[2]),
        NUM2INT(RARRAY_PTR(args)[3]), NUM2INT(RARRAY_PTR(args)[4]),
        NUM2INT(RARRAY_PTR(args)[5]),
        cptr, &listItem, StringValuePtr(RARRAY_PTR(args)[7]), StringValuePtr(RARRAY_PTR(args)[8]), NULL);
    return INT2NUM(listItem);
  } else {
    rb_raise(rb_eArgError, "8 or 9 arguments required");
  }

  return Qnil;
}

.win_message(args) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
# File 'ext/ruby_newt/ruby_newt.c', line 189

static VALUE rb_ext_Screen_WinMessage(VALUE self, VALUE args)
{
  if (RARRAY_LEN(args) < 3) {
    rb_raise(rb_eArgError, "3 arguments required");
  } else {

    newtWinMessage(StringValuePtr(RARRAY_PTR(args)[0]), StringValuePtr(RARRAY_PTR(args)[1]), StringValuePtr(RARRAY_PTR(args)[2]));
  }

  return Qnil;
}