Esempio n. 1
0
/****inserttexts()************************************************************/
void    inserttexts(char texts[256], int dummy) 
{
  dummy = dummy; /*PC uses 0 insert, 1 replace*/
#ifdef UNIX_MOTIF  /*060324 re compile with NOGUI, requires Lquiet=1*/
  if(Lquiet==0)  /*was Lcommanded before 990402*/
  {
        if(!Limittext)
        {
            laststrlen = (long)strlen(texts);
            maxtextchar = maxtextchar + laststrlen;
            if(maxtextchar >= 32767L)
            {
                Limittext = 1;
                printf("Text about to exceed 32767 characters, \n"
                    "   no more text will be put into Text Window!\n");
            }
            else
            {
                position = XmTextGetLastPosition(textwindow);
                XmTextInsert(textwindow, position, texts);
                /*advance position*/
                position = XmTextGetLastPosition(textwindow);
                /*set laststrlength=0 as will not overwrite this new text*/
                laststrlen = 0;
            }
        }
  }
#endif /* UNIX_MOTIF 060324 re compile with NOGUI, requires Lquiet=1*/
}
Esempio n. 2
0
void runCB(Widget w, XtPointer client_data, XtPointer xt_call_data)
{
	XmPushButtonCallbackStruct *call_data = (XmPushButtonCallbackStruct *) xt_call_data ;
	
	char* cmd;
	cmd = (char*)XmTextGetString(inW);
	
	FILE *fp;
	fp = popen(cmd, "r");
	
	char c[1024];
	XmTextPosition pos;
	pos = XmTextGetLastPosition(outW);
	
	while(fgets(c, 1024, fp)) {
		pos = XmTextGetLastPosition(outW);
		XmTextInsert(outW, pos, c);
	#ifdef DEBUG
		printf("fp: %s", c);
		printf("pos: %d\n", (int)pos);
	#endif
	}

	pclose(fp);
}
Esempio n. 3
0
// Veto changes before the current input line
void gdbModifyCB(Widget gdb_w, XtPointer, XtPointer call_data)
{
    if (private_gdb_output)
	return;

    XmTextVerifyCallbackStruct *change = 
	(XmTextVerifyCallbackStruct *)call_data;

    if (do_isearch(gdb_w, change))
	return;

    clear_isearch();

    if (change->startPos < promptPosition)
    {
	// Attempt to change text before prompt
#if 0
	// This only works in LessTif.  
	// With Motif, this causes a core dump on Solaris.  - AZ
	change->doit = false;
#else
	// Make it a no-op
	XmTextPosition lastPos = XmTextGetLastPosition(gdb_w);
	XmTextPosition newPos = lastPos;

	if (change->text->length == 0)
	{
	    // Deletion
	    newPos = promptPosition;
	    if (change->event != 0)
		XtCallActionProc(gdb_w, "beep", change->event, 0, 0);
	}
	else
	{
	    // Some character
	    XtAppAddTimeOut(XtWidgetToApplicationContext(gdb_w), 0, 
			    move_to_end_of_line, XtPointer(0));
	}
	change->startPos = change->endPos = 
	    change->newInsert = change->currInsert = newPos;
#endif
	return;
    }

    // Make sure newlines are always inserted at the end of the line
    if (change->startPos == change->endPos &&
	(change->startPos < promptPosition || 
	 (change->text->length == 1 && change->text->ptr[0] == '\n')))
    {
	// Add any text at end of text window
	XmTextPosition lastPos = XmTextGetLastPosition(gdb_w);
	change->newInsert = change->startPos = change->endPos = lastPos;
	
	XtAppAddTimeOut(XtWidgetToApplicationContext(gdb_w), 0, 
			move_to_end_of_line, XtPointer(0));
    }
}
Esempio n. 4
0
void listener_append(const char *msg)
{
  if ((listener_print_p(msg)) && /* we need this first -- runs print-hook */
      (listener_text))
    {
      XmTextInsert(listener_text, XmTextGetLastPosition(listener_text), (char *)msg);
      printout_end = XmTextGetLastPosition(listener_text) - 1;
    }
}
Esempio n. 5
0
/* appends text at the bottom of the main text widget */
void appendText(char *msg)
{
    XmTextPosition lastPos;

    lastPos = XmTextGetLastPosition(outputArea);
    XmTextInsert(outputArea, lastPos, msg);
    lastPos = XmTextGetLastPosition(outputArea);
    XmTextSetInsertionPosition(outputArea, lastPos);
}
Esempio n. 6
0
void append_listener_text(int end, const char *msg)
{
  if (listener_text)
    {
      if (end == -1) end = XmTextGetLastPosition(listener_text);
      XmTextInsert(listener_text, end, (char *)msg);
      XmTextSetCursorPosition(listener_text, XmTextGetLastPosition(listener_text));
    }
}
Esempio n. 7
0
static void set_line_from_history()
{
    private_gdb_history = true;

    const string& input = gdb_history[gdb_current_history];
    XmTextReplace(gdb_w, promptPosition,
		  XmTextGetLastPosition(gdb_w), XMST(input.chars()));
    XmTextSetInsertionPosition(gdb_w, XmTextGetLastPosition(gdb_w));

    if (gdb_history_w)
	ListSetAndSelectPos(gdb_commands_w, gdb_current_history + 1);

    private_gdb_history = false;
}
Esempio n. 8
0
void listener_append_and_prompt(const char *msg)
{
  if ((listener_print_p(msg)) &&
      (listener_text))
    {
      XmTextPosition cmd_eot;
      if (msg)
	XmTextInsert(listener_text, XmTextGetLastPosition(listener_text), (char *)msg);
      cmd_eot = XmTextGetLastPosition(listener_text);
      XmTextInsert(listener_text, cmd_eot, listener_prompt_with_cr());
      cmd_eot = XmTextGetLastPosition(listener_text);
      printout_end = cmd_eot - 1;
      XmTextShowPosition(listener_text, cmd_eot - 1);
    }
}
Esempio n. 9
0
/****cleartexts()*************************************************************/
void    cleartexts() 
{
#ifdef UNIX_MOTIF  /*060324 re compile with NOGUI, requires Lquiet=1*/
  if(Lquiet==0)  /*was Lcommanded before 990402*/
  {
    XmTextReplace(textwindow,
                   0,
                   XmTextGetLastPosition(textwindow),
                   " ");
    /*reset text position*/
    position = XmTextGetLastPosition(textwindow);
    maxtextchar = 0;
  }
#endif /* UNIX_MOTIF 060324 re compile with NOGUI, requires Lquiet=1*/
}
Esempio n. 10
0
/****pkintextreplace()********************************************************/
void pkintextreplace(char texts[256])
{/*does this from the last position set by inserttexts*/
#ifdef UNIX_MOTIF  /*060324 re compile with NOGUI, requires Lquiet=1*/
  if(Lquiet==0)  /*was Lcommanded before 990402*/
  {
        if(!Limittext)
        {
            maxtextchar = maxtextchar - laststrlen + (long)strlen(texts);
            if(maxtextchar >= 32767L)
            {
                Limittext = 1;
                printf("Text about to exceed 32767 characters, \n"
                    "   no more text will be put into Text Window!\n");
            }
            else
            {
                laststrlen = (long)strlen(texts);/*update*/
                XmTextReplace(textwindow,
                   position,
                   XmTextGetLastPosition(textwindow),
                   texts);
                /*position is end of last inserttext*/
            }
        }
  }
#endif /* UNIX_MOTIF 060324 re compile with NOGUI, requires Lquiet=1*/
}
Esempio n. 11
0
void PutPropInfo( Window window ) 
{
  Bool show_type, ignore_frames;

  if( ! XtIsManaged(prop_frame) )   return;  

  SetWidgetCursor( tab_form, XC_watch );
  XmTextClear( prop_out );  

  SetStatus( "Retrieving window properties..." );

  show_type = pref_db.propPrefs[0].value;
  ignore_frames = pref_db.propPrefs[1].value;

  xprop( window, show_type, ignore_frames );

  if( XmTextGetLastPosition(prop_out) == 0 )
       XmTextPrintf( prop_out, "No properties defined for window ( 0x%x )",
		     (unsigned int)window );
       /* SetStatus( "No properties defined for window" ); */
  else XtVaSetValues( prop_out, XmNcursorPosition, 0,  NULL );

  ClearStatus();	 
  UnsetWidgetCursor( tab_form );

}
Esempio n. 12
0
File: TextStrSo.c Progetto: att/uwin
/*
 * Another widget has taken the selection that we used to own.
 */
static void
_XmTextLoseSelection(Widget w, Atom *selection)
{
    XmAnyCallbackStruct	cbs;
    XmTextWidget	tw = (XmTextWidget)w;

    if (*selection == XA_PRIMARY)
    {
	DEBUGOUT(_LtDebug(__FILE__, w, "_XmTextLoseSelection(PRIMARY)\n"));

	XmTextSetHighlight(w, 0, XmTextGetLastPosition(w),
			   XmHIGHLIGHT_NORMAL);

	/*
	 * FIX ME
	 * Need to call losePrimaryCallback here ?
	 */
	cbs.reason = XmCR_LOSE_PRIMARY;
	cbs.event = NULL;	/* ??? */
	XtCallCallbackList(w,
                           tw->text.lose_primary_callback,
                           (XtPointer)&cbs);
    }
    else
    {
	DEBUGOUT(_LtDebug(__FILE__, w, "_XmTextLoseSelection(?)\n"));
	/* ??? */
    }
}
Esempio n. 13
0
static int motTextSetSelectionPosAttrib(Ihandle* ih, const char* value)
{
  int start=0, end=0;

  if (!value || iupStrEqualNoCase(value, "NONE"))
  {
    XmTextClearSelection(ih->handle, CurrentTime);
    return 0;
  }

  if (iupStrEqualNoCase(value, "ALL"))
  {
    XmTextSetSelection(ih->handle, (XmTextPosition)0, (XmTextPosition)XmTextGetLastPosition(ih->handle), CurrentTime);
    return 0;
  }

  if (iupStrToIntInt(value, &start, &end, ':')!=2) 
    return 0;

  if(start<0 || end<0) 
    return 0;

  /* end is inside the selection, in IUP is outside */
  end--;

  XmTextSetSelection(ih->handle, (XmTextPosition)start, (XmTextPosition)end, CurrentTime);

  return 0;
}
Esempio n. 14
0
void
ClientsTabActive()
{  
  int maxcmdlen = 15000;
  Bool all_screens, more;

  
  XtManageChild( clients_frame );
  if( info_dpy == NULL ) return;

  XmTextClear( clients_out );

  SetWidgetCursor( tab_form, XC_watch );
  SetStatus( "Retrieving client info..." );

  all_screens = pref_db.cliPrefs[0].value;
  more = pref_db.cliPrefs[1].value;

  xlsclients( info_dpy, all_screens, more, maxcmdlen );
  
  if( XmTextGetLastPosition(clients_out) == 0 )
       SetStatus( "No clients found" );
  else {
       ClearStatus();
       XtVaSetValues( clients_out, XmNcursorPosition, 0, NULL );
  }
    
  UnsetWidgetCursor( tab_form );

}
Esempio n. 15
0
void view_message_display_file(char msg_type) {
    int pos;

    if ((All_messages_dialog != NULL)) {
        mscan_file(msg_type, view_message_print_record);
    }
    pos = (int)XmTextGetLastPosition(view_messages_text);
    XmTextShowPosition(view_messages_text, pos);
}
Esempio n. 16
0
void clear_text (Widget textwid)
{
XmTextPosition last_pos;
char *empty = "";

last_pos = XmTextGetLastPosition (textwid);
XmTextReplace (textwid, 0, last_pos, empty);

return;
}
Esempio n. 17
0
void set_status_from_gdb(const string& text)
{
    if (private_gdb_input)
	return;

    if (!show_next_line_in_status && !text.contains(gdb->prompt(), -1))
	return;

    // Fetch line before prompt in GDB window
    String s = XmTextGetString(gdb_w);
    string message = s + messagePosition;
    XtFree(s);

    if (message.empty() && text.contains('\n'))
	message = text;

    if (show_next_line_in_status && 
	(message.empty() || message[message.length() - 1] != '\n'))
	return;

    // Skip prompt and uncomplete lines
    int idx = message.index('\n', -1);
    if (idx >= 0)
	message = message.before(idx);

    strip_trailing_newlines(message);
    if (message.empty() && text.contains('\n'))
	message = text;

    if (show_next_line_in_status)
    {
	messagePosition = XmTextGetLastPosition(gdb_w) + text.length();
	show_next_line_in_status = false;
	message.gsub('\n', ' ');
    }
    else
    {
	// Show first line only
	while (!message.empty() && message[0] == '\n')
	    message = message.after('\n');
	if (message.contains('\n'))
	    message = message.before('\n');
    }

    strip_trailing_newlines(message);
    message.gsub('\t', ' ');
    if (message.empty())
	return;

    // Don't log this stuff - it's already logged
    bool old_log_status = log_status;
    log_status = false;
    set_status(message);
    log_status = old_log_status;
}
Esempio n. 18
0
// Return current line
string current_line()
{
    if (have_isearch_line)
	return isearch_line;

    String str = XmTextGetString(gdb_w);
    string input(str + promptPosition, 
		 XmTextGetLastPosition(gdb_w) - promptPosition);
    XtFree(str);
    return input;
}
Esempio n. 19
0
// TTY input received
static void tty_command(Agent *, void *, void *call_data)
{
    annotate("post-prompt");

    DataLength *d = (DataLength *)call_data;

    // Simply insert text, invoking all necessary callbacks
    tty_gdb_input = true;
    XmTextInsert(gdb_w, XmTextGetLastPosition(gdb_w), (String)d->data);
    tty_gdb_input = false;
}
Esempio n. 20
0
int DmxPrintOutput::getLastPosition ()
{
    XmTextPosition last;

#ifdef USE_DTEDITOR
    last = DtEditorGetLastPosition(_editor);
#else
    last = XmTextGetLastPosition(_editor);
#endif
    return((int) last);
}
Esempio n. 21
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;
    }
}
Esempio n. 22
0
static XEN g_goto_listener_end(void)
{
  #define H_goto_listener_end "(" S_goto_listener_end "): move cursor and scroll to bottom of listener pane"
  if (listener_text)
    {
      XmTextPosition eot;
      eot = XmTextGetLastPosition(listener_text);
      XmTextShowPosition(listener_text, eot);
      XmTextSetInsertionPosition(listener_text, eot);
      return(C_TO_XEN_INT(eot));
    }
  return(XEN_FALSE);
}
Esempio n. 23
0
static void completions_browse_callback(Widget w, XtPointer context, XtPointer info) 
{
  int i, j, old_len, new_len;
  char *text = NULL, *old_text = NULL;
  XmListCallbackStruct *cbs = (XmListCallbackStruct *)info;
  Widget requestor;
  if (ss->sgx->completion_requestor == NULL) 
    requestor = listener_text;
  else requestor = ss->sgx->completion_requestor;
  /* choice = cbs->item_position - 1; */
  text = (char *)XmStringUnparse(cbs->item, NULL, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
  old_text = XmTextGetString(requestor);
  old_len = snd_strlen(old_text);
  new_len = snd_strlen(text);
  for (i = old_len - 1, j = new_len - 1; j >= 0; j--)
    {
      if (old_text[i] != text[j])
	{
	  i = old_len - 1;
	  if (old_text[i] == text[j]) i--;
	  /* this added 15-Apr-02 for case like map-chan(nel) */
	  /*   probably should go back new_len and scan forwards instead */
	}
      else i--;
    }
  if (requestor == listener_text)
    append_listener_text(XmTextGetLastPosition(listener_text), 
			 (char *)(text - 1 + old_len - i));
  else
    {
      /* try to append to who(m?)ever asked for completion help */
      XmTextInsert(requestor, 
		   XmTextGetLastPosition(requestor), 
		   (char *)(text - 1 + old_len - i));
    }
  if (text) XtFree(text);
  if (old_text) XtFree(old_text);
  unpost_completion(requestor);
}
Esempio n. 24
0
static void Listener_help(Widget w, XEvent *event, char **str, Cardinal *num) 
{
  char *source = NULL;
  int end = 0, beg, len;
  end = XmTextGetLastPosition(w); /* cursor perhaps? */
  beg = end - 1024;
  if (beg < 0) beg = 0;
  if (beg >= end) return;
  len = end - beg + 1;
  source = (char *)CALLOC(len + 1, sizeof(char));
  XmTextGetSubstring(w, beg, len, len + 1, source);
  provide_listener_help(source);
  FREE(source);
}
Esempio n. 25
0
static void Word_upper(Widget w, XEvent *event, char **str, Cardinal *num) 
{
  bool up, cap;
  XmTextPosition curpos, endpos;
  up = (str[0][0] == 'u');
  cap = (str[0][0] == 'c');
  curpos = XmTextGetCursorPosition(w);
  endpos = XmTextGetLastPosition(w);
  if (curpos < endpos)
    {
      int i, length, wstart, wend;
      char *buf = NULL;
      length = endpos - curpos;
      buf = (char *)CALLOC(length + 1, sizeof(char));
      XmTextGetSubstring(w, curpos, length, length + 1, buf);
      wstart = 0;
      wend = length;
      for (i = 0; i < length; i++)
	if (!isspace((int)(buf[i])))
	  {
	    wstart = i;
	    break;
	  }
      for (i = wstart + 1; i < length; i++)
	if (isspace((int)(buf[i])))
	  {
	    wend = i;
	    break;
	  }
      if (cap)
	{
	  buf[0] = toupper(buf[wstart]);
	  buf[1] = '\0';
	  XmTextReplace(w, curpos + wstart, curpos + wstart + 1, buf);
	}
      else
	{
	  int j;
	  for (i = wstart, j = 0; i < wend; i++, j++)
	    if (up) 
	      buf[j] = toupper(buf[i]);
	    else buf[j] = tolower(buf[i]);
	  buf[j] = '\0';
	  XmTextReplace(w, curpos + wstart, curpos + wend, buf);
	}
      XmTextSetCursorPosition(w, curpos + wend);
      if (buf) FREE(buf);
    }
}
Esempio n. 26
0
static int motTextSetAppendAttrib(Ihandle* ih, const char* value)
{
  XmTextPosition pos;
  if (!ih->handle)  /* do not store the action before map */
    return 0;
  pos = XmTextGetLastPosition(ih->handle);
  /* disable callbacks */
  iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");
  if (ih->data->is_multiline && ih->data->append_newline)
    XmTextInsert(ih->handle, pos, "\n");
	if (value)
    XmTextInsert(ih->handle, pos+1, (char*)value);
  iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  return 0;
}
Esempio n. 27
0
static int motTextSetSelectionAttrib(Ihandle* ih, const char* value)
{
  int start=1, end=1;

  if (!value || iupStrEqualNoCase(value, "NONE"))
  {
    XmTextClearSelection(ih->handle, CurrentTime);
    return 0;
  }

  if (iupStrEqualNoCase(value, "ALL"))
  {
    XmTextSetSelection(ih->handle, (XmTextPosition)0, (XmTextPosition)XmTextGetLastPosition(ih->handle), CurrentTime);
    return 0;
  }

  if (ih->data->is_multiline)
  {
    int lin_start=1, col_start=1, lin_end=1, col_end=1;
    char *str;

    if (sscanf(value, "%d,%d:%d,%d", &lin_start, &col_start, &lin_end, &col_end)!=4) return 0;
    if (lin_start<1 || col_start<1 || lin_end<1 || col_end<1) return 0;

    str = XmTextGetString(ih->handle);
    start = motTextSetLinColToPosition(str, lin_start, col_start);
    end = motTextSetLinColToPosition(str, lin_end, col_end);
    XtFree(str);
  }
  else
  {
    if (iupStrToIntInt(value, &start, &end, ':')!=2) 
      return 0;

    if(start<1 || end<1) 
      return 0;

    start--; /* IUP starts at 1 */
    end--;
  }

  /* end is inside the selection, in IUP is outside */
  end--;

  XmTextSetSelection(ih->handle, (XmTextPosition)start, (XmTextPosition)end, CurrentTime);

  return 0;
}
Esempio n. 28
0
static void Kill_line(Widget w, XEvent *ev, char **str, Cardinal *num) 
{
  /* C-k with storage of killed text */
  XmTextPosition curpos, loc;
  Boolean found;
  curpos = XmTextGetCursorPosition(w);
  found = XmTextFindString(w, curpos, "\n", XmTEXT_FORWARD, &loc);
  if (!found) loc = XmTextGetLastPosition(w);
  if (loc > curpos)
    {
      if (listener_selection) {XtFree(listener_selection); listener_selection = NULL;}
      XmTextSetSelection(w, curpos, loc, CurrentTime);
      listener_selection = XmTextGetSelection(w); /* xm manual p329 sez storage is allocated here */
      XmTextCut(w, CurrentTime);
    }
}
Esempio n. 29
0
// Remove any text up to the last GDB prompt
void gdbClearWindowCB(Widget, XtPointer, XtPointer)
{
    XmTextPosition start = start_of_line();
    if (start == XmTextPosition(-1))
	return;

    private_gdb_output = true;

    XmTextReplace(gdb_w, 0, start, XMST(""));

    promptPosition  -= start;
    messagePosition -= start;
    XmTextSetInsertionPosition(gdb_w, XmTextGetLastPosition(gdb_w));

    private_gdb_output = false;
}
Esempio n. 30
0
void DmxPrintOutput::appendContents (void* stream, char *contents)
{
    DmxPrintOutput	*thisOutput = (DmxPrintOutput *) stream;

#ifdef USE_DTEDITOR
    DtEditorContentRec	rec;

    rec.type = DtEDITOR_TEXT;
    rec.value.string = contents;
    DtEditorInsert(thisOutput->_editor, &rec);
#else
    XmTextPosition pos;

    pos = XmTextGetLastPosition(thisOutput->_editor);
    XmTextInsert(thisOutput->_editor, pos, contents);
#endif
}