/*--------------------------- catch_child() -----------------------------*/ static void catch_child(Widget w) { int n; char buffer[4096 + 3]; if ((n = read(cmd_fd, buffer, 4096)) > 0) { buffer[n] = '\0'; XmTextInsert(cmd_output, wpr_position, buffer); wpr_position += n; if (go_to_beginning == NO) { XmTextShowPosition(cmd_output, wpr_position); } XFlush(display); } else if (n == 0) { buffer[0] = '>'; buffer[1] = '\0'; XmTextInsert(cmd_output, wpr_position, buffer); if (go_to_beginning == NO) { XmTextShowPosition(cmd_output, wpr_position); } else { XmTextShowPosition(cmd_output, 0); } XFlush(display); if (cmd_pid > 0) { if (wait(NULL) == -1) { (void)fprintf(stderr, "wait() error : %s (%s %d)\n", strerror(errno), __FILE__, __LINE__); exit(INCORRECT); } cmd_pid = 0; } wpr_position = 0; if (cmd_input_id != 0L) { XtRemoveInput(cmd_input_id); cmd_input_id = 0L; if (close(cmd_fd) == -1) { (void)fprintf(stderr, "close() error : %s (%s %d)\n", strerror(errno), __FILE__, __LINE__); } } } return; }
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; }
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); }
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); }
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); }
static int motTextSetScrollToAttrib(Ihandle* ih, const char* value) { int pos = 1; if (!value) return 0; if (ih->data->is_multiline) { int lin = 1, col = 1, pos; char* str; iupStrToIntInt(value, &lin, &col, ','); if (lin < 1) lin = 1; if (col < 1) col = 1; str = XmTextGetString(ih->handle); pos = motTextSetLinColToPosition(str, lin, col); XtFree(str); } else { sscanf(value,"%i",&pos); if (pos < 1) pos = 1; pos--; /* return to Motif referece */ } XmTextShowPosition(ih->handle, (XmTextPosition)pos); return 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); }
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); }
/*############################## 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; }
void wxTextEntry::WriteText(const wxString& text) { long pos = GetInsertionPoint(); XmTextInsert(GetText(), pos, text.char_str()); pos += text.length(); XtVaSetValues(GetText(), XmNcursorPosition, pos, NULL); SetInsertionPoint(pos); XmTextShowPosition(GetText(), pos); }
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); }
static void Yank(Widget w, XEvent *ev, char **str, Cardinal *num) { /* copy current selection at current cursor position */ if (listener_selection) { XmTextPosition curpos; curpos = XmTextGetCursorPosition(w); XmTextInsert(w, curpos, listener_selection); curpos += strlen(listener_selection); XmTextShowPosition(w, curpos); XmTextSetCursorPosition(w, curpos); XmTextClearSelection(w, ev->xkey.time); /* so C-y + edit doesn't forbid the edit */ } }
static int motTextSetScrollToPosAttrib(Ihandle* ih, const char* value) { int pos = 0; if (!value) return 0; sscanf(value,"%i",&pos); if (pos < 0) pos = 0; XmTextShowPosition(ih->handle, (XmTextPosition)pos); return 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); } }
static int motTextSetCaretPosAttrib(Ihandle* ih, const char* value) { int pos = 0; if (!value) return 0; iupStrToInt(value, &pos); if (pos < 0) pos = 0; XmTextSetInsertionPosition(ih->handle, (XmTextPosition)pos); XmTextShowPosition(ih->handle, (XmTextPosition)pos); return 0; }
void wxTextCtrl::DoSetValue(const wxString& text, int flags) { m_inSetValue = true; XmTextSetString ((Widget) m_mainWidget, text.char_str()); XtVaSetValues ((Widget) m_mainWidget, XmNcursorPosition, text.length(), NULL); SetInsertionPoint(text.length()); XmTextShowPosition ((Widget) m_mainWidget, text.length()); m_modified = true; m_inSetValue = false; if ( flags & SetValue_SendEvent ) SendTextUpdatedEvent(); }
void all_messages(char from, char *call_sign, char *from_call, char *message) { char temp_my_course[10]; char *temp; char data1[97]; char data2[97]; int pos; int i; int my_size = 200; XmTextPosition drop_ptr; if (Read_messages_mine_only || (!Read_messages_mine_only && ((vm_range == 0) || ((int)distance_from_my_station(call_sign,temp_my_course) <= vm_range)) ) ) { // Check that it's coming from the correct type of interface // Compare Read_messages_packet_data_type against the port // type associated with data_port to determine whether or // not to display it. // // I = Internet // L = Local // T = TNC // F = File // switch (Read_messages_packet_data_type) { case 2: // Display NET data only // if not network_interface, return if (from != 'I') return; // Don't display it break; case 1: // Display TNC data only // if not local_tnc_interface, return if (from != 'T') return; // Don't display it break; case 0: // Display both TNC and NET data default: break; } // Check for my stations only if set if (Read_messages_mine_only) { char short_call[MAX_CALLSIGN]; char *p; xastir_snprintf(short_call, sizeof(short_call), "%s", my_callsign); if ( (p = index(short_call,'-')) ) { *p = '\0'; // Terminate it } if (!strstr(call_sign, short_call) && !strstr(from_call, short_call)) { return; } } if ((temp = malloc((size_t)my_size)) == NULL) return; if (strlen(message)>95) { xastir_snprintf(data1, sizeof(data1), "%s", message); data1[95]='\0'; xastir_snprintf(data2, sizeof(data2), "\n\t%s", message+95); } else { xastir_snprintf(data1, sizeof(data1), "%s", message); data2[0] = '\0'; } if (strncmp(call_sign, "java",4) == 0) { xastir_snprintf(call_sign, MAX_CALLSIGN+1, "%s", langcode("WPUPMSB015") ); // Broadcast xastir_snprintf(temp, my_size, "%s %s\t%s%s\n", from_call, call_sign, data1, data2); } else if (strncmp(call_sign, "USER", 4) == 0) { xastir_snprintf(call_sign, MAX_CALLSIGN+1, "%s", langcode("WPUPMSB015") ); // Broadcast xastir_snprintf(temp, my_size, "%s %s\t%s%s\n", from_call, call_sign, data1, data2); } else xastir_snprintf(temp, my_size, "%s to %s via:%c\t%s%s\n", from_call, call_sign, from, data1, data2); if ((All_messages_dialog != NULL)) { begin_critical_section(&All_messages_dialog_lock, "view_message_gui.c:all_messages" ); pos = (int)XmTextGetLastPosition(view_messages_text); XmTextInsert(view_messages_text, pos, temp); pos += strlen(temp); while (pos > view_message_limit) { for (drop_ptr = i = 0; i < 3; i++) { (void)XmTextFindString(view_messages_text, drop_ptr, "\n", XmTEXT_FORWARD, &drop_ptr); drop_ptr++; } XmTextReplace(view_messages_text, 0, drop_ptr, ""); pos = (int)XmTextGetLastPosition(view_messages_text); } XtVaSetValues(view_messages_text, XmNcursorPosition, pos, NULL); XmTextShowPosition(view_messages_text, pos); end_critical_section(&All_messages_dialog_lock, "view_message_gui.c:all_messages" ); } free(temp); } }
void CreateWindow(Widget top, Display *pdpy, XPContext pctxt, Screen *scr) { Widget form, shell, tw; FILE *f; static char buffer[64000]; Arg al[20]; int ac; unsigned short wid, ht; XRectangle rect; Dimension width, height; short nrows = 80; int nlines = 481, npages, page, i; int save_data = XPGetData; /* * Here we are sure that printer name, print display, screen are * initialized, and a print context has been created. */ if (XpGetPageDimensions(pdpy, pctxt, &wid, &ht, &rect)) { fprintf(stderr, "Paper size is %d %d\n", wid, ht); } else { fprintf(stderr, "test8: failed to get Page Dimensions\n"); exit(1); } ac = 0; /* Size from paper size */ XtSetArg(al[ac], XmNheight, ht); ac++; XtSetArg(al[ac], XmNwidth, wid); ac++; shell = XmPrintSetup(top, scr, "Print", al, ac); /* start job must precede XpGetDocumentData in XmPrintToFile */ fprintf(stderr, "test8: XpStartJob\n"); XpStartJob(XtDisplay(shell), save_data); /* Maintain sequence StartJob - GetDocument */ XFlush(XtDisplay(shell)); XmPrintToFile(XtDisplay(shell), "test8.out", FinishPrintToFile, NULL); /* * Now we can get the size of the shell, create widgets, etc. */ XtVaGetValues(shell, XmNheight, &height, XmNwidth, &width, NULL); /* * Create a text widget as big as the page */ fprintf(stderr, "test8: XmCreateText(wid %d ht %d)\n", width, height); ac=0; XtSetArg(al[ac], XmNheight, height); ac++; XtSetArg(al[ac], XmNwidth, width); ac++; form = XmCreateForm(shell, "form", al, ac); XtManageChild(form); /* Re-use settings from above */ XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++; XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; tw = XmCreateText(form, "tw", al, ac); XtManageChild(tw); /* * Get some data in here - the LGPL text (you probably * need to be in the LessTif source tree for this to work). */ for (i=0; i<10; i++) { f = fopen("COPYING.LIB", "r"); if (f) break; chdir(".."); } if (f) { fread(buffer, 1, sizeof(buffer), f); fclose(f); } XmTextSetString(tw, buffer); XmTextShowPosition(tw, 0); fprintf(stderr, "test8: XtRealizeWidget()\n"); XtRealizeWidget(shell); /* Get data to calculate number of pages to print */ XtVaGetValues(tw, XmNrows, &nrows, XmNtotalLines, &nlines, NULL); /* Calculate number of pages to print */ npages = nlines / nrows + 1; fprintf(stderr, "Text lines %d rows %d pages %d\n", nlines, nrows, npages); for (page = 0; page < npages; page++) { XpStartPage(XtDisplay(shell), XtWindow(shell)); fprintf(stderr, "test8: XmRedisplayWidget\n"); XmRedisplayWidget(tw); /* works !! */ /* Calling XmRedisplayWidget() only works for * widgets that have an expose() method. This simple * point is documented in the XmRedisplayWidget docs. * Not so obvious consequence is what to do with other * widgets. It seems to be up to the application * programmer to figure out which widget to use. * * Calling it on a shell or on a form won't work. XmRedisplayWidget(shell); */ XpEndPage(XtDisplay(shell)); if (XmIsText(tw)) XmTextScroll(tw, nrows); } XpEndJob(XtDisplay(shell)); }
void wxTextCtrl::ShowPosition(long pos) { XmTextShowPosition ((Widget) m_mainWidget, (XmTextPosition) pos); }
static void move_to_end_of_line(XtPointer, XtIntervalId *) { XmTextPosition pos = XmTextGetLastPosition(gdb_w); XmTextSetInsertionPosition(gdb_w, pos); XmTextShowPosition(gdb_w, pos); }
// 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; }