int createconsole(int argc, char *argv[])
{
  if (win != NULL)
    return 1;

  if (app != NULL)      /* delete existing partial data structures */
    deleteconsole();

  lines = malloc(NUM_LINES*NUM_COLUMNS*sizeof(TCHAR));
  if (lines == NULL)
    return 0;
  memset(lines, __T(' '), NUM_LINES * NUM_COLUMNS);

  app = new_app(argc, argv);
  if (app == NULL) {
    deleteconsole();
    return 0;
  } /* if */

  font = new_font(app, "unifont", PLAIN | PORTABLE_FONT, 16);
  if (font == NULL)
    font = new_font(app, "courier", PLAIN | NATIVE_FONT, 16);
  if (font == NULL)
    font = find_default_font(app);
  if (font == NULL) {
    deleteconsole();
    return 0;
  } /* if */

  win = new_window(app,
                   rect(0,0,
                        NUM_COLUMNS*font_width(font,"x",1),
                        NUM_LINES*font_height(font)),
                   "Pawn console",
                   TITLEBAR|CLOSEBOX|MAXIMIZE|MINIMIZE|CENTRED);
  on_window_redraw(win, window_redraw);
  on_window_close (win, window_close);
  on_window_key_down(win, window_key_action);     /* normal keys (including CR) */
  show_window(win);

  /* handle any pending events */
  while (do_event(app))
    /* nothing */;

  csrx = 0;
  csry = 0;
  autowrap = 0;
  attrib = 0x07;

  return 1;
}
Exemple #2
0
int amx_termctl(int cmd,int value)
{
  switch (cmd) {
  case 0:
    return 1;           /* simple "is terminal support available" check */

  case 1:
    if (createconsole(0, NULL)) {
      autowrap=value;
      return 1;
    } /* if */
    return 0;

  case 2:
    return 0;

  case 3:
    return 0;

  case 4:
    while (app != NULL && win != NULL && do_event(app))
      /* nothing */;
    if (win == NULL)
      deleteconsole();
    return (win != NULL);

  default:
    return 0;
  } /* switch */
}