Пример #1
0
void cmd_delete (char *cp)

{

  first = 1;
  count = 0;
  if (range_multiple (cp, &cp, delete_range, &first) >= 0) eoltest (cp);
  if (count == 0) outerr (0, "no lines deleted\n");
  else outerr (12, "%u line%s deleted\n", count, (count == 1) ? "" : "s");
  if (cur_position.line != NULL) line_print (cur_position.line);
  else outfmt (strlen (buffer_name (cur_position.buffer)), "[EOB=%s]\n", buffer_name (cur_position.buffer));
}
Пример #2
0
static int realloc_buffer(struct exynos_data *pdata,
                          enum exynos_buffer_type type, unsigned size) {
  struct exynos_bo *buf = pdata->buf[type];
  unsigned i;

  if (size > buf->size) {
#if (EXYNOS_GFX_DEBUG_LOG == 1)
    RARCH_LOG("video_exynos: reallocating %s buffer (%u -> %u bytes)\n",
              buffer_name(type), buf->size, size);
#endif

    exynos_bo_destroy(buf);
    buf = create_mapped_buffer(pdata->device, size);

    if (buf == NULL) {
      RARCH_ERR("video_exynos: reallocation failed\n");
      return -1;
    }

    pdata->buf[type] = buf;

    /* Map new GEM buffer to the G2D images backed by it. */
    for (i = 0; i < exynos_image_count; ++i) {
      if (defaults[i].buf_type == type)
        pdata->src[i]->bo[0] = buf->handle;
    }
  }

  return 0;
}
Пример #3
0
void realmain(int argc, char **argv)
{
	char b[256];
	struct stat statbuf;
	/* vars from oldmain */
	buffer *buf = NULL;
	char path[1024];
	int i;

	setlocale(LC_NUMERIC, "C");
	common_init("Egon Animator %s. No Warranty");

	sprintf(b, "%s/%ld", siag_basedir, (long)getpid());
	mkdir(b, 0700);
	sprintf(b, "%s/egon.scm", siag_basedir);
	egonrc = MwStrdup(b);

	init_interpreters();
	siod_interpreter = init_parser(argc, argv);
	init_python_parser();
	init_guile_parser();
	init_ruby_parser();
	waitforchild(0);

	init_position();
	init_cmds();

	buf = new_buffer("noname.egon", "noname.egon");

	sprintf(path, "%s/egon/egon.scm", datadir);
	if (stat(path, &statbuf)) {
		fprintf(stderr, "Can't find the runtime library (egon.scm).\n");
		fprintf(stderr, "Expected it in %s\n", path);
		fprintf(stderr, "SIAGHOME (if set) is '%s'\n", datadir);
		fprintf(stderr, "Please read installation instructions.\n");
		exit(EXIT_FAILURE);
	}

	setvar(cintern("libdir"), strcons(-1, libdir), NIL);
	setvar(cintern("datadir"), strcons(-1, datadir), NIL);
	setvar(cintern("docdir"), strcons(-1, docdir), NIL);

	/* load runtime library */
	sprintf(b, "(load \"%s/egon/egon.scm\")", datadir);
	execute(b);

	init_windows(buf, &argc, argv);
	setlocale(LC_NUMERIC, "C");	/* possibly hosed by X */

	/* load user customizations, if any */
	if (!stat(egonrc, &statbuf)) {
		sprintf(b, "(load \"%s\")", egonrc);
		execute(b);
	}

	execute("(init-windows)");
	execute("(create-menus)");

	fileio_init();
	for (i = 1; i < argc; i++) {
		if (argv[i][0] != '-') {
			strcpy(path, argv[i]);
			free_buffer(w_list->buf);
			buf = new_buffer(buffer_name(argv[i]), path);
			loadmatrix(path, buf, guess_file_format(path));
			buf->change = FALSE;
			w_list->buf = buf;
		}
	}
	pr_scr_flag = TRUE;

	execute("(popup-editor)");
	/* this works, for reasons beyond my comprehension */
	execute("(print-version)");
	execute("(print-version)");
	activate_window(w_list);
#ifdef HAVE_LIBTCL
	Tcl_Main(argc, argv, Tcl_AppInit);
#else
	mainloop();
#endif
}
Пример #4
0
void cmd_exit (char *cp)

{
  const char *bn, *fn, *ynanswer;
  Buffer *buffer;
  int prompt, saveflag, ynflag;
  String *ynstring;

  /* Check for -save qualifier - it inhibits deleting the journal file */

  saveflag = 0;
  if ((strncasecmp (cp, "-save", 5) == 0) && (cp[5] <= ' ')) {
    if ((journal_name == NULL) || (journal_name[0] == 0)) {
      outerr (0, "there is no journal file to save\n");
      return;
    }
    saveflag = 1;
    cp = skipspaces (cp + 5);
  }

  /* Maybe use a different name for main buffer */

  if (*cp != 0) buffer_setfile (main_buffer, cp);

  /* Don't bother if recovery mode, we want them to be able to do more.  They can re-type exit command */

  if (recover_file != NULL) {
    outerr (0, "EXIT command ignored in recovery mode\n");
    return;
  }

  /* Check for buffers that have filename of "" (opened -readonly) but were modified */

  prompt = 0;
  for (buffer = NULL; (buffer = buffer_next (buffer)) != NULL;) {
    fn = buffer_filename (buffer);
    if (fn == NULL) continue;
    if (fn[0] != 0) continue;
    if (buffer_dirty (buffer, -1)) {
      bn = buffer_name (buffer);
      if (!prompt) outerr (0, "\n");
      outerr (strlen (bn), "buffer %s was modified but has no output file\n", bn);
      prompt = 1;
    }
  }
  if (prompt) {
    do {
      ynstring = jnl_readprompt ("\r\n  do you still want to exit (yes or no)? ");
      if (ynstring == NULL) return;
      ynflag   = -1;
      ynanswer = string_getval (ynstring);
      if (strcasecmp (ynanswer, "no")  == 0) ynflag = 0;
      if (strcasecmp (ynanswer, "yes") == 0) ynflag = 1;
      string_delete (ynstring);
    } while (ynflag < 0);
    if (!ynflag) return;
  }

  /* Write the entire contents of all the buffers that have files and that have been modified to their respective files */

  for (buffer = NULL; (buffer = buffer_next (buffer)) != NULL;) {
    fn = buffer_filename (buffer);							/* get output filename */
    if (fn == NULL) continue;								/* if none, don't try to write */
    bn = buffer_name (buffer);								/* ok, write it out */
    if (!buffer_dirty (buffer, -1)) {
      outerr (strlen (fn) + strlen (bn), "not writing %s from =%s because it is unmodified\n", fn, bn);
      continue;
    }
    outerr (strlen (fn) + strlen (bn), "writing %s from =%s: ", fn, bn);
    if (!write_file (fn, buffer_first_line (buffer), buffer_last_line (buffer))) {
      outerr (strlen (fn), "output file %s not written, not exiting\n", fn);		/* if error, don't exit */
      return;
    }
    buffer_dirty (buffer, 0);
  }

  /* Write successful, maybe delete journal file and terminate process */

  jnl_close (!saveflag);
  output ();
  exit (0);
}
Пример #5
0
void cmd_show (char *cp)

{
  char c, curbf, dirty, *p;
  const char *fname, *name;
  int l, rf;
  Buffer *buffer;
  uLong lines;

  if (*cp == 0) goto usage;

  do {
    p = uptospace (cp);

    /* Show buffer info */

    if (strncasecmp ("buffers", cp, p - cp) == 0) {
      outfmt (0, "\nBuffers:\n");
      l = 0;
      for (buffer = NULL; (buffer = buffer_next (buffer)) != NULL;) {
        name  = buffer_name (buffer);
        if (strlen (name) > l) l = strlen (name);
      }
      for (buffer = NULL; (buffer = buffer_next (buffer)) != NULL;) {
        name  = buffer_name (buffer);
        fname = buffer_filename (buffer);
        lines = buffer_linecount (buffer);
        rf    = (buffer_getreadfile (buffer) != NULL);
        curbf = (buffer == cur_position.buffer) ? '>' : ' ';
        dirty = buffer_dirty (buffer, -1) ? '*' : ' ';
        outfmt (strlen (name) + 16, " %c %c %*.*s: %5u%c line%c", curbf, dirty, l, l, name, lines, rf ? '+' : ' ', (lines == 1) ? ' ' : 's');
        if (fname != NULL) outfmt (strlen (fname), " => %s", fname);
        if (buffer == main_buffer) outstr ("  (main buffer)");
        outchr ('\n');
      }
      continue;
    }

    /* Show info about files */

    if (strncasecmp ("files", cp, p - cp) == 0) {
      outfmt (0, "\nFiles:\n");
      outfmt (strlen (help_name),    "     Help: %s\n", help_name);
      outfmt (strlen (journal_name), "  Journal: %s\n", journal_name[0] == 0 ? "<none>" : journal_name);
      continue;
    }

    /* Show keypad definitions */

    if (strncasecmp ("keypad", cp, p - cp) == 0) {
      show_keypad ();
      continue;
    }
    goto usage;

  } while (*(cp = skipspaces (p)) != 0);
  return;

usage:
  outerr (0, "specify BUFFERS, FILES, KEYPAD\n");
}