Example #1
0
static int motTextSetClipboardAttrib(Ihandle *ih, const char *value)
{
  if (iupStrEqualNoCase(value, "COPY"))
  {
    char *str = XmTextGetSelection(ih->handle);
    if (!str) return 0;

    XmTextCopy(ih->handle, CurrentTime);

    /* do it also for the X clipboard */
    XStoreBytes(iupmot_display, str, strlen(str)+1);
    XtFree(str);
  }
  else if (iupStrEqualNoCase(value, "CUT"))
  {
    char *str = XmTextGetSelection(ih->handle);
    if (!str) return 0;

    /* disable callbacks */
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");

    XmTextCut(ih->handle, CurrentTime);

    /* do it also for the X clipboard */
    XStoreBytes(iupmot_display, str, strlen(str)+1);
    XtFree(str);
    XmTextRemove(ih->handle);

    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  else if (iupStrEqualNoCase(value, "PASTE"))
  {
    int size;
    char* str = XFetchBytes(iupmot_display, &size);
    if (!str) return 0;

    /* disable callbacks */
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");

    XmTextPaste(ih->handle); /* TODO: this could force 2 pastes, check in CDE */

    /* do it also for the X clipboard */
    XmTextRemove(ih->handle);
    XmTextInsert(ih->handle, XmTextGetInsertionPosition(ih->handle), str);
    XFree(str);

    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  else if (iupStrEqualNoCase(value, "CLEAR"))
  {
    /* disable callbacks */
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");
    XmTextRemove(ih->handle);
    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  return 0;
}
Example #2
0
File: CEdit.C Project: dhaley/dcp
void CEdit::Clear(void)
{
    // Deletes the currently selected text
    if (_xd_textwidget != NULL)
    {
	if (XmIsText(_xd_textwidget))
	    XmTextRemove(_xd_textwidget);
	else if (XmIsTextField(_xd_textwidget))
	    XmTextFieldRemove(_xd_rootwidget);
    }
}
Example #3
0
void clear_listener(void)
{
  if ((listener_text) && /* this can be called even when there is no listener */
      (XmTextGetCursorPosition(listener_text) > 1))
    {
      dont_check_motion = true;
      XmTextSetSelection(listener_text, 1, XmTextGetCursorPosition(listener_text), CurrentTime);
      XmTextRemove(listener_text);
      dont_check_motion = false;
    }
}
Example #4
0
void listener_delete_text(int new_end)
{
  int old_end;
  old_end = XmTextGetLastPosition(listener_text);
  if (old_end > new_end)
    {
      dont_check_motion = true;
      XmTextSetSelection(listener_text, new_end, old_end, CurrentTime);
      XmTextRemove(listener_text);
      dont_check_motion = false;
    }
}
Example #5
0
void
editCB( Widget w, XtPointer client_data, 
 		XtPointer call_data)
{
	int i;
	char *s;
	long action;
	Time time;
	Widget widget;
	XButtonEvent *event;
	XmPushButtonCallbackStruct *acs;
	XmTextPosition left, right;
	
	action = (long) client_data;
	acs = (XmPushButtonCallbackStruct *) call_data; 
	event = (XButtonEvent *) acs->event;
	time = event->time;
	widget = get_document_text(w, "editCB");
	
	switch (action) {
		case EDIT_CUT:
			XmTextCut(widget, time);
			break;
		case EDIT_COPY:
			XmTextCopy(widget, time);
			break;
		case EDIT_PASTE:
			XmTextPaste(widget);
			break;
		case EDIT_DELETE:
			XmTextRemove(widget);
			break;
		case EDIT_CLEAR:
			if (False == XmTextGetSelectionPosition(widget, 
			    &left, &right)) 
				break; 
			s = calloc(1 + right - left, sizeof(char));
			if (NULL == s) {
				perror("Dtpad (calloc)");
				exit(1);
			}
			for (i = 0; i < right - left; i++) s[i] = ' ';
			s[right - left] = '\0';
			XmTextReplace(widget, left, right, s);
			XtFree(s);
			break;
		default:
			break;
	}
}
Example #6
0
static int motTextSetInsertAttrib(Ihandle* ih, const char* value)
{
  if (!ih->handle)  /* do not store the action before map */
    return 0;
  if (!value)
    return 0;

  /* disable callbacks */
  iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");
  XmTextRemove(ih->handle);
  XmTextInsert(ih->handle, XmTextGetInsertionPosition(ih->handle), (char*)value);
  iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);

  return 0;
}
Example #7
0
static int motTextSetInsertAttrib(Ihandle* ih, const char* value)
{
  if (!ih->handle)  /* do not do the action before map */
    return 0;
  if (!value)
    return 0;

  /* disable callbacks */
  ih->data->disable_callbacks = 1;
  XmTextRemove(ih->handle);
  XmTextInsert(ih->handle, XmTextGetInsertionPosition(ih->handle), (char*)value);
  ih->data->disable_callbacks = 0;

  return 0;
}
Example #8
0
void
editCB( Widget w, XtPointer client_data, 
 		XtPointer call_data)
{
	long action;
	Time time;
	Widget widget;
	XButtonEvent *event;
	XmPushButtonCallbackStruct *acs;
	
	action = (long) client_data;
	acs = (XmPushButtonCallbackStruct *) call_data; 
	event = (XButtonEvent *) acs->event;
	time = event->time;
	widget = get_document_text(w, "editCB");
	
	switch (action) {
		case EDIT_CUT:
			XmTextCut(widget, time);
			break;
		case EDIT_COPY:
			XmTextCopy(widget, time);
			break;
		case EDIT_PASTE:
			XmTextPaste(widget);
			break;
		case EDIT_DELETE:
			XmTextRemove(widget);
			break;
		case EDIT_CLEAR:
			edit_clear(widget);
			break;
		default:
			break;
	}
}
Example #9
0
/***************************************************************************
  This routine is called to pop up the process dialog/form.
  This is done only after obtaining information about the process
  and setting various fields.
  
  The form can be used to shows process information, set process
  priority and/or send a signal to the process or process group.

  If want_kill is True and active.quick_killis True, this routine instead
  sends the signal last selected to the process.
***************************************************************************/
void 
Handle_Process(Widget w, pid_t pid, XEvent *event, Boolean want_kill)
{

  char line[MAXLINE];
  FILE *fp;
  
  XmProcessTraversal(active.canvas, XmTRAVERSE_CURRENT);
#ifdef HAVE_KILL
  if (active.quick_kill && want_kill) {
    if (last_global_signal_pos>=0 && last_global_signal_pos<sigmap_elts) {
      do_kill(w, pid, signal_map[last_global_signal_pos+1].sig);
      ForceRedisplay(); 
    } else {
      char buf[300];
      sprintf(buf, "Invalid signal position in signal list: %d\n", 
	      last_global_signal_pos+1);
      ShowDialog(w, XmDIALOG_ERROR, buf);
    }
    return;
  }
#endif

  base.selected_pid = pid;
  ForceRedisplay(); 

  /* Set priority to current priority value for the process */
#ifdef HAVE_GETPRIORITY
  errno = 0;
  priority = getpriority(PRIO_PROCESS, base.selected_pid);
  if ( priority == -1 && errno != 0 ) {
      /* beep if we can't get the priority. */
      XBell(XtDisplay(active.shell),0);  
  } else {
    XmScaleSetValue(priority_slider, priority);
  }
#endif
  
#ifdef HAVE_KILL
  /* Unless we have selected quick kill, make sure position 1 -- no
     action is selected for the signal value.  */
  if (active.quick_kill) {
    /* Off by one because we have "NO ACTION" while other menu doesn't */
    XmListSelectPos(signal_list, last_global_signal_pos+1+1, False);
  } else {
    XmListSelectPos(signal_list, 1, False);
  }
#endif
  
  /* process group button is not pushed/selected */
  do_process_group = False;
  XmToggleButtonSetState(process_group_button, do_process_group, False);

#ifdef HAVE_SETPRIORITY
  do_priority = False;
  XmToggleButtonSetState(priority_button, do_priority, False);
#endif
  
  /* Set process command info . */
  sprintf(line, base.ps_cmd_info, base.selected_pid); 
  XmTextRemove(ps_info);
  /*XmScrollBarSetValues(ps_info, 1, 4, 1, 4, False);*/
  fp = popen(line, "r");
  if (fp != NULL) {
    int pos;
    XmTextSetString(ps_info, "");
    while(fgets(line, MAXLINE, fp) != NULL) {
      pos = XmTextGetLastPosition(ps_info);
      XmTextInsert(ps_info, pos, line);
    }
  }
  pclose(fp);

  /* Set to show full command-line invocation. */
  sprintf(line, base.ps_cmdline, base.selected_pid); 
  fp = popen(line, "r");
  if (fp != NULL) {
    int pos;
    while(fgets(line, MAXLINE, fp) != NULL) {
      pos = XmTextGetLastPosition(ps_info);
      XmTextInsert(ps_info, pos, line);
    }
    pclose(fp);
  }

  XtManageChild(ps_info);
  XtManageChild(process_dialog);
  /* By itself the popup appears at 0,0. I don't know why 
     XMenuPosition doesn't do better. */
  /*
    XmMenuPosition(process_dialog, (XButtonPressedEvent *) event);
  */
#ifdef TESTING
  switch (event->type) {
  case ButtonPress:
    XtVaSetValues(process_dialog, 
		  XmNx, event->xbutton.x,
		  XmNy, event->xbutton.y,
		  NULL);
    break;
    
  case KeyPress:
    XtVaSetValues(process_dialog, 
		  XmNx, event->xkey.x,
		  XmNy, event->xkey.y,
		  NULL);
    break;
  default:
  }
#endif
}
Example #10
0
void wxTextEntry::Remove(long from, long to)
{
    SetSelection(from, to);
    XmTextRemove(GetText());
}
Example #11
0
static int motTextSetClipboardAttrib(Ihandle *ih, const char *value)
{
  Boolean editable;
  XtVaGetValues(ih->handle, XmNeditable, &editable, NULL);
  
  /* NOTE: the functions XmTextCopy, XmTextPaste and XmTextCut did not work as expected.
    But using IupClipboard does not catch selections made in a terminal. */

  if (iupStrEqualNoCase(value, "COPY"))
  {
    Ihandle* clipboard;
    char *str = XmTextGetSelection(ih->handle);
    if (!str) 
      return 0;

    clipboard = IupClipboard();
    IupSetAttribute(clipboard, "TEXT", str);
    IupDestroy(clipboard);

    XtFree(str);
  }
  else if (iupStrEqualNoCase(value, "CUT"))
  {
    Ihandle* clipboard;
    char *str;

    if (!editable)
      return 0;

    str = XmTextGetSelection(ih->handle);
    if (!str) 
      return 0;

    clipboard = IupClipboard();
    IupSetAttribute(clipboard, "TEXT", str);
    IupDestroy(clipboard);

    XtFree(str);

    /* disable callbacks if not interactive */
    if (ih->data->disable_callbacks == -1)
      ih->data->disable_callbacks = 0;
    else
      ih->data->disable_callbacks = 1;
    XmTextRemove(ih->handle);
    ih->data->disable_callbacks = 0;
  }
  else if (iupStrEqualNoCase(value, "PASTE"))
  {
    Ihandle* clipboard;
    char *str;

    if (!editable)
      return 0;

    clipboard = IupClipboard();
    str = IupGetAttribute(clipboard, "TEXT");

    /* disable callbacks */
    /* disable callbacks if not interactive */
    if (ih->data->disable_callbacks == -1)
      ih->data->disable_callbacks = 0;
    else
      ih->data->disable_callbacks = 1;
    XmTextRemove(ih->handle);
    XmTextInsert(ih->handle, XmTextGetInsertionPosition(ih->handle), str);
    ih->data->disable_callbacks = 0;
  }
  else if (iupStrEqualNoCase(value, "CLEAR"))
  {
    if (!editable)
      return 0;

    /* disable callbacks if not interactive */
    if (ih->data->disable_callbacks == -1)
      ih->data->disable_callbacks = 0;
    else
      ih->data->disable_callbacks = 1;
    XmTextRemove(ih->handle);
    ih->data->disable_callbacks = 0;
  }
  return 0;
}