Ejemplo n.º 1
0
char *owl_viewwin_command_start_search(owl_viewwin *v, int argc, const char *const *argv, const char *buff)
{
  int direction;
  const char *buffstart;
  owl_editwin *tw;
  owl_context *ctx;
  owl_viewwin_search_data *data;

  direction=OWL_DIRECTION_DOWNWARDS;
  buffstart=skiptokens(buff, 1);
  if (argc>1 && !strcmp(argv[1], "-r")) {
    direction=OWL_DIRECTION_UPWARDS;
    buffstart=skiptokens(buff, 2);
  }

  /* TODO: Add a search history? */
  tw = owl_viewwin_set_typwin_active(v, NULL);
  owl_editwin_set_locktext(tw, (direction == OWL_DIRECTION_DOWNWARDS) ? "/" : "?");
  owl_editwin_insert_string(tw, buffstart);

  data = g_new(owl_viewwin_search_data, 1);
  data->v = v;
  data->direction = direction;

  ctx = owl_editcontext_new(OWL_CTX_EDITLINE, tw, "editline",
                            owl_viewwin_deactivate_editcontext, v);
  ctx->cbdata = v;
  owl_global_push_context_obj(&g, ctx);
  owl_editwin_set_callback(tw, owl_viewwin_callback_search);
  owl_editwin_set_cbdata(tw, data, g_free);
  /* We aren't saving tw, so release the reference we were given. */
  owl_editwin_unref(tw);
  return NULL;
}
Ejemplo n.º 2
0
int owl_editwin_regtest(void) {
  int numfailed = 0;
  const char *p;

  printf("# BEGIN testing owl_editwin\n");

  owl_editwin *oe;
  oe = owl_editwin_new(NULL, 80, 80, OWL_EDITWIN_STYLE_MULTILINE, NULL);

  /* TODO: make the strings a little more lenient w.r.t trailing whitespace */

  /* check paragraph fill */
  owl_editwin_insert_string(oe, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.\n\nblah");
  owl_editwin_move_to_top(oe);
  owl_editwin_fill_paragraph(oe);
  p = owl_editwin_get_text(oe);
  FAIL_UNLESS("text was correctly wrapped", p && !strcmp(p, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n"
							    "blah blah blah.\n"
							    "\n"
							    "blah"));

  owl_editwin_delete(oe); oe = NULL;
  oe = owl_editwin_new(NULL, 80, 80, OWL_EDITWIN_STYLE_MULTILINE, NULL);

  /* check that lines ending with ". " correctly fill */
  owl_editwin_insert_string(oe, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah. \n\nblah");
  owl_editwin_move_to_top(oe);
  owl_editwin_fill_paragraph(oe);
  p = owl_editwin_get_text(oe);
  FAIL_UNLESS("text was correctly wrapped", p && !strcmp(p, "blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n"
							    "blah blah blah. \n"
							    "\n"
							    "blah"));

  owl_editwin_delete(oe); oe = NULL;

  printf("# END testing owl_editwin (%d failures)\n", numfailed);

  return numfailed;
}
Ejemplo n.º 3
0
char *owl_viewwin_start_command(owl_viewwin *v, int argc, const char *const *argv, const char *buff)
{
  owl_editwin *tw;
  owl_context *ctx;

  buff = skiptokens(buff, 1);

  tw = owl_viewwin_set_typwin_active(v, owl_global_get_cmd_history(&g));
  owl_editwin_set_locktext(tw, ":");

  owl_editwin_insert_string(tw, buff);

  ctx = owl_editcontext_new(OWL_CTX_EDITLINE, tw, "editline",
                            owl_viewwin_deactivate_editcontext, v);
  owl_global_push_context_obj(&g, ctx);
  owl_editwin_set_callback(tw, owl_callback_command);
  /* We aren't saving tw, so release the reference we were given. */
  owl_editwin_unref(tw);

  return NULL;
}