Beispiel #1
0
	int main(int argc, char *argv[])
	{
		int i, n;
		Arg args[10];
		XtAppContext app;
		Widget toplevel, rowcol, textf, text;
		XmString str_months[12];

		setlocale(LC_ALL, "");

		//建立顶级窗口
		toplevel = XtVaAppInitialize(&app, "Edit", NULL, 0,
			&argc, argv, NULL, NULL);

		//建立rowcolumn 布局
		n = 0;
		XtSetArg(args[n], XmNpacking, XmPACK_TIGHT);   n++;
		rowcol = XmCreateRowColumn(toplevel, "rowcol", args, n);
		XtManageChild(rowcol);

		//建立输入条
		n = 0;
		XtSetArg(args[n], XmNvalue, "输入条");	n++;
		textf = XmCreateTextField(rowcol, "textf", args, n);
		XtManageChild(textf);

		//建立文本区
		n = 0;
		XtSetArg(args[n], XmNrows, 10);				n++;
		XtSetArg(args[n], XmNcolumns, 40);			n++;
		XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT);	n++;
		XtSetArg(args[n], XmNwordWrap, True);			n++;
		XtSetArg(args[n], XmNvalue, "输入区域\n请测试");	n++;
		text = XmCreateScrolledText(rowcol, "text", args, n);
		XtManageChild(text);
		
		//显示窗口
		XtRealizeWidget(toplevel);

		//edit
		XmTextSetInsertionPosition(text, 3);
		XmTextInsert(text, 5, "测试插入");
		XmTextSetSelection(text, 5, 8, CurrentTime);
		XmTextCopy(text, CurrentTime);
		XmTextSetInsertionPosition(text, 1);
		XmTextPaste(text);
		

		//进入事件循环
		XtAppMainLoop(app);

	}
Beispiel #2
0
static void ChangeString (Widget w, XtPointer client_data,
	XtPointer call_data)
{
        XmString  tcs = (XmString)0;
	int n = 0;
	char *value;

        n = 0;

	value = XmTextGetString(w);
	XmTextSetInsertionPosition(w, strlen(value));
	XtFree(value);

	XtSetArg(args[n], XmNmarginWidth, 10);  n++;
	XtSetArg(args[n], XmNmarginHeight, 10);  n++;
	XtSetArg(args[n], XmNwordWrap, False); n++;
	XtSetArg(args[n], XmNrows, 5);  n++;
	XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
	XtSetArg(args[n], XmNforeground, CommonGetColor("navy"));  n++;
	XtSetArg(args[n], XmNvalue, string2 ); n++;
	XtSetArg(args[n], XmNfontList, CommonGetFontList(font_name1));  n++;
	XtSetValues(w, args, n);

        if ( tcs )
           XmStringFree(tcs);
}
Beispiel #3
0
void backward_characterAct(Widget, XEvent*, String*, Cardinal*)
{
    clear_isearch();
    XmTextPosition pos = XmTextGetInsertionPosition(gdb_w);
    if (pos > promptPosition)
	XmTextSetInsertionPosition(gdb_w, pos - 1);
}
Beispiel #4
0
static int motTextSetCaretAttrib(Ihandle* ih, const char* value)
{
  int pos = 1;

  if (!value)
    return 0;

  if (ih->data->is_multiline)
  {
    int lin = 1, col = 1;
    char *str;

    iupStrToIntInt(value, &lin, &col, ',');

    str = XmTextGetString(ih->handle);
    pos = motTextSetLinColToPosition(str, lin, col);
    XtFree(str);
  }
  else
  {
    sscanf(value,"%i",&pos);
    pos--; /* IUP starts at 1 */
  }

  XmTextSetInsertionPosition(ih->handle, (XmTextPosition)pos);
  XmTextShowPosition(ih->handle, (XmTextPosition)pos);

  return 0;
}
Beispiel #5
0
void Browser::gotoByte(unsigned long offset)
{
    XmTextPosition pos;

    //
    // Is it on this page?
    //
    if( (offset > this->page_start) &&
	(offset < (this->page_start + this->page_size)) )
    {
	pos = offset - this->page_start;
    }
    else
    {
	if(offset > this->page_size/2)
	    this->page_start = offset - this->page_size/2;
	else
	    this->page_start = 0;

	if(this->page_start + this->page_size > this->file_size)
	    this->page_start = this->file_size - this->page_size;

	this->loadBuffer(this->page_start);
	pos = offset - this->page_start;
    }

    XmTextShowPosition(this->text, pos);
    XmTextSetInsertionPosition(this->text, pos);
}
Beispiel #6
0
void Browser::gotoByteMarkOffsetCB(Widget w, XtPointer client, XtPointer)
{
    Browser *browser = (Browser *)client;
    XmTextPosition pos;

    theIBMApplication->setBusyCursor(TRUE);
    char *str = XmTextGetString(w);
    if(STRLEN(str) > 0)
    {
	pos = atoi(str) + browser->marker_pos;
    }
    else
    {
	theIBMApplication->setBusyCursor(FALSE);
	return;
    }
    if(!(pos >= browser->page_start) &&
	(pos < (browser->page_start + browser->page_size)) )
    {
	browser->page_start = browser->marker_pos - browser->page_size/2;
	if(browser->page_start + browser->page_size > browser->file_size)
	    browser->page_start = browser->file_size - browser->page_size;
	/*if(browser->page_start < 0) browser->page_start = 0;*/
	browser->loadBuffer(browser->page_start);
    }
    pos = pos - browser->page_start;
    XmTextShowPosition(browser->text, pos);
    XmTextSetInsertionPosition(browser->text, pos);

    theIBMApplication->setBusyCursor(FALSE);
}
Beispiel #7
0
void Browser::firstPage()
{

    this->loadBuffer(0);
    XmTextSetInsertionPosition(this->text, 0);
    this->updateOffsets(0);
}
Beispiel #8
0
void Browser::gotoByteStartOffsetCB(Widget w, XtPointer client, XtPointer )
{
    Browser *browser = (Browser *)client;
    XmTextPosition pos;

    theIBMApplication->setBusyCursor(TRUE);
    char *str = XmTextGetString(w);
    if(STRLEN(str) > 0)
    {
	pos = atoi(str);
    }
    else
    {
	theIBMApplication->setBusyCursor(FALSE);
	return;
    }
    char *text_str = XmTextGetString(browser->text);
    XmTextPosition current_pos = XmTextGetInsertionPosition(browser->text);
    long line_start = current_pos;

    //
    // Search backwards for the start of the line
    //
    while (line_start >= 0)
    {
	if(text_str[line_start] == '\n') break;
	line_start--;
    }
    line_start++;
	
    XmTextShowPosition(browser->text, line_start + pos);
    XmTextSetInsertionPosition(browser->text, line_start + pos);

    theIBMApplication->setBusyCursor(FALSE);
}
Beispiel #9
0
static void templates_cb(
	Widget		w,
	XtPointer	cbd,
	XtPointer	cbs)
{
	TemplateCallbackData *cbdata = cbd;
	XmTextPosition start, end, after;

	if(!text_w) {
		char m[80];
		sprintf(m, "unexpected argument %p", cbdata);
		msg("template handler", m);
		return;
	}

	if(get_map_state(text_w) != IsViewable) {
		beep();
		return;
	}

	if(	XmTextGetSelectionPosition(text_w, &start, &end)
	&&	start < end) {
		XmTextReplace(text_w, start, end, *cbdata);
		XmTextClearSelection(text_w, CurrentTime);
	} else {
		start = XmTextGetInsertionPosition(text_w);
		XmTextInsert(text_w, start, *cbdata);
	}

	after = start + strlen (*cbdata);
	XmTextSetInsertionPosition(text_w, after);
	XmTextShowPosition(text_w, after);
	set_input_focus(text_w);
}
Beispiel #10
0
void
lineTextFieldActivateCB( Widget w, XtPointer client_data, 
 		XtPointer call_data)
{
	short line, rows, cols;
	int conv;
	char *cb, *buf, *linestr;
	Widget doc_w, line_w;
	XmTextPosition pos;
	
	cb = "lineTextFieldActivateCB";
	doc_w = get_document_text(w, cb);
	line_w = get_widget_by_name(w, cb, "lineTextField");
	XtVaGetValues(doc_w,
	    XmNrows, &rows,
	    XmNcolumns, &cols,
	    NULL);
	buf = XmTextGetString(doc_w);
	linestr = XmTextFieldGetString(line_w);
	conv = atoi(linestr);
	
	if (conv > rows) {
		manage_widget(w, cb, "lineOutOfRangeMessageBox");
		goto Cleanup;
	}
	
	line = (short) conv;
	
	pos = line_to_position(buf, line, rows, cols);
	XmTextSetInsertionPosition(doc_w, pos);
	
Cleanup:
	XtFree(linestr);
	XtFree(buf);
}
Beispiel #11
0
/* Appends str to the command text */
static void AppendComText(String str)
{
  XmTextPosition old_pos;

  old_pos = XmTextGetInsertionPosition(appData->com_text);
  XmTextInsert(appData->com_text, old_pos, str);
  XmTextSetInsertionPosition(appData->com_text, old_pos + strlen(str));
}
Beispiel #12
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);
}
Beispiel #13
0
/*############################## init_text() ############################*/
void
init_text(void)
{
   wpr_position = 0;
   XmTextSetString(log_output, NULL);
   XmTextSetInsertionPosition(log_output, 0);
   if (current_log_number == -1)
   {
      int  i;
      char log_file[MAX_PATH_LENGTH];

      for (i = max_log_number; i >= 0; i--)
      {
         if (p_log_file != NULL)
         {
            (void)fclose(p_log_file);
         }
         (void)sprintf(log_file, "%s/%s%d", log_dir, log_name, i);
         if ((p_log_file = fopen(log_file, "r")) == NULL)
         {
            if (errno != ENOENT)
            {
               (void)xrec(FATAL_DIALOG, "Could not fopen() %s : %s (%s %d)",
                          log_file, strerror(errno), __FILE__, __LINE__);
               return;
            }
         }
         else
         {
            read_text();
            if ((log_type_flag != TRANSFER_LOG_TYPE) &&
                (log_type_flag != RECEIVE_LOG_TYPE) &&
                (i == 0))
            {
               struct stat stat_buf;

               if (fstat(fileno(p_log_file), &stat_buf) == -1)
               {
                  (void)fprintf(stderr,
                                "ERROR   : Could not fstat() %s : %s (%s %d)\n",
                                log_file, strerror(errno), __FILE__, __LINE__);
                  exit(INCORRECT);
               }
               current_inode_no = stat_buf.st_ino;
            }
         }
      }
   }
   else
   {
      read_text();
   }
   XmTextShowPosition(log_output, wpr_position);

   return;
}
Beispiel #14
0
void AttrMotif::change_value()
{
  int sts;
  Widget text_w;
  int multiline;
  char* value;
  int size;

  if (input_open) {
    XtUnmanageChild(cmd_input);
    set_prompt("");
    input_open = 0;
    return;
  }

  sts = ((AttrNav*)attrnav)->check_attr_value(&multiline, &size, &value);
  if (EVEN(sts)) {
    if (sts == GE__NOATTRSEL)
      message('E', "No attribute is selected");
    else
      message('E', "Attribute can't be modified");
    return;
  }

  if (multiline) {
    text_w = cmd_scrolledinput;
    XtManageChild(text_w);
    XtManageChild(cmd_scrolled_ok);
    XtManageChild(cmd_scrolled_ca);
  } else {
    text_w = cmd_input;
    XtManageChild(text_w);
  }

  message(' ', "");
  flow_SetInputFocus(text_w);
  //  XtSetKeyboardFocus( toplevel, text_w);
  //  XtCallAcceptFocus( text_w, CurrentTime);

  if (value) {
    XmTextSetString(text_w, value);
    if (!multiline) {
      XmTextSetInsertionPosition(text_w, strlen(value));
      XmTextSetSelection(text_w, 0, strlen(value), CurrentTime);
    }
  } else {
    XmTextSetString(cmd_input, (char*)"");
  }
  //  i = 0;
  //  XtSetArg(args[i],XmNeditMode, XmMULTI_LINE_EDIT); i++;
  //  XtSetValues( text_w, args, i);
  set_prompt("value >");
  input_open = 1;
}
Beispiel #15
0
/*++++++++++++++++++++++++++++ repeat_cmd() +++++++++++++++++++++++++++++*/
static void
repeat_cmd(Widget w)
{
   XmTextSetInsertionPosition(cmd_output, 0);
   XmTextSetString(cmd_output, NULL);
   XFlush(display);
   wpr_position = 0;

   xexec_cmd(cmd);

   return;
}
Beispiel #16
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);
}
Beispiel #17
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;
}
Beispiel #18
0
static int motTextSetCaretPosAttrib(Ihandle* ih, const char* value)
{
  int pos = 0;

  if (!value)
    return 0;

  sscanf(value,"%i",&pos);
  if (pos < 0) pos = 0;

  XmTextSetInsertionPosition(ih->handle, (XmTextPosition)pos);
  XmTextShowPosition(ih->handle, (XmTextPosition)pos);

  return 0;
}
Beispiel #19
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;
}
Beispiel #20
0
static void motTextKeyPressEvent(Widget w, Ihandle *ih, XKeyEvent *evt, Boolean *cont)
{
  Widget spinbox;

  *cont = True;
  iupmotKeyPressEvent(w, ih, (XEvent*)evt, cont);
  if (*cont == False)
    return;

  if (evt->state & ControlMask && !(state & Mod1Mask || state & Mod5Mask))   /* Ctrl but NOT Alt */
  {
    KeySym motcode = iupmotKeycodeToKeysym(evt);
    if (motcode == XK_c || motcode == XK_x || motcode == XK_v || motcode == XK_a)
    {
      ih->data->disable_callbacks = -1; /* let callbacks be processed in motTextSetClipboardAttrib */

      if (motcode == XK_c)
        motTextSetClipboardAttrib(ih, "COPY");
      else if (motcode == XK_x)
        motTextSetClipboardAttrib(ih, "CUT");
      else if (motcode == XK_v)
        motTextSetClipboardAttrib(ih, "PASTE");
      else if (motcode == XK_a)
        XmTextSetSelection(ih->handle, 0, XmTextGetLastPosition(ih->handle), CurrentTime);

      ih->data->disable_callbacks = 0;

      *cont = False; 
      return;
    }
  }

  spinbox = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (spinbox && XmIsSpinBox(spinbox))
  {
    KeySym motcode = iupmotKeycodeToKeysym(evt);
    if (motcode == XK_Left || motcode == XK_Right)
    {
      /* avoid spin increment using Left/Right arrows, 
         but must manually handle the new cursor position */
      XmTextPosition caret_pos = XmTextGetInsertionPosition(ih->handle);
      XmTextSetInsertionPosition(ih->handle, (motcode == XK_Left)? caret_pos-1: caret_pos+1);
      *cont = False; 
    }
  }
}
Beispiel #21
0
void Browser::placeMark()
{
    int i;
    int line_no;
    char mark_str[2];

    mark_str[0] = '\001';
    mark_str[1] = '\0';

    theIBMApplication->setBusyCursor(TRUE);
    char *str = XmTextGetString(this->text);

    this->clearMark();

    //
    // Calc where it should go
    //
    unsigned long pos = XmTextGetInsertionPosition(this->text);
    this->marker_pos = this->page_start + pos;

    line_no = 0;
    for(i = 0; i < pos; i++)
    {
	if(str[i] == '\n') line_no++;
    }
    this->marker_line_no = this->page_start_line_no + line_no;
    this->updateOffsets(pos);
    
    //
    // Save the marker character
    //
    this->marker_char[0] = str[pos];

    this->ignore_cb = True;
    XmTextReplace(this->text, pos, pos+1, mark_str);
    this->ignore_cb = False;

    XmTextSetInsertionPosition(this->text, pos);

    XtFree(str);
    theIBMApplication->setBusyCursor(FALSE);
}
Beispiel #22
0
static void motTextKeyPressEvent(Widget w, Ihandle *ih, XKeyEvent *evt, Boolean *cont)
{
  Widget spinbox;

  *cont = True;
  iupmotKeyPressEvent(w, ih, (XEvent*)evt, cont);
  if (*cont == False)
    return;

  if (evt->state & ControlMask)   /* Ctrl */
  {
    KeySym motcode = XKeycodeToKeysym(iupmot_display, evt->keycode, 0);
    if (motcode == XK_c)
      motTextSetClipboardAttrib(ih, "COPY");
    else if (motcode == XK_x)
      motTextSetClipboardAttrib(ih, "CUT");
    else if (motcode == XK_v)
      motTextSetClipboardAttrib(ih, "PASTE");
    else if (motcode == XK_a)
      XmTextSetSelection(ih->handle, 0, XmTextGetLastPosition(ih->handle), CurrentTime);
  }

  spinbox = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (spinbox && XmIsSpinBox(spinbox))
  {
    KeySym motcode = XKeycodeToKeysym(iupmot_display, evt->keycode, 0);
    if (motcode == XK_Left || motcode == XK_Right)
    {
      /* avoid spin increment using Left/Right arrows, 
         but must manually handle the new cursor position */
      XmTextPosition caret_pos = XmTextGetInsertionPosition(ih->handle);
      XmTextSetInsertionPosition(ih->handle, (motcode == XK_Left)? caret_pos-1: caret_pos+1);
      *cont = False; 
    }
  }
}
Beispiel #23
0
void
options_spinbox_chgCB( 
     Widget widget,
     XtPointer clientdata,
     XtPointer calldata
)
{
     Widget  spinbox = (Widget) clientdata;
     int             mvalue, value = 
			(int) strtol(XmTextGetString(widget), NULL, 10);
     Display         *dpy = XtDisplayOfObject(widget);
     calldata = calldata;
     
     props_changed = TRUE;
     if (!all_digits(XmTextGetString(widget))){
	XtVaSetValues(spinbox, XmNposition, 1, NULL);
	XBell(dpy, 50);
	return;
     }
     XtVaGetValues(spinbox, XmNmaximumValue, &mvalue, NULL); 
     if (value > mvalue) {
	XtVaSetValues(spinbox, XmNposition, mvalue, NULL);
	XBell(dpy, 50);
	return;
     }
     // It could never be less than the minimum value because a 
     // '-' is an invalid entry and it would be cleared and reset
     // if entered. So if we made it here it is a valid entry. We
     // also have to reset the insertion point! Another spinbox bug
     // we have to work around. 
     XtVaSetValues(spinbox, XmNposition, value, NULL);
     int shift = 1;
     while ((value /= 10) > 0)
	shift++; 
     XmTextSetInsertionPosition(widget, shift);
}
Beispiel #24
0
void WdaMotif::change_value( int set_focus)
{
  int		sts;
  Widget	text_w;
  int		multiline;
  char		*value;
  Arg 		args[5];
  int		input_size;

  if ( input_open) {
    XtUnmanageChild( cmd_input);
    set_prompt( "");
    input_open = 0;
    return;
  }

  sts = ((WdaNav *)wdanav)->check_attr( &multiline, &input_node, input_name,
		&value, &input_size);
  if ( EVEN(sts)) {
    if ( sts == WDA__NOATTRSEL)
      message( 'E', "No attribute is selected");
    else
      message( 'E', wnav_get_message( sts));
    return;
  }

  if ( multiline) {
    text_w = cmd_scrolledinput;
    XtManageChild( text_w);
    XtManageChild( cmd_scrolled_ok);
    XtManageChild( cmd_scrolled_ca);

    // XtSetArg(args[0], XmNpaneMaximum, 300);
    // XtSetValues( wdanav_form, args, 1);

    XtSetArg(args[0], XmNmaxLength, input_size-1);
    XtSetValues( text_w, args, 1);
    if ( value) {
      XmTextSetString( text_w, value);
//    XmTextSetInsertionPosition( text_w, strlen(value));
    }
    else
      XmTextSetString( text_w, (char*) "");

    input_multiline = 1;
  }
  else {
    text_w = cmd_input;
    XtManageChild( text_w);
    XtSetArg(args[0],XmNmaxLength, input_size-1);
    XtSetValues( text_w, args, 1);
    if ( value) {
      XmTextSetString( text_w, value);
      XmTextSetInsertionPosition( text_w, strlen(value));
    }
    else
      XmTextSetString( text_w, (char*) "");

    input_multiline = 0;
  }

  if ( value)
    free( value);

  message( ' ', "");
  if ( set_focus)
    flow_SetInputFocus( text_w);
  set_prompt( "value >");
  input_open = 1;
}
Beispiel #25
0
static void motTextModifyVerifyCallback(Widget w, Ihandle *ih, XmTextVerifyPtr text)
{
  int start, end, key = 0;
  char *value, *new_value, *insert_value;
  KeySym motcode = 0;
  IFnis cb;

  if (iupAttribGet(ih, "_IUPMOT_DISABLE_TEXT_CB"))
    return;

  if (iupAttribGet(ih, "_IUPMOT_SPIN_DISABLE_TEXT_CB"))
  {
    if (iupAttribGet(ih, "_IUPMOT_SPIN_NOAUTO"))
      text->doit = False;

    iupAttribSetStr(ih, "_IUPMOT_SPIN_DISABLE_TEXT_CB", NULL);
    return;
  }

  cb = (IFnis)IupGetCallback(ih, "ACTION");
  if (!cb && !ih->data->mask)
    return;

  if (text->event && text->event->type == KeyPress)
  {
    unsigned int state = ((XKeyEvent*)text->event)->state;
    if (state & ControlMask ||  /* Ctrl */
        state & Mod1Mask || 
        state & Mod5Mask ||  /* Alt */
        state & Mod4Mask) /* Apple/Win */
      return;

    motcode = XKeycodeToKeysym(iupmot_display, ((XKeyEvent*)text->event)->keycode, 0);
  }

  value = XmTextGetString(ih->handle);
  start = text->startPos;
  end = text->endPos;
  insert_value = text->text->ptr;

  if (motcode == XK_Delete)
  {
    new_value = value;
    iupStrRemove(value, start, end, 1);
  }
  else if (motcode == XK_BackSpace)
  {
    new_value = value;
    iupStrRemove(value, start, end, -1);
  }
  else
  {
    if (!value)
      new_value = iupStrDup(insert_value);
    else if (insert_value)
      new_value = iupStrInsert(value, insert_value, start, end);
    else
      new_value = value;
  }

  if (insert_value && insert_value[0]!=0 && insert_value[1]==0)
    key = insert_value[0];

  if (ih->data->mask && iupMaskCheck(ih->data->mask, new_value)==0)
  {
    if (new_value != value) free(new_value);
    XtFree(value);
    text->doit = False;     /* abort processing */
    return;
  }

  if (cb)
  {
    int cb_ret = cb(ih, key, (char*)new_value);
    if (cb_ret==IUP_IGNORE)
      text->doit = False;     /* abort processing */
    else if (cb_ret==IUP_CLOSE)
    {
      IupExitLoop();
      text->doit = False;     /* abort processing */
    }
    else if (cb_ret!=0 && key!=0 && 
             cb_ret != IUP_DEFAULT && cb_ret != IUP_CONTINUE)  
    {
      insert_value[0] = (char)cb_ret;  /* replace key */
    }
  }

  if (text->doit)
  {
    /* Spin is not automatically updated when you directly edit the text */
    Widget spinbox = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");
    if (spinbox && XmIsSpinBox(spinbox) && !iupAttribGet(ih, "_IUPMOT_SPIN_NOAUTO"))
    {
      int pos;
      if (iupStrToInt(new_value, &pos))
      {
        XmTextPosition caret_pos = text->currInsert;
        iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1");
        XtVaSetValues(ih->handle, XmNposition, pos, NULL);
        iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
        /* do not handle all situations, but handle the basic ones */
        if (text->startPos == text->endPos) /* insert */
          caret_pos++;
        else if (text->startPos < text->endPos && text->startPos < text->currInsert)  /* backspace */
          caret_pos--;
        XmTextSetInsertionPosition(ih->handle, caret_pos);
        text->doit = False;
      }
    }
  }

  if (new_value != value) free(new_value);
  XtFree(value);
  (void)w;
}
Beispiel #26
0
int XAttOneMotif::change_value( int set_focus)
{
  int		sts;
  Widget	text_w;
  char		*value = 0;
  Arg 		args[5];
  int		input_size = 80;
  char		aval[1024];
  char 		buf[1024];
  int		len;

  sts = gdh_GetAttributeCharAttrref( &aref, &atype, &asize, &aoffs, &aelem);
  if ( EVEN(sts)) return sts;
  
  sts = gdh_GetObjectInfoAttrref( &aref, aval, sizeof(aval));
  if ( EVEN(sts)) return sts;

  XNav::attrvalue_to_string( atype, atype, &aval, buf, sizeof(buf), &len, NULL, 0);

  value = buf;

  if ( !access_rw) {
    XmString	cstr;

    cstr=XmStringCreateLtoR( aval, (char*) "ISO8859-1");
    XtSetArg(args[0],XmNlabelString, cstr);
    XtSetValues( cmd_label, args, 1);
    XmStringFree( cstr);
  }
  else {
    if ( atype == pwr_eType_Text) {
      input_multiline = 1;
      text_w = cmd_scrolledinput;
      XtUnmanageChild( cmd_input);
      XtManageChild( text_w);
      XtManageChild( cmd_scrolled_ok);
      XtManageChild( cmd_scrolled_ca);

      // XtSetArg(args[0], XmNpaneMaximum, 300);
      // XtSetValues( xattnav_form, args, 1);

      XtSetArg(args[0], XmNmaxLength, input_size-1);
      XtSetValues( text_w, args, 1);
      if ( value) {
	XmTextSetString( text_w, value);
	//    XmTextSetInsertionPosition( text_w, strlen(value));
      }
      else
	XmTextSetString( text_w, (char*) "");

      input_multiline = 1;
    }
    else {
      input_multiline = 0;
      text_w = cmd_input;
      XtSetArg(args[0],XmNmaxLength, input_size-1);
      XtSetValues( text_w, args, 1);
      if ( value) {
	XmTextSetString( text_w, value);
	XmTextSetInsertionPosition( text_w, strlen(value));
      }
      else
	XmTextSetString( text_w, (char*) "");

      input_multiline = 0;
    }
    message( ' ', "");
    if ( set_focus)
      flow_SetInputFocus( text_w);
    set_prompt( Lng::translate("value >"));
    input_open = 1;
  }
  return XATT__SUCCESS;
}
Beispiel #27
0
static void move_to_end_of_line(XtPointer, XtIntervalId *)
{
    XmTextPosition pos = XmTextGetLastPosition(gdb_w);
    XmTextSetInsertionPosition(gdb_w, pos);
    XmTextShowPosition(gdb_w, pos);
}
Beispiel #28
0
void end_of_lineAct(Widget, XEvent*, String*, Cardinal*)
{
    clear_isearch();
    XmTextSetInsertionPosition(gdb_w, XmTextGetLastPosition(gdb_w));
}
Beispiel #29
0
void beginning_of_lineAct(Widget, XEvent*, String*, Cardinal*)
{
    clear_isearch();
    XmTextSetInsertionPosition(gdb_w, promptPosition);
}
Beispiel #30
0
// Show prompt according to current mode
static void show_isearch()
{
    XmTextPosition start = start_of_line();
    if (start == XmTextPosition(-1))
	return;

    string prompt;
    switch (isearch_state)
    {
    case ISEARCH_NONE:
	prompt = gdb->prompt();
	break;

    case ISEARCH_NEXT:
	prompt = isearch_prompt;
	break;

    case ISEARCH_PREV:
	prompt = reverse_isearch_prompt;
	break;
    }

    if (isearch_state != ISEARCH_NONE)
	prompt += "`" + cook(isearch_string) + "': ";
    string input = current_line();
    string line  = prompt + input;

    bool old_private_gdb_output = private_gdb_output;
    private_gdb_output = true;
    XmTextReplace(gdb_w, start, XmTextGetLastPosition(gdb_w), XMST(line.chars()));
    promptPosition = start + prompt.length();

    XmTextPosition pos = promptPosition;
    int index = input.index(isearch_string);
    if (isearch_state == ISEARCH_NONE || index < 0)
    {
	XmTextSetHighlight(gdb_w, 0, XmTextGetLastPosition(gdb_w),
			   XmHIGHLIGHT_NORMAL);
    }
    else
    {
	XmTextSetHighlight(gdb_w,
			   0,
			   pos + index,
			   XmHIGHLIGHT_NORMAL);
	XmTextSetHighlight(gdb_w,
			   pos + index, 
			   pos + index + isearch_string.length(),
			   XmHIGHLIGHT_SECONDARY_SELECTED);
	XmTextSetHighlight(gdb_w, 
			   pos + index + isearch_string.length(),
			   XmTextGetLastPosition(gdb_w),
			   XmHIGHLIGHT_NORMAL);
    }

    if (index >= 0)
	pos += index;

    XmTextSetInsertionPosition(gdb_w, pos);
    XmTextShowPosition(gdb_w, pos);
    have_isearch_line = false;
    private_gdb_output = old_private_gdb_output;
}