Example #1
0
void ttext_::set_cursor(const size_t offset, const bool select)
{
	if(select) {

		if(selection_start_ == offset) {
			selection_length_ = 0;
		} else {
			selection_length_ = - static_cast<int>(selection_start_ - offset);
		}

#ifdef __unix__
		// selecting copies on UNIX systems.
		copy_selection(true);
#endif
		update_canvas();
		set_dirty(true);

	} else {
		assert(offset <= text_.get_length());
		selection_start_ = offset;
		selection_length_ = 0;

		update_canvas();
		set_dirty(true);
	}
}
Example #2
0
void TE_View::copy()
{
   Session* session = Session::instance();
   Display* display = session->default_display();
   SelectionManager* s = display->clipboard_selection();

   // copy selection into selection buffer
   copy_selection(s);

   // mark selection as owned
   own_selection(s);
}
Example #3
0
File: util.c Project: LaHaine/ohpc
read_request * copy_read_request (const read_request * r)
{
    read_request * newreq;

    newreq = (read_request *) malloc (sizeof (read_request));
    assert (newreq);

    newreq->sel = copy_selection (r->sel);
    newreq->varid = r->varid;
    newreq->from_steps = r->from_steps;
    newreq->nsteps = r->nsteps;
    newreq->data = r->data;
    newreq->datasize = r->datasize;
    newreq->priv = r->priv;
    newreq->next = 0;

    return newreq;
}
Example #4
0
static ADIOS_VARCHUNK * extract_chunk_from_finished_read_reqgroup(adios_transform_read_request *reqgroup) {
    assert(reqgroup);
    assert(reqgroup->completed);

    ADIOS_VARCHUNK *chunk = malloc(sizeof(ADIOS_VARCHUNK));
    chunk->varid = reqgroup->raw_varinfo->varid;
    chunk->type = reqgroup->transinfo->orig_type;
    chunk->from_steps = reqgroup->from_steps;
    chunk->nsteps = reqgroup->nsteps;

    // Transfer ownership of orig_data
    chunk->data = reqgroup->orig_data;
    reqgroup->orig_data = NULL;

    // Transfer ownership of orig_sel
    chunk->sel = copy_selection(reqgroup->orig_sel);
    reqgroup->orig_sel = NULL;

    return chunk;
}
Example #5
0
void TE_View::release(const Event& e) 
{
    if (active_) {
   current_window_ = e.window();

   SelectionManager* s = e.display()->primary_selection();
   switch(drag_mode_) {
   case DragSelect:
      // copy and own current selection
      copy_selection(s);
      own_selection(s);
      break;
   case DragMenu:
      // unselect menu and unmap window
      menu_->release(e);
      menu_->unselect();
      menu_window_->unmap();
      menu_window_->unbind();      // required ??
      break;
   default:
      break; 
   }
}
}
Example #6
0
File: pvs.c Project: jff/mathspad
void pvs_construct_hint(int selection, int forward, Char *hint)
{
  PVSProof *p;
  FILE *f;
  Char *hintstr;
  ProofStep **cstep;
  KeywordItem *kwi;
  p = pvs_temporary_file(lasthintfile,&f);
  copy_selection(&p->selection, get_selection(selection));
  {
    char lemmabuf[500];
    sprintf(lemmabuf, "%s%i", UstrtoLocale(pvs_lemma_name), lastlemmanr);
    lastlemmanr++;
    p->lemma = strdup(lemmabuf);
    fprintf(f,"%s: THEOREM\n\t\t", lemmabuf);
  }
  cstep = &p->step;
  /* add an empty proof step to store the starting expression */
  *cstep = malloc(sizeof(ProofStep));
  (*cstep)->next=0;
  (*cstep)->keyword=0;
  (*cstep)->pvsinput=0;
  (*cstep)->comment=translate("starting formula");
  (*cstep)->result=0;
  (*cstep)->failed=0;
  (*cstep)->steptype=SkipStep;
  (*cstep)->use_result=0;
  cstep = &((*cstep)->next);  
  /* add the initial proof step to start the hints */
  *cstep = malloc(sizeof(ProofStep));
  (*cstep)->next=0;
  (*cstep)->keyword=get_pvskeyword(translate("INITSTEP"));
  (*cstep)->pvsinput=0;
  (*cstep)->comment=translate("initialisation steps");
  (*cstep)->result=0;
  (*cstep)->failed=0;
  (*cstep)->use_result=0;
  (*cstep)->steptype=InitStep;
  cstep = &((*cstep)->next);
  kwi = get_pvskeyword(hint);
  if (kwi) {
    if (kwi->induct) {
      void *node;
      char *str=0;
      char *h;
      void *upsel;
      upsel=0;
      copy_selection(&upsel, p->selection);
      up_selection(upsel);
      tex_set_string(&str);
      tex_placeholders(0);
      latex_all_parens(MP_True);
      tex_mode(ASCII);
      node = first_node(upsel);
      latex_node(node);
      out_latex_char('=');
      node = last_node(upsel);
      latex_node(node);
      tex_unset();
      latex_all_parens(MP_False);
      destruct_selection(upsel);
      /*
      ** Filter out '+(1)' and '+1'.
      ** This should be adjusted for allow induction on other types
      */
      h=str;
      while (h && ((h=strstr(h,"+(1)")))) {
	int i;
	for (i=0; i<4;i++) h[i]=' ';
	h=h+4;
      }
      h=str;
      while (h && ((h=strstr(h,"+1")))) {
	int i;
	for (i=0; i<2;i++) h[i]=' ';
	h=h+2;
      }
      fprintf(f, "(%s) IMPLIES\n",str);
      free(str);
    }
    *cstep = malloc(sizeof(ProofStep));
    (*cstep)->next=0;
    (*cstep)->keyword=kwi;
    (*cstep)->pvsinput=0;
    (*cstep)->comment=0;
    (*cstep)->result=0;
    (*cstep)->failed=0;
    (*cstep)->steptype=KeywordStep;
    (*cstep)->use_result=0;
    cstep = &((*cstep)->next);
  }
  {
    char *str=0;
    tex_set_string(&str);
    tex_placeholders(0);
    latex_all_parens(MP_True);
    tex_mode(ASCII);
    latex_selection(selection);
    tex_unset();
    latex_all_parens(MP_False);
    if (using_booleans) {
      fprintf(f,"%s\n\n", str);
    } else {
      fprintf(f, "(%s) = Tresult\n\n", str);
    }
  }
  *cstep = malloc(sizeof(ProofStep));
  (*cstep)->next=0;
  (*cstep)->keyword=get_pvskeyword(translate("RESULTSTEP"));
  (*cstep)->pvsinput=0;
  (*cstep)->comment=0;
  (*cstep)->result=0;
  (*cstep)->failed=0;
  (*cstep)->steptype=FinishStep;
  (*cstep)->use_result=(forward? 2:1);
  cstep = &((*cstep)->next);
  fprintf(f, "\nEND %s\n", p->theory);
  fclose(f);
  lasthintfile++;
  pvs_start_proof(p);
}
Example #7
0
File: pvs.c Project: jff/mathspad
void pvs_check_hint(int selection)
{
  int nr,vnr;
  unsigned long uvnr=0;
  Char *hintstr;
  PVSProof *pvsproof;
  ProofStep **cstep;
  char *head;
  int assumptions=0;
  int np=0;
  int curlinenr=0;
  FILE *f;
  char buffer[1024];
  /* check if hint is selected */
  nr = selected_notation(selection, &vnr);
  if (nr>=0) uvnr = which_notation(nnr_vnr2innr(nr,0))->vers[vnr].vnr;
  if (nr<0 || uvnr<firsthintnr || uvnr> lasthintnr) {
    message(MP_ERROR, translate("No valid hint selected"));
    return;
  }
  pvsproof=pvs_temporary_file(lasthintfile, &f);
  {
    int pos[2];
    copy_selection(&pvsproof->selection, get_selection(selection));
    pos[0]=1;pos[1]=0;
    change_selection(pvsproof->selection, pos,2);
  }
  {
    char lemmabuf[500];
    sprintf(lemmabuf, "%s%i", UstrtoLocale(pvs_lemma_name), lastlemmanr);
    lastlemmanr++;
    pvsproof->lemma = strdup(lemmabuf);
    fprintf(f,"%s: THEOREM\n\t\t", lemmabuf);
    curlinenr++;
  }
  assumptions=0;
  cstep = &pvsproof->step;
  /* add an empty proof step to store the starting expression */
  *cstep = malloc(sizeof(ProofStep));
  (*cstep)->next=0;
  (*cstep)->keyword=0;
  (*cstep)->pvsinput=0;
  (*cstep)->comment=translate("starting formula");
  (*cstep)->result=0;
  (*cstep)->failed=0;
  (*cstep)->steptype=SkipStep;
  (*cstep)->use_result=0;
  cstep = &((*cstep)->next);  
  /* add the initial proof step to start the hints */
  *cstep = malloc(sizeof(ProofStep));
  (*cstep)->next=0;
  (*cstep)->keyword=get_pvskeyword(translate("INITSTEP"));
  (*cstep)->pvsinput=0;
  (*cstep)->comment=translate("initialisation steps");
  (*cstep)->result=0;
  (*cstep)->failed=0;
  (*cstep)->use_result=0;
  (*cstep)->steptype=InitStep;
  cstep = &((*cstep)->next);
  /* parse text in hint:
  ** - expression   ->  add to assumptions
  ** - "induction"  ->  add 'Ef = El' to assumptions
  **                    (Ef: first expr., El: last expr,  =: weakest operator)
  **                    add (inst?)(ground)(try-triv-step (replace*)) to proof
  ** - "name"       ->  add (modulo-assoc (bidi-rewrite "name")) to proof
  ** - "definition" ->  add (expand-simp* "def1" ... "defn") to proof
  **                    (def1 ... defn extracted from expressions)
  ** - hidden PVS   ->  add content to proof
  */
  {
    int pos[2];
    pos[0]=1;
    pos[1]=0;
    hintstr = get_subnode_string(selection, pos,2);
  }
  if (!hintstr || !hintstr[0]) {
    /* empty hints usually indicate trivial steps */
    hintstr = translate("trivial");
  }
  while (*hintstr) {
    if (IsPh(hintstr[0])) {
      /* An expression, identifier, operator of text */
      void *node;
      int pos[3];
      char *str=0;
      pos[0]=1;
      pos[1]=0;
      pos[2]=np++;
      node = get_subnode(selection, pos, 3);
      nr = node_notation(node, &vnr);
      if (nr!= -1) uvnr = which_notation(nnr_vnr2innr(nr,0))->vers[0].vnr;
      tex_set_string(&str);
      tex_placeholders(0);
      latex_all_parens(MP_True);
      tex_mode(ASCII);
      latex_node(node);
      tex_unset();
      latex_all_parens(MP_False);
      if (str && str[0]) {
	/* the expression produces output */
	if (uvnr==pvshiddenstep) {
	  /* a special PVS related template to add steps to the proof list */
	  *cstep = malloc(sizeof(ProofStep));
	  (*cstep)->next=0;
	  (*cstep)->keyword=0;
	  (*cstep)->pvsinput=str;
	  (*cstep)->comment=translate("hidden proof steps");
	  (*cstep)->result=0;
	  (*cstep)->failed=0;
	  (*cstep)->use_result=0;
	  (*cstep)->steptype=HiddenStep;
	  cstep = &((*cstep)->next);
	} else {
	  /* A normal expression. For now, an assumption, but it could be
	  ** an identifier  (as in "definition of $fold$") or 
	  ** a single operator (as in "$\times$ distributes over $\plus$")
	  */
	  if (!assumptions) {
	    fprintf(f,"(\t");
	  } else {
	    fprintf(f,"\t\t    AND ");
	  }
	  fprintf(f, "%s\n",str);
	  curlinenr++;
	  {
	    char *h;
	    for (h=str; *h; h++) { if (*h=='\n') curlinenr++; }
	  }
	  free(str);
	  assumptions++;
	  *cstep = malloc(sizeof(ProofStep));
	  (*cstep)->next=0;
	  (*cstep)->keyword=get_pvskeyword(translate("EXPRESSIONSTEP"));
	  (*cstep)->pvsinput=0;
	  (*cstep)->comment=translate("assumption step");
	  (*cstep)->result=0;
	  (*cstep)->failed=0;
	  (*cstep)->use_result=0;
	  (*cstep)->steptype=ExpressionStep;
	  cstep = &((*cstep)->next);
	}
      }
      hintstr++;
    } else {
      KeywordItem *kwi= kwlist;
      kwi = get_pvskeyword(hintstr);
      if (kwi) {
	if (kwi->induct) {
	  void *node;
	  char *str=0;
	  char *h;
	  tex_set_string(&str);
	  tex_placeholders(0);
	  latex_all_parens(MP_True);
	  tex_mode(ASCII);
	  node = first_node(get_selection(selection));
	  latex_node(node);
	  out_latex_char('=');
	  node = last_node(get_selection(selection));
	  latex_node(node);
	  tex_unset();
	  latex_all_parens(MP_False);
	  /*
	  ** Filter out '+(1)' and '+1'.
	  ** This should be adjusted for allow induction on other types
	  */
	  h=str;
	  while (h && ((h=strstr(h,"+(1)")))) {
	    int i;
	    for (i=0; i<4;i++) h[i]=' ';
	    h=h+4;
	  }
	  h=str;
	  while (h && ((h=strstr(h,"+1")))) {
	    int i;
	    for (i=0; i<2;i++) h[i]=' ';
	    h=h+2;
	  }
	  if (!assumptions) {
	    fprintf(f,"(\t");
	  } else {
	    fprintf(f,"\t\t    AND ");
	  }
	  fprintf(f, "%s\n",str);
	  curlinenr++;
	  {
	    char *nlc;
	    for (nlc=str; *nlc; nlc++) { if (*nlc=='\n') curlinenr++; }
	  }
	  free(str);
	  assumptions++;
	}
	if (kwi->step && kwi->step[0]) {
	  *cstep = malloc(sizeof(ProofStep));
	  (*cstep)->next=0;
	  (*cstep)->keyword=kwi;
	  (*cstep)->pvsinput=0;
	  (*cstep)->comment=0;
	  (*cstep)->result=0;
	  (*cstep)->failed=0;
	  (*cstep)->use_result=0;
	  (*cstep)->steptype=KeywordStep;
	  cstep = &((*cstep)->next);
	}
	hintstr=hintstr+kwi->len;
      }
      /* might want to skip to the next place holder/word boundary */
      hintstr++;
    }
  }
  if (assumptions) {
    fprintf(f,"\t\t) IMPLIES\n\t\t\t");
    curlinenr++;
  }
  /* generate lemma */
  {
    char *str=0;
    tex_set_string(&str);
    tex_placeholders(0);
    latex_all_parens(MP_True);
    tex_mode(ASCII);
    latex_selection(selection);
    tex_unset();
    latex_all_parens(MP_False);
    {
      char *nlc;
      for (nlc=str; *nlc; nlc++) if (*nlc=='\n') curlinenr++;
    }
    fprintf(f, "%s\n\n", str);
    curlinenr += 2;
  }
  *cstep = malloc(sizeof(ProofStep));
  (*cstep)->next=0;
  (*cstep)->keyword=get_pvskeyword(translate("FINISHSTEP"));
  (*cstep)->pvsinput=0;
  (*cstep)->comment=0;
  (*cstep)->result=0;
  (*cstep)->failed=0;
  (*cstep)->use_result=0;
  (*cstep)->steptype=FinishStep;
  cstep = &((*cstep)->next);
  fprintf(f, "\nEND %s\n", pvsproof->theory);
  fclose(f);
  lasthintfile++;
  /* start PVS proof of temporary lemma */
  pvs_start_proof(pvsproof);
  /* pvs_start_proof starts the proof of the selected hint(s)
  ** and checks if each step is correct, by sending the step,
  ** parse the output, check for errors, send next step, etc.
  ** At the end, Q.E.D. should appear and the 
  ** delivery.
  */
  if (pvsproof) {
    ProofStep *ps;
    for (ps=pvsproof->step; ps; ps=ps->next) {
      if (ps->pvsinput) {
	string_to_window(translate("PVS Generated Proof"),
			 LocaletoUstr((unsigned char*)ps->pvsinput));
      } else if (ps->keyword && ps->keyword->step) {
	string_to_window(translate("PVS Generated Proof"),
			 LocaletoUstr((unsigned char*)ps->keyword->step));
      }
    }
  }
  /* set PVS parse function correct */
}
Example #8
0
void ttext_::signal_handler_sdl_key_down(const event::tevent event
		, bool& handled
		, const SDLKey key
		, SDLMod modifier
		, const Uint16 unicode)
{

	DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";

// For copy/paste we use a different key on the MAC. Other ctrl modifiers won't
// be modifed seems not to be required when I read the comment in
// widgets/textbox.cpp:516. Would be nice if somebody on a MAC would test it.
#ifdef __APPLE__
	const unsigned copypaste_modifier = KMOD_LMETA | KMOD_RMETA;
#else
	const unsigned copypaste_modifier = KMOD_CTRL;
#endif

	switch(key) {

		case SDLK_LEFT :
			handle_key_left_arrow(modifier, handled);
			break;

		case SDLK_RIGHT :
			handle_key_right_arrow(modifier, handled);
			break;

		case SDLK_UP :
			handle_key_up_arrow(modifier, handled);
			break;

		case SDLK_DOWN :
			handle_key_down_arrow(modifier, handled);
			break;

		case SDLK_PAGEUP :
			handle_key_page_up(modifier, handled);
			break;

		case SDLK_PAGEDOWN :
			handle_key_page_down(modifier, handled);
			break;

		case SDLK_a :
			if(!(modifier & KMOD_CTRL)) {
				handle_key_default(handled, key, modifier, unicode);
				break;
			}

			// If ctrl-a is used for home drop the control modifier
			modifier = static_cast<SDLMod>(modifier &~ KMOD_CTRL);
			/* FALL DOWN */

		case SDLK_HOME :
			handle_key_home(modifier, handled);
			break;

		case SDLK_e :
			if(!(modifier & KMOD_CTRL)) {
				handle_key_default(handled, key, modifier, unicode);
				break;
			}

			// If ctrl-e is used for end drop the control modifier
			modifier = static_cast<SDLMod>(modifier &~ KMOD_CTRL);
			/* FALL DOWN */

		case SDLK_END :
			handle_key_end(modifier, handled);
			break;

		case SDLK_BACKSPACE :
			handle_key_backspace(modifier, handled);
			break;

		case SDLK_u :
			if(modifier & KMOD_CTRL) {
				handle_key_clear_line(modifier, handled);
			} else {
				handle_key_default(handled, key, modifier, unicode);
			}
			break;

		case SDLK_DELETE :
			handle_key_delete(modifier, handled);
			break;

		case SDLK_c :
			if(!(modifier & copypaste_modifier)) {
				handle_key_default(handled, key, modifier, unicode);
				break;
			}

			// atm we don't care whether there is something to copy or paste
			// if nothing is there we still don't want to be chained.
			copy_selection(false);
			handled = true;
			break;

		case SDLK_x :
			if(!(modifier & copypaste_modifier)) {
				handle_key_default(handled, key, modifier, unicode);
				break;
			}

			copy_selection(false);
			delete_selection();
			handled = true;
			break;

		case SDLK_v :
			if(!(modifier & copypaste_modifier)) {
				handle_key_default(handled, key, modifier, unicode);
				break;
			}

			paste_selection(false);
			handled = true;
			break;

		default :
			handle_key_default(handled, key, modifier, unicode);

	}

	if(text_changed_callback_) {
		text_changed_callback_(this, this->text());
	}

}
Example #9
0
/**
 * Edit a stream
 * @param console_in   stream to read console from
 * @param console_out  stream to write console to
 * @param stream  stream to read/write file to
 */
void muon_edit(handle_t console_in, handle_t console_out, const char *title, handle_t stream)
  {
  int rc;
  int i;

  editor_t *ed = (editor_t *) neutron_malloc(sizeof(editor_t));
  memset(ed, 0, sizeof(editor_t));
  ed->console_in = console_in;
  ed->console_out = console_out;
  ed->title = title;
  ed->anchor = -1;

  rc = load_file(ed, stream);

  get_console_size(ed);

  bool done = false;
  int key;

  ed->refresh = 1;
  while (!done)
    {
    if (ed->refresh)
      {
      draw_screen(ed);
      draw_full_statusline(ed);
      ed->refresh = 0;
      ed->lineupdate = 0;
      }
    else if (ed->lineupdate)
      {
      update_line(ed);
      ed->lineupdate = 0;
      draw_statusline(ed);
      }
    else
      {
      draw_statusline(ed);
      }

    position_cursor(ed);

    key = getkey(ed);

    if (key >= ' ' && key <= 0x7F)
      {
      insert_char(ed, (char) key);
      }
    else
      {
      switch (key)
        {
        case KEY_F1:
          help(ed);
          break;
        case KEY_F5:
          redraw_screen(ed);
          break;
       case KEY_UP:
         up(ed, 0);
          break;
        case KEY_DOWN:
          down(ed, 0);
          break;
        case KEY_LEFT:
          left(ed, 0);
          break;
        case KEY_RIGHT:
          right(ed, 0);
          break;
        case KEY_HOME:
          home(ed, 0);
          break;
        case KEY_END:
          end(ed, 0);
          break;
        case KEY_PGUP:
          pageup(ed, 0);
          break;
        case KEY_PGDN:
          pagedown(ed, 0);
          break;
        case KEY_CTRL_RIGHT:
          wordright(ed, 0);
          break;
        case KEY_CTRL_LEFT:
          wordleft(ed, 0);
          break;
        case KEY_CTRL_HOME:
          top(ed, 0);
          break;
        case KEY_CTRL_END:
          bottom(ed, 0);
          break;
        case KEY_SHIFT_UP:
          up(ed, 1);
          break;
        case KEY_SHIFT_DOWN:
          down(ed, 1);
          break;
        case KEY_SHIFT_LEFT:
          left(ed, 1);
          break;
        case KEY_SHIFT_RIGHT:
          right(ed, 1);
          break;
        case KEY_SHIFT_PGUP:
          pageup(ed, 1);
          break;
        case KEY_SHIFT_PGDN:
          pagedown(ed, 1);
          break;
        case KEY_SHIFT_HOME:
          home(ed, 1);
          break;
        case KEY_SHIFT_END:
          end(ed, 1);
          break;
        case KEY_SHIFT_CTRL_RIGHT:
          wordright(ed, 1);
          break;
        case KEY_SHIFT_CTRL_LEFT:
          wordleft(ed, 1);
          break;
        case KEY_SHIFT_CTRL_HOME:
          top(ed, 1);
          break;
        case KEY_SHIFT_CTRL_END:
          bottom(ed, 1);
          break;
        case ctrl('a'):
          select_all(ed);
          break;
        case ctrl('c'):
          copy_selection(ed);
          break;
        case ctrl('f'):
          find_text(ed, 0);
          break;
        case ctrl('l'):
          goto_line(ed);
          break;
        case ctrl('g'):
          find_text(ed, 1);
          break;
        case KEY_TAB:
          indent(ed, INDENT);
          break;
        case KEY_SHIFT_TAB:
          unindent(ed, INDENT);
          break;
        case KEY_ENTER:
          newline(ed);
          break;
        case KEY_BACKSPACE:
          backspace(ed);
          break;
        case KEY_DEL:
          del(ed);
          break;
        case ctrl('x'):
          cut_selection(ed);
          break;
        case ctrl('z'):
          undo(ed);
          break;
        case ctrl('r'):
          redo(ed);
          break;
        case ctrl('v'):
          paste_selection(ed);
          break;
        case ctrl('s'):
          save_editor(ed);
          break;
        case ctrl('q'):
          done = close_editor(ed);
          break;
        }
      }
    }

  gotoxy(ed, 0, ed->lines + 1);

  outstr(ed, RESET_COLOR CLREOL);

  if (ed->clipboard)
    neutron_free(ed->clipboard);

  if (ed->search)
    neutron_free(ed->search);

  if (ed->linebuf)
    neutron_free(ed->linebuf);

  clear_undo(ed);
  neutron_free(ed);
  }
Example #10
0
void cut_selection(editor_t *ed)
  {
  copy_selection(ed);
  erase_selection(ed);
  }
Example #11
0
int 
adios_read_flexpath_schedule_read_byid(const ADIOS_FILE *adiosfile,
				       const ADIOS_SELECTION *sel,
				       int varid,
				       int from_steps,
				       int nsteps,
				       void *data)
{   
    fp_log("FUNC", "entering schedule_read_byid\n");
    flexpath_reader_file * fp = (flexpath_reader_file*)adiosfile->fh;
    flexpath_var * var = fp->var_list;
    while(var){
        if(var->id == varid)
        	break;
        else
	    var=var->next;
    }
    if(!var){
        adios_error(err_invalid_varid,
		    "Invalid variable id: %d\n",
		    varid);
        return err_invalid_varid;
    }    
    //store the user allocated buffer.
    flexpath_var_chunk *chunk = &var->chunks[0];  
    chunk->user_buf = data;
    var->start_position = 0;
    if(nsteps != 1){
	adios_error (err_invalid_timestep,
                     "Only one step can be read from a stream at a time. "
                     "You requested % steps in adios_schedule_read()\n", 
		     nsteps);
        return err_invalid_timestep;
    }
    // this is done so that the user can do multiple schedule_read/perform_reads
    // within before doing release/advance step. Might need a better way to 
    // manage the ADIOS selections.
    if(var->sel){
	free_selection(var->sel);
    }
    var->sel = copy_selection(sel);

    switch(var->sel->type)
    {
    case ADIOS_SELECTION_WRITEBLOCK:
    {
	int writer_index = var->sel->u.block.index;
	if(writer_index > fp->num_bridges){
	    adios_error(err_out_of_bound,
			"No process exists on the writer side matching the index.\n");
	    return err_out_of_bound;
	}
	send_var_message(fp, writer_index, var->varname);
	break;
    }
    case ADIOS_SELECTION_BOUNDINGBOX:
    {   
	free_displacements(var->displ, var->num_displ);
	var->displ = NULL;
        int j=0;
	int need_count = 0;
	array_displacements * all_disp = NULL;
	uint64_t pos = 0;
	double sched_start = MPI_Wtime();
        for(j=0; j<fp->num_bridges; j++) {
            int destination=0;	    	    
            if(need_writer(fp, j, var->sel, fp->gp, var->varname)==1){           
		uint64_t _pos = 0;
		need_count++;
                destination = j;
		global_var *gvar = find_gbl_var(fp->gp->vars, var->varname, fp->gp->num_vars);
		// TODO: memory leak here. have to free these at some point.
		array_displacements *displ = get_writer_displacements(j, var->sel, gvar, &_pos);
		displ->pos = pos;
		_pos *= (uint64_t)var->type_size; 
		pos += _pos;
		
		all_disp = realloc(all_disp, sizeof(array_displacements)*need_count);
		all_disp[need_count-1] = *displ;
		send_var_message(fp, j, var->varname);				
            }
	}
	double sched_end = MPI_Wtime();
	var->displ = all_disp;
	var->num_displ = need_count;
        break;
    }
    case ADIOS_SELECTION_AUTO:
    {
	adios_error(err_operation_not_supported,
		    "ADIOS_SELECTION_AUTO not yet supported by flexpath.");
	break;
    }
    case ADIOS_SELECTION_POINTS:
    {
	adios_error(err_operation_not_supported,
		    "ADIOS_SELECTION_POINTS not yet supported by flexpath.");
	break;
    }
    }
    fp_log("FUNC", "entering schedule_read_byid\n");
    return 0;
}
Example #12
0
void TE_View::keystroke(const Event& e)
{
    if (active_) {
   current_window_ = e.window();
   
   // check if known key symbol
   unsigned long keysym = e.keysym();
   for (TE_ViewKeySymInfo* k = &default_key_sym_map[0];
	k->keysym != 0; k++) {
      if (keysym == k->keysym) {
	 TE_ViewKeyFunc f = k->func;
	 (this->*f)();
	 return;
      }
   }

   // map event to key
   signed char c;
   if (e.mapkey((char *)&c, 1) == 0)
      return;

   // check if known key map
#ifndef __sgi /* avoid SGI gcc warning */
   if (c >= 0) { // fix alt-V on linux/pc
#else
   if (1) { 
#endif
       TE_ViewKeyFunc f =  key_[c];
       if (f != nil) {
	   (this->*f)();
	   return;
       }
   }

#ifndef __sgi /* avoid SGI gcc warning */
   if (c >= 0 && (isspace(c) || !iscntrl(c))) 
#else
   if (isspace(c) || !iscntrl(c)) 
#endif
      insert_char(c);
   else 
      printf("Unknown character - ignored!\n");
}
}

void TE_View::double_click(const Event& e)
{
    if (active_) {
   boolean tripple_click = false;
   int dot, mark;
   unsigned long t = e.time();
   if (t - click_time_ < threshold_) {
      tripple_click = true;
   }
   click_time_ = t;

   int index = event_to_index(e);
   text_editor_->Select(index);

   // select work or line
   if (tripple_click) {
      // line
      text_editor_->BeginningOfLine();
      dot = text_editor_->Dot();
      text_editor_->EndOfLine();
      mark = text_editor_->Dot();
   }
   else {
      // word
      text_editor_->BeginningOfWord();
      dot = text_editor_->Dot();
      text_editor_->EndOfWord();
      mark = text_editor_->Dot();
   }
   text_editor_->Select(dot, mark);

   // copy and own current selection
   SelectionManager* s = e.display()->primary_selection();
   copy_selection(s);
   own_selection(s);
}
}

void TE_View::popup_menu(const Event&e)
{
  // display popup-menu
  const Window& rel = *e.window();
  Coord x = rel.left() + e.pointer_x();
  Coord y = rel.bottom() + e.pointer_y() - menu_window_->height() + 6;
  menu_window_->place(x, y);
  menu_window_->map();
}

void TE_View::line_update()
{
   // update line information
   lines_ = displayed_lines();
   end_row_ = start_row_ + lines_ - 1;
   notify();			// notify adjustable
}